mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-06 03:57:49 +08:00
2 lines
54 KiB
JavaScript
2 lines
54 KiB
JavaScript
const me={maskColor:{type:String,default:"rgba(255, 255, 255, 0.96)"},watchText:{type:Boolean,default:!0},status:{type:String},errorDescription:{type:[String,Object],default:"二维码已过期"},errorActionDescription:{type:String,default:"重新加载"},text:{type:String,required:!0},size:{type:Number,default:160},margin:{type:Number,default:12},correctLevel:{type:Number,default:1,validator:o=>[0,1,2,3].includes(o)},maskPattern:{type:Number},version:{type:Number},components:{type:Object,default:()=>({data:{scale:1},timing:{scale:1,protectors:!1},alignment:{scale:1,protectors:!1},cornerAlignment:{scale:1,protectors:!0}})},colorDark:{type:String,default:"#000000"},colorLight:{type:String,default:"#ffffff"},autoColor:{type:Boolean,default:!0},backgroundImage:{type:String},backgroundDimming:{type:String,default:"rgba(0, 0, 0, 0)"},gifBackgroundURL:{type:String},gifBackground:{type:ArrayBuffer},whiteMargin:{type:Boolean,default:!0},logoImage:{type:String},logoScale:{type:Number,default:.4},logoMargin:{type:Number,default:6},logoCornerRadius:{type:Number,default:8},dotScale:{type:Number,default:1},onSuccess:{type:[Function,Array],default:null},onError:{type:[Function,Array],default:null},onReload:{type:[Function,Array],default:null}};function we(o,t,e){const r=ie(t),i=o-1;let n=0;switch(e){case X.L:n=rt[i][0];break;case X.M:n=rt[i][1];break;case X.Q:n=rt[i][2];break;case X.H:n=rt[i][3];break}return r<=n}function be(o,t){for(var e=1,r=ie(o),i=0,n=rt.length;i<n;i++){var s=0;switch(t){case X.L:s=rt[i][0];break;case X.M:s=rt[i][1];break;case X.Q:s=rt[i][2];break;case X.H:s=rt[i][3];break}if(r<=s)break;e++}if(e>rt.length)throw new Error("Too long data");return e}function ie(o){var t=encodeURI(o).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return t.length+(t.length!=Number(o)?3:0)}class ye{constructor(t){this.mode=q.MODE_8BIT_BYTE,this.parsedData=[],this.data=t;const e=[];for(let r=0,i=this.data.length;r<i;r++){const n=[],s=this.data.charCodeAt(r);s>65536?(n[0]=240|(s&1835008)>>>18,n[1]=128|(s&258048)>>>12,n[2]=128|(s&4032)>>>6,n[3]=128|s&63):s>2048?(n[0]=224|(s&61440)>>>12,n[1]=128|(s&4032)>>>6,n[2]=128|s&63):s>128?(n[0]=192|(s&1984)>>>6,n[1]=128|s&63):n[0]=s,e.push(n)}this.parsedData=Array.prototype.concat.apply([],e),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}getLength(){return this.parsedData.length}write(t){for(let e=0,r=this.parsedData.length;e<r;e++)t.put(this.parsedData[e],8)}}class ct{constructor(t=-1,e=X.L){this.moduleCount=0,this.dataList=[],this.typeNumber=t,this.errorCorrectLevel=e,this.moduleCount=0,this.dataList=[]}addData(t){if(this.typeNumber<=0)this.typeNumber=be(t,this.errorCorrectLevel);else{if(this.typeNumber>40)throw new Error(`Invalid QR version: ${this.typeNumber}`);if(!we(this.typeNumber,t,this.errorCorrectLevel))throw new Error(`Data is too long for QR version: ${this.typeNumber}`)}const e=new ye(t);this.dataList.push(e),this.dataCache=void 0}isDark(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(`${t},${e}`);return this.modules[t][e]}getModuleCount(){return this.moduleCount}make(){this.makeImpl(!1,this.getBestMaskPattern())}makeImpl(t,e){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(let r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(let i=0;i<this.moduleCount;i++)this.modules[r][i]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),this.dataCache==null&&(this.dataCache=ct.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)}setupPositionProbePattern(t,e){for(let r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(let i=-1;i<=7;i++)e+i<=-1||this.moduleCount<=e+i||(0<=r&&r<=6&&(i==0||i==6)||0<=i&&i<=6&&(r==0||r==6)||2<=r&&r<=4&&2<=i&&i<=4?this.modules[t+r][e+i]=!0:this.modules[t+r][e+i]=!1)}getBestMaskPattern(){if(Number.isInteger(this.maskPattern)&&Object.values(nt).includes(this.maskPattern))return this.maskPattern;let t=0,e=0;for(let r=0;r<8;r++){this.makeImpl(!0,r);const i=L.getLostPoint(this);(r==0||t>i)&&(t=i,e=r)}return e}setupTimingPattern(){for(let t=8;t<this.moduleCount-8;t++)this.modules[t][6]==null&&(this.modules[t][6]=t%2==0);for(let t=8;t<this.moduleCount-8;t++)this.modules[6][t]==null&&(this.modules[6][t]=t%2==0)}setupPositionAdjustPattern(){const t=L.getPatternPosition(this.typeNumber);for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++){const i=t[e],n=t[r];if(this.modules[i][n]==null)for(let s=-2;s<=2;s++)for(let a=-2;a<=2;a++)s==-2||s==2||a==-2||a==2||s==0&&a==0?this.modules[i+s][n+a]=!0:this.modules[i+s][n+a]=!1}}setupTypeNumber(t){const e=L.getBCHTypeNumber(this.typeNumber);for(var r=0;r<18;r++){var i=!t&&(e>>r&1)==1;this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=i}for(var r=0;r<18;r++){var i=!t&&(e>>r&1)==1;this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=i}}setupTypeInfo(t,e){const r=this.errorCorrectLevel<<3|e,i=L.getBCHTypeInfo(r);for(var n=0;n<15;n++){var s=!t&&(i>>n&1)==1;n<6?this.modules[n][8]=s:n<8?this.modules[n+1][8]=s:this.modules[this.moduleCount-15+n][8]=s}for(var n=0;n<15;n++){var s=!t&&(i>>n&1)==1;n<8?this.modules[8][this.moduleCount-n-1]=s:n<9?this.modules[8][15-n-1+1]=s:this.modules[8][15-n-1]=s}this.modules[this.moduleCount-8][8]=!t}mapData(t,e){let r=-1,i=this.moduleCount-1,n=7,s=0;for(let a=this.moduleCount-1;a>0;a-=2)for(a==6&&a--;;){for(let l=0;l<2;l++)if(this.modules[i][a-l]==null){let c=!1;s<t.length&&(c=(t[s]>>>n&1)==1),L.getMask(e,i,a-l)&&(c=!c),this.modules[i][a-l]=c,n--,n==-1&&(s++,n=7)}if(i+=r,i<0||this.moduleCount<=i){i-=r,r=-r;break}}}static createData(t,e,r){const i=st.getRSBlocks(t,e),n=new Ce;for(var s=0;s<r.length;s++){const l=r[s];n.put(l.mode,4),n.put(l.getLength(),L.getLengthInBits(l.mode,t)),l.write(n)}let a=0;for(var s=0;s<i.length;s++)a+=i[s].dataCount;if(n.getLengthInBits()>a*8)throw new Error(`code length overflow. (${n.getLengthInBits()}>${a*8})`);for(n.getLengthInBits()+4<=a*8&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=a*8||(n.put(ct.PAD0,8),n.getLengthInBits()>=a*8));)n.put(ct.PAD1,8);return ct.createBytes(n,i)}static createBytes(t,e){let r=0,i=0,n=0;const s=new Array(e.length),a=new Array(e.length);for(var l=0;l<e.length;l++){const A=e[l].dataCount,k=e[l].totalCount-A;i=Math.max(i,A),n=Math.max(n,k),s[l]=new Array(A);for(var c=0;c<s[l].length;c++)s[l][c]=255&t.buffer[c+r];r+=A;const T=L.getErrorCorrectPolynomial(k),g=new pt(s[l],T.getLength()-1).mod(T);a[l]=new Array(T.getLength()-1);for(var c=0;c<a[l].length;c++){const P=c+g.getLength()-a[l].length;a[l][c]=P>=0?g.get(P):0}}let h=0;for(var c=0;c<e.length;c++)h+=e[c].totalCount;const f=new Array(h);let v=0;for(var c=0;c<i;c++)for(var l=0;l<e.length;l++)c<s[l].length&&(f[v++]=s[l][c]);for(var c=0;c<n;c++)for(var l=0;l<e.length;l++)c<a[l].length&&(f[v++]=a[l][c]);return f}}ct.PAD0=236;ct.PAD1=17;const X={L:1,M:0,Q:3,H:2},q={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},nt={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};class L{static getBCHTypeInfo(t){let e=t<<10;for(;L.getBCHDigit(e)-L.getBCHDigit(L.G15)>=0;)e^=L.G15<<L.getBCHDigit(e)-L.getBCHDigit(L.G15);return(t<<10|e)^L.G15_MASK}static getBCHTypeNumber(t){let e=t<<12;for(;L.getBCHDigit(e)-L.getBCHDigit(L.G18)>=0;)e^=L.G18<<L.getBCHDigit(e)-L.getBCHDigit(L.G18);return t<<12|e}static getBCHDigit(t){let e=0;for(;t!=0;)e++,t>>>=1;return e}static getPatternPosition(t){return L.PATTERN_POSITION_TABLE[t-1]}static getMask(t,e,r){switch(t){case nt.PATTERN000:return(e+r)%2==0;case nt.PATTERN001:return e%2==0;case nt.PATTERN010:return r%3==0;case nt.PATTERN011:return(e+r)%3==0;case nt.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case nt.PATTERN101:return e*r%2+e*r%3==0;case nt.PATTERN110:return(e*r%2+e*r%3)%2==0;case nt.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error(`bad maskPattern:${t}`)}}static getErrorCorrectPolynomial(t){let e=new pt([1],0);for(let r=0;r<t;r++)e=e.multiply(new pt([1,j.gexp(r)],0));return e}static getLengthInBits(t,e){if(1<=e&&e<10)switch(t){case q.MODE_NUMBER:return 10;case q.MODE_ALPHA_NUM:return 9;case q.MODE_8BIT_BYTE:return 8;case q.MODE_KANJI:return 8;default:throw new Error(`mode:${t}`)}else if(e<27)switch(t){case q.MODE_NUMBER:return 12;case q.MODE_ALPHA_NUM:return 11;case q.MODE_8BIT_BYTE:return 16;case q.MODE_KANJI:return 10;default:throw new Error(`mode:${t}`)}else if(e<41)switch(t){case q.MODE_NUMBER:return 14;case q.MODE_ALPHA_NUM:return 13;case q.MODE_8BIT_BYTE:return 16;case q.MODE_KANJI:return 12;default:throw new Error(`mode:${t}`)}else throw new Error(`type:${e}`)}static getLostPoint(t){const e=t.getModuleCount();let r=0;for(var i=0;i<e;i++)for(var n=0;n<e;n++){let l=0;const c=t.isDark(i,n);for(let h=-1;h<=1;h++)if(!(i+h<0||e<=i+h))for(let f=-1;f<=1;f++)n+f<0||e<=n+f||h==0&&f==0||c==t.isDark(i+h,n+f)&&l++;l>5&&(r+=3+l-5)}for(var i=0;i<e-1;i++)for(var n=0;n<e-1;n++){let h=0;t.isDark(i,n)&&h++,t.isDark(i+1,n)&&h++,t.isDark(i,n+1)&&h++,t.isDark(i+1,n+1)&&h++,(h==0||h==4)&&(r+=3)}for(var i=0;i<e;i++)for(var n=0;n<e-6;n++)t.isDark(i,n)&&!t.isDark(i,n+1)&&t.isDark(i,n+2)&&t.isDark(i,n+3)&&t.isDark(i,n+4)&&!t.isDark(i,n+5)&&t.isDark(i,n+6)&&(r+=40);for(var n=0;n<e;n++)for(var i=0;i<e-6;i++)t.isDark(i,n)&&!t.isDark(i+1,n)&&t.isDark(i+2,n)&&t.isDark(i+3,n)&&t.isDark(i+4,n)&&!t.isDark(i+5,n)&&t.isDark(i+6,n)&&(r+=40);let s=0;for(var n=0;n<e;n++)for(var i=0;i<e;i++)t.isDark(i,n)&&s++;const a=Math.abs(100*s/e/e-50)/5;return r+=a*10,r}}L.PATTERN_POSITION_TABLE=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]];L.G15=1335;L.G18=7973;L.G15_MASK=21522;class j{static glog(t){if(t<1)throw new Error(`glog(${t})`);return j.LOG_TABLE[t]}static gexp(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return j.EXP_TABLE[t]}}j.EXP_TABLE=new Array(256);j.LOG_TABLE=new Array(256);j._constructor=function(){for(var o=0;o<8;o++)j.EXP_TABLE[o]=1<<o;for(var o=8;o<256;o++)j.EXP_TABLE[o]=j.EXP_TABLE[o-4]^j.EXP_TABLE[o-5]^j.EXP_TABLE[o-6]^j.EXP_TABLE[o-8];for(var o=0;o<255;o++)j.LOG_TABLE[j.EXP_TABLE[o]]=o}();class pt{constructor(t,e){if(t.length==null)throw new Error(`${t.length}/${e}`);let r=0;for(;r<t.length&&t[r]==0;)r++;this.num=new Array(t.length-r+e);for(let i=0;i<t.length-r;i++)this.num[i]=t[i+r]}get(t){return this.num[t]}getLength(){return this.num.length}multiply(t){const e=new Array(this.getLength()+t.getLength()-1);for(let r=0;r<this.getLength();r++)for(let i=0;i<t.getLength();i++)e[r+i]^=j.gexp(j.glog(this.get(r))+j.glog(t.get(i)));return new pt(e,0)}mod(t){if(this.getLength()-t.getLength()<0)return this;const e=j.glog(this.get(0))-j.glog(t.get(0)),r=new Array(this.getLength());for(var i=0;i<this.getLength();i++)r[i]=this.get(i);for(var i=0;i<t.getLength();i++)r[i]^=j.gexp(j.glog(t.get(i))+e);return new pt(r,0).mod(t)}}class st{constructor(t,e){this.totalCount=t,this.dataCount=e}static getRSBlocks(t,e){const r=st.getRsBlockTable(t,e);if(r==null)throw new Error(`bad rs block @ typeNumber:${t}/errorCorrectLevel:${e}`);const i=r.length/3,n=[];for(let s=0;s<i;s++){const a=r[s*3+0],l=r[s*3+1],c=r[s*3+2];for(let h=0;h<a;h++)n.push(new st(l,c))}return n}static getRsBlockTable(t,e){switch(e){case X.L:return st.RS_BLOCK_TABLE[(t-1)*4+0];case X.M:return st.RS_BLOCK_TABLE[(t-1)*4+1];case X.Q:return st.RS_BLOCK_TABLE[(t-1)*4+2];case X.H:return st.RS_BLOCK_TABLE[(t-1)*4+3];default:return}}}st.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];class Ce{constructor(){this.buffer=[],this.length=0}get(t){const e=Math.floor(t/8);return(this.buffer[e]>>>7-t%8&1)==1}put(t,e){for(let r=0;r<e;r++)this.putBit((t>>>e-r-1&1)==1)}getLengthInBits(){return this.length}putBit(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}}const rt=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function et(o){if(typeof o!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(o))}function Xt(o,t){for(var e="",r=0,i=-1,n=0,s,a=0;a<=o.length;++a){if(a<o.length)s=o.charCodeAt(a);else{if(s===47)break;s=47}if(s===47){if(!(i===a-1||n===1))if(i!==a-1&&n===2){if(e.length<2||r!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",r=0):(e=e.slice(0,l),r=e.length-1-e.lastIndexOf("/")),i=a,n=0;continue}}else if(e.length===2||e.length===1){e="",r=0,i=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",r=2)}else e.length>0?e+="/"+o.slice(i+1,a):e=o.slice(i+1,a),r=a-i-1;i=a,n=0}else s===46&&n!==-1?++n:n=-1}return e}function Ae(o,t){var e=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+r:e+o+r:r}var ft={resolve:function(){for(var t="",e=!1,r,i=arguments.length-1;i>=-1&&!e;i--){var n;i>=0?n=arguments[i]:(r===void 0&&(r=process.cwd()),n=r),et(n),n.length!==0&&(t=n+"/"+t,e=n.charCodeAt(0)===47)}return t=Xt(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(et(t),t.length===0)return".";var e=t.charCodeAt(0)===47,r=t.charCodeAt(t.length-1)===47;return t=Xt(t,!e),t.length===0&&!e&&(t="."),t.length>0&&r&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return et(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var r=arguments[e];et(r),r.length>0&&(t===void 0?t=r:t+="/"+r)}return t===void 0?".":ft.normalize(t)},relative:function(t,e){if(et(t),et(e),t===e||(t=ft.resolve(t),e=ft.resolve(e),t===e))return"";for(var r=1;r<t.length&&t.charCodeAt(r)===47;++r);for(var i=t.length,n=i-r,s=1;s<e.length&&e.charCodeAt(s)===47;++s);for(var a=e.length,l=a-s,c=n<l?n:l,h=-1,f=0;f<=c;++f){if(f===c){if(l>c){if(e.charCodeAt(s+f)===47)return e.slice(s+f+1);if(f===0)return e.slice(s+f)}else n>c&&(t.charCodeAt(r+f)===47?h=f:f===0&&(h=0));break}var v=t.charCodeAt(r+f),A=e.charCodeAt(s+f);if(v!==A)break;v===47&&(h=f)}var k="";for(f=r+h+1;f<=i;++f)(f===i||t.charCodeAt(f)===47)&&(k.length===0?k+="..":k+="/..");return k.length>0?k+e.slice(s+h):(s+=h,e.charCodeAt(s)===47&&++s,e.slice(s))},_makeLong:function(t){return t},dirname:function(t){if(et(t),t.length===0)return".";for(var e=t.charCodeAt(0),r=e===47,i=-1,n=!0,s=t.length-1;s>=1;--s)if(e=t.charCodeAt(s),e===47){if(!n){i=s;break}}else n=!1;return i===-1?r?"/":".":r&&i===1?"//":t.slice(0,i)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');et(t);var r=0,i=-1,n=!0,s;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var a=e.length-1,l=-1;for(s=t.length-1;s>=0;--s){var c=t.charCodeAt(s);if(c===47){if(!n){r=s+1;break}}else l===-1&&(n=!1,l=s+1),a>=0&&(c===e.charCodeAt(a)?--a===-1&&(i=s):(a=-1,i=l))}return r===i?i=l:i===-1&&(i=t.length),t.slice(r,i)}else{for(s=t.length-1;s>=0;--s)if(t.charCodeAt(s)===47){if(!n){r=s+1;break}}else i===-1&&(n=!1,i=s+1);return i===-1?"":t.slice(r,i)}},extname:function(t){et(t);for(var e=-1,r=0,i=-1,n=!0,s=0,a=t.length-1;a>=0;--a){var l=t.charCodeAt(a);if(l===47){if(!n){r=a+1;break}continue}i===-1&&(n=!1,i=a+1),l===46?e===-1?e=a:s!==1&&(s=1):e!==-1&&(s=-1)}return e===-1||i===-1||s===0||s===1&&e===i-1&&e===r+1?"":t.slice(e,i)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return Ae("/",t)},parse:function(t){et(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var r=t.charCodeAt(0),i=r===47,n;i?(e.root="/",n=1):n=0;for(var s=-1,a=0,l=-1,c=!0,h=t.length-1,f=0;h>=n;--h){if(r=t.charCodeAt(h),r===47){if(!c){a=h+1;break}continue}l===-1&&(c=!1,l=h+1),r===46?s===-1?s=h:f!==1&&(f=1):s!==-1&&(f=-1)}return s===-1||l===-1||f===0||f===1&&s===l-1&&s===a+1?l!==-1&&(a===0&&i?e.base=e.name=t.slice(1,l):e.base=e.name=t.slice(a,l)):(a===0&&i?(e.name=t.slice(1,s),e.base=t.slice(1,l)):(e.name=t.slice(a,s),e.base=t.slice(a,l)),e.ext=t.slice(s,l)),a>0?e.dir=t.slice(0,a-1):i&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};ft.posix=ft;const Pe=ft.extname,oe=ft.basename;class Be{constructor(){let t=typeof global>"u",e="image/png",r="image/jpeg",i="image/jpeg",n="image/webp",s="application/pdf",a="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:r,jpeg:i,webp:n}:{png:e,jpg:r,jpeg:i,pdf:s,svg:a},mimes:t?{[e]:"png",[r]:"jpg",[n]:"webp"}:{[e]:"png",[r]:"jpg",[s]:"pdf",[a]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function De(o,{filename:t="",extension:e="",format:T,page:i,quality:n,matte:s,density:a,outline:l,archive:A}={}){var{fromMime:h,toMime:f,expected:v}=new Be,A=A||"canvas",k=T||e.replace(/@\d+x$/i,"")||Pe(t),T=h(f(k)||k),M=f(T),g=o.length;if(!k)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!T)throw new Error(`Unsupported file format "${k}" (expected ${v})`);if(!g)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let p,P,d=t.replace(/{(\d*)}/g,(m,y)=>(P=!0,y=parseInt(y,10),p=isFinite(y)?y:isFinite(p)?p:-1,"{}")),b=i>0?i-1:i<0?g+i:void 0;if(isFinite(b)&&b<0||b>=g)throw new RangeError(g==1?`Canvas only has a ‘page 1’ (${b} is out of bounds)`:`Canvas has pages 1–${g} (${b} is out of bounds)`);if(o=isFinite(b)?[o[b]]:P||T=="pdf"?o:o.slice(-1),n===void 0)n=.92;else if(typeof n!="number"||!isFinite(n)||n<0||n>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(a===void 0){let m=(e||oe(t,k)).match(/@(\d+)x$/i);a=m?parseInt(m[1],10):1}else if(typeof a!="number"||!Number.isInteger(a)||a<1)throw new TypeError("The density option must be a non-negative integer");return l===void 0?l=!0:T=="svg"&&(l=!!l),{filename:t,pattern:d,format:T,mime:M,pages:o,padding:p,quality:n,matte:s,density:a,outline:l,archive:A}}class Dt{static for(t){return new Dt().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,r=this.table,i=0,n=t.length|0;i<n;i++)e=e>>>8^r[(e^t[i])&255];return this.crc=e,this}}Dt.prototype.table=(()=>{var o,t,e,r=[];for(o=0;o<256;o++){for(e=o,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;r[o]=e}return r})();function St(o){let t=new Uint8Array(o),e=new DataView(t.buffer),r={array:t,view:e,size:o,set8(i,n){return e.setUint8(i,n),r},set16(i,n){return e.setUint16(i,n,!0),r},set32(i,n){return e.setUint32(i,n,!0),r},bytes(i,n){return t.set(n,i),r}};return r}class kt{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let r=!e,i=kt.encoder.encode(`${this.directory}/${r?"":t}`),n=new Uint8Array(r?0:await e.arrayBuffer()),s=30+i.length,a=s+n.length,l=16,{offset:c}=this,h=St(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,Dt.for(n)).set32(14,n.length).set32(18,n.length).set16(22,i.length);c+=s;let f=St(s+n.length+l).set32(0,67324752).bytes(4,h.array).bytes(30,i).bytes(s,n);c+=n.length,f.set32(a,134695760).bytes(a+4,h.array.slice(10,22)),c+=l,this.files.push({offset:c,folder:r,name:i,header:h,payload:f}),this.offset=c}toBuffer(){let t=this.files.reduce((f,{name:v})=>46+v.length+f,0),e=St(t+22),r=0;for(var{offset:i,name:n,header:s,folder:a}of this.files)e.set32(r,33639248).set16(r+4,20).bytes(r+6,s.array).set8(r+38,a?16:0).set32(r+42,i).bytes(r+46,n),r+=46+n.length;e.set32(r,101010256).set16(r+8,this.files.length).set16(r+10,this.files.length).set32(r+12,t).set32(r+16,this.offset);let l=new Uint8Array(this.offset+e.size),c=0;for(var{payload:h}of this.files)l.set(h.array,c),c+=h.size;return l.set(e.array,c),l}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}}kt.encoder=new TextEncoder;const $t=(o,t,e,r)=>{if(r){let{width:i,height:n}=o,s=Object.assign(document.createElement("canvas"),{width:i,height:n}),a=s.getContext("2d");a.fillStyle=r,a.fillRect(0,0,i,n),a.drawImage(o,0,0),o=s}return new Promise((i,n)=>o.toBlob(i,t,e))},ke=(...o)=>$t(...o).then(t=>t.arrayBuffer()),Te=async(o,t,e,r,i)=>{ne(i,await $t(o,t,e,r))},Ee=async(o,t,e,r,i,n,s)=>{let a=h=>n.replace("{}",String(h+1).padStart(s,"0")),l=oe(i,".zip")||"archive",c=new kt(l);await Promise.all(o.map(async(h,f)=>{let v=a(f);await c.add(v,await $t(h,t,e,r))})),ne(`${l}.zip`,c.blob)},ne=(o,t)=>{const e=window.URL.createObjectURL(t),r=document.createElement("a");r.style.display="none",r.href=e,r.setAttribute("download",o),typeof r.download>"u"&&r.setAttribute("target","_blank"),document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>window.URL.revokeObjectURL(e),100)},Ie=(o,t,e)=>o.map(r=>{if(t==1&&!e)return r.canvas;let i=document.createElement("canvas"),n=i.getContext("2d"),s=r.canvas?r.canvas:r;return i.width=s.width*t,i.height=s.height*t,e&&(n.fillStyle=e,n.fillRect(0,0,i.width,i.height)),n.scale(t,t),n.drawImage(s,0,0),i}),xe={asBuffer:ke,asDownload:Te,asZipDownload:Ee,atScale:Ie,options:De},{asBuffer:_t,asDownload:Se,asZipDownload:_e,atScale:Lt,options:Mt}=xe,Zt=Symbol.for("toDataURL"),Le=o=>new Promise((t,e)=>Object.assign(new se,{crossOrigin:"Anonymous",onload:t,onerror:e,src:o}));let Me=class{constructor(t,e){let r=document.createElement("canvas"),i=[];Object.defineProperty(r,"async",{value:!0,writable:!1,enumerable:!0});for(var[n,s]of Object.entries({png:()=>_t(r,"image/png"),jpg:()=>_t(r,"image/jpeg"),pages:()=>i.concat(r).map(a=>a.getContext("2d"))}))Object.defineProperty(r,n,{get:s});return Object.assign(r,{width:t,height:e,newPage(...a){var{width:c,height:h}=r,l=Object.assign(document.createElement("canvas"),{width:c,height:h});l.getContext("2d").drawImage(r,0,0),i.push(l);var[c,h]=a.length?a:[c,h];return Object.assign(r,{width:c,height:h}).getContext("2d")},saveAs(a,l){l=typeof l=="number"?{quality:l}:l;let c=Mt(this.pages,{filename:a,...l}),{pattern:h,padding:f,mime:v,quality:A,matte:k,density:T,archive:M}=c,g=Lt(c.pages,T);return f==null?Se(g[0],v,A,k,a):_e(g,v,A,k,M,h,f)},toBuffer(a="png",l={}){l=typeof l=="number"?{quality:l}:l;let c=Mt(this.pages,{extension:a,...l}),{mime:h,quality:f,matte:v,pages:A,density:k}=c,T=Lt(A,k,v)[0];return _t(T,h,f,v)},[Zt]:r.toDataURL.bind(r),toDataURL(a="png",l={}){l=typeof l=="number"?{quality:l}:l;let c=Mt(this.pages,{extension:a,...l}),{mime:h,quality:f,matte:v,pages:A,density:k}=c,T=Lt(A,k,v)[0],M=T[T===r?Zt:"toDataURL"](h,f);return Promise.resolve(M)}})}};const{CanvasRenderingContext2D:Ne,CanvasGradient:Re,CanvasPattern:Oe,Image:se,ImageData:$e,Path2D:Fe,DOMMatrix:Ue,DOMRect:Ge,DOMPoint:je}=window,Ve={Canvas:Me,loadImage:Le,CanvasRenderingContext2D:Ne,CanvasGradient:Re,CanvasPattern:Oe,Image:se,ImageData:$e,Path2D:Fe,DOMMatrix:Ue,DOMRect:Ge,DOMPoint:je},wt=(o,t,e={},r=e)=>{if(Array.isArray(t))t.forEach(i=>wt(o,i,e,r));else if(typeof t=="function")t(o,e,r,wt);else{const i=Object.keys(t)[0];Array.isArray(t[i])?(r[i]={},wt(o,t[i],e,r[i])):r[i]=t[i](o,e,r,wt)}return e},dt=(o,t)=>(e,r,i,n)=>{t(e,r,i)&&n(e,o,r,i)},ze=(o,t)=>(e,r,i,n)=>{const s=[];let a=e.pos;for(;t(e,r,i);){const l={};if(n(e,o,r,l),e.pos===a)break;a=e.pos,s.push(l)}return s},He=o=>({data:o,pos:0}),W=()=>o=>o.data[o.pos++],ae=(o=0)=>t=>t.data[t.pos+o],it=o=>t=>t.data.subarray(t.pos,t.pos+=o),Tt=o=>t=>t.data.subarray(t.pos,t.pos+o),Rt=o=>t=>Array.from(it(o)(t)).map(e=>String.fromCharCode(e)).join(""),ht=o=>t=>{const e=it(2)(t);return(e[1]<<8)+e[0]},le=(o,t)=>(e,r,i)=>{const n=typeof t=="function"?t(e,r,i):t,s=it(o),a=new Array(n);for(var l=0;l<n;l++)a[l]=s(e);return a},Ke=(o,t,e)=>{for(var r=0,i=0;i<e;i++)r+=o[t+i]&&2**(e-i-1);return r},Ft=o=>t=>{const e=W()(t),r=new Array(8);for(var i=0;i<8;i++)r[7-i]=!!(e&1<<i);return Object.keys(o).reduce((n,s)=>{const a=o[s];return a.length?n[s]=Ke(r,a.index,a.length):n[s]=r[a.index],n},{})};var Et={blocks:o=>{const e=[],r=o.data.length;for(var i=0,n=W()(o);n!==0&&n;n=W()(o)){if(o.pos+n>=r){const c=r-o.pos;e.push(it(c)(o)),i+=c;break}e.push(it(n)(o)),i+=n}const s=new Uint8Array(i);for(var a=0,l=0;l<e.length;l++)s.set(e[l],a),a+=e[l].length;return s}};const Xe=dt({gce:[{codes:it(2)},{byteSize:W()},{extras:Ft({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:ht()},{transparentColorIndex:W()},{terminator:W()}]},o=>{var t=Tt(2)(o);return t[0]===33&&t[1]===249}),Ze=dt({image:[{code:W()},{descriptor:[{left:ht()},{top:ht()},{width:ht()},{height:ht()},{lct:Ft({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},dt({lct:le(3,(o,t,e)=>Math.pow(2,e.descriptor.lct.size+1))},(o,t,e)=>e.descriptor.lct.exists),{data:[{minCodeSize:W()},Et]}]},o=>ae()(o)===44),qe=dt({text:[{codes:it(2)},{blockSize:W()},{preData:(o,t,e)=>it(e.text.blockSize)(o)},Et]},o=>{var t=Tt(2)(o);return t[0]===33&&t[1]===1}),Je=dt({application:[{codes:it(2)},{blockSize:W()},{id:(o,t,e)=>Rt(e.blockSize)(o)},Et]},o=>{var t=Tt(2)(o);return t[0]===33&&t[1]===255}),We=dt({comment:[{codes:it(2)},Et]},o=>{var t=Tt(2)(o);return t[0]===33&&t[1]===254}),Ye=[{header:[{signature:Rt(3)},{version:Rt(3)}]},{lsd:[{width:ht()},{height:ht()},{gct:Ft({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:W()},{pixelAspectRatio:W()}]},dt({gct:le(3,(o,t)=>Math.pow(2,t.lsd.gct.size+1))},(o,t)=>t.lsd.gct.exists),{frames:ze([Xe,Je,We,Ze,qe],o=>{var t=ae()(o);return t===33||t===44})}],Qe=(o,t)=>{const e=new Array(o.length),r=o.length/t,i=function(h,f){const v=o.slice(f*t,(f+1)*t);e.splice.apply(e,[h*t,t].concat(v))},n=[0,4,2,1],s=[8,8,4,2];for(var a=0,l=0;l<4;l++)for(var c=n[l];c<r;c+=s[l])i(c,a),a++;return e},tr=(o,t,e)=>{const n=e;var s,a,l,c,h,f,v,b,A,k,d,T,m,y,I,B;const M=new Array(e),g=new Array(4096),p=new Array(4096),P=new Array(4097);for(T=o,a=1<<T,h=a+1,s=a+2,v=-1,c=T+1,l=(1<<c)-1,A=0;A<a;A++)g[A]=0,p[A]=A;var d,b,m,y,B,I;for(d=b=m=y=B=I=0,k=0;k<n;){if(y===0){if(b<c){d+=t[I]<<b,b+=8,I++;continue}if(A=d&l,d>>=c,b-=c,A>s||A==h)break;if(A==a){c=T+1,l=(1<<c)-1,s=a+2,v=-1;continue}if(v==-1){P[y++]=p[A],v=A,m=A;continue}for(f=A,A==s&&(P[y++]=m,A=v);A>a;)P[y++]=p[A],A=g[A];m=p[A]&255,P[y++]=m,s<4096&&(g[s]=v,p[s]=m,s++,!(s&l)&&s<4096&&(c++,l+=s)),v=f}y--,M[B++]=P[y],k++}for(k=B;k<n;k++)M[k]=0;return M},er=o=>{const t=new Uint8Array(o);return wt(He(t),Ye)},rr=o=>{const t=o.pixels.length,e=new Uint8ClampedArray(t*4);for(var r=0;r<t;r++){const i=r*4,n=o.pixels[r],s=o.colorTable[n];e[i]=s[0],e[i+1]=s[1],e[i+2]=s[2],e[i+3]=n!==o.transparentIndex?255:0}return e},ir=(o,t,e)=>{if(!o.image){console.warn("gif frame does not have associated image.");return}const{image:r}=o,i=r.descriptor.width*r.descriptor.height;var n=tr(r.data.minCodeSize,r.data.blocks,i);r.descriptor.lct.interlaced&&(n=Qe(n,r.descriptor.width));const s={pixels:n,dims:{top:o.image.descriptor.top,left:o.image.descriptor.left,width:o.image.descriptor.width,height:o.image.descriptor.height}};return r.descriptor.lct&&r.descriptor.lct.exists?s.colorTable=r.lct:s.colorTable=t,o.gce&&(s.delay=(o.gce.delay||10)*10,s.disposalType=o.gce.extras.disposal,o.gce.extras.transparentColorGiven&&(s.transparentIndex=o.gce.transparentColorIndex)),s.patch=rr(s),s},or=(o,t)=>o.frames.filter(e=>e.image).map(e=>ir(e,o.gct));var nr=100,H=256,qt=H-1,lt=4,ce=16,Ut=1<<ce,ue=10,Gt=10,sr=Ut>>Gt,ar=Ut<<ue-Gt,lr=H>>3,Ot=6,cr=1<<Ot,ur=lr*cr,hr=30,he=10,yt=1<<he,fe=8,Jt=1<<fe,fr=he+fe,gt=1<<fr,Wt=499,Yt=491,Qt=487,de=503,dr=3*de;function gr(o,t){var e,r,i,n,s;function a(){e=[],r=new Int32Array(256),i=new Int32Array(H),n=new Int32Array(H),s=new Int32Array(H>>3);var g,p;for(g=0;g<H;g++)p=(g<<lt+8)/H,e[g]=new Float64Array([p,p,p,0]),n[g]=Ut/H,i[g]=0}function l(){for(var g=0;g<H;g++)e[g][0]>>=lt,e[g][1]>>=lt,e[g][2]>>=lt,e[g][3]=g}function c(g,p,P,d,b){e[p][0]-=g*(e[p][0]-P)/yt,e[p][1]-=g*(e[p][1]-d)/yt,e[p][2]-=g*(e[p][2]-b)/yt}function h(g,p,P,d,b){for(var m=Math.abs(p-g),y=Math.min(p+g,H),B=p+1,I=p-1,N=1,u,R;B<y||I>m;)R=s[N++],B<y&&(u=e[B++],u[0]-=R*(u[0]-P)/gt,u[1]-=R*(u[1]-d)/gt,u[2]-=R*(u[2]-b)/gt),I>m&&(u=e[I--],u[0]-=R*(u[0]-P)/gt,u[1]-=R*(u[1]-d)/gt,u[2]-=R*(u[2]-b)/gt)}function f(g,p,P){var d=2147483647,b=d,m=-1,y=m,B,I,N,u,R;for(B=0;B<H;B++)I=e[B],N=Math.abs(I[0]-g)+Math.abs(I[1]-p)+Math.abs(I[2]-P),N<d&&(d=N,m=B),u=N-(i[B]>>ce-lt),u<b&&(b=u,y=B),R=n[B]>>Gt,n[B]-=R,i[B]+=R<<ue;return n[m]+=sr,i[m]-=ar,y}function v(){var g,p,P,d,b,m,y=0,B=0;for(g=0;g<H;g++){for(P=e[g],b=g,m=P[1],p=g+1;p<H;p++)d=e[p],d[1]<m&&(b=p,m=d[1]);if(d=e[b],g!=b&&(p=d[0],d[0]=P[0],P[0]=p,p=d[1],d[1]=P[1],P[1]=p,p=d[2],d[2]=P[2],P[2]=p,p=d[3],d[3]=P[3],P[3]=p),m!=y){for(r[y]=B+g>>1,p=y+1;p<m;p++)r[p]=g;y=m,B=g}}for(r[y]=B+qt>>1,p=y+1;p<256;p++)r[p]=qt}function A(g,p,P){for(var d,b,m,y=1e3,B=-1,I=r[p],N=I-1;I<H||N>=0;)I<H&&(b=e[I],m=b[1]-p,m>=y?I=H:(I++,m<0&&(m=-m),d=b[0]-g,d<0&&(d=-d),m+=d,m<y&&(d=b[2]-P,d<0&&(d=-d),m+=d,m<y&&(y=m,B=b[3])))),N>=0&&(b=e[N],m=p-b[1],m>=y?N=-1:(N--,m<0&&(m=-m),d=b[0]-g,d<0&&(d=-d),m+=d,m<y&&(d=b[2]-P,d<0&&(d=-d),m+=d,m<y&&(y=m,B=b[3]))));return B}function k(){var g,p=o.length,P=30+(t-1)/3,d=p/(3*t),b=~~(d/nr),m=yt,y=ur,B=y>>Ot;for(B<=1&&(B=0),g=0;g<B;g++)s[g]=m*((B*B-g*g)*Jt/(B*B));var I;p<dr?(t=1,I=3):p%Wt!==0?I=3*Wt:p%Yt!==0?I=3*Yt:p%Qt!==0?I=3*Qt:I=3*de;var N,u,R,C,O=0;for(g=0;g<d;)if(N=(o[O]&255)<<lt,u=(o[O+1]&255)<<lt,R=(o[O+2]&255)<<lt,C=f(N,u,R),c(m,C,N,u,R),B!==0&&h(B,C,N,u,R),O+=I,O>=p&&(O-=p),g++,b===0&&(b=1),g%b===0)for(m-=m/P,y-=y/hr,B=y>>Ot,B<=1&&(B=0),C=0;C<B;C++)s[C]=m*((B*B-C*C)*Jt/(B*B))}function T(){a(),k(),l(),v()}this.buildColormap=T;function M(){for(var g=[],p=[],P=0;P<H;P++)p[e[P][3]]=P;for(var d=0,b=0;b<H;b++){var m=p[b];g[d++]=e[m][0],g[d++]=e[m][1],g[d++]=e[m][2]}return g}this.getColormap=M,this.lookupRGB=A}var te=-1,Ct=12,mt=5003,pr=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function vr(o,t,e,r){var i=Math.max(2,r),n=new Uint8Array(256),s=new Int32Array(mt),a=new Int32Array(mt),l,c=0,h,f=0,v,A=!1,k,T,M,g,p,P;function d(C,O){n[h++]=C,h>=254&&I(O)}function b(C){m(mt),f=T+2,A=!0,R(T,C)}function m(C){for(var O=0;O<C;++O)s[O]=-1}function y(C,O){var w,ut,G,Y,at,V,Q;for(k=C,A=!1,P=k,v=N(P),T=1<<C-1,M=T+1,f=T+2,h=0,Y=u(),Q=0,w=mt;w<65536;w*=2)++Q;Q=8-Q,V=mt,m(V),R(T,O);t:for(;(ut=u())!=te;){if(w=(ut<<Ct)+Y,G=ut<<Q^Y,s[G]===w){Y=a[G];continue}else if(s[G]>=0){at=V-G,G===0&&(at=1);do if((G-=at)<0&&(G+=V),s[G]===w){Y=a[G];continue t}while(s[G]>=0)}R(Y,O),Y=ut,f<1<<Ct?(a[G]=f++,s[G]=w):b(O)}R(Y,O),R(M,O)}function B(C){C.writeByte(i),g=o*t,p=0,y(i+1,C),C.writeByte(0)}function I(C){h>0&&(C.writeByte(h),C.writeBytes(n,0,h),h=0)}function N(C){return(1<<C)-1}function u(){if(g===0)return te;--g;var C=e[p++];return C&255}function R(C,O){for(l&=pr[c],c>0?l|=C<<c:l=C,c+=P;c>=8;)d(l&255,O),l>>=8,c-=8;if((f>v||A)&&(A?(v=N(P=k),A=!1):(++P,P==Ct?v=1<<Ct:v=N(P))),C==M){for(;c>0;)d(l&255,O),l>>=8,c-=8;I(O)}}this.encode=B}function Z(){this.page=-1,this.pages=[],this.newPage()}Z.pageSize=4096;Z.charMap={};for(var At=0;At<256;At++)Z.charMap[At]=String.fromCharCode(At);Z.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(Z.pageSize),this.cursor=0};Z.prototype.getData=function(){for(var o="",t=0;t<this.pages.length;t++)for(var e=0;e<Z.pageSize;e++)o+=Z.charMap[this.pages[t][e]];return o};Z.prototype.toFlattenUint8Array=function(){const o=[];for(var t=0;t<this.pages.length;t++)if(t===this.pages.length-1){const r=Uint8Array.from(this.pages[t].slice(0,this.cursor));o.push(r)}else o.push(this.pages[t]);const e=new Uint8Array(o.reduce((r,i)=>r+i.length,0));return o.reduce((r,i)=>(e.set(i,r),r+i.length),0),e};Z.prototype.writeByte=function(o){this.cursor>=Z.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=o};Z.prototype.writeUTFBytes=function(o){for(var t=o.length,e=0;e<t;e++)this.writeByte(o.charCodeAt(e))};Z.prototype.writeBytes=function(o,t,e){for(var r=e||o.length,i=t||0;i<r;i++)this.writeByte(o[i])};function $(o,t){this.width=~~o,this.height=~~t,this.transparent=null,this.transIndex=0,this.repeat=-1,this.delay=0,this.image=null,this.pixels=null,this.indexedPixels=null,this.colorDepth=null,this.colorTab=null,this.neuQuant=null,this.usedEntry=new Array,this.palSize=7,this.dispose=-1,this.firstFrame=!0,this.sample=10,this.dither=!1,this.globalPalette=!1,this.out=new Z}$.prototype.setDelay=function(o){this.delay=Math.round(o/10)};$.prototype.setFrameRate=function(o){this.delay=Math.round(100/o)};$.prototype.setDispose=function(o){o>=0&&(this.dispose=o)};$.prototype.setRepeat=function(o){this.repeat=o};$.prototype.setTransparent=function(o){this.transparent=o};$.prototype.addFrame=function(o){this.image=o,this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null,this.getImagePixels(),this.analyzePixels(),this.globalPalette===!0&&(this.globalPalette=this.colorTab),this.firstFrame&&(this.writeHeader(),this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),!this.firstFrame&&!this.globalPalette&&this.writePalette(),this.writePixels(),this.firstFrame=!1};$.prototype.finish=function(){this.out.writeByte(59)};$.prototype.setQuality=function(o){o<1&&(o=1),this.sample=o};$.prototype.setDither=function(o){o===!0&&(o="FloydSteinberg"),this.dither=o};$.prototype.setGlobalPalette=function(o){this.globalPalette=o};$.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette};$.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")};$.prototype.analyzePixels=function(){this.colorTab||(this.neuQuant=new gr(this.pixels,this.sample),this.neuQuant.buildColormap(),this.colorTab=this.neuQuant.getColormap()),this.dither?this.ditherPixels(this.dither.replace("-serpentine",""),this.dither.match(/-serpentine/)!==null):this.indexPixels(),this.pixels=null,this.colorDepth=8,this.palSize=7,this.transparent!==null&&(this.transIndex=this.findClosest(this.transparent,!0))};$.prototype.indexPixels=function(o){var t=this.pixels.length/3;this.indexedPixels=new Uint8Array(t);for(var e=0,r=0;r<t;r++){var i=this.findClosestRGB(this.pixels[e++]&255,this.pixels[e++]&255,this.pixels[e++]&255);this.usedEntry[i]=!0,this.indexedPixels[r]=i}};$.prototype.ditherPixels=function(o,t){var e={FalseFloydSteinberg:[[.375,1,0],[.375,0,1],[.25,1,1]],FloydSteinberg:[[.4375,1,0],[.1875,-1,1],[.3125,0,1],[.0625,1,1]],Stucki:[[.19047619047619047,1,0],[.09523809523809523,2,0],[.047619047619047616,-2,1],[.09523809523809523,-1,1],[.19047619047619047,0,1],[.09523809523809523,1,1],[.047619047619047616,2,1],[.023809523809523808,-2,2],[.047619047619047616,-1,2],[.09523809523809523,0,2],[.047619047619047616,1,2],[.023809523809523808,2,2]],Atkinson:[[.125,1,0],[.125,2,0],[.125,-1,1],[.125,0,1],[.125,1,1],[.125,0,2]]};if(!o||!e[o])throw"Unknown dithering kernel: "+o;var r=e[o],i=0,n=this.height,s=this.width,a=this.pixels,l=t?-1:1;this.indexedPixels=new Uint8Array(this.pixels.length/3);for(var c=0;c<n;c++){t&&(l=l*-1);for(var h=l==1?0:s-1,f=l==1?s:0;h!==f;h+=l){i=c*s+h;var v=i*3,A=a[v],k=a[v+1],T=a[v+2];v=this.findClosestRGB(A,k,T),this.usedEntry[v]=!0,this.indexedPixels[i]=v,v*=3;for(var M=this.colorTab[v],g=this.colorTab[v+1],p=this.colorTab[v+2],P=A-M,d=k-g,b=T-p,m=l==1?0:r.length-1,y=l==1?r.length:0;m!==y;m+=l){var B=r[m][1],I=r[m][2];if(B+h>=0&&B+h<s&&I+c>=0&&I+c<n){var N=r[m][0];v=i+B+I*s,v*=3,a[v]=Math.max(0,Math.min(255,a[v]+P*N)),a[v+1]=Math.max(0,Math.min(255,a[v+1]+d*N)),a[v+2]=Math.max(0,Math.min(255,a[v+2]+b*N))}}}}};$.prototype.findClosest=function(o,t){return this.findClosestRGB((o&16711680)>>16,(o&65280)>>8,o&255,t)};$.prototype.findClosestRGB=function(o,t,e,r){if(this.colorTab===null)return-1;if(this.neuQuant&&!r)return this.neuQuant.lookupRGB(o,t,e);for(var i=0,n=256*256*256,s=this.colorTab.length,a=0,l=0;a<s;l++){var c=o-(this.colorTab[a++]&255),h=t-(this.colorTab[a++]&255),f=e-(this.colorTab[a++]&255),v=c*c+h*h+f*f;(!r||this.usedEntry[l])&&v<n&&(n=v,i=l)}return i};$.prototype.getImagePixels=function(){var o=this.width,t=this.height;this.pixels=new Uint8Array(o*t*3);for(var e=this.image,r=0,i=0,n=0;n<t;n++)for(var s=0;s<o;s++)this.pixels[i++]=e[r++],this.pixels[i++]=e[r++],this.pixels[i++]=e[r++],r++};$.prototype.writeGraphicCtrlExt=function(){this.out.writeByte(33),this.out.writeByte(249),this.out.writeByte(4);var o,t;this.transparent===null?(o=0,t=0):(o=1,t=2),this.dispose>=0&&(t=this.dispose&7),t<<=2,this.out.writeByte(0|t|0|o),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)};$.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)};$.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)};$.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)};$.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var o=3*256-this.colorTab.length,t=0;t<o;t++)this.out.writeByte(0)};$.prototype.writeShort=function(o){this.out.writeByte(o&255),this.out.writeByte(o>>8&255)};$.prototype.writePixels=function(){var o=new vr(this.width,this.height,this.indexedPixels,this.colorDepth);o.encode(this.out)};$.prototype.stream=function(){return this.out};var mr=globalThis&&globalThis.__awaiter||function(o,t,e,r){function i(n){return n instanceof e?n:new e(function(s){s(n)})}return new(e||(e=Promise))(function(n,s){function a(h){try{c(r.next(h))}catch(f){s(f)}}function l(h){try{c(r.throw(h))}catch(f){s(f)}}function c(h){h.done?n(h.value):i(h.value).then(a,l)}c((r=r.apply(o,t||[])).next())})};const{Canvas:ot}=Ve,Pt=.4;function ee(o){if(!o)return;function t(e){e.onload=null,e.onerror=null}return new Promise(function(e,r){if(o.slice(0,4)=="data"){let n=new Image;n.onload=function(){e(n),t(n)},n.onerror=function(){r("Image load error"),t(n)},n.src=o;return}let i=new Image;i.setAttribute("crossOrigin","Anonymous"),i.onload=function(){e(i)},i.onerror=function(){r("Image load error")},i.src=o})}class _{constructor(t){const e=Object.assign({},t);if(Object.keys(_.defaultOptions).forEach(r=>{r in e||Object.defineProperty(e,r,{value:_.defaultOptions[r],enumerable:!0,writable:!0})}),e.components?typeof e.components=="object"&&Object.keys(_.defaultComponentOptions).forEach(r=>{r in e.components?Object.defineProperty(e.components,r,{value:Object.assign(Object.assign({},_.defaultComponentOptions[r]),e.components[r]),enumerable:!0,writable:!0}):Object.defineProperty(e.components,r,{value:_.defaultComponentOptions[r],enumerable:!0,writable:!0})}):e.components=_.defaultComponentOptions,e.dotScale!==null&&e.dotScale!==void 0){if(e.dotScale<=0||e.dotScale>1)throw new Error("dotScale should be in range (0, 1].");e.components.data.scale=e.dotScale,e.components.timing.scale=e.dotScale,e.components.alignment.scale=e.dotScale}this.options=e,this.canvas=new ot(t.size,t.size),this.canvasContext=this.canvas.getContext("2d"),this.qrCode=new ct(-1,this.options.correctLevel),Number.isInteger(this.options.maskPattern)&&(this.qrCode.maskPattern=this.options.maskPattern),Number.isInteger(this.options.version)&&(this.qrCode.typeNumber=this.options.version),this.qrCode.addData(this.options.text),this.qrCode.make()}draw(){return new Promise(t=>this._draw().then(t))}_clear(){this.canvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)}static _prepareRoundedCornerClip(t,e,r,i,n,s){t.beginPath(),t.moveTo(e,r),t.arcTo(e+i,r,e+i,r+n,s),t.arcTo(e+i,r+n,e,r+n,s),t.arcTo(e,r+n,e,r,s),t.arcTo(e,r,e+i,r,s),t.closePath()}static _getAverageRGB(t){const r={r:0,g:0,b:0};let i,n,s=-4;const a={r:0,g:0,b:0};let l=0;n=t.naturalHeight||t.height,i=t.naturalWidth||t.width;const h=new ot(i,n).getContext("2d");if(!h)return r;h.drawImage(t,0,0);let f;try{f=h.getImageData(0,0,i,n)}catch{return r}for(;(s+=5*4)<f.data.length;)f.data[s]>200||f.data[s+1]>200||f.data[s+2]>200||(++l,a.r+=f.data[s],a.g+=f.data[s+1],a.b+=f.data[s+2]);return a.r=~~(a.r/l),a.g=~~(a.g/l),a.b=~~(a.b/l),a}static _drawDot(t,e,r,i,n=0,s=1){t.fillRect((e+n)*i,(r+n)*i,s*i,s*i)}static _drawAlignProtector(t,e,r,i){t.clearRect((e-2)*i,(r-2)*i,5*i,5*i),t.fillRect((e-2)*i,(r-2)*i,5*i,5*i)}static _drawAlign(t,e,r,i,n=0,s=1,a,l){const c=t.fillStyle;t.fillStyle=a,new Array(4).fill(0).map((h,f)=>{_._drawDot(t,e-2+f,r-2,i,n,s),_._drawDot(t,e+2,r-2+f,i,n,s),_._drawDot(t,e+2-f,r+2,i,n,s),_._drawDot(t,e-2,r+2-f,i,n,s)}),_._drawDot(t,e,r,i,n,s),l||(t.fillStyle="rgba(255, 255, 255, 0.6)",new Array(2).fill(0).map((h,f)=>{_._drawDot(t,e-1+f,r-1,i,n,s),_._drawDot(t,e+1,r-1+f,i,n,s),_._drawDot(t,e+1-f,r+1,i,n,s),_._drawDot(t,e-1,r+1-f,i,n,s)})),t.fillStyle=c}_draw(){var t,e,r,i,n,s,a,l,c,h,f,v,A,k,T,M,g,p,P;return mr(this,void 0,void 0,function*(){const d=(t=this.qrCode)===null||t===void 0?void 0:t.moduleCount,b=this.options.size;let m=this.options.margin;(m<0||m*2>=b)&&(m=0);const y=Math.ceil(m),B=b-2*m,I=this.options.whiteMargin,N=this.options.backgroundDimming,u=Math.ceil(B/d),R=u*d,C=R+2*y,O=new ot(C,C),w=O.getContext("2d");this._clear(),w.save(),w.translate(y,y);const ut=new ot(C,C),G=ut.getContext("2d");let Y=null,at=[];if(this.options.gifBackground){const D=er(this.options.gifBackground);if(Y=D,at=or(D),this.options.autoColor){let E=0,x=0,S=0,z=0;for(let F=0;F<at[0].colorTable.length;F++){const U=at[0].colorTable[F];U[0]>200||U[1]>200||U[2]>200||U[0]===0&&U[1]===0&&U[2]===0||(z++,E+=U[0],x+=U[1],S+=U[2])}E=~~(E/z),x=~~(x/z),S=~~(S/z),this.options.colorDark=`rgb(${E},${x},${S})`}}else if(this.options.backgroundImage){const D=yield ee(this.options.backgroundImage);if(this.options.autoColor){const E=_._getAverageRGB(D);this.options.colorDark=`rgb(${E.r},${E.g},${E.b})`}G.drawImage(D,0,0,D.width,D.height,0,0,C,C),G.rect(0,0,C,C),G.fillStyle=N,G.fill()}else G.rect(0,0,C,C),G.fillStyle=this.options.colorLight,G.fill();const V=L.getPatternPosition(this.qrCode.typeNumber),Q=((r=(e=this.options.components)===null||e===void 0?void 0:e.data)===null||r===void 0?void 0:r.scale)||Pt,jt=(1-Q)*.5;for(let D=0;D<d;D++)for(let E=0;E<d;E++){const x=this.qrCode.isDark(D,E),S=E<8&&(D<8||D>=d-8)||E>=d-8&&D<8,z=D==6&&E>=8&&E<=d-8||E==6&&D>=8&&D<=d-8;let F=S||z;for(let K=1;K<V.length-1;K++)F=F||D>=V[K]-2&&D<=V[K]+2&&E>=V[K]-2&&E<=V[K]+2;const U=E*u+(F?0:jt*u),tt=D*u+(F?0:jt*u);if(w.strokeStyle=x?this.options.colorDark:this.options.colorLight,w.lineWidth=.5,w.fillStyle=x?this.options.colorDark:this.options.colorLight,V.length===0)F||w.fillRect(U,tt,(F?1:Q)*u,(F?1:Q)*u);else{const K=E<d-4&&E>=d-4-5&&D<d-4&&D>=d-4-5;!F&&!K&&w.fillRect(U,tt,(F?1:Q)*u,(F?1:Q)*u)}}const J=V[V.length-1],ge=this.options.colorLight;if(w.fillStyle=ge,w.fillRect(0,0,8*u,8*u),w.fillRect(0,(d-8)*u,8*u,8*u),w.fillRect((d-8)*u,0,8*u,8*u),!((n=(i=this.options.components)===null||i===void 0?void 0:i.timing)===null||n===void 0)&&n.protectors&&(w.fillRect(8*u,6*u,(d-8-8)*u,u),w.fillRect(6*u,8*u,u,(d-8-8)*u)),!((a=(s=this.options.components)===null||s===void 0?void 0:s.cornerAlignment)===null||a===void 0)&&a.protectors&&_._drawAlignProtector(w,J,J,u),!((c=(l=this.options.components)===null||l===void 0?void 0:l.alignment)===null||c===void 0)&&c.protectors)for(let D=0;D<V.length;D++)for(let E=0;E<V.length;E++){const x=V[E],S=V[D];if(!(x===6&&(S===6||S===J))){if(S===6&&(x===6||x===J))continue;if(x===J&&S===J)continue;_._drawAlignProtector(w,x,S,u)}}w.fillStyle=this.options.colorDark,w.fillRect(0,0,7*u,u),w.fillRect((d-7)*u,0,7*u,u),w.fillRect(0,6*u,7*u,u),w.fillRect((d-7)*u,6*u,7*u,u),w.fillRect(0,(d-7)*u,7*u,u),w.fillRect(0,(d-7+6)*u,7*u,u),w.fillRect(0,0,u,7*u),w.fillRect(6*u,0,u,7*u),w.fillRect((d-7)*u,0,u,7*u),w.fillRect((d-7+6)*u,0,u,7*u),w.fillRect(0,(d-7)*u,u,7*u),w.fillRect(6*u,(d-7)*u,u,7*u),w.fillRect(2*u,2*u,3*u,3*u),w.fillRect((d-7+2)*u,2*u,3*u,3*u),w.fillRect(2*u,(d-7+2)*u,3*u,3*u);const It=((f=(h=this.options.components)===null||h===void 0?void 0:h.timing)===null||f===void 0?void 0:f.scale)||Pt,Vt=(1-It)*.5;for(let D=0;D<d-8;D+=2)_._drawDot(w,8+D,6,u,Vt,It),_._drawDot(w,6,8+D,u,Vt,It);const zt=((A=(v=this.options.components)===null||v===void 0?void 0:v.cornerAlignment)===null||A===void 0?void 0:A.scale)||Pt,pe=(1-zt)*.5;_._drawAlign(w,J,J,u,pe,zt,this.options.colorDark,((T=(k=this.options.components)===null||k===void 0?void 0:k.cornerAlignment)===null||T===void 0?void 0:T.protectors)||!1);const Ht=((g=(M=this.options.components)===null||M===void 0?void 0:M.alignment)===null||g===void 0?void 0:g.scale)||Pt,ve=(1-Ht)*.5;for(let D=0;D<V.length;D++)for(let E=0;E<V.length;E++){const x=V[E],S=V[D];if(!(x===6&&(S===6||S===J))){if(S===6&&(x===6||x===J))continue;if(x===J&&S===J)continue;_._drawAlign(w,x,S,u,ve,Ht,this.options.colorDark,((P=(p=this.options.components)===null||p===void 0?void 0:p.alignment)===null||P===void 0?void 0:P.protectors)||!1)}}if(I&&(w.fillStyle=this.options.backgroundColor,w.fillRect(-y,-y,C,y),w.fillRect(-y,R,C,y),w.fillRect(R,-y,y,C),w.fillRect(-y,-y,y,C)),this.options.logoImage){const D=yield ee(this.options.logoImage);let E=this.options.logoScale,x=this.options.logoMargin,S=this.options.logoCornerRadius;(E<=0||E>=1)&&(E=.2),x<0&&(x=0),S<0&&(S=0);const z=R*E,F=.5*(C-z),U=F;w.restore(),w.fillStyle=this.options.logoBackgroundColor,w.save(),_._prepareRoundedCornerClip(w,F-x,U-x,z+2*x,z+2*x,S+x),w.clip();const tt=w.globalCompositeOperation;w.globalCompositeOperation="destination-out",w.fill(),w.globalCompositeOperation=tt,w.restore(),w.save(),_._prepareRoundedCornerClip(w,F,U,z,z,S),w.clip(),w.drawImage(D,F,U,z,z),w.restore(),w.save(),w.translate(y,y)}if(Y){let D,E,x,S,z,F;if(at.forEach(function(U){D||(D=new $(b,b),D.setDelay(U.delay),D.setRepeat(0));const{width:tt,height:K}=U.dims;E||(E=new ot(tt,K),x=E.getContext("2d"),x.rect(0,0,E.width,E.height),x.fillStyle="#ffffff",x.fill()),(!S||!F||tt!==S.width||K!==S.height)&&(S=new ot(tt,K),z=S.getContext("2d"),F=z.createImageData(tt,K)),F.data.set(U.patch),z.putImageData(F,0,0),x.drawImage(S.getContext("2d").canvas,U.dims.left,U.dims.top);const bt=new ot(C,C),vt=bt.getContext("2d");vt.drawImage(E.getContext("2d").canvas,0,0,C,C),vt.rect(0,0,C,C),vt.fillStyle=N,vt.fill(),vt.drawImage(O.getContext("2d").canvas,0,0,C,C);const xt=new ot(b,b),Kt=xt.getContext("2d");Kt.drawImage(bt.getContext("2d").canvas,0,0,b,b),D.addFrame(Kt.getImageData(0,0,xt.width,xt.height).data)}),!D)throw new Error("No frames.");if(D.finish(),re(this.canvas)){const tt=D.stream().toFlattenUint8Array().reduce((K,bt)=>K+String.fromCharCode(bt),"");return Promise.resolve(`data:image/gif;base64,${window.btoa(tt)}`)}return Promise.resolve(Buffer.from(D.stream().toFlattenUint8Array()))}else{G.drawImage(O.getContext("2d").canvas,0,0,C,C),w.drawImage(ut.getContext("2d").canvas,-y,-y,C,C);const D=new ot(b,b);D.getContext("2d").drawImage(O.getContext("2d").canvas,0,0,b,b),this.canvas=D;const x=this.options.gifBackground?"gif":"png";return re(this.canvas)?Promise.resolve(this.canvas.toDataURL(x)):Promise.resolve(this.canvas.toBuffer(x))}})}}_.CorrectLevel=X;_.defaultComponentOptions={data:{scale:.4},timing:{scale:.5,protectors:!1},alignment:{scale:.5,protectors:!1},cornerAlignment:{scale:.5,protectors:!0}};_.defaultOptions={text:"",size:400,margin:20,colorDark:"#000000",colorLight:"rgba(255, 255, 255, 0.6)",correctLevel:X.M,backgroundImage:void 0,backgroundDimming:"rgba(0,0,0,0)",logoImage:void 0,logoScale:.2,logoMargin:4,logoCornerRadius:8,whiteMargin:!0,components:_.defaultComponentOptions,autoColor:!0,logoBackgroundColor:"#ffffff",backgroundColor:"#ffffff"};function re(o){try{return o instanceof HTMLElement}catch{return typeof o=="object"&&o.nodeType===1&&typeof o.style=="object"&&typeof o.ownerDocument=="object"}}function Bt(o,...t){if(Array.isArray(o))o.forEach(e=>Bt(e,...t));else return o(...t)}const wr=(o,t)=>{const e=document.createElement("a");e.href=o,e.download=t||new Date().getTime()+".png",e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e)},br=o=>new Promise((t,e)=>{const r=new XMLHttpRequest;r.responseType="blob",r.onload=()=>{const i=new FileReader;i.onloadend=()=>{t(i.result)},i.onerror=n=>{e(n)},i.onabort=n=>{e(n)},i.readAsArrayBuffer(r.response)},r.open("GET",o),r.send()}),Nt=Vue.defineComponent({name:"Vue3NextQrcode",props:me,setup(o,t){const{expose:e}=t,r=Vue.computed(()=>({"--ray-qrcode-width":o.size+"px","--ray-qrcode-height":o.size+"px","--ray-qrcode-border-radius":o.logoCornerRadius+"px","--ray-qrcode-mask-color":o.maskColor})),i=Vue.ref();let n;const s=Vue.ref(!1);let a;const l=async()=>{const{gifBackgroundURL:v}=o;if(v)try{n=await br(v)}catch(A){console.error(A)}},c=()=>{const{gifBackgroundURL:v,gifBackground:A,...k}=o;new _({...k,gifBackground:n??void 0}).draw().then(T=>{const{onSuccess:M}=o;M&&Bt(M,T),i.value=T}).catch(T=>{const{onError:M}=o;M&&Bt(M,T)})},h=()=>{if(t.slots.errorAction)return;const{onReload:v}=o;v&&Bt(v)},f=v=>i.value&&typeof i.value=="string"?new Promise(A=>{wr(i.value,v),A()}):Promise.reject();return Vue.watchEffect(()=>{o.watchText?a=Vue.watch(()=>o.text,()=>c()):a==null||a()}),e({downloadQRCode:f}),Vue.onMounted(async()=>{await l(),c()}),Vue.onBeforeUnmount(()=>{a==null||a()}),{qrcodeURL:i,errorActionClick:h,cssVars:r,isClick:s}},render(){return Vue.createVNode("div",{class:"ray-qrcode",style:[this.cssVars]},[Vue.createVNode("div",{class:[this.status==="loading"&&!this.$slots.loading?"ray-qrcode__loading":"",this.$slots.loading?"ray-qrcode__loading--custom":""]},[this.status==="loading"?this.$slots.loading?Vue.createVNode("div",{class:"ray-qrcode__loading-slots"},[this.$slots.loading()]):Vue.createVNode("div",{class:"ray-qrcode__spin"},null):null,Vue.createVNode("img",Vue.mergeProps({src:this.qrcodeURL},{img_tag:"VUE3_NEXT_QRCODE"}),null)]),this.status==="error"?Vue.createVNode("div",{class:"ray-qrcode__error"},[Vue.createVNode("div",{class:"ray-qrcode__error-content"},[typeof this.errorDescription=="string"?this.errorDescription:()=>this.errorDescription]),Vue.createVNode("div",{class:"ray-qrcode__error-btn",onClick:this.errorActionClick.bind(this)},[this.$slots.errorAction?this.$slots.errorAction():Vue.createVNode("span",{onMousedown:()=>{this.isClick=!0},onMouseup:()=>{this.isClick=!1},class:[this.isClick?"ray-qrcode__error-btn-click":""]},[this.errorActionDescription])])]):null])}});Nt.install=function(o){o.component(Nt.name,Nt)};export{Nt as Q};
|