@woosh/meep-engine 2.126.4 → 2.126.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/package.json +1 -1
- package/src/core/assert.d.ts +8 -0
- package/src/core/assert.d.ts.map +1 -1
- package/src/core/assert.js +19 -3
- package/src/engine/ecs/storage/BinaryBufferDeSerializer.d.ts +6 -3
- package/src/engine/ecs/storage/BinaryBufferDeSerializer.d.ts.map +1 -1
- package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +15 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),i=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),r=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=new Array(576);t(a);const s=new Array(60);t(s);const o=new Array(512);t(o);const h=new Array(256);t(h);const l=new Array(29);t(l);const d=new Array(30);function c(t,e,i,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}let f,u,_;function p(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);const w=t=>t<256?o[t]:o[256+(t>>>7)],g=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},b=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,g(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)},m=(t,e,i)=>{b(t,i[2*e],i[2*e+1])},y=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},k=(t,e,i)=>{const n=new Array(16);let r,a,s=0;for(r=1;r<=15;r++)n[r]=s=s+i[r-1]<<1;for(a=0;a<=e;a++){let e=t[2*a+1];0!==e&&(t[2*a]=y(n[e]++,e))}},v=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},A=t=>{t.bi_valid>8?g(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},x=(t,e,i,n)=>{const r=2*e,a=2*i;return t[r]<t[a]||t[r]===t[a]&&n[e]<=n[i]},U=(t,e,i)=>{const n=t.heap[i];let r=i<<1;for(;r<=t.heap_len&&(r<t.heap_len&&x(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!x(e,n,t.heap[r],t.depth));)t.heap[i]=t.heap[r],i=r,r<<=1;t.heap[i]=n},E=(t,n,r)=>{let a,s,o,c,f=0;if(0!==t.last_lit)do{a=t.pending_buf[t.d_buf+2*f]<<8|t.pending_buf[t.d_buf+2*f+1],s=t.pending_buf[t.l_buf+f],f++,0===a?m(t,s,n):(o=h[s],m(t,o+256+1,n),c=e[o],0!==c&&(s-=l[o],b(t,s,c)),a--,o=w(a),m(t,o,r),c=i[o],0!==c&&(a-=d[o],b(t,a,c)))}while(f<t.last_lit);m(t,256,n)},I=(t,e)=>{const i=e.dyn_tree,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,a=e.stat_desc.elems;let s,o,h,l=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<a;s++)0!==i[2*s]?(t.heap[++t.heap_len]=l=s,t.depth[s]=0):i[2*s+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=l<2?++l:0,i[2*h]=1,t.depth[h]=0,t.opt_len--,r&&(t.static_len-=n[2*h+1]);for(e.max_code=l,s=t.heap_len>>1;s>=1;s--)U(t,i,s);h=a;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],U(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=o,i[2*h]=i[2*s]+i[2*o],t.depth[h]=(t.depth[s]>=t.depth[o]?t.depth[s]:t.depth[o])+1,i[2*s+1]=i[2*o+1]=h,t.heap[1]=h++,U(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,r=e.stat_desc.static_tree,a=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let l,d,c,f,u,_,p=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(i[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)d=t.heap[l],f=i[2*i[2*d+1]+1]+1,f>h&&(f=h,p++),i[2*d+1]=f,d>n||(t.bl_count[f]++,u=0,d>=o&&(u=s[d-o]),_=i[2*d],t.opt_len+=_*(f+u),a&&(t.static_len+=_*(r[2*d+1]+u)));if(0!==p){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,p-=2}while(p>0);for(f=h;0!==f;f--)for(d=t.bl_count[f];0!==d;)c=t.heap[--l],c>n||(i[2*c+1]!==f&&(t.opt_len+=(f-i[2*c+1])*i[2*c],i[2*c+1]=f),d--)}})(t,e),k(i,l,t.bl_count)},z=(t,e,i)=>{let n,r,a=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)r=s,s=e[2*(n+1)+1],++o<h&&r===s||(o<l?t.bl_tree[2*r]+=o:0!==r?(r!==a&&t.bl_tree[2*r]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,a=r,0===s?(h=138,l=3):r===s?(h=6,l=3):(h=7,l=4))},S=(t,e,i)=>{let n,r,a=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),n=0;n<=i;n++)if(r=s,s=e[2*(n+1)+1],!(++o<h&&r===s)){if(o<l)do{m(t,r,t.bl_tree)}while(0!=--o);else 0!==r?(r!==a&&(m(t,r,t.bl_tree),o--),m(t,16,t.bl_tree),b(t,o-3,2)):o<=10?(m(t,17,t.bl_tree),b(t,o-3,3)):(m(t,18,t.bl_tree),b(t,o-11,7));o=0,a=r,0===s?(h=138,l=3):r===s?(h=6,l=3):(h=7,l=4)}};let C=!1;const T=(t,e,i,n)=>{b(t,0+(n?1:0),3),((t,e,i,n)=>{A(t),g(t,i),g(t,~i),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i)};var R={_tr_init:t=>{C||((()=>{let t,r,p,w,g;const b=new Array(16);for(p=0,w=0;w<28;w++)for(l[w]=p,t=0;t<1<<e[w];t++)h[p++]=w;for(h[p-1]=w,g=0,w=0;w<16;w++)for(d[w]=g,t=0;t<1<<i[w];t++)o[g++]=w;for(g>>=7;w<30;w++)for(d[w]=g<<7,t=0;t<1<<i[w]-7;t++)o[256+g++]=w;for(r=0;r<=15;r++)b[r]=0;for(t=0;t<=143;)a[2*t+1]=8,t++,b[8]++;for(;t<=255;)a[2*t+1]=9,t++,b[9]++;for(;t<=279;)a[2*t+1]=7,t++,b[7]++;for(;t<=287;)a[2*t+1]=8,t++,b[8]++;for(k(a,287,b),t=0;t<30;t++)s[2*t+1]=5,s[2*t]=y(t,5);f=new c(a,e,257,286,15),u=new c(s,i,0,30,15),_=new c(new Array(0),n,0,19,7)})(),C=!0),t.l_desc=new p(t.dyn_ltree,f),t.d_desc=new p(t.dyn_dtree,u),t.bl_desc=new p(t.bl_tree,_),t.bi_buf=0,t.bi_valid=0,v(t)},_tr_stored_block:T,_tr_flush_block:(t,e,i,n)=>{let o,h,l=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),I(t,t.l_desc),I(t,t.d_desc),l=(t=>{let e;for(z(t,t.dyn_ltree,t.l_desc.max_code),z(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*r[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),o=t.opt_len+3+7>>>3,h=t.static_len+3+7>>>3,h<=o&&(o=h)):o=h=i+5,i+4<=o&&-1!==e?T(t,e,i,n):4===t.strategy||h===o?(b(t,2+(n?1:0),3),E(t,a,s)):(b(t,4+(n?1:0),3),((t,e,i,n)=>{let a;for(b(t,e-257,5),b(t,i-1,5),b(t,n-4,4),a=0;a<n;a++)b(t,t.bl_tree[2*r[a]+1],3);S(t,t.dyn_ltree,e-1),S(t,t.dyn_dtree,i-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,l+1),E(t,t.dyn_ltree,t.dyn_dtree)),v(t),n&&A(t)},_tr_tally:(t,e,i)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(h[i]+256+1)]++,t.dyn_dtree[2*w(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{b(t,2,3),m(t,256,a),(t=>{16===t.bi_valid?(g(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},F=(t,e,i,n)=>{let r=65535&t|0,a=t>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{r=r+e[n++]|0,a=a+r|0}while(--s);r%=65521,a%=65521}return r|a<<16|0};const B=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var N=(t,e,i,n)=>{const r=B,a=n+i;t^=-1;for(let i=n;i<a;i++)t=t>>>8^r[255&(t^e[i])];return-1^t},D={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Z={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:L,_tr_stored_block:O,_tr_flush_block:M,_tr_tally:V,_tr_align:$}=R,{Z_NO_FLUSH:H,Z_PARTIAL_FLUSH:P,Z_FULL_FLUSH:j,Z_FINISH:G,Z_BLOCK:K,Z_OK:X,Z_STREAM_END:Y,Z_STREAM_ERROR:q,Z_DATA_ERROR:W,Z_BUF_ERROR:J,Z_DEFAULT_COMPRESSION:Q,Z_FILTERED:tt,Z_HUFFMAN_ONLY:et,Z_RLE:it,Z_FIXED:nt,Z_DEFAULT_STRATEGY:rt,Z_UNKNOWN:at,Z_DEFLATED:st}=Z,ot=258,ht=262,lt=103,dt=113,ct=666,ft=(t,e)=>(t.msg=D[e],e),ut=t=>(t<<1)-(t>4?9:0),_t=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let pt=(t,e,i)=>(e<<t.hash_shift^i)&t.hash_mask;const wt=t=>{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},gt=(t,e)=>{M(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,wt(t.strm)},bt=(t,e)=>{t.pending_buf[t.pending++]=e},mt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},yt=(t,e,i,n)=>{let r=t.avail_in;return r>n&&(r=n),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),i),1===t.state.wrap?t.adler=F(t.adler,e,r,i):2===t.state.wrap&&(t.adler=N(t.adler,e,r,i)),t.next_in+=r,t.total_in+=r,r)},kt=(t,e)=>{let i,n,r=t.max_chain_length,a=t.strstart,s=t.prev_length,o=t.nice_match;const h=t.strstart>t.w_size-ht?t.strstart-(t.w_size-ht):0,l=t.window,d=t.w_mask,c=t.prev,f=t.strstart+ot;let u=l[a+s-1],_=l[a+s];t.prev_length>=t.good_match&&(r>>=2),o>t.lookahead&&(o=t.lookahead);do{if(i=e,l[i+s]===_&&l[i+s-1]===u&&l[i]===l[a]&&l[++i]===l[a+1]){a+=2,i++;do{}while(l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&a<f);if(n=ot-(f-a),a=f-ot,n>s){if(t.match_start=e,s=n,n>=o)break;u=l[a+s-1],_=l[a+s]}}}while((e=c[e&d])>h&&0!=--r);return s<=t.lookahead?s:t.lookahead},vt=t=>{const e=t.w_size;let i,n,r,a,s;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ht)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,i=n;do{r=t.head[--i],t.head[i]=r>=e?r-e:0}while(--n);n=e,i=n;do{r=t.prev[--i],t.prev[i]=r>=e?r-e:0}while(--n);a+=e}if(0===t.strm.avail_in)break;if(n=yt(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=n,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=pt(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=pt(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<ht&&0!==t.strm.avail_in)},At=(t,e)=>{let i,n;for(;;){if(t.lookahead<ht){if(vt(t),t.lookahead<ht&&e===H)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-ht&&(t.match_length=kt(t,i)),t.match_length>=3)if(n=V(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=pt(t,t.ins_h,t.window[t.strstart+1]);else n=V(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2},xt=(t,e)=>{let i,n,r;for(;;){if(t.lookahead<ht){if(vt(t),t.lookahead<ht&&e===H)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-ht&&(t.match_length=kt(t,i),t.match_length<=5&&(t.strategy===tt||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=V(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(gt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=V(t,0,t.window[t.strstart-1]),n&>(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=V(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2};function Ut(t,e,i,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=r}const Et=[new Ut(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(vt(t),0===t.lookahead&&e===H)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,gt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-ht&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(gt(t,!1),t.strm.avail_out),1)})),new Ut(4,4,8,4,At),new Ut(4,5,16,8,At),new Ut(4,6,32,32,At),new Ut(4,4,16,16,xt),new Ut(8,16,32,32,xt),new Ut(8,16,128,128,xt),new Ut(8,32,128,256,xt),new Ut(32,128,258,1024,xt),new Ut(32,258,258,4096,xt)];function It(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=st,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),_t(this.dyn_ltree),_t(this.dyn_dtree),_t(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),_t(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),_t(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const zt=t=>{if(!t||!t.state)return ft(t,q);t.total_in=t.total_out=0,t.data_type=at;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:dt,t.adler=2===e.wrap?0:1,e.last_flush=H,L(e),X},St=t=>{const e=zt(t);var i;return e===X&&((i=t.state).window_size=2*i.w_size,_t(i.head),i.max_lazy_match=Et[i.level].max_lazy,i.good_match=Et[i.level].good_length,i.nice_match=Et[i.level].nice_length,i.max_chain_length=Et[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},Ct=(t,e,i,n,r,a)=>{if(!t)return q;let s=1;if(e===Q&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),r<1||r>9||i!==st||n<8||n>15||e<0||e>9||a<0||a>nt)return ft(t,q);8===n&&(n=9);const o=new It;return t.state=o,o.strm=t,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=r+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<r+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=a,o.method=i,St(t)};var Tt={deflateInit:(t,e)=>Ct(t,e,st,15,8,rt),deflateInit2:Ct,deflateReset:St,deflateResetKeep:zt,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?q:(t.state.gzhead=e,X):q,deflate:(t,e)=>{let i,n;if(!t||!t.state||e>K||e<0)return t?ft(t,q):q;const r=t.state;if(!t.output||!t.input&&0!==t.avail_in||r.status===ct&&e!==G)return ft(t,0===t.avail_out?J:q);r.strm=t;const a=r.last_flush;if(r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,bt(r,31),bt(r,139),bt(r,8),r.gzhead?(bt(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),bt(r,255&r.gzhead.time),bt(r,r.gzhead.time>>8&255),bt(r,r.gzhead.time>>16&255),bt(r,r.gzhead.time>>24&255),bt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),bt(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(bt(r,255&r.gzhead.extra.length),bt(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=N(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(bt(r,0),bt(r,0),bt(r,0),bt(r,0),bt(r,0),bt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),bt(r,3),r.status=dt);else{let e=st+(r.w_bits-8<<4)<<8,i=-1;i=r.strategy>=et||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=i<<6,0!==r.strstart&&(e|=32),e+=31-e%31,r.status=dt,mt(r,e),0!==r.strstart&&(mt(r,t.adler>>>16),mt(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),wt(t),i=r.pending,r.pending!==r.pending_buf_size));)bt(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),wt(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,bt(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),wt(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,bt(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.status=lt)}else r.status=lt;if(r.status===lt&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&wt(t),r.pending+2<=r.pending_buf_size&&(bt(r,255&t.adler),bt(r,t.adler>>8&255),t.adler=0,r.status=dt)):r.status=dt),0!==r.pending){if(wt(t),0===t.avail_out)return r.last_flush=-1,X}else if(0===t.avail_in&&ut(e)<=ut(a)&&e!==G)return ft(t,J);if(r.status===ct&&0!==t.avail_in)return ft(t,J);if(0!==t.avail_in||0!==r.lookahead||e!==H&&r.status!==ct){let i=r.strategy===et?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(vt(t),0===t.lookahead)){if(e===H)return 1;break}if(t.match_length=0,i=V(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===it?((t,e)=>{let i,n,r,a;const s=t.window;for(;;){if(t.lookahead<=ot){if(vt(t),t.lookahead<=ot&&e===H)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,n=s[r],n===s[++r]&&n===s[++r]&&n===s[++r])){a=t.strstart+ot;do{}while(n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&r<a);t.match_length=ot-(a-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=V(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=V(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(gt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(gt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(gt(t,!1),0===t.strm.avail_out)?1:2})(r,e):Et[r.level].func(r,e);if(3!==i&&4!==i||(r.status=ct),1===i||3===i)return 0===t.avail_out&&(r.last_flush=-1),X;if(2===i&&(e===P?$(r):e!==K&&(O(r,0,0,!1),e===j&&(_t(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),wt(t),0===t.avail_out))return r.last_flush=-1,X}return e!==G?X:r.wrap<=0?Y:(2===r.wrap?(bt(r,255&t.adler),bt(r,t.adler>>8&255),bt(r,t.adler>>16&255),bt(r,t.adler>>24&255),bt(r,255&t.total_in),bt(r,t.total_in>>8&255),bt(r,t.total_in>>16&255),bt(r,t.total_in>>24&255)):(mt(r,t.adler>>>16),mt(r,65535&t.adler)),wt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?X:Y)},deflateEnd:t=>{if(!t||!t.state)return q;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==lt&&e!==dt&&e!==ct?ft(t,q):(t.state=null,e===dt?ft(t,W):X)},deflateSetDictionary:(t,e)=>{let i=e.length;if(!t||!t.state)return q;const n=t.state,r=n.wrap;if(2===r||1===r&&42!==n.status||n.lookahead)return q;if(1===r&&(t.adler=F(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===r&&(_t(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const a=t.avail_in,s=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,vt(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=pt(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,vt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=o,t.avail_in=a,n.wrap=r,X},deflateInfo:"pako deflate (from Nodeca project)"};const Rt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ft={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Rt(i,e)&&(t[e]=i[e])}}return t},flattenChunks:t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,n=0,r=t.length;e<r;e++){let r=t[e];i.set(r,n),n+=r.length}return i}};let Bt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Bt=!1}const Nt=new Uint8Array(256);for(let t=0;t<256;t++)Nt[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Nt[254]=Nt[254]=1;var Dt={string2buf:t=>{let e,i,n,r,a,s=t.length,o=0;for(r=0;r<s;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<s&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(o),a=0,r=0;a<o;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<s&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?e[a++]=i:i<2048?(e[a++]=192|i>>>6,e[a++]=128|63&i):i<65536?(e[a++]=224|i>>>12,e[a++]=128|i>>>6&63,e[a++]=128|63&i):(e[a++]=240|i>>>18,e[a++]=128|i>>>12&63,e[a++]=128|i>>>6&63,e[a++]=128|63&i);return e},buf2string:(t,e)=>{let i,n;const r=e||t.length,a=new Array(2*r);for(n=0,i=0;i<r;){let e=t[i++];if(e<128){a[n++]=e;continue}let s=Nt[e];if(s>4)a[n++]=65533,i+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&i<r;)e=e<<6|63&t[i++],s--;s>1?a[n++]=65533:e<65536?a[n++]=e:(e-=65536,a[n++]=55296|e>>10&1023,a[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Bt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n<e;n++)i+=String.fromCharCode(t[n]);return i})(a,n)},utf8border:(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Nt[t[i]]>e?i:e}},Zt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Lt=Object.prototype.toString,{Z_NO_FLUSH:Ot,Z_SYNC_FLUSH:Mt,Z_FULL_FLUSH:Vt,Z_FINISH:$t,Z_OK:Ht,Z_STREAM_END:Pt,Z_DEFAULT_COMPRESSION:jt,Z_DEFAULT_STRATEGY:Gt,Z_DEFLATED:Kt}=Z;function Xt(t){this.options=Ft.assign({level:jt,method:Kt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Gt},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zt,this.strm.avail_out=0;let i=Tt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==Ht)throw new Error(D[i]);if(e.header&&Tt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Dt.string2buf(e.dictionary):"[object ArrayBuffer]"===Lt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=Tt.deflateSetDictionary(this.strm,t),i!==Ht)throw new Error(D[i]);this._dict_set=!0}}function Yt(t,e){const i=new Xt(e);if(i.push(t,!0),i.err)throw i.msg||D[i.err];return i.result}Xt.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let r,a;if(this.ended)return!1;for(a=e===~~e?e:!0===e?$t:Ot,"string"==typeof t?i.input=Dt.string2buf(t):"[object ArrayBuffer]"===Lt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(a===Mt||a===Vt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Tt.deflate(i,a),r===Pt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Tt.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Ht;if(0!==i.avail_out){if(a>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Xt.prototype.onData=function(t){this.chunks.push(t)},Xt.prototype.onEnd=function(t){t===Ht&&(this.result=Ft.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var qt={Deflate:Xt,deflate:Yt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Yt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Yt(t,e)},constants:Z},Wt=function(t,e){let i,n,r,a,s,o,h,l,d,c,f,u,_,p,w,g,b,m,y,k,v,A,x,U;const E=t.state;i=t.next_in,x=t.input,n=i+(t.avail_in-5),r=t.next_out,U=t.output,a=r-(e-t.avail_out),s=r+(t.avail_out-257),o=E.dmax,h=E.wsize,l=E.whave,d=E.wnext,c=E.window,f=E.hold,u=E.bits,_=E.lencode,p=E.distcode,w=(1<<E.lenbits)-1,g=(1<<E.distbits)-1;t:do{u<15&&(f+=x[i++]<<u,u+=8,f+=x[i++]<<u,u+=8),b=_[f&w];e:for(;;){if(m=b>>>24,f>>>=m,u-=m,m=b>>>16&255,0===m)U[r++]=65535&b;else{if(!(16&m)){if(0==(64&m)){b=_[(65535&b)+(f&(1<<m)-1)];continue e}if(32&m){E.mode=12;break t}t.msg="invalid literal/length code",E.mode=30;break t}y=65535&b,m&=15,m&&(u<m&&(f+=x[i++]<<u,u+=8),y+=f&(1<<m)-1,f>>>=m,u-=m),u<15&&(f+=x[i++]<<u,u+=8,f+=x[i++]<<u,u+=8),b=p[f&g];i:for(;;){if(m=b>>>24,f>>>=m,u-=m,m=b>>>16&255,!(16&m)){if(0==(64&m)){b=p[(65535&b)+(f&(1<<m)-1)];continue i}t.msg="invalid distance code",E.mode=30;break t}if(k=65535&b,m&=15,u<m&&(f+=x[i++]<<u,u+=8,u<m&&(f+=x[i++]<<u,u+=8)),k+=f&(1<<m)-1,k>o){t.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=m,u-=m,m=r-a,k>m){if(m=k-m,m>l&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(v=0,A=c,0===d){if(v+=h-m,m<y){y-=m;do{U[r++]=c[v++]}while(--m);v=r-k,A=U}}else if(d<m){if(v+=h+d-m,m-=d,m<y){y-=m;do{U[r++]=c[v++]}while(--m);if(v=0,d<y){m=d,y-=m;do{U[r++]=c[v++]}while(--m);v=r-k,A=U}}}else if(v+=d-m,m<y){y-=m;do{U[r++]=c[v++]}while(--m);v=r-k,A=U}for(;y>2;)U[r++]=A[v++],U[r++]=A[v++],U[r++]=A[v++],y-=3;y&&(U[r++]=A[v++],y>1&&(U[r++]=A[v++]))}else{v=r-k;do{U[r++]=U[v++],U[r++]=U[v++],U[r++]=U[v++],y-=3}while(y>2);y&&(U[r++]=U[v++],y>1&&(U[r++]=U[v++]))}break}}break}}while(i<n&&r<s);y=u>>3,i-=y,u-=y<<3,f&=(1<<u)-1,t.next_in=i,t.next_out=r,t.avail_in=i<n?n-i+5:5-(i-n),t.avail_out=r<s?s-r+257:257-(r-s),E.hold=f,E.bits=u};const Jt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Qt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),te=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ee=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ie=(t,e,i,n,r,a,s,o)=>{const h=o.bits;let l,d,c,f,u,_,p=0,w=0,g=0,b=0,m=0,y=0,k=0,v=0,A=0,x=0,U=null,E=0;const I=new Uint16Array(16),z=new Uint16Array(16);let S,C,T,R=null,F=0;for(p=0;p<=15;p++)I[p]=0;for(w=0;w<n;w++)I[e[i+w]]++;for(m=h,b=15;b>=1&&0===I[b];b--);if(m>b&&(m=b),0===b)return r[a++]=20971520,r[a++]=20971520,o.bits=1,0;for(g=1;g<b&&0===I[g];g++);for(m<g&&(m=g),v=1,p=1;p<=15;p++)if(v<<=1,v-=I[p],v<0)return-1;if(v>0&&(0===t||1!==b))return-1;for(z[1]=0,p=1;p<15;p++)z[p+1]=z[p]+I[p];for(w=0;w<n;w++)0!==e[i+w]&&(s[z[e[i+w]]++]=w);if(0===t?(U=R=s,_=19):1===t?(U=Jt,E-=257,R=Qt,F-=257,_=256):(U=te,R=ee,_=-1),x=0,w=0,p=g,u=a,y=m,k=0,c=-1,A=1<<m,f=A-1,1===t&&A>852||2===t&&A>592)return 1;for(;;){S=p-k,s[w]<_?(C=0,T=s[w]):s[w]>_?(C=R[F+s[w]],T=U[E+s[w]]):(C=96,T=0),l=1<<p-k,d=1<<y,g=d;do{d-=l,r[u+(x>>k)+d]=S<<24|C<<16|T|0}while(0!==d);for(l=1<<p-1;x&l;)l>>=1;if(0!==l?(x&=l-1,x+=l):x=0,w++,0==--I[p]){if(p===b)break;p=e[i+s[w]]}if(p>m&&(x&f)!==c){for(0===k&&(k=m),u+=g,y=p-k,v=1<<y;y+k<b&&(v-=I[y+k],!(v<=0));)y++,v<<=1;if(A+=1<<y,1===t&&A>852||2===t&&A>592)return 1;c=x&f,r[c]=m<<24|y<<16|u-a|0}}return 0!==x&&(r[u+x]=p-k<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ne,Z_BLOCK:re,Z_TREES:ae,Z_OK:se,Z_STREAM_END:oe,Z_NEED_DICT:he,Z_STREAM_ERROR:le,Z_DATA_ERROR:de,Z_MEM_ERROR:ce,Z_BUF_ERROR:fe,Z_DEFLATED:ue}=Z,_e=12,pe=30,we=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const be=t=>{if(!t||!t.state)return le;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,se},me=t=>{if(!t||!t.state)return le;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,be(t)},ye=(t,e)=>{let i;if(!t||!t.state)return le;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?le:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,me(t))},ke=(t,e)=>{if(!t)return le;const i=new ge;t.state=i,i.window=null;const n=ye(t,e);return n!==se&&(t.state=null),n};let ve,Ae,xe=!0;const Ue=t=>{if(xe){ve=new Int32Array(512),Ae=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ie(1,t.lens,0,288,ve,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ie(2,t.lens,0,32,Ae,0,t.work,{bits:5}),xe=!1}t.lencode=ve,t.lenbits=9,t.distcode=Ae,t.distbits=5},Ee=(t,e,i,n)=>{let r;const a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(e.subarray(i-a.wsize,i),0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>n&&(r=n),a.window.set(e.subarray(i-n,i-n+r),a.wnext),(n-=r)?(a.window.set(e.subarray(i-n,i),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=r))),0};var Ie={inflateReset:me,inflateReset2:ye,inflateResetKeep:be,inflateInit:t=>ke(t,15),inflateInit2:ke,inflate:(t,e)=>{let i,n,r,a,s,o,h,l,d,c,f,u,_,p,w,g,b,m,y,k,v,A,x=0;const U=new Uint8Array(4);let E,I;const z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return le;i=t.state,i.mode===_e&&(i.mode=13),s=t.next_out,r=t.output,h=t.avail_out,a=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,c=o,f=h,A=se;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(2&i.wrap&&35615===l){i.check=0,U[0]=255&l,U[1]=l>>>8&255,i.check=N(i.check,U,2,0),l=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=pe;break}if((15&l)!==ue){t.msg="unknown compression method",i.mode=pe;break}if(l>>>=4,d-=4,v=8+(15&l),0===i.wbits)i.wbits=v;else if(v>i.wbits){t.msg="invalid window size",i.mode=pe;break}i.dmax=1<<i.wbits,t.adler=i.check=1,i.mode=512&l?10:_e,l=0,d=0;break;case 2:for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(i.flags=l,(255&i.flags)!==ue){t.msg="unknown compression method",i.mode=pe;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=pe;break}i.head&&(i.head.text=l>>8&1),512&i.flags&&(U[0]=255&l,U[1]=l>>>8&255,i.check=N(i.check,U,2,0)),l=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.head&&(i.head.time=l),512&i.flags&&(U[0]=255&l,U[1]=l>>>8&255,U[2]=l>>>16&255,U[3]=l>>>24&255,i.check=N(i.check,U,4,0)),l=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.head&&(i.head.xflags=255&l,i.head.os=l>>8),512&i.flags&&(U[0]=255&l,U[1]=l>>>8&255,i.check=N(i.check,U,2,0)),l=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.length=l,i.head&&(i.head.extra_len=l),512&i.flags&&(U[0]=255&l,U[1]=l>>>8&255,i.check=N(i.check,U,2,0)),l=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(u=i.length,u>o&&(u=o),u&&(i.head&&(v=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(a,a+u),v)),512&i.flags&&(i.check=N(i.check,n,u,a)),o-=u,a+=u,i.length-=u),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break t;u=0;do{v=n[a+u++],i.head&&v&&i.length<65536&&(i.head.name+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&(i.check=N(i.check,n,u,a)),o-=u,a+=u,v)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===o)break t;u=0;do{v=n[a+u++],i.head&&v&&i.length<65536&&(i.head.comment+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&(i.check=N(i.check,n,u,a)),o-=u,a+=u,v)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(l!==(65535&i.check)){t.msg="header crc mismatch",i.mode=pe;break}l=0,d=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=_e;break;case 10:for(;d<32;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}t.adler=i.check=we(l),l=0,d=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=s,t.avail_out=h,t.next_in=a,t.avail_in=o,i.hold=l,i.bits=d,he;t.adler=i.check=1,i.mode=_e;case _e:if(e===re||e===ae)break t;case 13:if(i.last){l>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}switch(i.last=1&l,l>>>=1,d-=1,3&l){case 0:i.mode=14;break;case 1:if(Ue(i),i.mode=20,e===ae){l>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=pe}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",i.mode=pe;break}if(i.length=65535&l,l=0,d=0,i.mode=15,e===ae)break t;case 15:i.mode=16;case 16:if(u=i.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;r.set(n.subarray(a,a+u),s),o-=u,a+=u,h-=u,s+=u,i.length-=u;break}i.mode=_e;break;case 17:for(;d<14;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(i.nlen=257+(31&l),l>>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=pe;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.lens[z[i.have++]]=7&l,l>>>=3,d-=3}for(;i.have<19;)i.lens[z[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,E={bits:i.lenbits},A=ie(0,i.lens,0,19,i.lencode,0,i.work,E),i.lenbits=E.bits,A){t.msg="invalid code lengths set",i.mode=pe;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;x=i.lencode[l&(1<<i.lenbits)-1],w=x>>>24,g=x>>>16&255,b=65535&x,!(w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(b<16)l>>>=w,d-=w,i.lens[i.have++]=b;else{if(16===b){for(I=w+2;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(l>>>=w,d-=w,0===i.have){t.msg="invalid bit length repeat",i.mode=pe;break}v=i.lens[i.have-1],u=3+(3&l),l>>>=2,d-=2}else if(17===b){for(I=w+3;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}l>>>=w,d-=w,v=0,u=3+(7&l),l>>>=3,d-=3}else{for(I=w+7;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}l>>>=w,d-=w,v=0,u=11+(127&l),l>>>=7,d-=7}if(i.have+u>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=pe;break}for(;u--;)i.lens[i.have++]=v}}if(i.mode===pe)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=pe;break}if(i.lenbits=9,E={bits:i.lenbits},A=ie(1,i.lens,0,i.nlen,i.lencode,0,i.work,E),i.lenbits=E.bits,A){t.msg="invalid literal/lengths set",i.mode=pe;break}if(i.distbits=6,i.distcode=i.distdyn,E={bits:i.distbits},A=ie(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,E),i.distbits=E.bits,A){t.msg="invalid distances set",i.mode=pe;break}if(i.mode=20,e===ae)break t;case 20:i.mode=21;case 21:if(o>=6&&h>=258){t.next_out=s,t.avail_out=h,t.next_in=a,t.avail_in=o,i.hold=l,i.bits=d,Wt(t,f),s=t.next_out,r=t.output,h=t.avail_out,a=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,i.mode===_e&&(i.back=-1);break}for(i.back=0;x=i.lencode[l&(1<<i.lenbits)-1],w=x>>>24,g=x>>>16&255,b=65535&x,!(w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(g&&0==(240&g)){for(m=w,y=g,k=b;x=i.lencode[k+((l&(1<<m+y)-1)>>m)],w=x>>>24,g=x>>>16&255,b=65535&x,!(m+w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}l>>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,i.length=b,0===g){i.mode=26;break}if(32&g){i.back=-1,i.mode=_e;break}if(64&g){t.msg="invalid literal/length code",i.mode=pe;break}i.extra=15&g,i.mode=22;case 22:if(i.extra){for(I=i.extra;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.length+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;x=i.distcode[l&(1<<i.distbits)-1],w=x>>>24,g=x>>>16&255,b=65535&x,!(w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(0==(240&g)){for(m=w,y=g,k=b;x=i.distcode[k+((l&(1<<m+y)-1)>>m)],w=x>>>24,g=x>>>16&255,b=65535&x,!(m+w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}l>>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,64&g){t.msg="invalid distance code",i.mode=pe;break}i.offset=b,i.extra=15&g,i.mode=24;case 24:if(i.extra){for(I=i.extra;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.offset+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=pe;break}i.mode=25;case 25:if(0===h)break t;if(u=f-h,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=pe;break}u>i.wnext?(u-=i.wnext,_=i.wsize-u):_=i.wnext-u,u>i.length&&(u=i.length),p=i.window}else p=r,_=s-i.offset,u=i.length;u>h&&(u=h),h-=u,i.length-=u;do{r[s++]=p[_++]}while(--u);0===i.length&&(i.mode=21);break;case 26:if(0===h)break t;r[s++]=i.length,h--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===o)break t;o--,l|=n[a++]<<d,d+=8}if(f-=h,t.total_out+=f,i.total+=f,f&&(t.adler=i.check=i.flags?N(i.check,r,f,s-f):F(i.check,r,f,s-f)),f=h,(i.flags?l:we(l))!==i.check){t.msg="incorrect data check",i.mode=pe;break}l=0,d=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(l!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=pe;break}l=0,d=0}i.mode=29;case 29:A=oe;break t;case pe:A=de;break t;case 31:return ce;default:return le}return t.next_out=s,t.avail_out=h,t.next_in=a,t.avail_in=o,i.hold=l,i.bits=d,(i.wsize||f!==t.avail_out&&i.mode<pe&&(i.mode<27||e!==ne))&&Ee(t,t.output,t.next_out,f-t.avail_out),c-=t.avail_in,f-=t.avail_out,t.total_in+=c,t.total_out+=f,i.total+=f,i.wrap&&f&&(t.adler=i.check=i.flags?N(i.check,r,f,t.next_out-f):F(i.check,r,f,t.next_out-f)),t.data_type=i.bits+(i.last?64:0)+(i.mode===_e?128:0)+(20===i.mode||15===i.mode?256:0),(0===c&&0===f||e===ne)&&A===se&&(A=fe),A},inflateEnd:t=>{if(!t||!t.state)return le;let e=t.state;return e.window&&(e.window=null),t.state=null,se},inflateGetHeader:(t,e)=>{if(!t||!t.state)return le;const i=t.state;return 0==(2&i.wrap)?le:(i.head=e,e.done=!1,se)},inflateSetDictionary:(t,e)=>{const i=e.length;let n,r,a;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?le:11===n.mode&&(r=1,r=F(r,e,i,0),r!==n.check)?de:(a=Ee(t,e,i,i),a?(n.mode=31,ce):(n.havedict=1,se))):le},inflateInfo:"pako inflate (from Nodeca project)"},ze=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Se=Object.prototype.toString,{Z_NO_FLUSH:Ce,Z_FINISH:Te,Z_OK:Re,Z_STREAM_END:Fe,Z_NEED_DICT:Be,Z_STREAM_ERROR:Ne,Z_DATA_ERROR:De,Z_MEM_ERROR:Ze}=Z;function Le(t){this.options=Ft.assign({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zt,this.strm.avail_out=0;let i=Ie.inflateInit2(this.strm,e.windowBits);if(i!==Re)throw new Error(D[i]);if(this.header=new ze,Ie.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Dt.string2buf(e.dictionary):"[object ArrayBuffer]"===Se.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Ie.inflateSetDictionary(this.strm,e.dictionary),i!==Re)))throw new Error(D[i])}function Oe(t,e){const i=new Le(e);if(i.push(t),i.err)throw i.msg||D[i.err];return i.result}Le.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let a,s,o;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Te:Ce,"[object ArrayBuffer]"===Se.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),a=Ie.inflate(i,s),a===Be&&r&&(a=Ie.inflateSetDictionary(i,r),a===Re?a=Ie.inflate(i,s):a===De&&(a=Be));i.avail_in>0&&a===Fe&&i.state.wrap>0&&0!==t[i.next_in];)Ie.inflateReset(i),a=Ie.inflate(i,s);switch(a){case Ne:case De:case Be:case Ze:return this.onEnd(a),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||a===Fe))if("string"===this.options.to){let t=Dt.utf8border(i.output,i.next_out),e=i.next_out-t,r=Dt.buf2string(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(a!==Re||0!==o){if(a===Fe)return a=Ie.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Le.prototype.onData=function(t){this.chunks.push(t)},Le.prototype.onEnd=function(t){t===Re&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ft.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Me={Inflate:Le,inflate:Oe,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Oe(t,e)},ungzip:Oe,constants:Z};const{Deflate:Ve,deflate:$e,deflateRaw:He,gzip:Pe}=qt,{Inflate:je,inflate:Ge,inflateRaw:Ke,ungzip:Xe}=Me;var Ye={Deflate:Ve,deflate:$e,deflateRaw:He,gzip:Pe,Inflate:je,inflate:Ge,inflateRaw:Ke,ungzip:Xe,constants:Z};function qe(t,e){const i=t.length;if(i!==e.length)return!1;for(let n=0;n<i;n++)if(t[n]!==e[n])return!1;return!0}class We{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,i,n){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,i,n){throw new Error("Not Implemented")}}class Je{describeTo(t){throw new Error("Not Implemented")}}class Qe extends Je{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class ti{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new Qe(t)}}class ei extends We{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,i,n){return this.appendList(t,e,i,new ti(n)),this}appendList(t,e,i,n){let r=!1;this.appendText(t);const a=n[Symbol.iterator]();for(let t=a.next();!0!==t.done;t=a.next())r&&this.appendText(e),this.appendDescriptionOf(t.value),r=!0;return this.appendText(i),this}}class ii extends ei{value="";appendText(t){return this.value+=t,this}}function ni(t,e){if(!t)throw new Error(e||"AssertionError")}ni.enum=function(t,e,i="value"){for(let i in e)if(e[i]===t)return;throw new Error(`${i}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},ni.notEqual=function(t,e,i){ni(t!==e,i)},ni.notOk=function(t,e){ni(!t,e)},ni.equal=function(t,e,i){if(t!==e){const n=`${t} !== ${e}`;throw new Error(void 0!==i&&""!==i?`${i}. ${n}`:n)}},ni.logicalyEqual=function(t,e,i){},ni.ok=ni,ni.greaterThan=function(t,e,i){if(!(t>e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} > ${e}.`,new Error(n)}},ni.greaterThanOrEqual=function(t,e,i){if(!(t>=e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} >= ${e}.`,new Error(n)}},ni.lessThan=function(t,e,i){if(!(t<e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} < ${e}.`,new Error(n)}},ni.lessThanOrEqual=function(t,e,i){if(!(t<=e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} <= ${e}.`,new Error(n)}},ni.typeOf=function(t,e,i="value"){const n=typeof t;if(n!==e)throw new Error(`expected ${i} to be ${e}, instead was '${n}'(=${t})`)},ni.arrayHas=function(t,e,i="Array does not contain the item"){},ni.arrayHasNo=function(t,e,i="Array contains the item"){},ni.arrayEqual=function(t,e,i="Arrays are not equal"){if(!qe(t,e))throw new Error(i)},ni.isInstanceOf=function(t,e,i="value",n=e.name){},ni.isNumber=function(t,e="value"){const i=typeof t;if("number"!==i)throw new Error(`expected ${e} to be a number, instead was '${i}'(=${t})`)},ni.isString=function(t,e="value"){const i=typeof t;if("string"!==i)throw new Error(`expected ${e} to be a string, instead was '${i}'(=${t})`)},ni.isBoolean=function(t,e="value"){const i=typeof t;if("boolean"!==i)throw new Error(`expected ${e} to be a boolean, instead was '${i}'(=${t})`)},ni.isFunction=function(t,e="value"){const i=typeof t;if("function"!==i)throw new Error(`expected ${e} to be a function, instead was '${i}'(=${t})`)},ni.isObject=function(t,e="value"){const i=typeof t;if("object"!==i)throw new Error(`expected ${e} to be an object, instead was '${i}'(=${t})`)},ni.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},ni.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},ni.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},ni.isArrayLike=function(t,e="value"){if(!function(t){if(Array.isArray(t))return!0;if("object"!=typeof t)return!1;if(null===t)return!1;if(function(t){if("object"!=typeof t)return!1;if(null===t)return!1;const e=t.constructor;return e===Uint8Array||e===Uint16Array||e===Uint32Array||e===Int8Array||e===Int16Array||e===Int32Array||e===Float32Array||e===Float64Array||e===BigUint64Array||e===BigInt64Array}(t))return!0;const e=t.length;return!("number"!=typeof e&&!Number.isInteger(e)||e<0)}(t))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`)},ni.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},ni.undefined=function(t,e="value"){if(void 0!==t)throw new Error(`${e} is not undefined`)},ni.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},ni.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},ni.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},ni.isFinite=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},ni.isFiniteNumber=ni.isFinite,ni.that=function(t,e,i){if(i.matches(t))return;const n=new ii;throw n.appendText(`Expected ${e} to be `),i.describeTo(n),n.appendText(" instead "),i.describeMismatch(t,n),new Error(n.value)};const ri=!1,ai=!0,si=new Float32Array(1),oi=new Int32Array(si.buffer);class hi{endianness=ai;position=0;get length(){throw new Error("Deprecated, use 'capacity' instead")}set length(t){throw new Error("Deprecated, use 'capacity' instead")}capacity=1024;data=new ArrayBuffer(1024);dataView=new DataView(this.data);__data_uint8=new Uint8Array(this.data);__growFactor=1.1;get raw_bytes(){return this.__data_uint8}fromArrayBuffer(t){this.data=t,this.dataView=new DataView(t),this.__data_uint8=new Uint8Array(t),this.capacity=t.byteLength,this.position=0}trim(){return this.setCapacity(this.position),this}setCapacity(t){if(t<this.position)throw new Error(`Attempting to set capacity(=${t}) below current position(=${this.position})`);const e=this.__data_uint8,i=new Uint8Array(t);!function(t,e,i,n,r){let a,s;const o=function(t,e,i){const n=0|i;return 0==(3&n)?4:0==(1&n)?2:1}(0,0,r);4===o?(a=new Uint32Array(t,0,r>>>2),s=new Uint32Array(i,0,r>>>2)):2===o?(a=new Uint16Array(t,0,r>>>1),s=new Uint16Array(i,0,r>>>1)):(a=new Uint8Array(t,0,r),s=new Uint8Array(i,0,r)),s.set(a)}(e.buffer,0,i.buffer,0,Math.min(e.buffer.byteLength,i.buffer.byteLength)),this.data=i.buffer,this.__data_uint8=i,this.dataView=new DataView(this.data),this.capacity=t}ensureCapacity(t){const e=this.capacity;if(e>=t)return;const i=Math.ceil(Math.max(t,e*this.__growFactor,e+1024))+3>>2<<2;this.setCapacity(i)}readFloat16(){return function(t){let e=0;const i=(31744&t)>>10,n=1023&t;let r=1;return t>>15!=0&&(r=-1),e=0!==i?31===i?0!==n?NaN:Infinity:r*Math.pow(2,i-15)*(1+n/1024):r*(n/1024*6103515625e-14),e}(this.readUint16())}readFloat32(){const t=this.dataView.getFloat32(this.position,this.endianness);return this.position+=4,t}readFloat64(){const t=this.dataView.getFloat64(this.position,this.endianness);return this.position+=8,t}readInt8(){const t=this.dataView.getInt8(this.position);return this.position+=1,t}readInt16(){const t=this.dataView.getInt16(this.position,this.endianness);return this.position+=2,t}readInt32(){const t=this.dataView.getInt32(this.position,this.endianness);return this.position+=4,t}readUint8(){const t=this.dataView.getUint8(this.position);return this.position+=1,t}readUint16(){const t=this.dataView.getUint16(this.position,this.endianness);return this.position+=2,t}readUint16LE(){const t=this.dataView.getUint16(this.position,ai);return this.position+=2,t}readUint16BE(){const t=this.dataView.getUint16(this.position,ri);return this.position+=2,t}readUint24(){return this.endianness===ri?this.readUint24BE():this.readUint24LE()}readUint24LE(){const t=this.dataView.getUint8(this.position),e=this.dataView.getUint8(this.position+1),i=this.dataView.getUint8(this.position+2);return this.position+=3,t|e<<8|i<<16}readUint24BE(){const t=this.dataView.getUint8(this.position),e=this.dataView.getUint8(this.position+1),i=this.dataView.getUint8(this.position+2);return this.position+=3,i|e<<8|t<<16}readUint32(){const t=this.dataView.getUint32(this.position,this.endianness);return this.position+=4,t}readUint32LE(){const t=this.dataView.getUint32(this.position,ai);return this.position+=4,t}readUint32BE(){const t=this.dataView.getUint32(this.position,ri);return this.position+=4,t}readUint8Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint8()}readUint16Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint16()}readUint32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint32()}readInt8Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt8()}readInt16Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt16()}readInt32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt32()}readFloat32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readFloat32()}readFloat64Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readFloat64()}writeFloat32Array(t,e,i){for(let n=0;n<i;n++)this.writeFloat32(t[n+e])}writeFloat16(t){const e=function(t){let e=t;e>65504&&(e=65504),si[0]=e;const i=oi[0];let n=i>>16&32768,r=i>>12&2047;const a=i>>23&255;return a<103?n:a>142?(n|=31744,n|=(255===a?0:1)&&8388607&i,n):a<113?(r|=2048,n|=(r>>114-a)+(r>>113-a&1),n):(n|=a-112<<10|r>>1,n+=1&r,n)}(t);this.writeUint16(e)}writeFloat32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setFloat32(this.position,t,this.endianness),this.position=e}writeFloat64(t){const e=this.position+8;this.ensureCapacity(e),this.dataView.setFloat64(this.position,t,this.endianness),this.position=e}writeInt8(t){const e=this.position+1;this.ensureCapacity(e),this.dataView.setInt8(this.position,t),this.position=e}writeInt16(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setInt16(this.position,t,this.endianness),this.position=e}writeInt32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setInt32(this.position,t,this.endianness),this.position=e}writeInt8Array(t,e,i){this.ensureCapacity(this.position+i);for(let n=0;n<i;n++)this.writeInt8(t[e+n])}writeInt16Array(t,e,i){this.ensureCapacity(this.position+2*i);for(let n=0;n<i;n++)this.writeInt16(t[e+n])}writeInt32Array(t,e,i){this.ensureCapacity(this.position+4*i);for(let n=0;n<i;n++)this.writeInt32(t[e+n])}writeUint8(t){const e=this.position+1;this.ensureCapacity(e),this.dataView.setUint8(this.position,t),this.position=e}writeUint8Array(t,e,i){for(let n=0;n<i;n++)this.writeUint8(t[e+n])}writeUint16(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,this.endianness),this.position=e}writeUint16BE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,ri),this.position=e}writeUint16LE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,ai),this.position=e}writeUint16Array(t,e,i){for(let n=0;n<i;n++)this.writeUint16(t[e+n])}writeUint24(t){this.endianness===ri?this.writeUint24BE(t):this.writeUint24LE(t)}writeUint24BE(t){const e=this.position+3;this.ensureCapacity(e);const i=255&t,n=t>>8&255,r=t>>16&255;this.dataView.setUint8(this.position,r),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,i),this.position=e}writeUint24LE(t){const e=this.position+3;this.ensureCapacity(e);const i=255&t,n=t>>8&255,r=t>>16&255;this.dataView.setUint8(this.position,i),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,r),this.position=e}writeUintVar(t){let e=!0;for(;e||0!==t;){e=!1;let i=127&t;(t>>=7)>0&&(i|=128),this.writeUint8(i)}}readUintVar(){let t=!0,e=0,i=0;for(;t;){let n=this.readUint8();t=0!=(128&n),e|=(127&n)<<i,i+=7}return e}writeUint32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,this.endianness),this.position=e}writeUint32BE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,ri),this.position=e}writeUint32LE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,ai),this.position=e}writeUint32Array(t,e,i){this.ensureCapacity(this.position+4*i);for(let n=0;n<i;n++)this.writeUint32(t[e+n])}writeBytes(t,e,i){const n=e+i,r=this.position,a=r+i;if(this.ensureCapacity(a),0===e&&t.length===i)this.__data_uint8.set(t,r);else if("function"==typeof t.subarray)this.__data_uint8.set(t.subarray(e,n),r);else for(let n=0;n<i;n++)this.__data_uint8[r+n]=t[e+n];this.position=a}readBytes(t,e,i){const n=this.position,r=n+i,a=this.__data_uint8;i<128?function(t,e,i,n,r){let a,s,o;for(o=0;o<r;o++)a=e+o,s=n+o,i[s]=t[a]}(a,n,t,e,i):t.set(a.subarray(n,r),e),this.position=r}writeUTF8String(t){if(null===t)return void this.writeUint32(4294967295);if(void 0===t)return void this.writeUint32(4294967294);let e=0;const i=t.length;if(i>=4294967294)throw new Error("String is too long");this.writeUint32(i);let n=this.position;const r=Math.max(32,i+(i>>1)+7);this.ensureCapacity(r+n);let a=this.__data_uint8,s=this.capacity;for(;e<i;){let r=t.charCodeAt(e++);if(r>=55296&&r<=56319){if(e<i){const i=t.charCodeAt(e);56320==(64512&i)&&(++e,r=((1023&r)<<10)+(1023&i)+65536)}if(r>=55296&&r<=56319)continue}if(n+4>s&&(this.ensureCapacity(n+4),s=this.capacity,a=this.__data_uint8),0!=(4294967168&r)){if(0==(4294965248&r))a[n++]=r>>6&31|192;else if(0==(4294901760&r))a[n++]=r>>12&15|224,a[n++]=r>>6&63|128;else{if(0!=(4292870144&r))continue;a[n++]=r>>18&7|240,a[n++]=r>>12&63|128,a[n++]=r>>6&63|128}a[n++]=63&r|128}else a[n++]=r}this.position=n}readUTF8String(){const t=this.readUint32();if(4294967295===t)return null;if(4294967294===t)return;const e=this.__data_uint8;let i="",n=this.position,r=0;for(;n<this.capacity&&r<t;){const t=e[n++];let a;if(0===t)break;0==(128&t)?a=t:192==(224&t)?a=(31&t)<<6|63&e[n++]:224==(240&t)?a=(31&t)<<12|(63&e[n++])<<6|63&e[n++]:240==(248&t)&&(a=(7&t)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++],a>65535&&(a-=65536,i+=String.fromCharCode(a>>>10&1023|55296),r++,a=56320|1023&a)),r++,i+=String.fromCharCode(a)}return this.position=n,i}writeASCIIString(t){const e=t.length,i=this.position,n=i+e;this.ensureCapacity(n);for(let n=0;n<e;n++){const e=t.charCodeAt(n);if(e>255)throw new Error(`Character ${String.fromCharCode(e)} can't be represented by a US-ASCII byte.`);this.__data_uint8[i+n]=e}this.position=n}readASCIICharacters(t,e=!1){let i="";for(let n=0;n<t;n++){const t=this.readUint8();if(e&&0===t)break;i+=String.fromCharCode(t)}return i}static fromEndianness(t){const e=new hi;return e.endianness=t,e}static fromArrayBuffer(t){const e=new hi;return e.fromArrayBuffer(t),e}static copyUTF8String(t,e){const i=t.readUTF8String();return e.writeUTF8String(i),i}static copyUintVar(t,e){const i=t.readUintVar();return e.writeUintVar(i),i}static copyUint8(t,e){const i=t.readUint8();return e.writeUint8(i),i}static copyUint16(t,e){const i=t.readUint16();return e.writeUint16(i),i}static copyUint32(t,e){const i=t.readUint32();return e.writeUint32(i),i}static copyFloat32(t,e){const i=t.readFloat32();return e.writeFloat32(i),i}static copyFloat64(t,e){const i=t.readFloat64();return e.writeFloat64(i),i}static copyBytes(t,e,i){const n=new Uint8Array(i);return t.readBytes(n,0,i),e.writeBytes(n,0,i),n}}hi.prototype.isBinaryBuffer=!0;const li=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)0!=(1&e)?e=3988292384^e>>>1:e>>>=1;li[t]=e}class di{width=0;height=0;bitDepth=0;colorType=0;compressionMethod=0;filterMethod=0;interlaceMethod=0;colors=0;alpha=!1;pixelBits=0;palette=null;pixels=null;trns=null;text={};getWidth(){return this.width}setWidth(t){this.width=t}getHeight(){return this.height}setHeight(t){this.height=t}getBitDepth(){return this.bitDepth}setBitDepth(t){if(-1===[1,2,4,8,16].indexOf(t))throw new Error("invalid bith depth "+t);this.bitDepth=t}getColorType(){return this.colorType}setColorType(t){let e=0,i=!1;switch(t){case 0:case 3:e=1;break;case 2:e=3;break;case 4:e=2,i=!0;break;case 6:e=4,i=!0;break;default:throw new Error("invalid color type")}this.colors=e,this.alpha=i,this.colorType=t}getCompressionMethod(){return this.compressionMethod}setCompressionMethod(t){if(0!==t)throw new Error("invalid compression method "+t);this.compressionMethod=t}getFilterMethod(){return this.filterMethod}setFilterMethod(t){if(0!==t)throw new Error("invalid filter method "+t);this.filterMethod=t}getInterlaceMethod(){return this.interlaceMethod}setInterlaceMethod(t){if(0!==t&&1!==t)throw new Error("invalid interlace method "+t);this.interlaceMethod=t}setTRNS(t){this.trns=t}setPalette(t){if(t.length%3!=0)throw new Error("incorrect PLTE chunk length");if(t.length>3*Math.pow(2,this.bitDepth))throw new Error("palette has more colors than 2^bitdepth");this.palette=t}getPalette(){return this.palette}getPixel(t,e,i,n){const r=this.pixels;if(!r)throw new Error("pixel data is empty");if(i>=this.width||n>=this.height)throw new Error("x,y position out of bound");const a=this.colors*this.bitDepth/8*(n*this.width+i);let s,o,h,l;switch(this.colorType){case 0:s=r[a],o=s,h=s,l=255;break;case 2:s=r[a],o=r[a+1],h=r[a+2],l=255;break;case 3:l=255,null!=this.trns&&(l=this.trns[r[a]]);const t=3*r[a],e=this.palette;s=e[t],o=e[t+1],h=e[t+2];break;case 4:s=r[a],o=s,h=s,l=r[a+1];break;case 6:s=r[a],o=r[a+1],h=r[a+2],l=r[a+3];break;default:throw new Error("Unsupported color type")}t[e+0]=s,t[e+1]=o,t[e+2]=h,t[e+3]=l}getRGBA8Array_fromRGB(t){const e=this.height,i=this.width*e,n=this.pixels;for(let e=0;e<i;e++){const i=3*e,r=i+e;t[r]=n[i],t[r+1]=n[i+1],t[r+2]=n[i+2],t[r+3]=255}}getRGBA8Array_generic(t){const e=this.height,i=this.width;for(let n=0;n<e;n++){const e=n*i;for(let r=0;r<i;r++){const i=4*(e+r);this.getPixel(t,i,r,n)}}}getRGBA8Array(){if(6===this.colorType)return this.pixels;const t=this.height,e=this.width,i=new Uint8Array(e*t*4);return 2===this.colorType?this.getRGBA8Array_fromRGB(i):this.getRGBA8Array_generic(i),i}getUint8Data_case3(){const t=this.width*this.height;let e;const i=this.trns;e=null!==i?4:3;const n=new Uint8Array(t*e),r=this.pixels,a=this.palette,s=this.colors*Math.ceil(this.bitDepth/8);for(let i=0;i<t;i++){const t=i*e,o=3*r[i*s];n[t]=a[o],n[t+1]=a[o+1],n[t+2]=a[o+2]}if(null!==i){const e=i.length;for(let a=0;a<t;a++){const t=r[a*s];n[4*a+3]=t>=e?255:i[t]}}return{data:n,itemSize:e}}getUint8Data(){let t,e=0;switch(this.colorType){case 0:t=this.pixels,e=1;break;case 2:t=this.pixels,e=3;break;case 3:const i=this.getUint8Data_case3();t=i.data,e=i.itemSize;break;case 4:t=this.pixels,e=2;break;case 6:t=this.pixels,e=4;break;default:throw new Error("Unsupported color type")}return{data:t,itemSize:e}}}const ci=[137,80,78,71,13,10,26,10];function fi(t){const e=new Ye.Inflate;if(e.push(t),e.err)throw new Error(e.err);return e.result.buffer}function ui(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function _i(t,e){return t[e]}function pi(t){this.i=0,this.bytes=new Uint8Array(t),this.png=new di,this.dataChunks=[],this.buffer=new hi,this.buffer.endianness=ri,this.buffer.fromArrayBuffer(t),this.crc_enabled=!1,this.header=new Uint8Array(8)}pi.prototype.readBytes=function(t){const e=new Uint8Array(t);return this.buffer.readBytes(e,0,t),e},pi.prototype.decodeHeader=function(){if(0!==this.i)throw new Error("file pointer should be at 0 to read the header");const t=this.buffer,e=this.header;if(t.readBytes(e,0,8),!qe(e,ci))throw new Error("invalid PNGReader file (bad signature)")},pi.prototype.decodeChunk=function(){const t=this.buffer,e=t.readUint32();if(e<0)throw new Error("Bad chunk length "+(4294967295&e));const i=t.position,n=t.readASCIICharacters(4),r=this.readBytes(e);switch(t.readUint32(),this.crc_enabled&&function(t,e=0,i=t.length){!function(t,e,i,n){let r=4294967295;const a=i+n;for(let t=i;t<a;t++){const i=e[t];r=li[255&(r^i)]^r>>>8}}(0,t,e,i)}(t.raw_bytes,i,e+4),n){case"IHDR":this.decodeIHDR(r);break;case"PLTE":this.decodePLTE(r);break;case"IDAT":this.decodeIDAT(r);break;case"tRNS":this.decodeTRNS(r);break;case"IEND":this.decodeIEND(r);break;case"sRGB":this.decodesRGB(r);break;case"tIME":this.decodetIME(r);break;case"zTXt":this.decodezTXt(r);break;case"iTXt":this.decodeiTXt(r)}return n},pi.prototype.decodesRGB=function(t){_i(t,0)},pi.prototype.decodetIME=function(t){_i(t,0),_i(t,1),_i(t,2),_i(t,3),_i(t,4),_i(t,5),_i(t,6)},pi.prototype.decodeiTXt=function(t){const e=hi.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(79,!0),n=e.readUint8();e.readUint8();const r=e.readASCIICharacters(Infinity,!0),a=e.readASCIICharacters(Infinity,!0),s=e.data.length-e.position;let o;if(0===n)o=e.readASCIICharacters(s);else{if(1!==n)throw new Error(`Invalid compression flag value '${n}'`);{const t=fi(new Uint8Array(e.data,e.position,s));e.fromArrayBuffer(t),o=e.readASCIICharacters(t.byteLength)}}return{keyword:i,language_tag:r,translated_keyword:a,text:o}},pi.prototype.decodezTXt=function(t){const e=hi.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(79,!0),n=e.readUint8();let r;if(0!==n)throw new Error(`Unsupported compression method '${n}'`);{const i=fi(new Uint8Array(t.buffer,e.position));e.fromArrayBuffer(i),r=e.readASCIICharacters(i.length)}return{keyword:i,text:r}},pi.prototype.decodetEXt=function(t){const e=hi.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(Number.POSITIVE_INFINITY,!0),n=e.readASCIICharacters(i.length-1,!1);this.png.text[i]=n},pi.prototype.decodeiEXt=function(t){const e=hi.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(Number.POSITIVE_INFINITY,!0);if(e.readUint8(),e.readUint8(),e.readASCIICharacters(Number.POSITIVE_INFINITY,!0),e.readUTF8String(),0!==e.readUint8())throw new Error("Expected Null Separator after Translated keyword");const n=e.readUTF8String();this.png.text[i]=n},pi.prototype.decodeIHDR=function(t){const e=this.png;e.setWidth(ui(t,0)),e.setHeight(ui(t,4)),e.setBitDepth(_i(t,8)),e.setColorType(_i(t,9)),e.setCompressionMethod(_i(t,10)),e.setFilterMethod(_i(t,11)),e.setInterlaceMethod(_i(t,12))},pi.prototype.decodePLTE=function(t){this.png.setPalette(t)},pi.prototype.decodeIDAT=function(t){this.dataChunks.push(t)},pi.prototype.decodeTRNS=function(t){this.png.setTRNS(t)},pi.prototype.decodeIEND=function(){},pi.prototype.decodePixels=function(){const t=this.png,e=new Ye.Inflate,i=this.dataChunks,n=i.length;for(let t=0;t<n;t++)if(e.push(i[t]),e.err)throw new Error(e.err);const r=e.result;0===t.getInterlaceMethod()?this.interlaceNone(r):this.interlaceAdam7(r)},pi.prototype.interlaceNone=function(t){const e=this.png,i=e.bitDepth,n=e.colors*i/8,r=e.width,a=e.height,s=Math.ceil(n*r),o=Math.ceil(n)*r,h=new Uint8Array(o*a);let l=0;const d=t.length;for(let e=0;e<d;e+=s+1){const r=e+1,a=_i(t,e);switch(a){case 0:if(1===i)for(let e=0;e<o;e++){const i=t[(e>>>4)+r]>>>(7&e)&1;h[l+e]=i}else if(2===i)for(let e=0;e<o;e++){const i=t[(e>>>2)+r]>>>((3&~e)<<1)&3;h[l+e]=i}else if(4===i)for(let e=0;e<o;e++){const i=t[(e>>>1)+r]>>>((1&~e)<<2)&15;h[l+e]=i}else{if(8!==i)throw new Error(`unsupported bit depth ${i}`);for(let e=0;e<o;e++)h[l+e]=t[e+r]}break;case 1:this.unFilterSub(t,r,h,n,l,s);break;case 2:this.unFilterUp(t,r,h,n,l,s);break;case 3:this.unFilterAverage(t,r,h,n,l,s);break;case 4:this.unFilterPaeth(t,r,h,n,l,s);break;default:throw new Error(`unknown filtered scanline type '${a}'`)}l+=o}e.pixels=h},pi.prototype.interlaceAdam7=function(t){throw new Error("Adam7 interlacing is not implemented yet")},pi.prototype.unFilterSub=function(t,e,i,n,r,a){let s=0;for(;s<n;s++)i[r+s]=t[s+e];for(;s<a;s++){const a=r+s;i[a]=t[s+e]+i[a-n]&255}},pi.prototype.unFilterUp=function(t,e,i,n,r,a){let s,o,h=0;if(r-a<0)for(;h<a;h++)i[r+h]=t[h+e];else for(;h<a;h++)s=t[h+e],o=i[r+h-a],i[r+h]=s+o&255},pi.prototype.unFilterAverage=function(t,e,i,n,r,a){let s,o,h,l=0;if(r-a<0){for(;l<n;l++)i[r+l]=t[l+e];for(;l<a;l++){const a=r+l;i[a]=t[l+e]+(i[a-n]>>1)&255}}else{for(;l<n;l++){const n=r+l;i[n]=t[l+e]+(i[n-a]>>1)&255}for(;l<a;l++){s=t[l+e];const d=r+l;o=i[d-n],h=i[d-a],i[d]=s+(o+h>>1)&255}}},pi.prototype.unFilterPaeth=function(t,e,i,n,r,a){let s,o,h,l,d,c,f,u,_,p=0;if(r-a<0){for(;p<n;p++)i[r+p]=t[p+e];for(;p<a;p++)i[r+p]=t[p+e]+i[r+p-n]&255}else{const w=r-a;for(;p<n;p++)i[r+p]=t[p+e]+i[w+p]&255;for(;p<a;p++){s=t[p+e];const w=r+p;l=i[w-a-n],h=i[w-a],o=i[w-n],d=o+h-l,c=Math.abs(d-o),f=Math.abs(d-h),u=Math.abs(d-l),_=c<=f&&c<=u?o:f<=u?h:l,i[w]=s+_&255}}},pi.prototype.parse=function(){for(this.decodeHeader();"IEND"!==this.decodeChunk(););return this.decodePixels(),this.png},self.Lib={decode:async function(t,e="png"){if(!(t instanceof ArrayBuffer))throw new Error(".data argument must be an ArrayBuffer, instead was something else");if("png"===e.toLowerCase())return await async function(t){return new Promise(((e,i)=>{const n=new pi(t).parse(),r=n.getUint8Data(),a=n.getWidth(),s=n.getHeight();e({data:r.data.buffer,width:a,height:s,itemSize:r.itemSize,bitDepth:8})}))}(t);throw new Error("Unsupported type")}};
|
|
1
|
+
function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),i=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),r=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=new Array(576);t(a);const s=new Array(60);t(s);const o=new Array(512);t(o);const h=new Array(256);t(h);const l=new Array(29);t(l);const d=new Array(30);function c(t,e,i,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}let f,u,_;function p(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(d);const w=t=>t<256?o[t]:o[256+(t>>>7)],b=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},g=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,b(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)},m=(t,e,i)=>{g(t,i[2*e],i[2*e+1])},y=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},k=(t,e,i)=>{const n=new Array(16);let r,a,s=0;for(r=1;r<=15;r++)n[r]=s=s+i[r-1]<<1;for(a=0;a<=e;a++){let e=t[2*a+1];0!==e&&(t[2*a]=y(n[e]++,e))}},v=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},A=t=>{t.bi_valid>8?b(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},x=(t,e,i,n)=>{const r=2*e,a=2*i;return t[r]<t[a]||t[r]===t[a]&&n[e]<=n[i]},U=(t,e,i)=>{const n=t.heap[i];let r=i<<1;for(;r<=t.heap_len&&(r<t.heap_len&&x(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!x(e,n,t.heap[r],t.depth));)t.heap[i]=t.heap[r],i=r,r<<=1;t.heap[i]=n},E=(t,n,r)=>{let a,s,o,c,f=0;if(0!==t.last_lit)do{a=t.pending_buf[t.d_buf+2*f]<<8|t.pending_buf[t.d_buf+2*f+1],s=t.pending_buf[t.l_buf+f],f++,0===a?m(t,s,n):(o=h[s],m(t,o+256+1,n),c=e[o],0!==c&&(s-=l[o],g(t,s,c)),a--,o=w(a),m(t,o,r),c=i[o],0!==c&&(a-=d[o],g(t,a,c)))}while(f<t.last_lit);m(t,256,n)},I=(t,e)=>{const i=e.dyn_tree,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,a=e.stat_desc.elems;let s,o,h,l=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<a;s++)0!==i[2*s]?(t.heap[++t.heap_len]=l=s,t.depth[s]=0):i[2*s+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=l<2?++l:0,i[2*h]=1,t.depth[h]=0,t.opt_len--,r&&(t.static_len-=n[2*h+1]);for(e.max_code=l,s=t.heap_len>>1;s>=1;s--)U(t,i,s);h=a;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],U(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=o,i[2*h]=i[2*s]+i[2*o],t.depth[h]=(t.depth[s]>=t.depth[o]?t.depth[s]:t.depth[o])+1,i[2*s+1]=i[2*o+1]=h,t.heap[1]=h++,U(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,r=e.stat_desc.static_tree,a=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let l,d,c,f,u,_,p=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(i[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)d=t.heap[l],f=i[2*i[2*d+1]+1]+1,f>h&&(f=h,p++),i[2*d+1]=f,d>n||(t.bl_count[f]++,u=0,d>=o&&(u=s[d-o]),_=i[2*d],t.opt_len+=_*(f+u),a&&(t.static_len+=_*(r[2*d+1]+u)));if(0!==p){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,p-=2}while(p>0);for(f=h;0!==f;f--)for(d=t.bl_count[f];0!==d;)c=t.heap[--l],c>n||(i[2*c+1]!==f&&(t.opt_len+=(f-i[2*c+1])*i[2*c],i[2*c+1]=f),d--)}})(t,e),k(i,l,t.bl_count)},z=(t,e,i)=>{let n,r,a=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)r=s,s=e[2*(n+1)+1],++o<h&&r===s||(o<l?t.bl_tree[2*r]+=o:0!==r?(r!==a&&t.bl_tree[2*r]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,a=r,0===s?(h=138,l=3):r===s?(h=6,l=3):(h=7,l=4))},S=(t,e,i)=>{let n,r,a=-1,s=e[1],o=0,h=7,l=4;for(0===s&&(h=138,l=3),n=0;n<=i;n++)if(r=s,s=e[2*(n+1)+1],!(++o<h&&r===s)){if(o<l)do{m(t,r,t.bl_tree)}while(0!=--o);else 0!==r?(r!==a&&(m(t,r,t.bl_tree),o--),m(t,16,t.bl_tree),g(t,o-3,2)):o<=10?(m(t,17,t.bl_tree),g(t,o-3,3)):(m(t,18,t.bl_tree),g(t,o-11,7));o=0,a=r,0===s?(h=138,l=3):r===s?(h=6,l=3):(h=7,l=4)}};let C=!1;const T=(t,e,i,n)=>{g(t,0+(n?1:0),3),((t,e,i,n)=>{A(t),b(t,i),b(t,~i),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i)};var R={_tr_init:t=>{C||((()=>{let t,r,p,w,b;const g=new Array(16);for(p=0,w=0;w<28;w++)for(l[w]=p,t=0;t<1<<e[w];t++)h[p++]=w;for(h[p-1]=w,b=0,w=0;w<16;w++)for(d[w]=b,t=0;t<1<<i[w];t++)o[b++]=w;for(b>>=7;w<30;w++)for(d[w]=b<<7,t=0;t<1<<i[w]-7;t++)o[256+b++]=w;for(r=0;r<=15;r++)g[r]=0;for(t=0;t<=143;)a[2*t+1]=8,t++,g[8]++;for(;t<=255;)a[2*t+1]=9,t++,g[9]++;for(;t<=279;)a[2*t+1]=7,t++,g[7]++;for(;t<=287;)a[2*t+1]=8,t++,g[8]++;for(k(a,287,g),t=0;t<30;t++)s[2*t+1]=5,s[2*t]=y(t,5);f=new c(a,e,257,286,15),u=new c(s,i,0,30,15),_=new c(new Array(0),n,0,19,7)})(),C=!0),t.l_desc=new p(t.dyn_ltree,f),t.d_desc=new p(t.dyn_dtree,u),t.bl_desc=new p(t.bl_tree,_),t.bi_buf=0,t.bi_valid=0,v(t)},_tr_stored_block:T,_tr_flush_block:(t,e,i,n)=>{let o,h,l=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),I(t,t.l_desc),I(t,t.d_desc),l=(t=>{let e;for(z(t,t.dyn_ltree,t.l_desc.max_code),z(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*r[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),o=t.opt_len+3+7>>>3,h=t.static_len+3+7>>>3,h<=o&&(o=h)):o=h=i+5,i+4<=o&&-1!==e?T(t,e,i,n):4===t.strategy||h===o?(g(t,2+(n?1:0),3),E(t,a,s)):(g(t,4+(n?1:0),3),((t,e,i,n)=>{let a;for(g(t,e-257,5),g(t,i-1,5),g(t,n-4,4),a=0;a<n;a++)g(t,t.bl_tree[2*r[a]+1],3);S(t,t.dyn_ltree,e-1),S(t,t.dyn_dtree,i-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,l+1),E(t,t.dyn_ltree,t.dyn_dtree)),v(t),n&&A(t)},_tr_tally:(t,e,i)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(h[i]+256+1)]++,t.dyn_dtree[2*w(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{g(t,2,3),m(t,256,a),(t=>{16===t.bi_valid?(b(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},F=(t,e,i,n)=>{let r=65535&t|0,a=t>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{r=r+e[n++]|0,a=a+r|0}while(--s);r%=65521,a%=65521}return r|a<<16|0};const B=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var N=(t,e,i,n)=>{const r=B,a=n+i;t^=-1;for(let i=n;i<a;i++)t=t>>>8^r[255&(t^e[i])];return-1^t},D={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Z={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:L,_tr_stored_block:O,_tr_flush_block:$,_tr_tally:M,_tr_align:V}=R,{Z_NO_FLUSH:H,Z_PARTIAL_FLUSH:P,Z_FULL_FLUSH:j,Z_FINISH:G,Z_BLOCK:K,Z_OK:X,Z_STREAM_END:Y,Z_STREAM_ERROR:q,Z_DATA_ERROR:W,Z_BUF_ERROR:J,Z_DEFAULT_COMPRESSION:Q,Z_FILTERED:tt,Z_HUFFMAN_ONLY:et,Z_RLE:it,Z_FIXED:nt,Z_DEFAULT_STRATEGY:rt,Z_UNKNOWN:at,Z_DEFLATED:st}=Z,ot=258,ht=262,lt=103,dt=113,ct=666,ft=(t,e)=>(t.msg=D[e],e),ut=t=>(t<<1)-(t>4?9:0),_t=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let pt=(t,e,i)=>(e<<t.hash_shift^i)&t.hash_mask;const wt=t=>{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},bt=(t,e)=>{$(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,wt(t.strm)},gt=(t,e)=>{t.pending_buf[t.pending++]=e},mt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},yt=(t,e,i,n)=>{let r=t.avail_in;return r>n&&(r=n),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),i),1===t.state.wrap?t.adler=F(t.adler,e,r,i):2===t.state.wrap&&(t.adler=N(t.adler,e,r,i)),t.next_in+=r,t.total_in+=r,r)},kt=(t,e)=>{let i,n,r=t.max_chain_length,a=t.strstart,s=t.prev_length,o=t.nice_match;const h=t.strstart>t.w_size-ht?t.strstart-(t.w_size-ht):0,l=t.window,d=t.w_mask,c=t.prev,f=t.strstart+ot;let u=l[a+s-1],_=l[a+s];t.prev_length>=t.good_match&&(r>>=2),o>t.lookahead&&(o=t.lookahead);do{if(i=e,l[i+s]===_&&l[i+s-1]===u&&l[i]===l[a]&&l[++i]===l[a+1]){a+=2,i++;do{}while(l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&l[++a]===l[++i]&&a<f);if(n=ot-(f-a),a=f-ot,n>s){if(t.match_start=e,s=n,n>=o)break;u=l[a+s-1],_=l[a+s]}}}while((e=c[e&d])>h&&0!=--r);return s<=t.lookahead?s:t.lookahead},vt=t=>{const e=t.w_size;let i,n,r,a,s;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ht)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,i=n;do{r=t.head[--i],t.head[i]=r>=e?r-e:0}while(--n);n=e,i=n;do{r=t.prev[--i],t.prev[i]=r>=e?r-e:0}while(--n);a+=e}if(0===t.strm.avail_in)break;if(n=yt(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=n,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=pt(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=pt(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<ht&&0!==t.strm.avail_in)},At=(t,e)=>{let i,n;for(;;){if(t.lookahead<ht){if(vt(t),t.lookahead<ht&&e===H)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-ht&&(t.match_length=kt(t,i)),t.match_length>=3)if(n=M(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=pt(t,t.ins_h,t.window[t.strstart+1]);else n=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(bt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===G?(bt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(bt(t,!1),0===t.strm.avail_out)?1:2},xt=(t,e)=>{let i,n,r;for(;;){if(t.lookahead<ht){if(vt(t),t.lookahead<ht&&e===H)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-ht&&(t.match_length=kt(t,i),t.match_length<=5&&(t.strategy===tt||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=M(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(bt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=M(t,0,t.window[t.strstart-1]),n&&bt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=M(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===G?(bt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(bt(t,!1),0===t.strm.avail_out)?1:2};function Ut(t,e,i,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=r}const Et=[new Ut(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(vt(t),0===t.lookahead&&e===H)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,bt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-ht&&(bt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(bt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(bt(t,!1),t.strm.avail_out),1)})),new Ut(4,4,8,4,At),new Ut(4,5,16,8,At),new Ut(4,6,32,32,At),new Ut(4,4,16,16,xt),new Ut(8,16,32,32,xt),new Ut(8,16,128,128,xt),new Ut(8,32,128,256,xt),new Ut(32,128,258,1024,xt),new Ut(32,258,258,4096,xt)];function It(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=st,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),_t(this.dyn_ltree),_t(this.dyn_dtree),_t(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),_t(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),_t(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const zt=t=>{if(!t||!t.state)return ft(t,q);t.total_in=t.total_out=0,t.data_type=at;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:dt,t.adler=2===e.wrap?0:1,e.last_flush=H,L(e),X},St=t=>{const e=zt(t);var i;return e===X&&((i=t.state).window_size=2*i.w_size,_t(i.head),i.max_lazy_match=Et[i.level].max_lazy,i.good_match=Et[i.level].good_length,i.nice_match=Et[i.level].nice_length,i.max_chain_length=Et[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},Ct=(t,e,i,n,r,a)=>{if(!t)return q;let s=1;if(e===Q&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),r<1||r>9||i!==st||n<8||n>15||e<0||e>9||a<0||a>nt)return ft(t,q);8===n&&(n=9);const o=new It;return t.state=o,o.strm=t,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=r+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<r+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=a,o.method=i,St(t)};var Tt={deflateInit:(t,e)=>Ct(t,e,st,15,8,rt),deflateInit2:Ct,deflateReset:St,deflateResetKeep:zt,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?q:(t.state.gzhead=e,X):q,deflate:(t,e)=>{let i,n;if(!t||!t.state||e>K||e<0)return t?ft(t,q):q;const r=t.state;if(!t.output||!t.input&&0!==t.avail_in||r.status===ct&&e!==G)return ft(t,0===t.avail_out?J:q);r.strm=t;const a=r.last_flush;if(r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,gt(r,31),gt(r,139),gt(r,8),r.gzhead?(gt(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),gt(r,255&r.gzhead.time),gt(r,r.gzhead.time>>8&255),gt(r,r.gzhead.time>>16&255),gt(r,r.gzhead.time>>24&255),gt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),gt(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(gt(r,255&r.gzhead.extra.length),gt(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=N(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(gt(r,0),gt(r,0),gt(r,0),gt(r,0),gt(r,0),gt(r,9===r.level?2:r.strategy>=et||r.level<2?4:0),gt(r,3),r.status=dt);else{let e=st+(r.w_bits-8<<4)<<8,i=-1;i=r.strategy>=et||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=i<<6,0!==r.strstart&&(e|=32),e+=31-e%31,r.status=dt,mt(r,e),0!==r.strstart&&(mt(r,t.adler>>>16),mt(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),wt(t),i=r.pending,r.pending!==r.pending_buf_size));)gt(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),wt(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,gt(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),wt(t),i=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,gt(r,n)}while(0!==n);r.gzhead.hcrc&&r.pending>i&&(t.adler=N(t.adler,r.pending_buf,r.pending-i,i)),0===n&&(r.status=lt)}else r.status=lt;if(r.status===lt&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&wt(t),r.pending+2<=r.pending_buf_size&&(gt(r,255&t.adler),gt(r,t.adler>>8&255),t.adler=0,r.status=dt)):r.status=dt),0!==r.pending){if(wt(t),0===t.avail_out)return r.last_flush=-1,X}else if(0===t.avail_in&&ut(e)<=ut(a)&&e!==G)return ft(t,J);if(r.status===ct&&0!==t.avail_in)return ft(t,J);if(0!==t.avail_in||0!==r.lookahead||e!==H&&r.status!==ct){let i=r.strategy===et?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(vt(t),0===t.lookahead)){if(e===H)return 1;break}if(t.match_length=0,i=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(bt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(bt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(bt(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===it?((t,e)=>{let i,n,r,a;const s=t.window;for(;;){if(t.lookahead<=ot){if(vt(t),t.lookahead<=ot&&e===H)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,n=s[r],n===s[++r]&&n===s[++r]&&n===s[++r])){a=t.strstart+ot;do{}while(n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&r<a);t.match_length=ot-(a-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=M(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=M(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(bt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===G?(bt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(bt(t,!1),0===t.strm.avail_out)?1:2})(r,e):Et[r.level].func(r,e);if(3!==i&&4!==i||(r.status=ct),1===i||3===i)return 0===t.avail_out&&(r.last_flush=-1),X;if(2===i&&(e===P?V(r):e!==K&&(O(r,0,0,!1),e===j&&(_t(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),wt(t),0===t.avail_out))return r.last_flush=-1,X}return e!==G?X:r.wrap<=0?Y:(2===r.wrap?(gt(r,255&t.adler),gt(r,t.adler>>8&255),gt(r,t.adler>>16&255),gt(r,t.adler>>24&255),gt(r,255&t.total_in),gt(r,t.total_in>>8&255),gt(r,t.total_in>>16&255),gt(r,t.total_in>>24&255)):(mt(r,t.adler>>>16),mt(r,65535&t.adler)),wt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?X:Y)},deflateEnd:t=>{if(!t||!t.state)return q;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==lt&&e!==dt&&e!==ct?ft(t,q):(t.state=null,e===dt?ft(t,W):X)},deflateSetDictionary:(t,e)=>{let i=e.length;if(!t||!t.state)return q;const n=t.state,r=n.wrap;if(2===r||1===r&&42!==n.status||n.lookahead)return q;if(1===r&&(t.adler=F(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===r&&(_t(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const a=t.avail_in,s=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,vt(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=pt(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,vt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=o,t.avail_in=a,n.wrap=r,X},deflateInfo:"pako deflate (from Nodeca project)"};const Rt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ft={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Rt(i,e)&&(t[e]=i[e])}}return t},flattenChunks:t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,n=0,r=t.length;e<r;e++){let r=t[e];i.set(r,n),n+=r.length}return i}};let Bt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Bt=!1}const Nt=new Uint8Array(256);for(let t=0;t<256;t++)Nt[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Nt[254]=Nt[254]=1;var Dt={string2buf:t=>{let e,i,n,r,a,s=t.length,o=0;for(r=0;r<s;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<s&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(o),a=0,r=0;a<o;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<s&&(n=t.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?e[a++]=i:i<2048?(e[a++]=192|i>>>6,e[a++]=128|63&i):i<65536?(e[a++]=224|i>>>12,e[a++]=128|i>>>6&63,e[a++]=128|63&i):(e[a++]=240|i>>>18,e[a++]=128|i>>>12&63,e[a++]=128|i>>>6&63,e[a++]=128|63&i);return e},buf2string:(t,e)=>{let i,n;const r=e||t.length,a=new Array(2*r);for(n=0,i=0;i<r;){let e=t[i++];if(e<128){a[n++]=e;continue}let s=Nt[e];if(s>4)a[n++]=65533,i+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&i<r;)e=e<<6|63&t[i++],s--;s>1?a[n++]=65533:e<65536?a[n++]=e:(e-=65536,a[n++]=55296|e>>10&1023,a[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Bt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n<e;n++)i+=String.fromCharCode(t[n]);return i})(a,n)},utf8border:(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Nt[t[i]]>e?i:e}},Zt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Lt=Object.prototype.toString,{Z_NO_FLUSH:Ot,Z_SYNC_FLUSH:$t,Z_FULL_FLUSH:Mt,Z_FINISH:Vt,Z_OK:Ht,Z_STREAM_END:Pt,Z_DEFAULT_COMPRESSION:jt,Z_DEFAULT_STRATEGY:Gt,Z_DEFLATED:Kt}=Z;function Xt(t){this.options=Ft.assign({level:jt,method:Kt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Gt},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zt,this.strm.avail_out=0;let i=Tt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==Ht)throw new Error(D[i]);if(e.header&&Tt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Dt.string2buf(e.dictionary):"[object ArrayBuffer]"===Lt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=Tt.deflateSetDictionary(this.strm,t),i!==Ht)throw new Error(D[i]);this._dict_set=!0}}function Yt(t,e){const i=new Xt(e);if(i.push(t,!0),i.err)throw i.msg||D[i.err];return i.result}Xt.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let r,a;if(this.ended)return!1;for(a=e===~~e?e:!0===e?Vt:Ot,"string"==typeof t?i.input=Dt.string2buf(t):"[object ArrayBuffer]"===Lt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(a===$t||a===Mt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Tt.deflate(i,a),r===Pt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Tt.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Ht;if(0!==i.avail_out){if(a>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Xt.prototype.onData=function(t){this.chunks.push(t)},Xt.prototype.onEnd=function(t){t===Ht&&(this.result=Ft.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var qt={Deflate:Xt,deflate:Yt,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Yt(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Yt(t,e)},constants:Z},Wt=function(t,e){let i,n,r,a,s,o,h,l,d,c,f,u,_,p,w,b,g,m,y,k,v,A,x,U;const E=t.state;i=t.next_in,x=t.input,n=i+(t.avail_in-5),r=t.next_out,U=t.output,a=r-(e-t.avail_out),s=r+(t.avail_out-257),o=E.dmax,h=E.wsize,l=E.whave,d=E.wnext,c=E.window,f=E.hold,u=E.bits,_=E.lencode,p=E.distcode,w=(1<<E.lenbits)-1,b=(1<<E.distbits)-1;t:do{u<15&&(f+=x[i++]<<u,u+=8,f+=x[i++]<<u,u+=8),g=_[f&w];e:for(;;){if(m=g>>>24,f>>>=m,u-=m,m=g>>>16&255,0===m)U[r++]=65535&g;else{if(!(16&m)){if(0==(64&m)){g=_[(65535&g)+(f&(1<<m)-1)];continue e}if(32&m){E.mode=12;break t}t.msg="invalid literal/length code",E.mode=30;break t}y=65535&g,m&=15,m&&(u<m&&(f+=x[i++]<<u,u+=8),y+=f&(1<<m)-1,f>>>=m,u-=m),u<15&&(f+=x[i++]<<u,u+=8,f+=x[i++]<<u,u+=8),g=p[f&b];i:for(;;){if(m=g>>>24,f>>>=m,u-=m,m=g>>>16&255,!(16&m)){if(0==(64&m)){g=p[(65535&g)+(f&(1<<m)-1)];continue i}t.msg="invalid distance code",E.mode=30;break t}if(k=65535&g,m&=15,u<m&&(f+=x[i++]<<u,u+=8,u<m&&(f+=x[i++]<<u,u+=8)),k+=f&(1<<m)-1,k>o){t.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=m,u-=m,m=r-a,k>m){if(m=k-m,m>l&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(v=0,A=c,0===d){if(v+=h-m,m<y){y-=m;do{U[r++]=c[v++]}while(--m);v=r-k,A=U}}else if(d<m){if(v+=h+d-m,m-=d,m<y){y-=m;do{U[r++]=c[v++]}while(--m);if(v=0,d<y){m=d,y-=m;do{U[r++]=c[v++]}while(--m);v=r-k,A=U}}}else if(v+=d-m,m<y){y-=m;do{U[r++]=c[v++]}while(--m);v=r-k,A=U}for(;y>2;)U[r++]=A[v++],U[r++]=A[v++],U[r++]=A[v++],y-=3;y&&(U[r++]=A[v++],y>1&&(U[r++]=A[v++]))}else{v=r-k;do{U[r++]=U[v++],U[r++]=U[v++],U[r++]=U[v++],y-=3}while(y>2);y&&(U[r++]=U[v++],y>1&&(U[r++]=U[v++]))}break}}break}}while(i<n&&r<s);y=u>>3,i-=y,u-=y<<3,f&=(1<<u)-1,t.next_in=i,t.next_out=r,t.avail_in=i<n?n-i+5:5-(i-n),t.avail_out=r<s?s-r+257:257-(r-s),E.hold=f,E.bits=u};const Jt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Qt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),te=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ee=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ie=(t,e,i,n,r,a,s,o)=>{const h=o.bits;let l,d,c,f,u,_,p=0,w=0,b=0,g=0,m=0,y=0,k=0,v=0,A=0,x=0,U=null,E=0;const I=new Uint16Array(16),z=new Uint16Array(16);let S,C,T,R=null,F=0;for(p=0;p<=15;p++)I[p]=0;for(w=0;w<n;w++)I[e[i+w]]++;for(m=h,g=15;g>=1&&0===I[g];g--);if(m>g&&(m=g),0===g)return r[a++]=20971520,r[a++]=20971520,o.bits=1,0;for(b=1;b<g&&0===I[b];b++);for(m<b&&(m=b),v=1,p=1;p<=15;p++)if(v<<=1,v-=I[p],v<0)return-1;if(v>0&&(0===t||1!==g))return-1;for(z[1]=0,p=1;p<15;p++)z[p+1]=z[p]+I[p];for(w=0;w<n;w++)0!==e[i+w]&&(s[z[e[i+w]]++]=w);if(0===t?(U=R=s,_=19):1===t?(U=Jt,E-=257,R=Qt,F-=257,_=256):(U=te,R=ee,_=-1),x=0,w=0,p=b,u=a,y=m,k=0,c=-1,A=1<<m,f=A-1,1===t&&A>852||2===t&&A>592)return 1;for(;;){S=p-k,s[w]<_?(C=0,T=s[w]):s[w]>_?(C=R[F+s[w]],T=U[E+s[w]]):(C=96,T=0),l=1<<p-k,d=1<<y,b=d;do{d-=l,r[u+(x>>k)+d]=S<<24|C<<16|T|0}while(0!==d);for(l=1<<p-1;x&l;)l>>=1;if(0!==l?(x&=l-1,x+=l):x=0,w++,0==--I[p]){if(p===g)break;p=e[i+s[w]]}if(p>m&&(x&f)!==c){for(0===k&&(k=m),u+=b,y=p-k,v=1<<y;y+k<g&&(v-=I[y+k],!(v<=0));)y++,v<<=1;if(A+=1<<y,1===t&&A>852||2===t&&A>592)return 1;c=x&f,r[c]=m<<24|y<<16|u-a|0}}return 0!==x&&(r[u+x]=p-k<<24|64<<16|0),o.bits=m,0};const{Z_FINISH:ne,Z_BLOCK:re,Z_TREES:ae,Z_OK:se,Z_STREAM_END:oe,Z_NEED_DICT:he,Z_STREAM_ERROR:le,Z_DATA_ERROR:de,Z_MEM_ERROR:ce,Z_BUF_ERROR:fe,Z_DEFLATED:ue}=Z,_e=12,pe=30,we=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function be(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ge=t=>{if(!t||!t.state)return le;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,se},me=t=>{if(!t||!t.state)return le;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ge(t)},ye=(t,e)=>{let i;if(!t||!t.state)return le;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?le:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,me(t))},ke=(t,e)=>{if(!t)return le;const i=new be;t.state=i,i.window=null;const n=ye(t,e);return n!==se&&(t.state=null),n};let ve,Ae,xe=!0;const Ue=t=>{if(xe){ve=new Int32Array(512),Ae=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ie(1,t.lens,0,288,ve,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ie(2,t.lens,0,32,Ae,0,t.work,{bits:5}),xe=!1}t.lencode=ve,t.lenbits=9,t.distcode=Ae,t.distbits=5},Ee=(t,e,i,n)=>{let r;const a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(e.subarray(i-a.wsize,i),0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>n&&(r=n),a.window.set(e.subarray(i-n,i-n+r),a.wnext),(n-=r)?(a.window.set(e.subarray(i-n,i),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=r))),0};var Ie={inflateReset:me,inflateReset2:ye,inflateResetKeep:ge,inflateInit:t=>ke(t,15),inflateInit2:ke,inflate:(t,e)=>{let i,n,r,a,s,o,h,l,d,c,f,u,_,p,w,b,g,m,y,k,v,A,x=0;const U=new Uint8Array(4);let E,I;const z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return le;i=t.state,i.mode===_e&&(i.mode=13),s=t.next_out,r=t.output,h=t.avail_out,a=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,c=o,f=h,A=se;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(2&i.wrap&&35615===l){i.check=0,U[0]=255&l,U[1]=l>>>8&255,i.check=N(i.check,U,2,0),l=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=pe;break}if((15&l)!==ue){t.msg="unknown compression method",i.mode=pe;break}if(l>>>=4,d-=4,v=8+(15&l),0===i.wbits)i.wbits=v;else if(v>i.wbits){t.msg="invalid window size",i.mode=pe;break}i.dmax=1<<i.wbits,t.adler=i.check=1,i.mode=512&l?10:_e,l=0,d=0;break;case 2:for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(i.flags=l,(255&i.flags)!==ue){t.msg="unknown compression method",i.mode=pe;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=pe;break}i.head&&(i.head.text=l>>8&1),512&i.flags&&(U[0]=255&l,U[1]=l>>>8&255,i.check=N(i.check,U,2,0)),l=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.head&&(i.head.time=l),512&i.flags&&(U[0]=255&l,U[1]=l>>>8&255,U[2]=l>>>16&255,U[3]=l>>>24&255,i.check=N(i.check,U,4,0)),l=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.head&&(i.head.xflags=255&l,i.head.os=l>>8),512&i.flags&&(U[0]=255&l,U[1]=l>>>8&255,i.check=N(i.check,U,2,0)),l=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.length=l,i.head&&(i.head.extra_len=l),512&i.flags&&(U[0]=255&l,U[1]=l>>>8&255,i.check=N(i.check,U,2,0)),l=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(u=i.length,u>o&&(u=o),u&&(i.head&&(v=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(a,a+u),v)),512&i.flags&&(i.check=N(i.check,n,u,a)),o-=u,a+=u,i.length-=u),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break t;u=0;do{v=n[a+u++],i.head&&v&&i.length<65536&&(i.head.name+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&(i.check=N(i.check,n,u,a)),o-=u,a+=u,v)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===o)break t;u=0;do{v=n[a+u++],i.head&&v&&i.length<65536&&(i.head.comment+=String.fromCharCode(v))}while(v&&u<o);if(512&i.flags&&(i.check=N(i.check,n,u,a)),o-=u,a+=u,v)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(l!==(65535&i.check)){t.msg="header crc mismatch",i.mode=pe;break}l=0,d=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=_e;break;case 10:for(;d<32;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}t.adler=i.check=we(l),l=0,d=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=s,t.avail_out=h,t.next_in=a,t.avail_in=o,i.hold=l,i.bits=d,he;t.adler=i.check=1,i.mode=_e;case _e:if(e===re||e===ae)break t;case 13:if(i.last){l>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}switch(i.last=1&l,l>>>=1,d-=1,3&l){case 0:i.mode=14;break;case 1:if(Ue(i),i.mode=20,e===ae){l>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=pe}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",i.mode=pe;break}if(i.length=65535&l,l=0,d=0,i.mode=15,e===ae)break t;case 15:i.mode=16;case 16:if(u=i.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;r.set(n.subarray(a,a+u),s),o-=u,a+=u,h-=u,s+=u,i.length-=u;break}i.mode=_e;break;case 17:for(;d<14;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(i.nlen=257+(31&l),l>>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=pe;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.lens[z[i.have++]]=7&l,l>>>=3,d-=3}for(;i.have<19;)i.lens[z[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,E={bits:i.lenbits},A=ie(0,i.lens,0,19,i.lencode,0,i.work,E),i.lenbits=E.bits,A){t.msg="invalid code lengths set",i.mode=pe;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;x=i.lencode[l&(1<<i.lenbits)-1],w=x>>>24,b=x>>>16&255,g=65535&x,!(w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(g<16)l>>>=w,d-=w,i.lens[i.have++]=g;else{if(16===g){for(I=w+2;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(l>>>=w,d-=w,0===i.have){t.msg="invalid bit length repeat",i.mode=pe;break}v=i.lens[i.have-1],u=3+(3&l),l>>>=2,d-=2}else if(17===g){for(I=w+3;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}l>>>=w,d-=w,v=0,u=3+(7&l),l>>>=3,d-=3}else{for(I=w+7;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}l>>>=w,d-=w,v=0,u=11+(127&l),l>>>=7,d-=7}if(i.have+u>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=pe;break}for(;u--;)i.lens[i.have++]=v}}if(i.mode===pe)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=pe;break}if(i.lenbits=9,E={bits:i.lenbits},A=ie(1,i.lens,0,i.nlen,i.lencode,0,i.work,E),i.lenbits=E.bits,A){t.msg="invalid literal/lengths set",i.mode=pe;break}if(i.distbits=6,i.distcode=i.distdyn,E={bits:i.distbits},A=ie(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,E),i.distbits=E.bits,A){t.msg="invalid distances set",i.mode=pe;break}if(i.mode=20,e===ae)break t;case 20:i.mode=21;case 21:if(o>=6&&h>=258){t.next_out=s,t.avail_out=h,t.next_in=a,t.avail_in=o,i.hold=l,i.bits=d,Wt(t,f),s=t.next_out,r=t.output,h=t.avail_out,a=t.next_in,n=t.input,o=t.avail_in,l=i.hold,d=i.bits,i.mode===_e&&(i.back=-1);break}for(i.back=0;x=i.lencode[l&(1<<i.lenbits)-1],w=x>>>24,b=x>>>16&255,g=65535&x,!(w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(b&&0==(240&b)){for(m=w,y=b,k=g;x=i.lencode[k+((l&(1<<m+y)-1)>>m)],w=x>>>24,b=x>>>16&255,g=65535&x,!(m+w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}l>>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,i.length=g,0===b){i.mode=26;break}if(32&b){i.back=-1,i.mode=_e;break}if(64&b){t.msg="invalid literal/length code",i.mode=pe;break}i.extra=15&b,i.mode=22;case 22:if(i.extra){for(I=i.extra;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.length+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;x=i.distcode[l&(1<<i.distbits)-1],w=x>>>24,b=x>>>16&255,g=65535&x,!(w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(0==(240&b)){for(m=w,y=b,k=g;x=i.distcode[k+((l&(1<<m+y)-1)>>m)],w=x>>>24,b=x>>>16&255,g=65535&x,!(m+w<=d);){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}l>>>=m,d-=m,i.back+=m}if(l>>>=w,d-=w,i.back+=w,64&b){t.msg="invalid distance code",i.mode=pe;break}i.offset=g,i.extra=15&b,i.mode=24;case 24:if(i.extra){for(I=i.extra;d<I;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}i.offset+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=pe;break}i.mode=25;case 25:if(0===h)break t;if(u=f-h,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=pe;break}u>i.wnext?(u-=i.wnext,_=i.wsize-u):_=i.wnext-u,u>i.length&&(u=i.length),p=i.window}else p=r,_=s-i.offset,u=i.length;u>h&&(u=h),h-=u,i.length-=u;do{r[s++]=p[_++]}while(--u);0===i.length&&(i.mode=21);break;case 26:if(0===h)break t;r[s++]=i.length,h--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===o)break t;o--,l|=n[a++]<<d,d+=8}if(f-=h,t.total_out+=f,i.total+=f,f&&(t.adler=i.check=i.flags?N(i.check,r,f,s-f):F(i.check,r,f,s-f)),f=h,(i.flags?l:we(l))!==i.check){t.msg="incorrect data check",i.mode=pe;break}l=0,d=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===o)break t;o--,l+=n[a++]<<d,d+=8}if(l!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=pe;break}l=0,d=0}i.mode=29;case 29:A=oe;break t;case pe:A=de;break t;case 31:return ce;default:return le}return t.next_out=s,t.avail_out=h,t.next_in=a,t.avail_in=o,i.hold=l,i.bits=d,(i.wsize||f!==t.avail_out&&i.mode<pe&&(i.mode<27||e!==ne))&&Ee(t,t.output,t.next_out,f-t.avail_out),c-=t.avail_in,f-=t.avail_out,t.total_in+=c,t.total_out+=f,i.total+=f,i.wrap&&f&&(t.adler=i.check=i.flags?N(i.check,r,f,t.next_out-f):F(i.check,r,f,t.next_out-f)),t.data_type=i.bits+(i.last?64:0)+(i.mode===_e?128:0)+(20===i.mode||15===i.mode?256:0),(0===c&&0===f||e===ne)&&A===se&&(A=fe),A},inflateEnd:t=>{if(!t||!t.state)return le;let e=t.state;return e.window&&(e.window=null),t.state=null,se},inflateGetHeader:(t,e)=>{if(!t||!t.state)return le;const i=t.state;return 0==(2&i.wrap)?le:(i.head=e,e.done=!1,se)},inflateSetDictionary:(t,e)=>{const i=e.length;let n,r,a;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?le:11===n.mode&&(r=1,r=F(r,e,i,0),r!==n.check)?de:(a=Ee(t,e,i,i),a?(n.mode=31,ce):(n.havedict=1,se))):le},inflateInfo:"pako inflate (from Nodeca project)"},ze=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Se=Object.prototype.toString,{Z_NO_FLUSH:Ce,Z_FINISH:Te,Z_OK:Re,Z_STREAM_END:Fe,Z_NEED_DICT:Be,Z_STREAM_ERROR:Ne,Z_DATA_ERROR:De,Z_MEM_ERROR:Ze}=Z;function Le(t){this.options=Ft.assign({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zt,this.strm.avail_out=0;let i=Ie.inflateInit2(this.strm,e.windowBits);if(i!==Re)throw new Error(D[i]);if(this.header=new ze,Ie.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Dt.string2buf(e.dictionary):"[object ArrayBuffer]"===Se.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Ie.inflateSetDictionary(this.strm,e.dictionary),i!==Re)))throw new Error(D[i])}function Oe(t,e){const i=new Le(e);if(i.push(t),i.err)throw i.msg||D[i.err];return i.result}Le.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let a,s,o;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Te:Ce,"[object ArrayBuffer]"===Se.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),a=Ie.inflate(i,s),a===Be&&r&&(a=Ie.inflateSetDictionary(i,r),a===Re?a=Ie.inflate(i,s):a===De&&(a=Be));i.avail_in>0&&a===Fe&&i.state.wrap>0&&0!==t[i.next_in];)Ie.inflateReset(i),a=Ie.inflate(i,s);switch(a){case Ne:case De:case Be:case Ze:return this.onEnd(a),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||a===Fe))if("string"===this.options.to){let t=Dt.utf8border(i.output,i.next_out),e=i.next_out-t,r=Dt.buf2string(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(a!==Re||0!==o){if(a===Fe)return a=Ie.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Le.prototype.onData=function(t){this.chunks.push(t)},Le.prototype.onEnd=function(t){t===Re&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ft.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var $e={Inflate:Le,inflate:Oe,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Oe(t,e)},ungzip:Oe,constants:Z};const{Deflate:Me,deflate:Ve,deflateRaw:He,gzip:Pe}=qt,{Inflate:je,inflate:Ge,inflateRaw:Ke,ungzip:Xe}=$e;var Ye={Deflate:Me,deflate:Ve,deflateRaw:He,gzip:Pe,Inflate:je,inflate:Ge,inflateRaw:Ke,ungzip:Xe,constants:Z};function qe(t,e){const i=t.length;if(i!==e.length)return!1;for(let n=0;n<i;n++)if(t[n]!==e[n])return!1;return!0}class We{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,i,n){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,i,n){throw new Error("Not Implemented")}}class Je{describeTo(t){throw new Error("Not Implemented")}}class Qe extends Je{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class ti{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new Qe(t)}}class ei extends We{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,i,n){return this.appendList(t,e,i,new ti(n)),this}appendList(t,e,i,n){let r=!1;this.appendText(t);const a=n[Symbol.iterator]();for(let t=a.next();!0!==t.done;t=a.next())r&&this.appendText(e),this.appendDescriptionOf(t.value),r=!0;return this.appendText(i),this}}class ii extends ei{value="";appendText(t){return this.value+=t,this}}function ni(t,e){if(!t)throw new Error(e||"AssertionError")}function ri(t,e,i="value"){if(-1===e.indexOf(t))throw new Error(`${i} must be one of [${e.join(", ")}], instead was '${t}'`)}const ai=["string","boolean","number","object","undefined","function","symbol"];ni.enum=function(t,e,i="value"){for(let i in e)if(e[i]===t)return;throw new Error(`${i}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},ni.notEqual=function(t,e,i){ni(t!==e,i)},ni.notOk=function(t,e){ni(!t,e)},ni.equal=function(t,e,i){if(t!==e){const n=`${t} !== ${e}`;throw new Error(void 0!==i&&""!==i?`${i}. ${n}`:n)}},ni.logicalyEqual=function(t,e,i){},ni.ok=ni,ni.greaterThan=function(t,e,i){if(!(t>e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} > ${e}.`,new Error(n)}},ni.greaterThanOrEqual=function(t,e,i){if(!(t>=e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} >= ${e}.`,new Error(n)}},ni.lessThan=function(t,e,i){if(!(t<e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} < ${e}.`,new Error(n)}},ni.lessThanOrEqual=function(t,e,i){if(!(t<=e)){let n="";throw void 0!==i&&(n+=i+". "),n+=`Expected ${t} <= ${e}.`,new Error(n)}},ni.typeOf=function(t,e,i="value"){ri(typeof t,ai);const n=typeof t;if(n!==e)throw new Error(`expected ${i} to be ${e}, instead was '${n}'(=${t})`)},ni.arrayHas=function(t,e,i="Array does not contain the item"){},ni.arrayHasNo=function(t,e,i="Array contains the item"){},ni.arrayEqual=function(t,e,i="Arrays are not equal"){if(!qe(t,e))throw new Error(i)},ni.isOneOf=ri,ni.isInstanceOf=function(t,e,i="value",n=e.name){},ni.isNumber=function(t,e="value"){const i=typeof t;if("number"!==i)throw new Error(`expected ${e} to be a number, instead was '${i}'(=${t})`)},ni.isString=function(t,e="value"){const i=typeof t;if("string"!==i)throw new Error(`expected ${e} to be a string, instead was '${i}'(=${t})`)},ni.isBoolean=function(t,e="value"){const i=typeof t;if("boolean"!==i)throw new Error(`expected ${e} to be a boolean, instead was '${i}'(=${t})`)},ni.isFunction=function(t,e="value"){const i=typeof t;if("function"!==i)throw new Error(`expected ${e} to be a function, instead was '${i}'(=${t})`)},ni.isObject=function(t,e="value"){const i=typeof t;if("object"!==i)throw new Error(`expected ${e} to be an object, instead was '${i}'(=${t})`)},ni.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},ni.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},ni.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},ni.isArrayLike=function(t,e="value"){if(!function(t){if(Array.isArray(t))return!0;if("object"!=typeof t)return!1;if(null===t)return!1;if(function(t){if("object"!=typeof t)return!1;if(null===t)return!1;const e=t.constructor;return e===Uint8Array||e===Uint16Array||e===Uint32Array||e===Int8Array||e===Int16Array||e===Int32Array||e===Float32Array||e===Float64Array||e===BigUint64Array||e===BigInt64Array}(t))return!0;const e=t.length;return!("number"!=typeof e&&!Number.isInteger(e)||e<0)}(t))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`)},ni.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},ni.undefined=function(t,e="value"){if(void 0!==t)throw new Error(`${e} is not undefined`)},ni.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},ni.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},ni.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},ni.isFinite=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},ni.isFiniteNumber=ni.isFinite,ni.that=function(t,e,i){if(i.matches(t))return;const n=new ii;throw n.appendText(`Expected ${e} to be `),i.describeTo(n),n.appendText(" instead "),i.describeMismatch(t,n),new Error(n.value)};const si=!1,oi=!0,hi=new Float32Array(1),li=new Int32Array(hi.buffer);class di{endianness=oi;position=0;get length(){throw new Error("Deprecated, use 'capacity' instead")}set length(t){throw new Error("Deprecated, use 'capacity' instead")}capacity=1024;data=new ArrayBuffer(1024);dataView=new DataView(this.data);__data_uint8=new Uint8Array(this.data);__growFactor=1.1;get raw_bytes(){return this.__data_uint8}fromArrayBuffer(t){this.data=t,this.dataView=new DataView(t),this.__data_uint8=new Uint8Array(t),this.capacity=t.byteLength,this.position=0}trim(){return this.setCapacity(this.position),this}setCapacity(t){if(t<this.position)throw new Error(`Attempting to set capacity(=${t}) below current position(=${this.position})`);const e=this.__data_uint8,i=new Uint8Array(t);!function(t,e,i,n,r){let a,s;const o=function(t,e,i){const n=0|i;return 0==(3&n)?4:0==(1&n)?2:1}(0,0,r);4===o?(a=new Uint32Array(t,0,r>>>2),s=new Uint32Array(i,0,r>>>2)):2===o?(a=new Uint16Array(t,0,r>>>1),s=new Uint16Array(i,0,r>>>1)):(a=new Uint8Array(t,0,r),s=new Uint8Array(i,0,r)),s.set(a)}(e.buffer,0,i.buffer,0,Math.min(e.buffer.byteLength,i.buffer.byteLength)),this.data=i.buffer,this.__data_uint8=i,this.dataView=new DataView(this.data),this.capacity=t}ensureCapacity(t){const e=this.capacity;if(e>=t)return;const i=Math.ceil(Math.max(t,e*this.__growFactor,e+1024))+3>>2<<2;this.setCapacity(i)}readFloat16(){return function(t){let e=0;const i=(31744&t)>>10,n=1023&t;let r=1;return t>>15!=0&&(r=-1),e=0!==i?31===i?0!==n?NaN:Infinity:r*Math.pow(2,i-15)*(1+n/1024):r*(n/1024*6103515625e-14),e}(this.readUint16())}readFloat32(){const t=this.dataView.getFloat32(this.position,this.endianness);return this.position+=4,t}readFloat64(){const t=this.dataView.getFloat64(this.position,this.endianness);return this.position+=8,t}readInt8(){const t=this.dataView.getInt8(this.position);return this.position+=1,t}readInt16(){const t=this.dataView.getInt16(this.position,this.endianness);return this.position+=2,t}readInt32(){const t=this.dataView.getInt32(this.position,this.endianness);return this.position+=4,t}readUint8(){const t=this.dataView.getUint8(this.position);return this.position+=1,t}readUint16(){const t=this.dataView.getUint16(this.position,this.endianness);return this.position+=2,t}readUint16LE(){const t=this.dataView.getUint16(this.position,oi);return this.position+=2,t}readUint16BE(){const t=this.dataView.getUint16(this.position,si);return this.position+=2,t}readUint24(){return this.endianness===si?this.readUint24BE():this.readUint24LE()}readUint24LE(){const t=this.dataView.getUint8(this.position),e=this.dataView.getUint8(this.position+1),i=this.dataView.getUint8(this.position+2);return this.position+=3,t|e<<8|i<<16}readUint24BE(){const t=this.dataView.getUint8(this.position),e=this.dataView.getUint8(this.position+1),i=this.dataView.getUint8(this.position+2);return this.position+=3,i|e<<8|t<<16}readUint32(){const t=this.dataView.getUint32(this.position,this.endianness);return this.position+=4,t}readUint32LE(){const t=this.dataView.getUint32(this.position,oi);return this.position+=4,t}readUint32BE(){const t=this.dataView.getUint32(this.position,si);return this.position+=4,t}readUint8Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint8()}readUint16Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint16()}readUint32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readUint32()}readInt8Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt8()}readInt16Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt16()}readInt32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readInt32()}readFloat32Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readFloat32()}readFloat64Array(t,e,i){for(let n=0;n<i;n++)t[n+e]=this.readFloat64()}writeFloat32Array(t,e,i){for(let n=0;n<i;n++)this.writeFloat32(t[n+e])}writeFloat16(t){const e=function(t){let e=t;e>65504&&(e=65504),hi[0]=e;const i=li[0];let n=i>>16&32768,r=i>>12&2047;const a=i>>23&255;return a<103?n:a>142?(n|=31744,n|=(255===a?0:1)&&8388607&i,n):a<113?(r|=2048,n|=(r>>114-a)+(r>>113-a&1),n):(n|=a-112<<10|r>>1,n+=1&r,n)}(t);this.writeUint16(e)}writeFloat32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setFloat32(this.position,t,this.endianness),this.position=e}writeFloat64(t){const e=this.position+8;this.ensureCapacity(e),this.dataView.setFloat64(this.position,t,this.endianness),this.position=e}writeInt8(t){const e=this.position+1;this.ensureCapacity(e),this.dataView.setInt8(this.position,t),this.position=e}writeInt16(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setInt16(this.position,t,this.endianness),this.position=e}writeInt32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setInt32(this.position,t,this.endianness),this.position=e}writeInt8Array(t,e,i){this.ensureCapacity(this.position+i);for(let n=0;n<i;n++)this.writeInt8(t[e+n])}writeInt16Array(t,e,i){this.ensureCapacity(this.position+2*i);for(let n=0;n<i;n++)this.writeInt16(t[e+n])}writeInt32Array(t,e,i){this.ensureCapacity(this.position+4*i);for(let n=0;n<i;n++)this.writeInt32(t[e+n])}writeUint8(t){const e=this.position+1;this.ensureCapacity(e),this.dataView.setUint8(this.position,t),this.position=e}writeUint8Array(t,e,i){for(let n=0;n<i;n++)this.writeUint8(t[e+n])}writeUint16(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,this.endianness),this.position=e}writeUint16BE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,si),this.position=e}writeUint16LE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,oi),this.position=e}writeUint16Array(t,e,i){for(let n=0;n<i;n++)this.writeUint16(t[e+n])}writeUint24(t){this.endianness===si?this.writeUint24BE(t):this.writeUint24LE(t)}writeUint24BE(t){const e=this.position+3;this.ensureCapacity(e);const i=255&t,n=t>>8&255,r=t>>16&255;this.dataView.setUint8(this.position,r),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,i),this.position=e}writeUint24LE(t){const e=this.position+3;this.ensureCapacity(e);const i=255&t,n=t>>8&255,r=t>>16&255;this.dataView.setUint8(this.position,i),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,r),this.position=e}writeUintVar(t){let e=!0;for(;e||0!==t;){e=!1;let i=127&t;(t>>=7)>0&&(i|=128),this.writeUint8(i)}}readUintVar(){let t=!0,e=0,i=0;for(;t;){let n=this.readUint8();t=0!=(128&n),e|=(127&n)<<i,i+=7}return e}writeUint32(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,this.endianness),this.position=e}writeUint32BE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,si),this.position=e}writeUint32LE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,oi),this.position=e}writeUint32Array(t,e,i){this.ensureCapacity(this.position+4*i);for(let n=0;n<i;n++)this.writeUint32(t[e+n])}writeBytes(t,e,i){const n=e+i,r=this.position,a=r+i;if(this.ensureCapacity(a),0===e&&t.length===i)this.__data_uint8.set(t,r);else if("function"==typeof t.subarray)this.__data_uint8.set(t.subarray(e,n),r);else for(let n=0;n<i;n++)this.__data_uint8[r+n]=t[e+n];this.position=a}readBytes(t,e,i){const n=this.position,r=n+i,a=this.__data_uint8;i<128?function(t,e,i,n,r){let a,s,o;for(o=0;o<r;o++)a=e+o,s=n+o,i[s]=t[a]}(a,n,t,e,i):t.set(a.subarray(n,r),e),this.position=r}writeUTF8String(t){if(null===t)return void this.writeUint32(4294967295);if(void 0===t)return void this.writeUint32(4294967294);let e=0;const i=t.length;if(i>=4294967294)throw new Error("String is too long");this.writeUint32(i);let n=this.position;const r=Math.max(32,i+(i>>1)+7);this.ensureCapacity(r+n);let a=this.__data_uint8,s=this.capacity;for(;e<i;){let r=t.charCodeAt(e++);if(r>=55296&&r<=56319){if(e<i){const i=t.charCodeAt(e);56320==(64512&i)&&(++e,r=((1023&r)<<10)+(1023&i)+65536)}if(r>=55296&&r<=56319)continue}if(n+4>s&&(this.ensureCapacity(n+4),s=this.capacity,a=this.__data_uint8),0!=(4294967168&r)){if(0==(4294965248&r))a[n++]=r>>6&31|192;else if(0==(4294901760&r))a[n++]=r>>12&15|224,a[n++]=r>>6&63|128;else{if(0!=(4292870144&r))continue;a[n++]=r>>18&7|240,a[n++]=r>>12&63|128,a[n++]=r>>6&63|128}a[n++]=63&r|128}else a[n++]=r}this.position=n}readUTF8String(){const t=this.readUint32();if(4294967295===t)return null;if(4294967294===t)return;const e=this.__data_uint8;let i="",n=this.position,r=0;for(;n<this.capacity&&r<t;){const t=e[n++];let a;if(0===t)break;0==(128&t)?a=t:192==(224&t)?a=(31&t)<<6|63&e[n++]:224==(240&t)?a=(31&t)<<12|(63&e[n++])<<6|63&e[n++]:240==(248&t)&&(a=(7&t)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++],a>65535&&(a-=65536,i+=String.fromCharCode(a>>>10&1023|55296),r++,a=56320|1023&a)),r++,i+=String.fromCharCode(a)}return this.position=n,i}writeASCIIString(t){const e=t.length,i=this.position,n=i+e;this.ensureCapacity(n);for(let n=0;n<e;n++){const e=t.charCodeAt(n);if(e>255)throw new Error(`Character ${String.fromCharCode(e)} can't be represented by a US-ASCII byte.`);this.__data_uint8[i+n]=e}this.position=n}readASCIICharacters(t,e=!1){let i="";for(let n=0;n<t;n++){const t=this.readUint8();if(e&&0===t)break;i+=String.fromCharCode(t)}return i}static fromEndianness(t){const e=new di;return e.endianness=t,e}static fromArrayBuffer(t){const e=new di;return e.fromArrayBuffer(t),e}static copyUTF8String(t,e){const i=t.readUTF8String();return e.writeUTF8String(i),i}static copyUintVar(t,e){const i=t.readUintVar();return e.writeUintVar(i),i}static copyUint8(t,e){const i=t.readUint8();return e.writeUint8(i),i}static copyUint16(t,e){const i=t.readUint16();return e.writeUint16(i),i}static copyUint32(t,e){const i=t.readUint32();return e.writeUint32(i),i}static copyFloat32(t,e){const i=t.readFloat32();return e.writeFloat32(i),i}static copyFloat64(t,e){const i=t.readFloat64();return e.writeFloat64(i),i}static copyBytes(t,e,i){const n=new Uint8Array(i);return t.readBytes(n,0,i),e.writeBytes(n,0,i),n}}di.prototype.isBinaryBuffer=!0;const ci=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)0!=(1&e)?e=3988292384^e>>>1:e>>>=1;ci[t]=e}class fi{width=0;height=0;bitDepth=0;colorType=0;compressionMethod=0;filterMethod=0;interlaceMethod=0;colors=0;alpha=!1;pixelBits=0;palette=null;pixels=null;trns=null;text={};getWidth(){return this.width}setWidth(t){this.width=t}getHeight(){return this.height}setHeight(t){this.height=t}getBitDepth(){return this.bitDepth}setBitDepth(t){if(-1===[1,2,4,8,16].indexOf(t))throw new Error("invalid bith depth "+t);this.bitDepth=t}getColorType(){return this.colorType}setColorType(t){let e=0,i=!1;switch(t){case 0:case 3:e=1;break;case 2:e=3;break;case 4:e=2,i=!0;break;case 6:e=4,i=!0;break;default:throw new Error("invalid color type")}this.colors=e,this.alpha=i,this.colorType=t}getCompressionMethod(){return this.compressionMethod}setCompressionMethod(t){if(0!==t)throw new Error("invalid compression method "+t);this.compressionMethod=t}getFilterMethod(){return this.filterMethod}setFilterMethod(t){if(0!==t)throw new Error("invalid filter method "+t);this.filterMethod=t}getInterlaceMethod(){return this.interlaceMethod}setInterlaceMethod(t){if(0!==t&&1!==t)throw new Error("invalid interlace method "+t);this.interlaceMethod=t}setTRNS(t){this.trns=t}setPalette(t){if(t.length%3!=0)throw new Error("incorrect PLTE chunk length");if(t.length>3*Math.pow(2,this.bitDepth))throw new Error("palette has more colors than 2^bitdepth");this.palette=t}getPalette(){return this.palette}getPixel(t,e,i,n){const r=this.pixels;if(!r)throw new Error("pixel data is empty");if(i>=this.width||n>=this.height)throw new Error("x,y position out of bound");const a=this.colors*this.bitDepth/8*(n*this.width+i);let s,o,h,l;switch(this.colorType){case 0:s=r[a],o=s,h=s,l=255;break;case 2:s=r[a],o=r[a+1],h=r[a+2],l=255;break;case 3:l=255,null!=this.trns&&(l=this.trns[r[a]]);const t=3*r[a],e=this.palette;s=e[t],o=e[t+1],h=e[t+2];break;case 4:s=r[a],o=s,h=s,l=r[a+1];break;case 6:s=r[a],o=r[a+1],h=r[a+2],l=r[a+3];break;default:throw new Error("Unsupported color type")}t[e+0]=s,t[e+1]=o,t[e+2]=h,t[e+3]=l}getRGBA8Array_fromRGB(t){const e=this.height,i=this.width*e,n=this.pixels;for(let e=0;e<i;e++){const i=3*e,r=i+e;t[r]=n[i],t[r+1]=n[i+1],t[r+2]=n[i+2],t[r+3]=255}}getRGBA8Array_generic(t){const e=this.height,i=this.width;for(let n=0;n<e;n++){const e=n*i;for(let r=0;r<i;r++){const i=4*(e+r);this.getPixel(t,i,r,n)}}}getRGBA8Array(){if(6===this.colorType)return this.pixels;const t=this.height,e=this.width,i=new Uint8Array(e*t*4);return 2===this.colorType?this.getRGBA8Array_fromRGB(i):this.getRGBA8Array_generic(i),i}getUint8Data_case3(){const t=this.width*this.height;let e;const i=this.trns;e=null!==i?4:3;const n=new Uint8Array(t*e),r=this.pixels,a=this.palette,s=this.colors*Math.ceil(this.bitDepth/8);for(let i=0;i<t;i++){const t=i*e,o=3*r[i*s];n[t]=a[o],n[t+1]=a[o+1],n[t+2]=a[o+2]}if(null!==i){const e=i.length;for(let a=0;a<t;a++){const t=r[a*s];n[4*a+3]=t>=e?255:i[t]}}return{data:n,itemSize:e}}getUint8Data(){let t,e=0;switch(this.colorType){case 0:t=this.pixels,e=1;break;case 2:t=this.pixels,e=3;break;case 3:const i=this.getUint8Data_case3();t=i.data,e=i.itemSize;break;case 4:t=this.pixels,e=2;break;case 6:t=this.pixels,e=4;break;default:throw new Error("Unsupported color type")}return{data:t,itemSize:e}}}const ui=[137,80,78,71,13,10,26,10];function _i(t){const e=new Ye.Inflate;if(e.push(t),e.err)throw new Error(e.err);return e.result.buffer}function pi(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function wi(t,e){return t[e]}function bi(t){this.i=0,this.bytes=new Uint8Array(t),this.png=new fi,this.dataChunks=[],this.buffer=new di,this.buffer.endianness=si,this.buffer.fromArrayBuffer(t),this.crc_enabled=!1,this.header=new Uint8Array(8)}bi.prototype.readBytes=function(t){const e=new Uint8Array(t);return this.buffer.readBytes(e,0,t),e},bi.prototype.decodeHeader=function(){if(0!==this.i)throw new Error("file pointer should be at 0 to read the header");const t=this.buffer,e=this.header;if(t.readBytes(e,0,8),!qe(e,ui))throw new Error("invalid PNGReader file (bad signature)")},bi.prototype.decodeChunk=function(){const t=this.buffer,e=t.readUint32();if(e<0)throw new Error("Bad chunk length "+(4294967295&e));const i=t.position,n=t.readASCIICharacters(4),r=this.readBytes(e);switch(t.readUint32(),this.crc_enabled&&function(t,e=0,i=t.length){!function(t,e,i,n){let r=4294967295;const a=i+n;for(let t=i;t<a;t++){const i=e[t];r=ci[255&(r^i)]^r>>>8}}(0,t,e,i)}(t.raw_bytes,i,e+4),n){case"IHDR":this.decodeIHDR(r);break;case"PLTE":this.decodePLTE(r);break;case"IDAT":this.decodeIDAT(r);break;case"tRNS":this.decodeTRNS(r);break;case"IEND":this.decodeIEND(r);break;case"sRGB":this.decodesRGB(r);break;case"tIME":this.decodetIME(r);break;case"zTXt":this.decodezTXt(r);break;case"iTXt":this.decodeiTXt(r)}return n},bi.prototype.decodesRGB=function(t){wi(t,0)},bi.prototype.decodetIME=function(t){wi(t,0),wi(t,1),wi(t,2),wi(t,3),wi(t,4),wi(t,5),wi(t,6)},bi.prototype.decodeiTXt=function(t){const e=di.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(79,!0),n=e.readUint8();e.readUint8();const r=e.readASCIICharacters(Infinity,!0),a=e.readASCIICharacters(Infinity,!0),s=e.data.length-e.position;let o;if(0===n)o=e.readASCIICharacters(s);else{if(1!==n)throw new Error(`Invalid compression flag value '${n}'`);{const t=_i(new Uint8Array(e.data,e.position,s));e.fromArrayBuffer(t),o=e.readASCIICharacters(t.byteLength)}}return{keyword:i,language_tag:r,translated_keyword:a,text:o}},bi.prototype.decodezTXt=function(t){const e=di.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(79,!0),n=e.readUint8();let r;if(0!==n)throw new Error(`Unsupported compression method '${n}'`);{const i=_i(new Uint8Array(t.buffer,e.position));e.fromArrayBuffer(i),r=e.readASCIICharacters(i.length)}return{keyword:i,text:r}},bi.prototype.decodetEXt=function(t){const e=di.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(Number.POSITIVE_INFINITY,!0),n=e.readASCIICharacters(i.length-1,!1);this.png.text[i]=n},bi.prototype.decodeiEXt=function(t){const e=di.fromArrayBuffer(t.buffer),i=e.readASCIICharacters(Number.POSITIVE_INFINITY,!0);if(e.readUint8(),e.readUint8(),e.readASCIICharacters(Number.POSITIVE_INFINITY,!0),e.readUTF8String(),0!==e.readUint8())throw new Error("Expected Null Separator after Translated keyword");const n=e.readUTF8String();this.png.text[i]=n},bi.prototype.decodeIHDR=function(t){const e=this.png;e.setWidth(pi(t,0)),e.setHeight(pi(t,4)),e.setBitDepth(wi(t,8)),e.setColorType(wi(t,9)),e.setCompressionMethod(wi(t,10)),e.setFilterMethod(wi(t,11)),e.setInterlaceMethod(wi(t,12))},bi.prototype.decodePLTE=function(t){this.png.setPalette(t)},bi.prototype.decodeIDAT=function(t){this.dataChunks.push(t)},bi.prototype.decodeTRNS=function(t){this.png.setTRNS(t)},bi.prototype.decodeIEND=function(){},bi.prototype.decodePixels=function(){const t=this.png,e=new Ye.Inflate,i=this.dataChunks,n=i.length;for(let t=0;t<n;t++)if(e.push(i[t]),e.err)throw new Error(e.err);const r=e.result;0===t.getInterlaceMethod()?this.interlaceNone(r):this.interlaceAdam7(r)},bi.prototype.interlaceNone=function(t){const e=this.png,i=e.bitDepth,n=e.colors*i/8,r=e.width,a=e.height,s=Math.ceil(n*r),o=Math.ceil(n)*r,h=new Uint8Array(o*a);let l=0;const d=t.length;for(let e=0;e<d;e+=s+1){const r=e+1,a=wi(t,e);switch(a){case 0:if(1===i)for(let e=0;e<o;e++){const i=t[(e>>>4)+r]>>>(7&e)&1;h[l+e]=i}else if(2===i)for(let e=0;e<o;e++){const i=t[(e>>>2)+r]>>>((3&~e)<<1)&3;h[l+e]=i}else if(4===i)for(let e=0;e<o;e++){const i=t[(e>>>1)+r]>>>((1&~e)<<2)&15;h[l+e]=i}else{if(8!==i)throw new Error(`unsupported bit depth ${i}`);for(let e=0;e<o;e++)h[l+e]=t[e+r]}break;case 1:this.unFilterSub(t,r,h,n,l,s);break;case 2:this.unFilterUp(t,r,h,n,l,s);break;case 3:this.unFilterAverage(t,r,h,n,l,s);break;case 4:this.unFilterPaeth(t,r,h,n,l,s);break;default:throw new Error(`unknown filtered scanline type '${a}'`)}l+=o}e.pixels=h},bi.prototype.interlaceAdam7=function(t){throw new Error("Adam7 interlacing is not implemented yet")},bi.prototype.unFilterSub=function(t,e,i,n,r,a){let s=0;for(;s<n;s++)i[r+s]=t[s+e];for(;s<a;s++){const a=r+s;i[a]=t[s+e]+i[a-n]&255}},bi.prototype.unFilterUp=function(t,e,i,n,r,a){let s,o,h=0;if(r-a<0)for(;h<a;h++)i[r+h]=t[h+e];else for(;h<a;h++)s=t[h+e],o=i[r+h-a],i[r+h]=s+o&255},bi.prototype.unFilterAverage=function(t,e,i,n,r,a){let s,o,h,l=0;if(r-a<0){for(;l<n;l++)i[r+l]=t[l+e];for(;l<a;l++){const a=r+l;i[a]=t[l+e]+(i[a-n]>>1)&255}}else{for(;l<n;l++){const n=r+l;i[n]=t[l+e]+(i[n-a]>>1)&255}for(;l<a;l++){s=t[l+e];const d=r+l;o=i[d-n],h=i[d-a],i[d]=s+(o+h>>1)&255}}},bi.prototype.unFilterPaeth=function(t,e,i,n,r,a){let s,o,h,l,d,c,f,u,_,p=0;if(r-a<0){for(;p<n;p++)i[r+p]=t[p+e];for(;p<a;p++)i[r+p]=t[p+e]+i[r+p-n]&255}else{const w=r-a;for(;p<n;p++)i[r+p]=t[p+e]+i[w+p]&255;for(;p<a;p++){s=t[p+e];const w=r+p;l=i[w-a-n],h=i[w-a],o=i[w-n],d=o+h-l,c=Math.abs(d-o),f=Math.abs(d-h),u=Math.abs(d-l),_=c<=f&&c<=u?o:f<=u?h:l,i[w]=s+_&255}}},bi.prototype.parse=function(){for(this.decodeHeader();"IEND"!==this.decodeChunk(););return this.decodePixels(),this.png},self.Lib={decode:async function(t,e="png"){if(!(t instanceof ArrayBuffer))throw new Error(".data argument must be an ArrayBuffer, instead was something else");if("png"===e.toLowerCase())return await async function(t){return new Promise(((e,i)=>{const n=new bi(t).parse(),r=n.getUint8Data(),a=n.getWidth(),s=n.getHeight();e({data:r.data.buffer,width:a,height:s,itemSize:r.itemSize,bitDepth:8})}))}(t);throw new Error("Unsupported type")}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function e(t){if("object"!=typeof t)return!1;if(null===t)return!1;const e=t.constructor;return e===Uint8Array||e===Uint16Array||e===Uint32Array||e===Int8Array||e===Int16Array||e===Int32Array||e===Float32Array||e===Float64Array||e===BigUint64Array||e===BigInt64Array}class n{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,r){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,r){throw new Error("Not Implemented")}}class r{describeTo(t){throw new Error("Not Implemented")}}class i extends r{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class s{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class o extends n{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,r){return this.appendList(t,e,n,new s(r)),this}appendList(t,e,n,r){let i=!1;this.appendText(t);const s=r[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())i&&this.appendText(e),this.appendDescriptionOf(t.value),i=!0;return this.appendText(n),this}}class a extends o{value="";appendText(t){return this.value+=t,this}}function c(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n,r,i){let s,o,a;for(a=0;a<i;a++)s=e+a,o=r+a,n[o]=t[s]}c.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},c.notEqual=function(t,e,n){c(t!==e,n)},c.notOk=function(t,e){c(!t,e)},c.equal=function(t,e,n){if(t!==e){const r=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${r}`:r)}},c.logicalyEqual=function(t,e,n){},c.ok=c,c.greaterThan=function(t,e,n){if(!(t>e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} > ${e}.`,new Error(r)}},c.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} >= ${e}.`,new Error(r)}},c.lessThan=function(t,e,n){if(!(t<e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} < ${e}.`,new Error(r)}},c.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} <= ${e}.`,new Error(r)}},c.typeOf=function(t,e,n="value"){const r=typeof t;if(r!==e)throw new Error(`expected ${n} to be ${e}, instead was '${r}'(=${t})`)},c.arrayHas=function(t,e,n="Array does not contain the item"){},c.arrayHasNo=function(t,e,n="Array contains the item"){},c.arrayEqual=function(e,n,r="Arrays are not equal"){if(!t(e,n))throw new Error(r)},c.isInstanceOf=function(t,e,n="value",r=e.name){},c.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},c.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},c.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},c.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},c.isObject=function(t,e="value"){const n=typeof t;if("object"!==n)throw new Error(`expected ${e} to be an object, instead was '${n}'(=${t})`)},c.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},c.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},c.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},c.isArrayLike=function(t,n="value"){if(!function(t){if(Array.isArray(t))return!0;if("object"!=typeof t)return!1;if(null===t)return!1;if(e(t))return!0;const n=t.length;return!("number"!=typeof n&&!Number.isInteger(n)||n<0)}(t))throw new Error(`expected ${n} to be an array-like structure, instead was something else (typeof ='${typeof t}')`)},c.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},c.undefined=function(t,e="value"){if(void 0!==t)throw new Error(`${e} is not undefined`)},c.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},c.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},c.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},c.isFinite=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},c.isFiniteNumber=c.isFinite,c.that=function(t,e,n){if(n.matches(t))return;const r=new a;throw r.appendText(`Expected ${e} to be `),n.describeTo(r),r.appendText(" instead "),n.describeMismatch(t,r),new Error(r.value)};const u=new Uint32Array(781250);function d(t,e){return t<e?e:t}function l(t,e){return t<e?t:e}function f(t,e,n,r,i,s){const o=n[r+0],a=n[r+1],c=n[r+2],h=n[r+3],u=n[r+4],f=n[r+5],g=i[s+0],p=i[s+1],y=i[s+2],_=i[s+3],w=i[s+4],m=i[s+5],v=l(o,g),x=l(a,p),A=l(c,y),b=d(h,_),E=d(u,w),$=d(f,m);t[e+0]=v,t[e+1]=x,t[e+2]=A,t[e+3]=b,t[e+4]=E,t[e+5]=$}function g(t,e,n,r,i,s,o,a){t[e]=n,t[e+1]=r,t[e+2]=i,t[e+3]=s,t[e+4]=o,t[e+5]=a}function p(t,e,n,r,i,s){const o=r-t,a=s-n;return(i-e)*(o+a)+a*o}function y(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function _(t,e,n){const r=t[n],i=t[n+1],s=t[n+2];g(t,e,r,i,s,r,i,s)}function w(t,e,n){const r=t[e],i=t[e+1],s=t[e+2];return function(t,e,n,r){const i=r[0],s=r[1],o=r[2],a=1023*(t-i)/(r[3]-i),c=1023*(e-s)/(r[4]-s),h=1023*(n-o)/(r[5]-o);return function(t,e,n){return y(t)|y(e)<<1|y(n)<<2}(Math.round(a),Math.round(c),Math.round(h))}(.5*(r+t[e+3]),.5*(i+t[e+4]),.5*(s+t[e+5]),n)}u.pointer=0;const m=u;class v{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}getLeafAddress(t){return 7*t+6*this.__node_count_binary}setLeafData(t,e,n,r,i,s,o,a){const c=this.getLeafAddress(t);g(this.__data_float32,c,n,r,i,s,o,a),this.__data_uint32[c+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let r;r=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(r,e,0),t+=p(e[0],e[1],e[2],e[3],e[4],e[5])}return t}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;const n=m.pointer;let r,i,s=n;m[s++]=0,m[s++]=this.__node_count_leaf-1;const o=this.__data_float32;for(;s>n;){s-=2;const n=m[s+1],a=m[s];r=a,i=n;const c=w(o,7*(a+n>>1)+e,t);for(;r<=i;){for(;w(o,7*r+e,t)<c;)r++;for(;w(o,7*i+e,t)>c;)i--;r<=i&&(r!==i&&this.__swap_leaves(r,i),r++,i--)}a<i&&(m[s++]=a,m[s++]=i),r<n&&(m[s++]=r,m[s++]=n)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),r=7*t+n,i=7*e+n;!function(t,e,n,r,i){for(let i=0;i<7;i++){const s=e+i,o=r+i,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,r,this.__data_float32,i)}build(){const t=this.__node_count_binary,e=6*t;let n,r,i,s,o=Math.floor(Math.log(t)/Math.log(2));i=Math.pow(2,o),r=6*(i-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<i;n++){const t=n<<1,i=t+1,s=e+7*t;i<a?f(c,r,c,s,c,e+7*i):t<a?h(c,s,c,r,6):_(this.__data_float32,r,r-6),r+=6}for(o--;o>=0;o--)for(i=1<<o,s=i-1,n=0;n<i;n++){const t=6*(1+(s<<1));f(c,6*s,c,t,c,t+6),s++}}}function x(t,e,n){let r=t;return r<e&&(r=e),r<n&&(r=n),r}function A(t,e,n){let r=t;return r>e&&(r=e),r>n&&(r=n),r}function b(t,e,n,r,i,s){const o=t.getLeafAddress(e);!function(t,e,n,r,i,s){const o=3*r,a=3*i,c=3*s,h=n[o],u=n[o+1],d=n[o+2],l=n[a],f=n[a+1],g=n[a+2],p=n[c],y=n[c+1],_=n[c+2];t[e]=A(h,l,p),t[e+1]=A(u,f,y),t[e+2]=A(d,g,_),t[e+3]=x(h,l,p),t[e+4]=x(u,f,y),t[e+5]=x(d,g,_)}(t.__data_float32,o,n,r,i,s),t.__data_uint32[o+6]=e}function E(t){return 1===t.faces.length}function $(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}var F,U="undefined"!=typeof Float32Array?Float32Array:Array;function S(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function z(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function C(){}function V(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function B(t,e,n=0,r=t.length){const i=n+r;for(let r=n;r<i;r++)if(t[r]===e)return t.splice(r,1),!0;return!1}function q(t,e){return t.v0===e||t.v1===e}function L(t,e,n){const r=t.v0,i=t.v1;return!(r!==e&&r!==n||i!==e&&i!==n)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),F=new U(3),U!=Float32Array&&(F[0]=0,F[1]=0,F[2]=0);let T=0;class M{index=T++;v0=null;v1=null;faces=[];lengthSqr=-1;get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new M;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsEdge(this)||(t(`Missing back-link from face[${i}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,r=n.length;for(let t=0;t<r;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){throw new Error('deprecated, use "query_edge_is_boundary" instead')}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,r=t.y,i=t.z,s=n-e.x,o=r-e.y,a=i-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,r=e.length;for(let i=0;i<r;i++){const r=e[i];r.removeEdge(t),-1===n.indexOf(r)&&(n.push(r),r.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){z(this.faces,t)}removeFace(t){B(this.faces,t)}getOtherVertex(t){return $(this,t)}containsVertex(t){return q(this,t)}containsBothVertices(t,e){return L(this,t,e)}containsSameVerticesAs(t){return L(this,t.v0,t.v1)}}function I(t,e,n){const r=t.length;for(let i=0;i<r;i++)t[i]===e&&(t[i]=n);return t}function k(t,e,n){return t*t+e*e+n*n}function N(t,e,n,r,i,s,o,a,c,h,u){const d=c-s,l=h-o,f=u-a,g=n-s,p=r-o,y=i-a,_=l*y-f*p,w=f*g-d*y,m=d*p-l*g,v=k(_,w,m);if(0===v)return t[e]=0,t[e+1]=1,void(t[e+2]=0);const x=1/Math.sqrt(v),A=_*x,b=w*x,E=m*x;t[e]=A,t[e+1]=b,t[e+2]=E}M.prototype.isTopoEdge=!0;let O=0;class j{index=O++;edges=[];faces=[];x=0;y=0;z=0;get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new j;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsVertex(this)||(t(`Missing back-link from face[${i}]`),e=!1);const i=this.edges,s=i.length;for(let n=0;n<s;n++)q(i[n],this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,r=this.z,i=t.x-e,s=t.y-n,o=t.z-r,Math.sqrt(i*i+s*s+o*o);var e,n,r,i,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return z(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){B(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return z(this.edges,t)}replaceEdge(t,e){const n=this.edges,r=n.indexOf(t);n[r]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return B(this.edges,t)}computeNeighbourVertices(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].getOtherVertex(this);t[e+n]=i,n++}return n}static from(t,e,n){const r=new j;return r.x=t,r.y=e,r.z=n,r}}j.prototype.isTopoVertex=!0;let D=0;class R{index=D++;vertices=[];edges=[];normal=[0,0,0];get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),S(this.normal,t.normal)}clone(){const t=new R;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,r=n.length;3!==r&&(t(`Expected number of vertices is 3, instead got ${r}`),e=!1);for(let i=0;i<r;i++)n[i].containsFace(this)||(t(`Missing back-link from vertex[${i}]`),e=!1);const i=this.edges,s=i.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)i[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){I(this.edges,t,e)}replaceVertex(t,e){I(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],r=t[2];return e===n||e===r||n===r}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,r=n.length;for(let t=0;t<r;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return z(this.edges,t)}removeEdge(t){B(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],r=t[2];!function(t,e,n,r){N(t,0,e[0],e[1],e[2],n[0],n[1],n[2],r[0],r[1],r[2])}(this.normal,e,n,r)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].faces,o=i.length;for(let r=0;r<o;r++){const s=i[r];s!==this&&(t[e+n]=s,n++)}}return n}static fromPoints(t,e,n,r,i,s,o,a,c){const h=j.from(t,e,n),u=j.from(r,i,s),d=j.from(o,a,c),l=new M,f=new M,g=new M;l.v0=h,l.v1=u,f.v0=u,f.v1=d,g.v0=d,g.v1=h;const p=new R;return p.edges.push(l,f,g),p.vertices.push(h,u,d),h.faces.push(p),u.faces.push(p),d.faces.push(p),l.faces.push(p),f.faces.push(p),g.faces.push(p),h.edges.push(l,g),u.edges.push(l,f),d.edges.push(f,g),p}}R.prototype.isTopoFace=!0;class J{vertices=[];__edges=new Set;__faces=new Set;get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t=C){let e=!0,n="",r=0;function i(i){t(`${n}[${r}]: ${i}`),e=!1}n="Edge",r=0;const s=this.getEdges();for(let t of s){t.validate(i),this.containsVertex(t.v0)||i("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||i("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||i(`Link to off-mesh face[${t}]`)}r++}const o=this.getFaces();n="Face",r=0;for(let t of o){t.validate(i);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||i(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||i(`Link to off-mesh vertex[${t}]`)}r++}const a=this.vertices,c=a.length;n="Vertex";for(let t=0;t<c;t++){r=t;const e=a[t];e.validate(i);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||i(`Link to off-mesh edge[${t}]`)}const o=e.faces,c=o.length;for(let t=0;t<c;t++){const e=o[t];this.containsFace(e)||i(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new J;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let r=0;r<n;r++){const n=e[r];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new R;S(n.normal,t.normal);const r=t.vertices;for(let t=0;t<3;t++){const i=r[t];let s=e.get(i.index);void 0===s&&(s=new j,s.index=i.index,s.x=i.x,s.y=i.y,s.z=i.z,e.set(i.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n),this.patchFaceEdges(n)}patchFaceEdges(t){const e=t.vertices,n=e[0],r=e[1],i=e[2],s=this.ensureEdge(n,r),o=this.ensureEdge(r,i),a=this.ensureEdge(i,n);s.addUniqueFace(t),o.addUniqueFace(t),a.addUniqueFace(t),t.addUniqueEdge(s),t.addUniqueEdge(o),t.addUniqueEdge(a)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){z(this.vertices,t)}removeVertex(t){throw new Error("deprecated, use tm_kill_only_vert instead")}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){throw new Error("deprecated, use tm_kill_only_edge instead")}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const r=t.vertices,i=r.length;for(let t=0;t<i;t++){const e=r[t];this.addUniqueVertex(e)}}removeFace(t){throw new Error("deprecated, use tm_kill_only_face instead")}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,r=n.length;for(let i=0;i<r;i++){const r=n[i];if($(r,t)===e)return r}const i=new M;return i.v0=t,i.v1=e,t.edges.push(i),e.edges.push(i),this.__edges.add(i),i}mergeEdges(){const t=this.getEdges();for(let n of t){const r=n.v0,i=n.v1;for(let s of t){if(n===s)continue;const t=s.v0,o=s.v1;if(r===t){if(i!==o)continue}else{if(r!==o)continue;if(i!==t)continue}e=s,this.__edges.delete(e),n.merge(s)}}var e}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}setVerticesFromArray(t){const e=t.length/3,n=this.vertices;for(let r=0;r<e;r++){const e=3*r,i=new j;i.index=r,i.x=t[e],i.y=t[e+1],i.z=t[e+2],n[r]=i}}setFacesFromIndexArray(t){const e=t.length,n=this.vertices,r=e/3;for(let e=0;e<r;e++){const r=3*e,i=t[r],s=t[r+1],o=t[r+2];this.createTriangle(e,n[i],n[s],n[o])}}setFacedUnindexed(){const t=this.vertices,e=t.length/3;for(let n=0;n<e;n++){const e=3*n;this.createTriangle(n,t[e],t[e+1],t[e+2])}}build(t,e){this.setVerticesFromArray(t),null==e?this.setFacedUnindexed():this.setFacesFromIndexArray(e)}createTriangle(t,e,n,r){const i=new R;i.index=t;const s=this.ensureEdge(e,n),o=this.ensureEdge(n,r),a=this.ensureEdge(r,e);return s.faces.push(i),o.faces.push(i),a.faces.push(i),i.vertices.push(e,n,r),i.edges.push(s,o,a),e.faces.push(i),n.faces.push(i),r.faces.push(i),this.__faces.add(i),i}toString(){return`TopoMesh{ vertices: ${V(this.vertices.length)}, edges: ${V(this.getEdges().size)}, faces: ${V(this.getFaces().size)} }`}}J.prototype.isTopoMesh=!0;const P=[],H=[],W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)P[t]=W[t],H[W.charCodeAt(t)]=t;function G(t,e,n){const r=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);r.push(P[(i=e)>>18&63]+P[i>>12&63]+P[i>>6&63]+P[63&i])}var i;return r.join("")}H["-".charCodeAt(0)]=62,H["_".charCodeAt(0)]=63;const Y=16383;class K{static encode(t){return function(t){const e=t.length,n=e%3,r=[],i=e-n;for(let e=0;e<i;e+=Y){const n=G(t,e,e+Y>i?i:e+Y);r.push(n)}if(1===n){const n=t[e-1];r.push(P[n>>2]+P[n<<4&63]+"==")}else if(2===n){const n=(t[e-2]<<8)+t[e-1];r.push(P[n>>10]+P[n>>4&63]+P[n<<2&63]+"=")}return r.join("")}(new Uint8Array(t))}static decode(t){return function(t){let e;const n=function(t){const e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");let n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=n[0],i=n[1],s=new Uint8Array(function(t,e){return 3*(t+e)/4-e}(r,i));let o=0;const a=i>0?r-4:r;let c=0;for(;c<a;c+=4){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2),a=t.charCodeAt(c+3);e=H[n]<<18|H[r]<<12|H[i]<<6|H[a],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=255&e}if(2===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1);e=H[n]<<2|H[r]>>4,s[o++]=255&e}if(1===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2);e=H[n]<<10|H[r]<<4|H[i]>>2,s[o++]=e>>8&255,s[o++]=255&e}return s}(t).buffer}}const Q="uint8",X="uint16",Z="uint32",tt="int8",et="int16",nt="int32",rt="float32",it="float64",st={[Q]:Uint8Array,[X]:Uint16Array,[Z]:Uint32Array,[tt]:Int8Array,[et]:Int16Array,[nt]:Int32Array,float16:Uint16Array,[rt]:Float32Array,[it]:Float64Array};function ot(t){const e=Object.getPrototypeOf(t).constructor;switch(e){case Uint8Array:case Uint8ClampedArray:return Q;case Uint16Array:return X;case Uint32Array:return Z;case Int8Array:return tt;case Int16Array:return et;case Int32Array:return nt;case Float32Array:return rt;case Float64Array:return it;default:throw new Error(`unsupported constructor type ${e.name}`)}}function at(t,e,n){return t<e?e:t>n?n:t}function ct(t,e,n){return(e-t)*n+t}function ht(t,e,n,r,i){return.5*(r-e+(2*e-5*n+4*r-i+(3*(n-r)+i-e)*t)*t)*t+n}const ut=4294967295;function dt(t){const e=t>>0;return ut-((t-e)*ut>>>0)^e}class lt{constructor(t=[],e=1,n=0,r=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(r)||n<0)throw new Error(`height must be a non-negative integer, instead was ${r}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*r*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*r*e}`);this.width=n,this.height=r,this.itemSize=e,this.data=t,this.version=0}sampleCatmullRomUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelCatmullRomUV(t,e,i)}sampleChannelCatmullRomUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelCatmullRom(r,i,n)}sampleChannelCatmullRom(t,e,n){const r=Math.floor(t),i=Math.floor(e),s=t-r,o=e-i,a=s*(s*(1-.5*s)-.5),c=o*(o*(1-.5*o)-.5),h=s*(.5+s*(2-1.5*s)),u=o*(.5+o*(2-1.5*o)),d=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+h,g=1+o*o*(1.5*o-2.5)+u,p=r-1,y=i-1,_=r+2,w=i+2,m=r+h/f,v=i+u/g;let x=0;return x+=this.sampleChannelBilinear(p,y,n)*a*c,x+=this.sampleChannelBilinear(m,y,n)*f*c,x+=this.sampleChannelBilinear(_,y,n)*d*c,x+=this.sampleChannelBilinear(p,v,n)*a*g,x+=this.sampleChannelBilinear(m,v,n)*f*g,x+=this.sampleChannelBilinear(_,v,n)*d*g,x+=this.sampleChannelBilinear(p,w,n)*a*l,x+=this.sampleChannelBilinear(m,w,n)*f*l,x+=this.sampleChannelBilinear(_,w,n)*d*l,x}sampleBicubicUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelBicubicUV(t,e,i)}sampleBicubic(t,e,n,r){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const r=t*this.width,i=e*this.height;return this.sampleChannelBicubic(r-.5,i-.5,n)}sampleChannelBicubic(t,e,n){const r=this.itemSize,i=this.width,s=this.height,o=this.data,a=i*r,c=i-1,h=s-1,u=at(t,0,c),f=at(e,0,h),g=0|u,p=0|f,y=u-g,_=f-p,w=d(0,g-1),m=d(0,p-1),v=l(c,g+1),x=l(h,p+1),A=l(c,v+1),b=m*a+n,E=p*a+n,$=x*a+n,F=l(h,x+1)*a+n,U=w*r,S=g*r,z=v*r,C=A*r,V=o[b+U],B=o[b+S],q=o[b+z],L=o[b+C],T=o[E+U],M=o[E+S],I=o[E+z],k=o[E+C],N=o[$+U],O=o[$+S],j=o[$+z],D=o[$+C],R=o[F+U],J=o[F+S],P=o[F+z],H=o[F+C],W=ht(y,V,B,q,L),G=ht(y,T,M,I,k),Y=ht(y,N,O,j,D),K=ht(y,R,J,P,H);return ht(_,W,G,Y,K)}sampleBilinearUV(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelBilinear(r,i,n)}sampleChannelBilinear(t,e,n){const r=this.itemSize,i=this.width,s=i*r,o=this.height-1,a=at(t,0,i-1),c=at(e,0,o),h=a>>>0,u=c>>>0,d=u*s,l=h*r+n,f=d+l;let g,p;g=a===h?h:h+1,p=c===u?u:u+1;const y=this.data,_=y[f];if(h===g&&u===p)return _;const w=a-h,m=c-u,v=g*r+n,x=p*s,A=x+l,b=x+v,E=y[d+v],$=y[A],F=y[b],U=ct(_,E,w),S=ct($,F,w);return ct(U,S,m)}sampleNearestUV(t,e,n){const r=this.width,i=this.height,s=Math.round(t*r-.5),o=Math.round(e*i-.5);this.read(at(s,0,r-1),at(o,0,i-1),n)}readChannel(t,e,n){const r=(e*this.width+t)*this.itemSize+n;return this.data[r]}read(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)n[t]=this.data[s+t]}write(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)this.data[s+t]=n[t];this.version++}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,r=t%n,i=t/n|0;e.set(r,i)}copy(t,e,n,r,i,s,o){const a=Math.min(s,t.width-e,this.width-r),c=Math.min(o,t.height-n,this.height-i),h=this.itemSize,u=t.itemSize,d=Math.min(h,u),l=h*this.width,f=u*t.width,g=t.data,p=this.data;let y,_,w;for(_=0;_<c;_++){const t=(_+i)*l,s=(_+n)*f;for(y=0;y<a;y++){const n=t+(y+r)*h,i=s+(y+e)*u;for(w=0;w<d;w++)p[n+w]=g[i+w]}}this.version++}zeroFill(t,e,n,r){const i=at(t,0,this.width),s=at(e,0,this.height),o=at(t+n,0,this.width),a=at(e+r,0,this.height),c=this.data,h=this.itemSize,u=h*this.width,d=i*h,l=o*h;let f;for(f=s;f<a;f++){const t=f*u;c.fill(0,t+d,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,r=this.data,i=r.length;for(let s=t;s<i;s+=n)r[s]=e;this.version++}fill(t,e,n,r,i){const s=this.width,o=this.height,a=at(t,0,s),c=at(e,0,o),h=at(t+n,0,s),u=at(e+r,0,o),d=this.data,l=this.itemSize,f=l*s;let g,p,y;for(g=c;g<u;g++){const t=g*f;for(p=a;p<h;p++){const e=t+p*l;for(y=0;y<l;y++)d[e+y]=i[y]}}this.version++}writeChannel(t,e,n,r){const i=(e*this.width+t)*this.itemSize+n;this.data[i]=r,this.version++}traverseCircle(t,e,n,r){let i,s;const o=0|t,a=0|e,c=n*n,h=Math.ceil(n);for(s=-h;s<=h;s++){const t=s*s;for(i=-h;i<=h;i++)i*i+t<=c&&r(o+i,a+s,this)}}resize(t,e,n=!0){const r=this.width,i=this.height;if(r===t&&i===e)return;const s=this.itemSize,o=t*e*s,a=this.data,c=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===r)c.set(a.subarray(0,Math.min(a.length,o)));else{const n=l(e,i),o=l(t,r);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const i=(e*t+n)*s,o=(e*r+n)*s;for(let t=0;t<s;t++)c[i+t]=a[o+t]}}this.width=t,this.height=e,this.data=c,this.version++}computeByteSize(){let t;const e=this.data;return t=Array.isArray(e)?8*e.length:e.byteLength,t+280}equals(e){return this===e||this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const r=e.length;if(r!==n.length)return!1;const i=e.constructor;if(i!==n.constructor)return!1;if(0===r)return!0;if(r<128)return t(e,n);const s=e.byteLength;if(s!==n.byteLength)return!1;const o=e.buffer,a=n.buffer,c=e.byteOffset,h=n.byteOffset;if(o===a&&c===h)return!0;let u=e,d=n;const l=i.BYTES_PER_ELEMENT,f=function(t,e,n){const r=t|e|n;return 0==(3&r)?4:0==(1&r)?2:1}(c,h,s);return l<4&&4===f?(u=new Uint32Array(o,c,s>>>2),d=new Uint32Array(a,h,s>>>2)):l<2&&2===f&&(u=new Uint16Array(o,c,s>>>1),d=new Uint16Array(a,h,s>>>1)),t(u,d)}(this.data,e.data)}hash(){const t=this.itemSize,n=this.width,r=this.height,i=this.data;let s=((65535&n)<<16|65535&r)^t;const o=n*r*t;if(e(i))s^=function(t,e,n){const r=e|n;return 0==(3&r)?function(t,e,n){let r=n;for(let e=0;e<n;++e)r=(r<<5)-r+t[e];return r}(new Uint32Array(t,e,n>>>2),0,n>>>2):0==(2&r)?function(t,e,n){let r=n,i=0;for(0!=(1&n)&&(r=(r<<5)-r+t[i++]);i<n;i+=2)r=(r<<5)-r+(t[i]<<16|t[i+1]);return r}(new Uint16Array(t,e,n>>>1),0,n>>>1):function(t,e,n){let r=n,i=0;const s=3&n;for(;i<0+s;i++)r=(r<<5)-r+t[i];for(;i<n;i+=4)r=(r<<5)-r+(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24);return r}(new Uint8Array(t,e,n),0,n)}(i.buffer,i.byteOffset,i.byteLength);else for(let t=0;t<o;++t)s=(s<<5)-s+dt(i[t]);return s}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new lt(t,this.itemSize,this.width,this.height)}toJSON(){const t=K.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:ot(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:r,data:i}){const s=function(t){const e=st[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(r);if("string"==typeof i){const t=K.decode(i);this.data=new s(t)}else{if(!Array.isArray(i))throw new Error("Unsupported data format");this.data=new s(i)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const r=new Uint8ClampedArray(e*n*t);return new lt(r,t,e,n)}static uint8(t,e,n){const r=new Uint8Array(e*n*t);return new lt(r,t,e,n)}static uint16(t,e,n){const r=new Uint16Array(e*n*t);return new lt(r,t,e,n)}static uint32(t,e,n){const r=new Uint32Array(e*n*t);return new lt(r,t,e,n)}static int8(t,e,n){const r=new Int8Array(e*n*t);return new lt(r,t,e,n)}static int16(t,e,n){const r=new Int16Array(e*n*t);return new lt(r,t,e,n)}static int32(t,e,n){const r=new Int32Array(e*n*t);return new lt(r,t,e,n)}static float32(t,e,n){const r=new Float32Array(e*n*t);return new lt(r,t,e,n)}static float64(t,e,n){const r=new Float64Array(e*n*t);return new lt(r,t,e,n)}}function ft(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2];t[e]+=i,t[e+1]+=s,t[e+2]+=o}function gt(t,e,n,r,i,s){const o=3*n,a=3*r,c=3*i;N(t,e,s[o],s[o+1],s[o+2],s[a],s[a+1],s[a+2],s[c],s[c+1],s[c+2])}function pt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2],a=k(i,s,o),c=0!==a?1/Math.sqrt(a):1;t[e]=i*c,t[e+1]=s*c,t[e+2]=o*c}lt.prototype.isSampler2D=!0,lt.typeName="Sampler2D";const yt=new Float64Array(3),_t={build:function(t,e,n,r,i,s){const o=n.x*s,a=n.y*s,c=o-1,h=a-1;let u=0,d=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),p=new Float32Array(2*l);let y,_;const w=n.y/i.y/h,m=n.x/i.x/c,v=e.y/i.y,x=e.x/i.x,A=i.x*r.x,b=i.y*r.y;let E,$,F;for(y=0;y<a;y++){const e=y*w+v;for(F=e*b,_=0;_<o;_++){const n=_*m+x;E=n*A,$=t.sampleChannelBicubicUV(n,e,0),f[u]=E,f[u+1]=$,f[u+2]=F,p[d]=n,p[d+1]=e,u+=3,d+=2}}u=0;const U=new(function(t){if(t<=256)return Uint8Array;if(t<=65536)return Uint16Array;if(t<=4294967295)return Uint32Array;throw new Error(`Unsupported size ${t}`)}(f.length/3))(c*h*6);for(y=0;y<h;y++)for(_=0;_<c;_++){const t=_+o*y,e=_+o*(y+1),n=_+1+o*(y+1),r=_+1+o*y;U[u]=t,U[u+1]=e,U[u+2]=r,U[u+3]=e,U[u+4]=n,U[u+5]=r,u+=6}return function(t,e,n){const r=n.length;for(let i=0;i<r;i+=3){const r=n[i],s=n[i+1],o=n[i+2];gt(yt,0,r,s,o,t),ft(e,3*r,yt,0),ft(e,3*s,yt,0),ft(e,3*o,yt,0)}!function(t,e=0,n=t.length-e){const r=e+n;for(let n=e;n<r;n+=3)pt(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:p}}};self.Lib={build_bvh(t,e){const n=new v;return function(t,e,n){const r=n.length/3;t.setLeafCount(r),t.initialize_structure();for(let i=0;i<r;i++){const r=3*i;b(t,i,e,n[r],n[r+1],n[r+2])}t.build()}(n,t,e),n},Sampler2D:lt,BufferedGeometryArraysBuilder:_t,tensionOptimizeUV:function(t,e,n,r=3){const i=new J;i.build(t,n),i.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<r;t++)t:for(let t=0;t<s;t++){const n=i.vertices[t],r=n.edges,s=r.length;if(0===s)continue;let o=0,a=0,c=0;for(let t=0;t<s;t++){const i=r[t];if(E(i))continue t;const s=2*$(i,n).index,h=e[s],u=e[s+1],d=1/i.lengthSqr;o+=h*d,a+=u*d,c+=d}const h=o/c,u=a/c,d=2*n.index;e[d]=h,e[d+1]=u}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s>e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s<e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}}};
|
|
1
|
+
function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function e(t){if("object"!=typeof t)return!1;if(null===t)return!1;const e=t.constructor;return e===Uint8Array||e===Uint16Array||e===Uint32Array||e===Int8Array||e===Int16Array||e===Int32Array||e===Float32Array||e===Float64Array||e===BigUint64Array||e===BigInt64Array}class n{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,r){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,r){throw new Error("Not Implemented")}}class r{describeTo(t){throw new Error("Not Implemented")}}class i extends r{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class s{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class o extends n{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,r){return this.appendList(t,e,n,new s(r)),this}appendList(t,e,n,r){let i=!1;this.appendText(t);const s=r[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())i&&this.appendText(e),this.appendDescriptionOf(t.value),i=!0;return this.appendText(n),this}}class a extends o{value="";appendText(t){return this.value+=t,this}}function c(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n="value"){if(-1===e.indexOf(t))throw new Error(`${n} must be one of [${e.join(", ")}], instead was '${t}'`)}const u=["string","boolean","number","object","undefined","function","symbol"];function d(t,e,n,r,i){let s,o,a;for(a=0;a<i;a++)s=e+a,o=r+a,n[o]=t[s]}c.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},c.notEqual=function(t,e,n){c(t!==e,n)},c.notOk=function(t,e){c(!t,e)},c.equal=function(t,e,n){if(t!==e){const r=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${r}`:r)}},c.logicalyEqual=function(t,e,n){},c.ok=c,c.greaterThan=function(t,e,n){if(!(t>e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} > ${e}.`,new Error(r)}},c.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} >= ${e}.`,new Error(r)}},c.lessThan=function(t,e,n){if(!(t<e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} < ${e}.`,new Error(r)}},c.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} <= ${e}.`,new Error(r)}},c.typeOf=function(t,e,n="value"){h(typeof t,u);const r=typeof t;if(r!==e)throw new Error(`expected ${n} to be ${e}, instead was '${r}'(=${t})`)},c.arrayHas=function(t,e,n="Array does not contain the item"){},c.arrayHasNo=function(t,e,n="Array contains the item"){},c.arrayEqual=function(e,n,r="Arrays are not equal"){if(!t(e,n))throw new Error(r)},c.isOneOf=h,c.isInstanceOf=function(t,e,n="value",r=e.name){},c.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},c.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},c.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},c.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},c.isObject=function(t,e="value"){const n=typeof t;if("object"!==n)throw new Error(`expected ${e} to be an object, instead was '${n}'(=${t})`)},c.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},c.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},c.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},c.isArrayLike=function(t,n="value"){if(!function(t){if(Array.isArray(t))return!0;if("object"!=typeof t)return!1;if(null===t)return!1;if(e(t))return!0;const n=t.length;return!("number"!=typeof n&&!Number.isInteger(n)||n<0)}(t))throw new Error(`expected ${n} to be an array-like structure, instead was something else (typeof ='${typeof t}')`)},c.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},c.undefined=function(t,e="value"){if(void 0!==t)throw new Error(`${e} is not undefined`)},c.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},c.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},c.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},c.isFinite=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},c.isFiniteNumber=c.isFinite,c.that=function(t,e,n){if(n.matches(t))return;const r=new a;throw r.appendText(`Expected ${e} to be `),n.describeTo(r),r.appendText(" instead "),n.describeMismatch(t,r),new Error(r.value)};const l=new Uint32Array(781250);function f(t,e){return t<e?e:t}function g(t,e){return t<e?t:e}function p(t,e,n,r,i,s){const o=n[r+0],a=n[r+1],c=n[r+2],h=n[r+3],u=n[r+4],d=n[r+5],l=i[s+0],p=i[s+1],y=i[s+2],w=i[s+3],_=i[s+4],m=i[s+5],v=g(o,l),x=g(a,p),A=g(c,y),b=f(h,w),E=f(u,_),$=f(d,m);t[e+0]=v,t[e+1]=x,t[e+2]=A,t[e+3]=b,t[e+4]=E,t[e+5]=$}function y(t,e,n,r,i,s,o,a){t[e]=n,t[e+1]=r,t[e+2]=i,t[e+3]=s,t[e+4]=o,t[e+5]=a}function w(t,e,n,r,i,s){const o=r-t,a=s-n;return(i-e)*(o+a)+a*o}function _(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function m(t,e,n){const r=t[n],i=t[n+1],s=t[n+2];y(t,e,r,i,s,r,i,s)}function v(t,e,n){const r=t[e],i=t[e+1],s=t[e+2];return function(t,e,n,r){const i=r[0],s=r[1],o=r[2],a=1023*(t-i)/(r[3]-i),c=1023*(e-s)/(r[4]-s),h=1023*(n-o)/(r[5]-o);return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(a),Math.round(c),Math.round(h))}(.5*(r+t[e+3]),.5*(i+t[e+4]),.5*(s+t[e+5]),n)}l.pointer=0;const x=l;class A{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}getLeafAddress(t){return 7*t+6*this.__node_count_binary}setLeafData(t,e,n,r,i,s,o,a){const c=this.getLeafAddress(t);y(this.__data_float32,c,n,r,i,s,o,a),this.__data_uint32[c+6]=e}readBounds(t,e,n){d(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let r;r=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(r,e,0),t+=w(e[0],e[1],e[2],e[3],e[4],e[5])}return t}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;const n=x.pointer;let r,i,s=n;x[s++]=0,x[s++]=this.__node_count_leaf-1;const o=this.__data_float32;for(;s>n;){s-=2;const n=x[s+1],a=x[s];r=a,i=n;const c=v(o,7*(a+n>>1)+e,t);for(;r<=i;){for(;v(o,7*r+e,t)<c;)r++;for(;v(o,7*i+e,t)>c;)i--;r<=i&&(r!==i&&this.__swap_leaves(r,i),r++,i--)}a<i&&(x[s++]=a,x[s++]=i),r<n&&(x[s++]=r,x[s++]=n)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),r=7*t+n,i=7*e+n;!function(t,e,n,r,i){for(let i=0;i<7;i++){const s=e+i,o=r+i,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,r,this.__data_float32,i)}build(){const t=this.__node_count_binary,e=6*t;let n,r,i,s,o=Math.floor(Math.log(t)/Math.log(2));i=Math.pow(2,o),r=6*(i-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<i;n++){const t=n<<1,i=t+1,s=e+7*t;i<a?p(c,r,c,s,c,e+7*i):t<a?d(c,s,c,r,6):m(this.__data_float32,r,r-6),r+=6}for(o--;o>=0;o--)for(i=1<<o,s=i-1,n=0;n<i;n++){const t=6*(1+(s<<1));p(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n){let r=t;return r<e&&(r=e),r<n&&(r=n),r}function E(t,e,n){let r=t;return r>e&&(r=e),r>n&&(r=n),r}function $(t,e,n,r,i,s){const o=t.getLeafAddress(e);!function(t,e,n,r,i,s){const o=3*r,a=3*i,c=3*s,h=n[o],u=n[o+1],d=n[o+2],l=n[a],f=n[a+1],g=n[a+2],p=n[c],y=n[c+1],w=n[c+2];t[e]=E(h,l,p),t[e+1]=E(u,f,y),t[e+2]=E(d,g,w),t[e+3]=b(h,l,p),t[e+4]=b(u,f,y),t[e+5]=b(d,g,w)}(t.__data_float32,o,n,r,i,s),t.__data_uint32[o+6]=e}function F(t){return 1===t.faces.length}function U(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}var S,z="undefined"!=typeof Float32Array?Float32Array:Array;function C(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function V(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function B(){}function q(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function L(t,e,n=0,r=t.length){const i=n+r;for(let r=n;r<i;r++)if(t[r]===e)return t.splice(r,1),!0;return!1}function T(t,e){return t.v0===e||t.v1===e}function M(t,e,n){const r=t.v0,i=t.v1;return!(r!==e&&r!==n||i!==e&&i!==n)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),S=new z(3),z!=Float32Array&&(S[0]=0,S[1]=0,S[2]=0);let I=0;class k{index=I++;v0=null;v1=null;faces=[];lengthSqr=-1;get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new k;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsEdge(this)||(t(`Missing back-link from face[${i}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,r=n.length;for(let t=0;t<r;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){throw new Error('deprecated, use "query_edge_is_boundary" instead')}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,r=t.y,i=t.z,s=n-e.x,o=r-e.y,a=i-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,r=e.length;for(let i=0;i<r;i++){const r=e[i];r.removeEdge(t),-1===n.indexOf(r)&&(n.push(r),r.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){V(this.faces,t)}removeFace(t){L(this.faces,t)}getOtherVertex(t){return U(this,t)}containsVertex(t){return T(this,t)}containsBothVertices(t,e){return M(this,t,e)}containsSameVerticesAs(t){return M(this,t.v0,t.v1)}}function N(t,e,n){const r=t.length;for(let i=0;i<r;i++)t[i]===e&&(t[i]=n);return t}function O(t,e,n){return t*t+e*e+n*n}function j(t,e,n,r,i,s,o,a,c,h,u){const d=c-s,l=h-o,f=u-a,g=n-s,p=r-o,y=i-a,w=l*y-f*p,_=f*g-d*y,m=d*p-l*g,v=O(w,_,m);if(0===v)return t[e]=0,t[e+1]=1,void(t[e+2]=0);const x=1/Math.sqrt(v),A=w*x,b=_*x,E=m*x;t[e]=A,t[e+1]=b,t[e+2]=E}k.prototype.isTopoEdge=!0;let D=0;class R{index=D++;edges=[];faces=[];x=0;y=0;z=0;get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new R;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsVertex(this)||(t(`Missing back-link from face[${i}]`),e=!1);const i=this.edges,s=i.length;for(let n=0;n<s;n++)T(i[n],this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,r=this.z,i=t.x-e,s=t.y-n,o=t.z-r,Math.sqrt(i*i+s*s+o*o);var e,n,r,i,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return V(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){L(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return V(this.edges,t)}replaceEdge(t,e){const n=this.edges,r=n.indexOf(t);n[r]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return L(this.edges,t)}computeNeighbourVertices(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].getOtherVertex(this);t[e+n]=i,n++}return n}static from(t,e,n){const r=new R;return r.x=t,r.y=e,r.z=n,r}}R.prototype.isTopoVertex=!0;let J=0;class P{index=J++;vertices=[];edges=[];normal=[0,0,0];get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),C(this.normal,t.normal)}clone(){const t=new P;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,r=n.length;3!==r&&(t(`Expected number of vertices is 3, instead got ${r}`),e=!1);for(let i=0;i<r;i++)n[i].containsFace(this)||(t(`Missing back-link from vertex[${i}]`),e=!1);const i=this.edges,s=i.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)i[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){N(this.edges,t,e)}replaceVertex(t,e){N(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],r=t[2];return e===n||e===r||n===r}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,r=n.length;for(let t=0;t<r;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return V(this.edges,t)}removeEdge(t){L(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],r=t[2];!function(t,e,n,r){j(t,0,e[0],e[1],e[2],n[0],n[1],n[2],r[0],r[1],r[2])}(this.normal,e,n,r)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].faces,o=i.length;for(let r=0;r<o;r++){const s=i[r];s!==this&&(t[e+n]=s,n++)}}return n}static fromPoints(t,e,n,r,i,s,o,a,c){const h=R.from(t,e,n),u=R.from(r,i,s),d=R.from(o,a,c),l=new k,f=new k,g=new k;l.v0=h,l.v1=u,f.v0=u,f.v1=d,g.v0=d,g.v1=h;const p=new P;return p.edges.push(l,f,g),p.vertices.push(h,u,d),h.faces.push(p),u.faces.push(p),d.faces.push(p),l.faces.push(p),f.faces.push(p),g.faces.push(p),h.edges.push(l,g),u.edges.push(l,f),d.edges.push(f,g),p}}P.prototype.isTopoFace=!0;class H{vertices=[];__edges=new Set;__faces=new Set;get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t=B){let e=!0,n="",r=0;function i(i){t(`${n}[${r}]: ${i}`),e=!1}n="Edge",r=0;const s=this.getEdges();for(let t of s){t.validate(i),this.containsVertex(t.v0)||i("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||i("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||i(`Link to off-mesh face[${t}]`)}r++}const o=this.getFaces();n="Face",r=0;for(let t of o){t.validate(i);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||i(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||i(`Link to off-mesh vertex[${t}]`)}r++}const a=this.vertices,c=a.length;n="Vertex";for(let t=0;t<c;t++){r=t;const e=a[t];e.validate(i);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||i(`Link to off-mesh edge[${t}]`)}const o=e.faces,c=o.length;for(let t=0;t<c;t++){const e=o[t];this.containsFace(e)||i(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new H;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let r=0;r<n;r++){const n=e[r];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new P;C(n.normal,t.normal);const r=t.vertices;for(let t=0;t<3;t++){const i=r[t];let s=e.get(i.index);void 0===s&&(s=new R,s.index=i.index,s.x=i.x,s.y=i.y,s.z=i.z,e.set(i.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n),this.patchFaceEdges(n)}patchFaceEdges(t){const e=t.vertices,n=e[0],r=e[1],i=e[2],s=this.ensureEdge(n,r),o=this.ensureEdge(r,i),a=this.ensureEdge(i,n);s.addUniqueFace(t),o.addUniqueFace(t),a.addUniqueFace(t),t.addUniqueEdge(s),t.addUniqueEdge(o),t.addUniqueEdge(a)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){V(this.vertices,t)}removeVertex(t){throw new Error("deprecated, use tm_kill_only_vert instead")}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){throw new Error("deprecated, use tm_kill_only_edge instead")}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const r=t.vertices,i=r.length;for(let t=0;t<i;t++){const e=r[t];this.addUniqueVertex(e)}}removeFace(t){throw new Error("deprecated, use tm_kill_only_face instead")}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,r=n.length;for(let i=0;i<r;i++){const r=n[i];if(U(r,t)===e)return r}const i=new k;return i.v0=t,i.v1=e,t.edges.push(i),e.edges.push(i),this.__edges.add(i),i}mergeEdges(){const t=this.getEdges();for(let n of t){const r=n.v0,i=n.v1;for(let s of t){if(n===s)continue;const t=s.v0,o=s.v1;if(r===t){if(i!==o)continue}else{if(r!==o)continue;if(i!==t)continue}e=s,this.__edges.delete(e),n.merge(s)}}var e}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}setVerticesFromArray(t){const e=t.length/3,n=this.vertices;for(let r=0;r<e;r++){const e=3*r,i=new R;i.index=r,i.x=t[e],i.y=t[e+1],i.z=t[e+2],n[r]=i}}setFacesFromIndexArray(t){const e=t.length,n=this.vertices,r=e/3;for(let e=0;e<r;e++){const r=3*e,i=t[r],s=t[r+1],o=t[r+2];this.createTriangle(e,n[i],n[s],n[o])}}setFacedUnindexed(){const t=this.vertices,e=t.length/3;for(let n=0;n<e;n++){const e=3*n;this.createTriangle(n,t[e],t[e+1],t[e+2])}}build(t,e){this.setVerticesFromArray(t),null==e?this.setFacedUnindexed():this.setFacesFromIndexArray(e)}createTriangle(t,e,n,r){const i=new P;i.index=t;const s=this.ensureEdge(e,n),o=this.ensureEdge(n,r),a=this.ensureEdge(r,e);return s.faces.push(i),o.faces.push(i),a.faces.push(i),i.vertices.push(e,n,r),i.edges.push(s,o,a),e.faces.push(i),n.faces.push(i),r.faces.push(i),this.__faces.add(i),i}toString(){return`TopoMesh{ vertices: ${q(this.vertices.length)}, edges: ${q(this.getEdges().size)}, faces: ${q(this.getFaces().size)} }`}}H.prototype.isTopoMesh=!0;const W=[],G=[],Y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)W[t]=Y[t],G[Y.charCodeAt(t)]=t;function K(t,e,n){const r=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);r.push(W[(i=e)>>18&63]+W[i>>12&63]+W[i>>6&63]+W[63&i])}var i;return r.join("")}G["-".charCodeAt(0)]=62,G["_".charCodeAt(0)]=63;const Q=16383;class X{static encode(t){return function(t){const e=t.length,n=e%3,r=[],i=e-n;for(let e=0;e<i;e+=Q){const n=K(t,e,e+Q>i?i:e+Q);r.push(n)}if(1===n){const n=t[e-1];r.push(W[n>>2]+W[n<<4&63]+"==")}else if(2===n){const n=(t[e-2]<<8)+t[e-1];r.push(W[n>>10]+W[n>>4&63]+W[n<<2&63]+"=")}return r.join("")}(new Uint8Array(t))}static decode(t){return function(t){let e;const n=function(t){const e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");let n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=n[0],i=n[1],s=new Uint8Array(function(t,e){return 3*(t+e)/4-e}(r,i));let o=0;const a=i>0?r-4:r;let c=0;for(;c<a;c+=4){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2),a=t.charCodeAt(c+3);e=G[n]<<18|G[r]<<12|G[i]<<6|G[a],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=255&e}if(2===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1);e=G[n]<<2|G[r]>>4,s[o++]=255&e}if(1===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2);e=G[n]<<10|G[r]<<4|G[i]>>2,s[o++]=e>>8&255,s[o++]=255&e}return s}(t).buffer}}const Z="uint8",tt="uint16",et="uint32",nt="int8",rt="int16",it="int32",st="float32",ot="float64",at={[Z]:Uint8Array,[tt]:Uint16Array,[et]:Uint32Array,[nt]:Int8Array,[rt]:Int16Array,[it]:Int32Array,float16:Uint16Array,[st]:Float32Array,[ot]:Float64Array};function ct(t){const e=Object.getPrototypeOf(t).constructor;switch(e){case Uint8Array:case Uint8ClampedArray:return Z;case Uint16Array:return tt;case Uint32Array:return et;case Int8Array:return nt;case Int16Array:return rt;case Int32Array:return it;case Float32Array:return st;case Float64Array:return ot;default:throw new Error(`unsupported constructor type ${e.name}`)}}function ht(t,e,n){return t<e?e:t>n?n:t}function ut(t,e,n){return(e-t)*n+t}function dt(t,e,n,r,i){return.5*(r-e+(2*e-5*n+4*r-i+(3*(n-r)+i-e)*t)*t)*t+n}const lt=4294967295;function ft(t){const e=t>>0;return lt-((t-e)*lt>>>0)^e}class gt{constructor(t=[],e=1,n=0,r=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(r)||n<0)throw new Error(`height must be a non-negative integer, instead was ${r}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*r*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*r*e}`);this.width=n,this.height=r,this.itemSize=e,this.data=t,this.version=0}sampleCatmullRomUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelCatmullRomUV(t,e,i)}sampleChannelCatmullRomUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelCatmullRom(r,i,n)}sampleChannelCatmullRom(t,e,n){const r=Math.floor(t),i=Math.floor(e),s=t-r,o=e-i,a=s*(s*(1-.5*s)-.5),c=o*(o*(1-.5*o)-.5),h=s*(.5+s*(2-1.5*s)),u=o*(.5+o*(2-1.5*o)),d=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+h,g=1+o*o*(1.5*o-2.5)+u,p=r-1,y=i-1,w=r+2,_=i+2,m=r+h/f,v=i+u/g;let x=0;return x+=this.sampleChannelBilinear(p,y,n)*a*c,x+=this.sampleChannelBilinear(m,y,n)*f*c,x+=this.sampleChannelBilinear(w,y,n)*d*c,x+=this.sampleChannelBilinear(p,v,n)*a*g,x+=this.sampleChannelBilinear(m,v,n)*f*g,x+=this.sampleChannelBilinear(w,v,n)*d*g,x+=this.sampleChannelBilinear(p,_,n)*a*l,x+=this.sampleChannelBilinear(m,_,n)*f*l,x+=this.sampleChannelBilinear(w,_,n)*d*l,x}sampleBicubicUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelBicubicUV(t,e,i)}sampleBicubic(t,e,n,r){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const r=t*this.width,i=e*this.height;return this.sampleChannelBicubic(r-.5,i-.5,n)}sampleChannelBicubic(t,e,n){const r=this.itemSize,i=this.width,s=this.height,o=this.data,a=i*r,c=i-1,h=s-1,u=ht(t,0,c),d=ht(e,0,h),l=0|u,p=0|d,y=u-l,w=d-p,_=f(0,l-1),m=f(0,p-1),v=g(c,l+1),x=g(h,p+1),A=g(c,v+1),b=m*a+n,E=p*a+n,$=x*a+n,F=g(h,x+1)*a+n,U=_*r,S=l*r,z=v*r,C=A*r,V=o[b+U],B=o[b+S],q=o[b+z],L=o[b+C],T=o[E+U],M=o[E+S],I=o[E+z],k=o[E+C],N=o[$+U],O=o[$+S],j=o[$+z],D=o[$+C],R=o[F+U],J=o[F+S],P=o[F+z],H=o[F+C],W=dt(y,V,B,q,L),G=dt(y,T,M,I,k),Y=dt(y,N,O,j,D),K=dt(y,R,J,P,H);return dt(w,W,G,Y,K)}sampleBilinearUV(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelBilinear(r,i,n)}sampleChannelBilinear(t,e,n){const r=this.itemSize,i=this.width,s=i*r,o=this.height-1,a=ht(t,0,i-1),c=ht(e,0,o),h=a>>>0,u=c>>>0,d=u*s,l=h*r+n,f=d+l;let g,p;g=a===h?h:h+1,p=c===u?u:u+1;const y=this.data,w=y[f];if(h===g&&u===p)return w;const _=a-h,m=c-u,v=g*r+n,x=p*s,A=x+l,b=x+v,E=y[d+v],$=y[A],F=y[b],U=ut(w,E,_),S=ut($,F,_);return ut(U,S,m)}sampleNearestUV(t,e,n){const r=this.width,i=this.height,s=Math.round(t*r-.5),o=Math.round(e*i-.5);this.read(ht(s,0,r-1),ht(o,0,i-1),n)}readChannel(t,e,n){const r=(e*this.width+t)*this.itemSize+n;return this.data[r]}read(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)n[t]=this.data[s+t]}write(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)this.data[s+t]=n[t];this.version++}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,r=t%n,i=t/n|0;e.set(r,i)}copy(t,e,n,r,i,s,o){const a=Math.min(s,t.width-e,this.width-r),c=Math.min(o,t.height-n,this.height-i),h=this.itemSize,u=t.itemSize,d=Math.min(h,u),l=h*this.width,f=u*t.width,g=t.data,p=this.data;let y,w,_;for(w=0;w<c;w++){const t=(w+i)*l,s=(w+n)*f;for(y=0;y<a;y++){const n=t+(y+r)*h,i=s+(y+e)*u;for(_=0;_<d;_++)p[n+_]=g[i+_]}}this.version++}zeroFill(t,e,n,r){const i=ht(t,0,this.width),s=ht(e,0,this.height),o=ht(t+n,0,this.width),a=ht(e+r,0,this.height),c=this.data,h=this.itemSize,u=h*this.width,d=i*h,l=o*h;let f;for(f=s;f<a;f++){const t=f*u;c.fill(0,t+d,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,r=this.data,i=r.length;for(let s=t;s<i;s+=n)r[s]=e;this.version++}fill(t,e,n,r,i){const s=this.width,o=this.height,a=ht(t,0,s),c=ht(e,0,o),h=ht(t+n,0,s),u=ht(e+r,0,o),d=this.data,l=this.itemSize,f=l*s;let g,p,y;for(g=c;g<u;g++){const t=g*f;for(p=a;p<h;p++){const e=t+p*l;for(y=0;y<l;y++)d[e+y]=i[y]}}this.version++}writeChannel(t,e,n,r){const i=(e*this.width+t)*this.itemSize+n;this.data[i]=r,this.version++}traverseCircle(t,e,n,r){let i,s;const o=0|t,a=0|e,c=n*n,h=Math.ceil(n);for(s=-h;s<=h;s++){const t=s*s;for(i=-h;i<=h;i++)i*i+t<=c&&r(o+i,a+s,this)}}resize(t,e,n=!0){const r=this.width,i=this.height;if(r===t&&i===e)return;const s=this.itemSize,o=t*e*s,a=this.data,c=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===r)c.set(a.subarray(0,Math.min(a.length,o)));else{const n=g(e,i),o=g(t,r);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const i=(e*t+n)*s,o=(e*r+n)*s;for(let t=0;t<s;t++)c[i+t]=a[o+t]}}this.width=t,this.height=e,this.data=c,this.version++}computeByteSize(){let t;const e=this.data;return t=Array.isArray(e)?8*e.length:e.byteLength,t+280}equals(e){return this===e||this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const r=e.length;if(r!==n.length)return!1;const i=e.constructor;if(i!==n.constructor)return!1;if(0===r)return!0;if(r<128)return t(e,n);const s=e.byteLength;if(s!==n.byteLength)return!1;const o=e.buffer,a=n.buffer,c=e.byteOffset,h=n.byteOffset;if(o===a&&c===h)return!0;let u=e,d=n;const l=i.BYTES_PER_ELEMENT,f=function(t,e,n){const r=t|e|n;return 0==(3&r)?4:0==(1&r)?2:1}(c,h,s);return l<4&&4===f?(u=new Uint32Array(o,c,s>>>2),d=new Uint32Array(a,h,s>>>2)):l<2&&2===f&&(u=new Uint16Array(o,c,s>>>1),d=new Uint16Array(a,h,s>>>1)),t(u,d)}(this.data,e.data)}hash(){const t=this.itemSize,n=this.width,r=this.height,i=this.data;let s=((65535&n)<<16|65535&r)^t;const o=n*r*t;if(e(i))s^=function(t,e,n){const r=e|n;return 0==(3&r)?function(t,e,n){let r=n;for(let e=0;e<n;++e)r=(r<<5)-r+t[e];return r}(new Uint32Array(t,e,n>>>2),0,n>>>2):0==(2&r)?function(t,e,n){let r=n,i=0;for(0!=(1&n)&&(r=(r<<5)-r+t[i++]);i<n;i+=2)r=(r<<5)-r+(t[i]<<16|t[i+1]);return r}(new Uint16Array(t,e,n>>>1),0,n>>>1):function(t,e,n){let r=n,i=0;const s=3&n;for(;i<0+s;i++)r=(r<<5)-r+t[i];for(;i<n;i+=4)r=(r<<5)-r+(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24);return r}(new Uint8Array(t,e,n),0,n)}(i.buffer,i.byteOffset,i.byteLength);else for(let t=0;t<o;++t)s=(s<<5)-s+ft(i[t]);return s}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new gt(t,this.itemSize,this.width,this.height)}toJSON(){const t=X.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:ct(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:r,data:i}){const s=function(t){const e=at[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(r);if("string"==typeof i){const t=X.decode(i);this.data=new s(t)}else{if(!Array.isArray(i))throw new Error("Unsupported data format");this.data=new s(i)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const r=new Uint8ClampedArray(e*n*t);return new gt(r,t,e,n)}static uint8(t,e,n){const r=new Uint8Array(e*n*t);return new gt(r,t,e,n)}static uint16(t,e,n){const r=new Uint16Array(e*n*t);return new gt(r,t,e,n)}static uint32(t,e,n){const r=new Uint32Array(e*n*t);return new gt(r,t,e,n)}static int8(t,e,n){const r=new Int8Array(e*n*t);return new gt(r,t,e,n)}static int16(t,e,n){const r=new Int16Array(e*n*t);return new gt(r,t,e,n)}static int32(t,e,n){const r=new Int32Array(e*n*t);return new gt(r,t,e,n)}static float32(t,e,n){const r=new Float32Array(e*n*t);return new gt(r,t,e,n)}static float64(t,e,n){const r=new Float64Array(e*n*t);return new gt(r,t,e,n)}}function pt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2];t[e]+=i,t[e+1]+=s,t[e+2]+=o}function yt(t,e,n,r,i,s){const o=3*n,a=3*r,c=3*i;j(t,e,s[o],s[o+1],s[o+2],s[a],s[a+1],s[a+2],s[c],s[c+1],s[c+2])}function wt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2],a=O(i,s,o),c=0!==a?1/Math.sqrt(a):1;t[e]=i*c,t[e+1]=s*c,t[e+2]=o*c}gt.prototype.isSampler2D=!0,gt.typeName="Sampler2D";const _t=new Float64Array(3),mt={build:function(t,e,n,r,i,s){const o=n.x*s,a=n.y*s,c=o-1,h=a-1;let u=0,d=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),p=new Float32Array(2*l);let y,w;const _=n.y/i.y/h,m=n.x/i.x/c,v=e.y/i.y,x=e.x/i.x,A=i.x*r.x,b=i.y*r.y;let E,$,F;for(y=0;y<a;y++){const e=y*_+v;for(F=e*b,w=0;w<o;w++){const n=w*m+x;E=n*A,$=t.sampleChannelBicubicUV(n,e,0),f[u]=E,f[u+1]=$,f[u+2]=F,p[d]=n,p[d+1]=e,u+=3,d+=2}}u=0;const U=new(function(t){if(t<=256)return Uint8Array;if(t<=65536)return Uint16Array;if(t<=4294967295)return Uint32Array;throw new Error(`Unsupported size ${t}`)}(f.length/3))(c*h*6);for(y=0;y<h;y++)for(w=0;w<c;w++){const t=w+o*y,e=w+o*(y+1),n=w+1+o*(y+1),r=w+1+o*y;U[u]=t,U[u+1]=e,U[u+2]=r,U[u+3]=e,U[u+4]=n,U[u+5]=r,u+=6}return function(t,e,n){const r=n.length;for(let i=0;i<r;i+=3){const r=n[i],s=n[i+1],o=n[i+2];yt(_t,0,r,s,o,t),pt(e,3*r,_t,0),pt(e,3*s,_t,0),pt(e,3*o,_t,0)}!function(t,e=0,n=t.length-e){const r=e+n;for(let n=e;n<r;n+=3)wt(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:p}}};self.Lib={build_bvh(t,e){const n=new A;return function(t,e,n){const r=n.length/3;t.setLeafCount(r),t.initialize_structure();for(let i=0;i<r;i++){const r=3*i;$(t,i,e,n[r],n[r+1],n[r+2])}t.build()}(n,t,e),n},Sampler2D:gt,BufferedGeometryArraysBuilder:mt,tensionOptimizeUV:function(t,e,n,r=3){const i=new H;i.build(t,n),i.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<r;t++)t:for(let t=0;t<s;t++){const n=i.vertices[t],r=n.edges,s=r.length;if(0===s)continue;let o=0,a=0,c=0;for(let t=0;t<s;t++){const i=r[t];if(F(i))continue t;const s=2*U(i,n).index,h=e[s],u=e[s+1],d=1/i.lengthSqr;o+=h*d,a+=u*d,c+=d}const h=o/c,u=a/c,d=2*n.index;e[d]=h,e[d+1]=u}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s>e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s<e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}}};
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.126.
|
|
8
|
+
"version": "2.126.6",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
package/src/core/assert.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export namespace assert {
|
|
|
26
26
|
export { arrayHas };
|
|
27
27
|
export { arrayHasNo };
|
|
28
28
|
export { arrayEqual };
|
|
29
|
+
export { isOneOf };
|
|
29
30
|
/**
|
|
30
31
|
*
|
|
31
32
|
* @param {*} value
|
|
@@ -226,5 +227,12 @@ declare function arrayHasNo<T>(haystack: T[], needle: T, message?: string): void
|
|
|
226
227
|
* @param {string} [message]
|
|
227
228
|
*/
|
|
228
229
|
declare function arrayEqual<T>(a: T[] | ArrayLike<T> | Float32Array | Int32Array, b: T[] | ArrayLike<T> | Float32Array | Int32Array, message?: string): void;
|
|
230
|
+
/**
|
|
231
|
+
* @template T
|
|
232
|
+
* @param {T} value
|
|
233
|
+
* @param {T[]} options must be string-serializable for useful error messages
|
|
234
|
+
* @param {string} [name] optional name for a better error message
|
|
235
|
+
*/
|
|
236
|
+
declare function isOneOf<T>(value: T, options: T[], name?: string): void;
|
|
229
237
|
export {};
|
|
230
238
|
//# sourceMappingURL=assert.d.ts.map
|
package/src/core/assert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/core/assert.js"],"names":[],"mappings":"AAgDA;;;;GAIG;AACH,0BAHW,OAAO,MACP,MAAM,QAMhB;;
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/core/assert.js"],"names":[],"mappings":"AAgDA;;;;GAIG;AACH,0BAHW,OAAO,MACP,MAAM,QAMhB;;IAmKD;;;;;OAKG;IACH,eALa,CAAC,SACH,CAAC,0BAED,MAAM,QAUhB;;;;;;;;;;;;;;;;IAoBD;;;;;;OAMG;IACH,oCALW,GAAC,SACD,KAAK,eACL,MAAM,eACN,MAAM,QAOhB;IAGD;;;;OAIG;IACH,gCAHW,MAAM,GAAC,GAAC,SACR,MAAM,QAQhB;IAED;;;;OAIG;IACH,gCAHW,MAAM,GAAC,GAAC,SACR,MAAM,QAQhB;IAED;;;;OAIG;IACH,iCAHW,OAAO,GAAC,GAAC,SACT,MAAM,QAQhB;IAED;;;;OAIG;IACH,kCAHW,WAAS,GAAC,SACV,MAAM,QAQhB;IAED;;;;OAIG;IACH,gCAHW,MAAO,GAAC,SACR,MAAM,QAQhB;IAED;;;;OAIG;IACH,iCAHW,MAAM,GAAC,GAAC,SACR,MAAM,QAQhB;IAED;;;;OAIG;IACH,4CAHW,MAAM,GAAC,GAAC,SACR,MAAM,QAQhB;IAED;;;;OAIG;IACH,wBAJa,CAAC,SACH,CAAC,EAAE,SACH,MAAM,QAOhB;IAED;;;;OAIG;IACH,4BAJa,CAAC,SACH,SAAS,CAAC,CAAC,CAAC,GAAC,CAAC,EAAE,GAAC,WAAW,GAAC,YAAY,SACzC,MAAM,QAOhB;IAGD;;;;OAIG;IACH,+BAHW,GAAC,uBASX;IAED;;;;OAIG;IACH,iCAHW,GAAC,uBASX;IAGD;;;;OAIG;IACH,8BAHW,GAAC,uBAOX;IAED;;;;OAIG;IACH,+BAHW,GAAC,uBASX;IAED;;;;OAIG;IACH,8BAHW,MAAM,SACN,MAAM,QAMhB;IAED;;;;;OAKG;IACH,gCAHW,MAAM,SACN,MAAM,QAMhB;;;IAQD;;;;;;;;;;;;;OAaG;IACH,qBALa,CAAC,SACH,CAAC,QACD,MAAM,WACN,OAAO,CAAC,CAAC,CAAC,QAwBpB;;AAleD;;;;;GAKG;AACH,0BALa,CAAC,KACH,CAAC,KACD,CAAC,MACD,MAAM,QAIhB;AAED;;;;GAIG;AACH,0BAHW,OAAO,MACP,MAAM,QAIhB;AAhCD;;;;;GAKG;AACH,uBALa,CAAC,KACH,CAAC,KACD,CAAC,MACD,MAAM,QAShB;AAqBD;;;;;GAKG;AACH,kCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAIhB;AAaD;;;;;GAKG;AACH,gCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAyBD;;;;;GAKG;AACH,uCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AA5CD;;;;;GAKG;AACH,6BAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAyBD;;;;;GAKG;AACH,oCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAkBD;;;;;GAKG;AACH,+BAJW,GAAC,QACD,MAAM,cACN,MAAM,QAehB;AAED;;;;;GAKG;AACH,0BALa,CAAC,YACH,CAAC,EAAE,UACH,CAAC,YACD,MAAM,QAIhB;AAED;;;;;GAKG;AACH,4BALa,CAAC,YACH,CAAC,EAAE,UACH,CAAC,YACD,MAAM,QAIhB;AAED;;;;;GAKG;AACH,4BALa,CAAC,KACH,CAAC,EAAE,GAAC,SAAS,CAAC,CAAC,CAAC,GAAC,YAAY,GAAC,UAAU,KACxC,CAAC,EAAE,GAAC,SAAS,CAAC,CAAC,CAAC,GAAC,YAAY,GAAC,UAAU,YACxC,MAAM,QAMhB;AAnED;;;;;GAKG;AACH,yBALa,CAAC,SACH,CAAC,WACD,CAAC,EAAE,SACH,MAAM,QAQhB"}
|
package/src/core/assert.js
CHANGED
|
@@ -149,8 +149,21 @@ function lessThanOrEqual(a, b, m) {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @template T
|
|
154
|
+
* @param {T} value
|
|
155
|
+
* @param {T[]} options must be string-serializable for useful error messages
|
|
156
|
+
* @param {string} [name] optional name for a better error message
|
|
157
|
+
*/
|
|
158
|
+
function isOneOf(value, options,name = "value") {
|
|
159
|
+
|
|
160
|
+
if(options.indexOf(value) === -1) {
|
|
161
|
+
throw new Error(`${name} must be one of [${options.join(', ')}], instead was '${value}'`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
152
166
|
const typeOfTypes = ['string', 'boolean', 'number', 'object', 'undefined', 'function', 'symbol'];
|
|
153
|
-
const stringListOfTypes = typeOfTypes.join(', ');
|
|
154
167
|
|
|
155
168
|
/**
|
|
156
169
|
*
|
|
@@ -160,7 +173,7 @@ const stringListOfTypes = typeOfTypes.join(', ');
|
|
|
160
173
|
*/
|
|
161
174
|
function typeOf(value, type, valueName = 'value') {
|
|
162
175
|
|
|
163
|
-
|
|
176
|
+
isOneOf(typeof value,typeOfTypes );
|
|
164
177
|
|
|
165
178
|
const typeofValueName = typeof valueName;
|
|
166
179
|
|
|
@@ -237,6 +250,7 @@ assert.typeOf = typeOf;
|
|
|
237
250
|
assert.arrayHas = arrayHas;
|
|
238
251
|
assert.arrayHasNo = arrayHasNo;
|
|
239
252
|
assert.arrayEqual = arrayEqual;
|
|
253
|
+
assert.isOneOf = isOneOf;
|
|
240
254
|
|
|
241
255
|
/**
|
|
242
256
|
*
|
|
@@ -245,7 +259,9 @@ assert.arrayEqual = arrayEqual;
|
|
|
245
259
|
* @param {string} [value_name]
|
|
246
260
|
* @param {string} [class_name]
|
|
247
261
|
*/
|
|
248
|
-
assert.isInstanceOf = function (
|
|
262
|
+
assert.isInstanceOf = function (
|
|
263
|
+
value,
|
|
264
|
+
klass, value_name = "value", class_name = klass.name) {
|
|
249
265
|
assert.defined(klass, 'klass');
|
|
250
266
|
assert.ok(value instanceof klass, `expected ${value_name} to be instance of class '${class_name}'`);
|
|
251
267
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export default BinaryBufferDeSerializer;
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @template CTX
|
|
4
|
+
*/
|
|
5
|
+
declare class BinaryBufferDeSerializer<CTX> {
|
|
3
6
|
/**
|
|
4
7
|
*
|
|
5
8
|
* @type {BinarySerializationRegistry}
|
|
@@ -8,11 +11,11 @@ declare class BinaryBufferDeSerializer {
|
|
|
8
11
|
/**
|
|
9
12
|
*
|
|
10
13
|
* @param {BinaryBuffer} buffer
|
|
11
|
-
* @param {
|
|
14
|
+
* @param {CTX} context
|
|
12
15
|
* @param {EntityComponentDataset} dataset
|
|
13
16
|
* @returns {Task}
|
|
14
17
|
*/
|
|
15
|
-
process(buffer: BinaryBuffer,
|
|
18
|
+
process(buffer: BinaryBuffer, context: CTX, dataset: EntityComponentDataset): Task;
|
|
16
19
|
}
|
|
17
20
|
import Task from "../../../core/process/task/Task.js";
|
|
18
21
|
//# sourceMappingURL=BinaryBufferDeSerializer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BinaryBufferDeSerializer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/storage/BinaryBufferDeSerializer.js"],"names":[],"mappings":";AAQA;
|
|
1
|
+
{"version":3,"file":"BinaryBufferDeSerializer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/storage/BinaryBufferDeSerializer.js"],"names":[],"mappings":";AAQA;;GAEG;AACH,uCAFa,GAAG;IAGZ;;;OAGG;IACH,UAFU,2BAA2B,CAErB;IAEhB;;;;;;OAMG;IACH,gBALW,YAAY,WACZ,GAAG,WACH,sBAAsB,GACpB,IAAI,CA8BhB;CACJ;iBApDgB,oCAAoC"}
|
|
@@ -6,6 +6,9 @@ import { emptyTask } from "../../../core/process/task/util/emptyTask.js";
|
|
|
6
6
|
import { BinaryCollectionDeSerializer } from "./binary/collection/BinaryCollectionDeSerializer.js";
|
|
7
7
|
import { BinaryObjectSerializationAdapter } from "./binary/object/BinaryObjectSerializationAdapter.js";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @template CTX
|
|
11
|
+
*/
|
|
9
12
|
class BinaryBufferDeSerializer {
|
|
10
13
|
/**
|
|
11
14
|
*
|
|
@@ -16,14 +19,14 @@ class BinaryBufferDeSerializer {
|
|
|
16
19
|
/**
|
|
17
20
|
*
|
|
18
21
|
* @param {BinaryBuffer} buffer
|
|
19
|
-
* @param {
|
|
22
|
+
* @param {CTX} context
|
|
20
23
|
* @param {EntityComponentDataset} dataset
|
|
21
24
|
* @returns {Task}
|
|
22
25
|
*/
|
|
23
|
-
process(buffer,
|
|
24
|
-
assert.
|
|
25
|
-
assert.
|
|
26
|
-
assert.
|
|
26
|
+
process(buffer, context, dataset) {
|
|
27
|
+
assert.defined(buffer, 'buffer');
|
|
28
|
+
assert.defined(context, 'context');
|
|
29
|
+
assert.defined(dataset, 'dataset');
|
|
27
30
|
|
|
28
31
|
const entity_count_before = dataset.entityCount;
|
|
29
32
|
|
|
@@ -35,7 +38,7 @@ class BinaryBufferDeSerializer {
|
|
|
35
38
|
//return NO-OP equivalent of a task
|
|
36
39
|
task = emptyTask();
|
|
37
40
|
} else {
|
|
38
|
-
task = deserializeTask(numSerializedTypes, buffer,
|
|
41
|
+
task = deserializeTask(numSerializedTypes, buffer, context, dataset, this.registry);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
task.on.completed.add(function () {
|
|
@@ -52,10 +55,10 @@ class BinaryBufferDeSerializer {
|
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
|
-
*
|
|
58
|
+
* @template CTX
|
|
56
59
|
* @param {number} numSerializedTypes
|
|
57
60
|
* @param {BinaryBuffer} buffer
|
|
58
|
-
* @param {
|
|
61
|
+
* @param {CTX} context
|
|
59
62
|
* @param {EntityComponentDataset} dataset
|
|
60
63
|
* @param {BinarySerializationRegistry}registry
|
|
61
64
|
* @returns {Task}
|
|
@@ -63,13 +66,13 @@ class BinaryBufferDeSerializer {
|
|
|
63
66
|
function deserializeTask(
|
|
64
67
|
numSerializedTypes,
|
|
65
68
|
buffer,
|
|
66
|
-
|
|
69
|
+
context,
|
|
67
70
|
dataset,
|
|
68
71
|
registry
|
|
69
72
|
) {
|
|
70
73
|
|
|
71
|
-
assert.defined(
|
|
72
|
-
assert.
|
|
74
|
+
assert.defined(context, 'context');
|
|
75
|
+
assert.notNull(context, 'context');
|
|
73
76
|
|
|
74
77
|
|
|
75
78
|
let typesDecoded = 0;
|
|
@@ -117,7 +120,7 @@ function deserializeTask(
|
|
|
117
120
|
* @param {BinaryClassSerializationAdapter} adapter
|
|
118
121
|
*/
|
|
119
122
|
adapterOptionsSupplier(className, klass, adapter) {
|
|
120
|
-
return [
|
|
123
|
+
return [context, objectAdapter];
|
|
121
124
|
}
|
|
122
125
|
});
|
|
123
126
|
} catch (e) {
|