"use strict";(this.webpackChunktweb=this.webpackChunktweb||[]).push([[866],{2553:(t,e,r)=>{r.d(e,{cv:()=>g});var i=r(2155),n=r(7885);const h=[137,80,78,71,13,10,26,10],s=[];for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;s[t]=e}const o=4294967295;var c,a,w,E,N,A,d,l;(l=c||(c={}))[l.UNKNOWN=-1]="UNKNOWN",l[l.GREYSCALE=0]="GREYSCALE",l[l.TRUECOLOUR=2]="TRUECOLOUR",l[l.INDEXED_COLOUR=3]="INDEXED_COLOUR",l[l.GREYSCALE_ALPHA=4]="GREYSCALE_ALPHA",l[l.TRUECOLOUR_ALPHA=6]="TRUECOLOUR_ALPHA",(d=a||(a={}))[d.UNKNOWN=-1]="UNKNOWN",d[d.DEFLATE=0]="DEFLATE",(A=w||(w={}))[A.UNKNOWN=-1]="UNKNOWN",A[A.ADAPTIVE=0]="ADAPTIVE",(N=E||(E={}))[N.UNKNOWN=-1]="UNKNOWN",N[N.NO_INTERLACE=0]="NO_INTERLACE",N[N.ADAM7=1]="ADAM7",new Uint8Array(0);const u=new Uint16Array([255]);new Uint8Array(u.buffer)[0];const U={level:3};class p extends i.l{constructor(t,e={}){super(),this._colorType=c.UNKNOWN,this._zlibOptions=Object.assign({},U,e.zlib),this._png=this._checkData(t),this.setBigEndian()}encode(){return this.encodeSignature(),this.encodeIHDR(),this.encodeData(),this.encodeIEND(),this.toArray()}encodeSignature(){this.writeBytes(h)}encodeIHDR(){this.writeUint32(13),this.writeChars("IHDR"),this.writeUint32(this._png.width),this.writeUint32(this._png.height),this.writeByte(this._png.depth),this.writeByte(this._colorType),this.writeByte(a.DEFLATE),this.writeByte(w.ADAPTIVE),this.writeByte(E.NO_INTERLACE),this.writeCrc(17)}encodeIEND(){this.writeUint32(0),this.writeChars("IEND"),this.writeCrc(4)}encodeIDAT(t){this.writeUint32(t.length),this.writeChars("IDAT"),this.writeBytes(t),this.writeCrc(t.length+4)}encodeData(){const{width:t,height:e,channels:r,depth:h,data:s}=this._png,o=r*t,c=(new i.l).setBigEndian();let a=0;for(let t=0;t<e;t++)if(c.writeByte(0),8===h)a=f(s,c,o,a);else{if(16!==h)throw new Error("unreachable");a=R(s,c,o,a)}const w=c.toArray(),E=(0,n.Wt)(w,this._zlibOptions);this.encodeIDAT(E)}_checkData(t){const{colorType:e,channels:r,depth:i}=function(t){const{channels:e=4,depth:r=8}=t;if(4!==e&&3!==e&&2!==e&&1!==e)throw new RangeError(`unsupported number of channels: ${e}`);if(8!==r&&16!==r)throw new RangeError(`unsupported bit depth: ${r}`);const i={channels:e,depth:r,colorType:c.UNKNOWN};switch(e){case 4:i.colorType=c.TRUECOLOUR_ALPHA;break;case 3:i.colorType=c.TRUECOLOUR;break;case 1:i.colorType=c.GREYSCALE;break;case 2:i.colorType=c.GREYSCALE_ALPHA;break;default:throw new Error("unsupported number of channels")}return i}(t),n={width:O(t.width,"width"),height:O(t.height,"height"),channels:r,data:t.data,depth:i,text:{}};this._colorType=e;const h=n.width*n.height*r;if(n.data.length!==h)throw new RangeError(`wrong data size. Found ${n.data.length}, expected ${h}`);return n}writeCrc(t){this.writeUint32(function(t,e){return(function(t,e,r){let i=4294967295;for(let t=0;t<r;t++)i=s[255&(i^e[t])]^i>>>8;return i}(0,t,e)^o)>>>0}(new Uint8Array(this.buffer,this.byteOffset+this.offset-t,t),t))}}function O(t,e){if(Number.isInteger(t)&&t>0)return t;throw new TypeError(`${e} must be a positive integer`)}function f(t,e,r,i){for(let n=0;n<r;n++)e.writeByte(t[i++]);return i}function R(t,e,r,i){for(let n=0;n<r;n++)e.writeUint16(t[i++]);return i}var T;function g(t,e){return new p(t,e).encode()}!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.METRE=1]="METRE"}(T||(T={}))}}]);
//# sourceMappingURL=npm.fast-png.a7cba17ee621cb2ad512.chunk.js.map