@file-viewer/assets-design 3.0.1

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.
Files changed (32) hide show
  1. package/LICENSE +160 -0
  2. package/README.en.md +3 -0
  3. package/README.md +3 -0
  4. package/bin/install.mjs +7 -0
  5. package/file-viewer.asset-pack.json +7 -0
  6. package/package.json +46 -0
  7. package/viewer/file-viewer-asset-pack.json +612 -0
  8. package/viewer/vendor/design/LICENSE.Carlito-OFL-1.1.txt +94 -0
  9. package/viewer/vendor/design/LICENSE.Cousine-OFL-1.1.txt +93 -0
  10. package/viewer/vendor/design/LICENSE.NotoSansSymbols2-OFL-1.1.txt +93 -0
  11. package/viewer/vendor/design/LICENSE.Tinos-OFL-1.1.txt +93 -0
  12. package/viewer/vendor/design/LICENSE.ag-psd-MIT.txt +24 -0
  13. package/viewer/vendor/design/LICENSE.base64-js-MIT.txt +21 -0
  14. package/viewer/vendor/design/LICENSE.fzstd-MIT.txt +21 -0
  15. package/viewer/vendor/design/LICENSE.illustrator-pgf-MIT.txt +9 -0
  16. package/viewer/vendor/design/LICENSE.introspect-wasm-MPL-2.0.txt +373 -0
  17. package/viewer/vendor/design/LICENSE.pako-MIT.txt +21 -0
  18. package/viewer/vendor/design/LICENSE.saxes-ISC.txt +57 -0
  19. package/viewer/vendor/design/LICENSE.stet-Apache-2.0.txt +190 -0
  20. package/viewer/vendor/design/LICENSE.stet-MIT.txt +21 -0
  21. package/viewer/vendor/design/LICENSE.webtoon-psd-MIT.txt +19 -0
  22. package/viewer/vendor/design/LICENSE.xmlchars-MIT.txt +18 -0
  23. package/viewer/vendor/design/LICENSE.xmldom-MIT.txt +8 -0
  24. package/viewer/vendor/design/THIRD_PARTY_NOTICES.md +91 -0
  25. package/viewer/vendor/design/adobe-container.worker.js +44 -0
  26. package/viewer/vendor/design/adobe-resource.worker.js +11 -0
  27. package/viewer/vendor/design/idml.worker.js +38 -0
  28. package/viewer/vendor/design/illustrator-pgf.worker.js +2 -0
  29. package/viewer/vendor/design/paged_introspect_wasm_bg.wasm +0 -0
  30. package/viewer/vendor/design/photoshop.worker.js +11 -0
  31. package/viewer/vendor/design/postscript.worker.js +1 -0
  32. package/viewer/vendor/design/stet_wasm_bg.wasm +0 -0
@@ -0,0 +1,11 @@
1
+ var bd=Object.create;var ss=Object.defineProperty;var yd=Object.getOwnPropertyDescriptor;var wd=Object.getOwnPropertyNames;var Sd=Object.getPrototypeOf,vd=Object.prototype.hasOwnProperty;var oe=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var xd=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of wd(t))!vd.call(e,o)&&o!==n&&ss(e,o,{get:()=>t[o],enumerable:!(i=yd(t,o))||i.enumerable});return e};var _d=(e,t,n)=>(n=e!=null?bd(Sd(e)):{},xd(t||!e||!e.__esModule?ss(n,"default",{value:e,enumerable:!0}):n,e));var Ds=oe((Gp,mn)=>{"use strict";function pn(e){let t=e.length;for(;--t>=0;)e[t]=0}var Ad=0,us=1,kd=2,Id=3,Dd=258,Fo=29,Nn=256,Tn=Nn+1+Fo,hn=30,Oo=19,hs=2*Tn+1,Xt=15,ko=16,Cd=7,Lo=256,ps=16,ms=17,gs=18,Po=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]),wi=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]),Pd=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),bs=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ed=512,vt=new Array((Tn+2)*2);pn(vt);var Mn=new Array(hn*2);pn(Mn);var jn=new Array(Ed);pn(jn);var zn=new Array(Dd-Id+1);pn(zn);var Bo=new Array(Fo);pn(Bo);var Si=new Array(hn);pn(Si);function Io(e,t,n,i,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=o,this.has_stree=e&&e.length}var ys,ws,Ss;function Do(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var vs=e=>e<256?jn[e]:jn[256+(e>>>7)],$n=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},je=(e,t,n)=>{e.bi_valid>ko-n?(e.bi_buf|=t<<e.bi_valid&65535,$n(e,e.bi_buf),e.bi_buf=t>>ko-e.bi_valid,e.bi_valid+=n-ko):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},lt=(e,t,n)=>{je(e,n[t*2],n[t*2+1])},xs=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},Fd=e=>{e.bi_valid===16?($n(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},Od=(e,t)=>{let n=t.dyn_tree,i=t.max_code,o=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,d,u,f,h,p,S=0;for(f=0;f<=Xt;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<hs;c++)d=e.heap[c],f=n[n[d*2+1]*2+1]+1,f>l&&(f=l,S++),n[d*2+1]=f,!(d>i)&&(e.bl_count[f]++,h=0,d>=a&&(h=s[d-a]),p=n[d*2],e.opt_len+=p*(f+h),r&&(e.static_len+=p*(o[d*2+1]+h)));if(S!==0){do{for(f=l-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[l]--,S-=2}while(S>0);for(f=l;f!==0;f--)for(d=e.bl_count[f];d!==0;)u=e.heap[--c],!(u>i)&&(n[u*2+1]!==f&&(e.opt_len+=(f-n[u*2+1])*n[u*2],n[u*2+1]=f),d--)}},_s=(e,t,n)=>{let i=new Array(Xt+1),o=0,r,s;for(r=1;r<=Xt;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=t;s++){let a=e[s*2+1];a!==0&&(e[s*2]=xs(i[a]++,a))}},Ld=()=>{let e,t,n,i,o,r=new Array(Xt+1);for(n=0,i=0;i<Fo-1;i++)for(Bo[i]=n,e=0;e<1<<Po[i];e++)zn[n++]=i;for(zn[n-1]=i,o=0,i=0;i<16;i++)for(Si[i]=o,e=0;e<1<<wi[i];e++)jn[o++]=i;for(o>>=7;i<hn;i++)for(Si[i]=o<<7,e=0;e<1<<wi[i]-7;e++)jn[256+o++]=i;for(t=0;t<=Xt;t++)r[t]=0;for(e=0;e<=143;)vt[e*2+1]=8,e++,r[8]++;for(;e<=255;)vt[e*2+1]=9,e++,r[9]++;for(;e<=279;)vt[e*2+1]=7,e++,r[7]++;for(;e<=287;)vt[e*2+1]=8,e++,r[8]++;for(_s(vt,Tn+1,r),e=0;e<hn;e++)Mn[e*2+1]=5,Mn[e*2]=xs(e,5);ys=new Io(vt,Po,Nn+1,Tn,Xt),ws=new Io(Mn,wi,0,hn,Xt),Ss=new Io(new Array(0),Pd,0,Oo,Cd)},As=e=>{let t;for(t=0;t<Tn;t++)e.dyn_ltree[t*2]=0;for(t=0;t<hn;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Oo;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Lo*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},ks=e=>{e.bi_valid>8?$n(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},as=(e,t,n,i)=>{let o=t*2,r=n*2;return e[o]<e[r]||e[o]===e[r]&&i[t]<=i[n]},Co=(e,t,n)=>{let i=e.heap[n],o=n<<1;for(;o<=e.heap_len&&(o<e.heap_len&&as(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!as(t,i,e.heap[o],e.depth));)e.heap[n]=e.heap[o],n=o,o<<=1;e.heap[n]=i},ls=(e,t,n)=>{let i,o,r=0,s,a;if(e.sym_next!==0)do i=e.pending_buf[e.sym_buf+r++]&255,i+=(e.pending_buf[e.sym_buf+r++]&255)<<8,o=e.pending_buf[e.sym_buf+r++],i===0?lt(e,o,t):(s=zn[o],lt(e,s+Nn+1,t),a=Po[s],a!==0&&(o-=Bo[s],je(e,o,a)),i--,s=vs(i),lt(e,s,n),a=wi[s],a!==0&&(i-=Si[s],je(e,i,a)));while(r<e.sym_next);lt(e,Lo,t)},Eo=(e,t)=>{let n=t.dyn_tree,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,r=t.stat_desc.elems,s,a,l=-1,c;for(e.heap_len=0,e.heap_max=hs,s=0;s<r;s++)n[s*2]!==0?(e.heap[++e.heap_len]=l=s,e.depth[s]=0):n[s*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=i[c*2+1]);for(t.max_code=l,s=e.heap_len>>1;s>=1;s--)Co(e,n,s);c=r;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Co(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[c*2]=n[s*2]+n[a*2],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[s*2+1]=n[a*2+1]=c,e.heap[1]=c++,Co(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Od(e,t),_s(n,l,e.bl_count)},cs=(e,t,n)=>{let i,o=-1,r,s=t[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),t[(n+1)*2+1]=65535,i=0;i<=n;i++)r=s,s=t[(i+1)*2+1],!(++a<l&&r===s)&&(a<c?e.bl_tree[r*2]+=a:r!==0?(r!==o&&e.bl_tree[r*2]++,e.bl_tree[ps*2]++):a<=10?e.bl_tree[ms*2]++:e.bl_tree[gs*2]++,a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4))},ds=(e,t,n)=>{let i,o=-1,r,s=t[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),i=0;i<=n;i++)if(r=s,s=t[(i+1)*2+1],!(++a<l&&r===s)){if(a<c)do lt(e,r,e.bl_tree);while(--a!==0);else r!==0?(r!==o&&(lt(e,r,e.bl_tree),a--),lt(e,ps,e.bl_tree),je(e,a-3,2)):a<=10?(lt(e,ms,e.bl_tree),je(e,a-3,3)):(lt(e,gs,e.bl_tree),je(e,a-11,7));a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4)}},Bd=e=>{let t;for(cs(e,e.dyn_ltree,e.l_desc.max_code),cs(e,e.dyn_dtree,e.d_desc.max_code),Eo(e,e.bl_desc),t=Oo-1;t>=3&&e.bl_tree[bs[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},Ud=(e,t,n,i)=>{let o;for(je(e,t-257,5),je(e,n-1,5),je(e,i-4,4),o=0;o<i;o++)je(e,e.bl_tree[bs[o]*2+1],3);ds(e,e.dyn_ltree,t-1),ds(e,e.dyn_dtree,n-1)},Rd=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(n=32;n<Nn;n++)if(e.dyn_ltree[n*2]!==0)return 1;return 0},fs=!1,Md=e=>{fs||(Ld(),fs=!0),e.l_desc=new Do(e.dyn_ltree,ys),e.d_desc=new Do(e.dyn_dtree,ws),e.bl_desc=new Do(e.bl_tree,Ss),e.bi_buf=0,e.bi_valid=0,As(e)},Is=(e,t,n,i)=>{je(e,(Ad<<1)+(i?1:0),3),ks(e),$n(e,n),$n(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},Td=e=>{je(e,us<<1,3),lt(e,Lo,vt),Fd(e)},jd=(e,t,n,i)=>{let o,r,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=Rd(e)),Eo(e,e.l_desc),Eo(e,e.d_desc),s=Bd(e),o=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=o&&(o=r)):o=r=n+5,n+4<=o&&t!==-1?Is(e,t,n,i):e.strategy===4||r===o?(je(e,(us<<1)+(i?1:0),3),ls(e,vt,Mn)):(je(e,(kd<<1)+(i?1:0),3),Ud(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),ls(e,e.dyn_ltree,e.dyn_dtree)),As(e),i&&ks(e)},zd=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(zn[n]+Nn+1)*2]++,e.dyn_dtree[vs(t)*2]++),e.sym_next===e.sym_end);mn.exports._tr_init=Md;mn.exports._tr_stored_block=Is;mn.exports._tr_flush_block=jd;mn.exports._tr_tally=zd;mn.exports._tr_align=Td});var Uo=oe((Hp,Cs)=>{"use strict";var $d=(e,t,n,i)=>{let o=e&65535|0,r=e>>>16&65535|0,s=0;for(;n!==0;){s=n>2e3?2e3:n,n-=s;do o=o+t[i++]|0,r=r+o|0;while(--s);o%=65521,r%=65521}return o|r<<16|0};Cs.exports=$d});var Ro=oe((Wp,Ps)=>{"use strict";var Nd=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},Vd=new Uint32Array(Nd()),Gd=(e,t,n,i)=>{let o=Vd,r=i+n;e^=-1;for(let s=i;s<r;s++)e=e>>>8^o[(e^t[s])&255];return e^-1};Ps.exports=Gd});var vi=oe((Xp,Es)=>{"use strict";Es.exports={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"}});var Ft=oe((Zp,Fs)=>{"use strict";Fs.exports={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}});var $s=oe((qp,ut)=>{"use strict";var{_tr_init:Hd,_tr_stored_block:jo,_tr_flush_block:Wd,_tr_tally:Ut,_tr_align:Xd}=Ds(),Us=Uo(),Ot=Ro(),Zd=vi(),{Z_NO_FLUSH:Rt,Z_PARTIAL_FLUSH:qd,Z_FULL_FLUSH:Kd,Z_FINISH:qe,Z_BLOCK:Os,Z_OK:Ae,Z_STREAM_END:Ls,Z_STREAM_ERROR:dt,Z_DATA_ERROR:Yd,Z_BUF_ERROR:Mo,Z_DEFAULT_COMPRESSION:Jd,Z_FILTERED:Qd,Z_HUFFMAN_ONLY:xi,Z_RLE:ef,Z_FIXED:tf,Z_DEFAULT_STRATEGY:nf,Z_UNKNOWN:of,Z_DEFLATED:_i}=Ft(),rf=9,sf=15,af=8,lf=29,cf=256,zo=cf+1+lf,df=30,ff=19,uf=2*zo+1,hf=15,Q=3,Bt=258,ft=Bt+Q+1,pf=32,bn=42,Wo=57,$o=69,No=73,Vo=91,Go=103,Zt=113,Gn=666,Ue=1,wn=2,Kt=3,Sn=4,mf=3,qt=(e,t)=>(e.msg=Zd[t],t),Bs=e=>e*2-(e>4?9:0),Lt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},gf=e=>{let t,n,i,o=e.w_size;t=e.hash_size,i=t;do n=e.head[--i],e.head[i]=n>=o?n-o:0;while(--t);t=o,i=t;do n=e.prev[--i],e.prev[i]=n>=o?n-o:0;while(--t)},bf=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,Mt=bf,Ne=e=>{let t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},Ve=(e,t)=>{Wd(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ne(e.strm)},se=(e,t)=>{e.pending_buf[e.pending++]=t},Vn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Ho=(e,t,n,i)=>{let o=e.avail_in;return o>i&&(o=i),o===0?0:(e.avail_in-=o,t.set(e.input.subarray(e.next_in,e.next_in+o),n),e.state.wrap===1?e.adler=Us(e.adler,t,o,n):e.state.wrap===2&&(e.adler=Ot(e.adler,t,o,n)),e.next_in+=o,e.total_in+=o,o)},Rs=(e,t)=>{let n=e.max_chain_length,i=e.strstart,o,r,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-ft?e.strstart-(e.w_size-ft):0,c=e.window,d=e.w_mask,u=e.prev,f=e.strstart+Bt,h=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do if(o=t,!(c[o+s]!==p||c[o+s-1]!==h||c[o]!==c[i]||c[++o]!==c[i+1])){i+=2,o++;do;while(c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&i<f);if(r=Bt-(f-i),i=f-Bt,r>s){if(e.match_start=t,s=r,r>=a)break;h=c[i+s-1],p=c[i+s]}}while((t=u[t&d])>l&&--n!==0);return s<=e.lookahead?s:e.lookahead},yn=e=>{let t=e.w_size,n,i,o;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ft)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),gf(e),i+=t),e.strm.avail_in===0)break;if(n=Ho(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=n,e.lookahead+e.insert>=Q)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=Mt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=Mt(e,e.ins_h,e.window[o+Q-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<Q)););}while(e.lookahead<ft&&e.strm.avail_in!==0)},Ms=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i,o,r,s=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_out<r||(r=e.strm.avail_out-r,o=e.strstart-e.block_start,i>o+e.strm.avail_in&&(i=o+e.strm.avail_in),i>r&&(i=r),i<n&&(i===0&&t!==qe||t===Rt||i!==o+e.strm.avail_in)))break;s=t===qe&&i===o+e.strm.avail_in?1:0,jo(e,0,0,s),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,Ne(e.strm),o&&(o>i&&(o=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+o),e.strm.next_out),e.strm.next_out+=o,e.strm.avail_out-=o,e.strm.total_out+=o,e.block_start+=o,i-=o),i&&(Ho(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(s===0);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?Sn:t!==Rt&&t!==qe&&e.strm.avail_in===0&&e.strstart===e.block_start?wn:(r=e.window_size-e.strstart,e.strm.avail_in>r&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Ho(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water<e.strstart&&(e.high_water=e.strstart),r=e.bi_valid+42>>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,n=r>e.w_size?e.w_size:r,o=e.strstart-e.block_start,(o>=n||(o||t===qe)&&t!==Rt&&e.strm.avail_in===0&&o<=r)&&(i=o>r?r:o,s=t===qe&&e.strm.avail_in===0&&i===o?1:0,jo(e,e.block_start,i,s),e.block_start+=i,Ne(e.strm)),s?Kt:Ue)},To=(e,t)=>{let n,i;for(;;){if(e.lookahead<ft){if(yn(e),e.lookahead<ft&&t===Rt)return Ue;if(e.lookahead===0)break}if(n=0,e.lookahead>=Q&&(e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+Q-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-ft&&(e.match_length=Rs(e,n)),e.match_length>=Q)if(i=Ut(e,e.strstart-e.match_start,e.match_length-Q),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Q){e.match_length--;do e.strstart++,e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+Q-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+1]);else i=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Ve(e,!1),e.strm.avail_out===0))return Ue}return e.insert=e.strstart<Q-1?e.strstart:Q-1,t===qe?(Ve(e,!0),e.strm.avail_out===0?Kt:Sn):e.sym_next&&(Ve(e,!1),e.strm.avail_out===0)?Ue:wn},gn=(e,t)=>{let n,i,o;for(;;){if(e.lookahead<ft){if(yn(e),e.lookahead<ft&&t===Rt)return Ue;if(e.lookahead===0)break}if(n=0,e.lookahead>=Q&&(e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+Q-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Q-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-ft&&(e.match_length=Rs(e,n),e.match_length<=5&&(e.strategy===Qd||e.match_length===Q&&e.strstart-e.match_start>4096)&&(e.match_length=Q-1)),e.prev_length>=Q&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-Q,i=Ut(e,e.strstart-1-e.prev_match,e.prev_length-Q),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+Q-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Q-1,e.strstart++,i&&(Ve(e,!1),e.strm.avail_out===0))return Ue}else if(e.match_available){if(i=Ut(e,0,e.window[e.strstart-1]),i&&Ve(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Ue}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Ut(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Q-1?e.strstart:Q-1,t===qe?(Ve(e,!0),e.strm.avail_out===0?Kt:Sn):e.sym_next&&(Ve(e,!1),e.strm.avail_out===0)?Ue:wn},yf=(e,t)=>{let n,i,o,r,s=e.window;for(;;){if(e.lookahead<=Bt){if(yn(e),e.lookahead<=Bt&&t===Rt)return Ue;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Q&&e.strstart>0&&(o=e.strstart-1,i=s[o],i===s[++o]&&i===s[++o]&&i===s[++o])){r=e.strstart+Bt;do;while(i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&o<r);e.match_length=Bt-(r-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Q?(n=Ut(e,1,e.match_length-Q),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Ve(e,!1),e.strm.avail_out===0))return Ue}return e.insert=0,t===qe?(Ve(e,!0),e.strm.avail_out===0?Kt:Sn):e.sym_next&&(Ve(e,!1),e.strm.avail_out===0)?Ue:wn},wf=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(yn(e),e.lookahead===0)){if(t===Rt)return Ue;break}if(e.match_length=0,n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Ve(e,!1),e.strm.avail_out===0))return Ue}return e.insert=0,t===qe?(Ve(e,!0),e.strm.avail_out===0?Kt:Sn):e.sym_next&&(Ve(e,!1),e.strm.avail_out===0)?Ue:wn};function ct(e,t,n,i,o){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=o}var Hn=[new ct(0,0,0,0,Ms),new ct(4,4,8,4,To),new ct(4,5,16,8,To),new ct(4,6,32,32,To),new ct(4,4,16,16,gn),new ct(8,16,32,32,gn),new ct(8,16,128,128,gn),new ct(8,32,128,256,gn),new ct(32,128,258,1024,gn),new ct(32,258,258,4096,gn)],Sf=e=>{e.window_size=2*e.w_size,Lt(e.head),e.max_lazy_match=Hn[e.level].max_lazy,e.good_match=Hn[e.level].good_length,e.nice_match=Hn[e.level].nice_length,e.max_chain_length=Hn[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Q-1,e.match_available=0,e.ins_h=0};function vf(){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=_i,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(uf*2),this.dyn_dtree=new Uint16Array((2*df+1)*2),this.bl_tree=new Uint16Array((2*ff+1)*2),Lt(this.dyn_ltree),Lt(this.dyn_dtree),Lt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(hf+1),this.heap=new Uint16Array(2*zo+1),Lt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*zo+1),Lt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Wn=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==bn&&t.status!==Wo&&t.status!==$o&&t.status!==No&&t.status!==Vo&&t.status!==Go&&t.status!==Zt&&t.status!==Gn?1:0},Ts=e=>{if(Wn(e))return qt(e,dt);e.total_in=e.total_out=0,e.data_type=of;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Wo:t.wrap?bn:Zt,e.adler=t.wrap===2?0:1,t.last_flush=-2,Hd(t),Ae},js=e=>{let t=Ts(e);return t===Ae&&Sf(e.state),t},xf=(e,t)=>Wn(e)||e.state.wrap!==2?dt:(e.state.gzhead=t,Ae),zs=(e,t,n,i,o,r)=>{if(!e)return dt;let s=1;if(t===Jd&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),o<1||o>rf||n!==_i||i<8||i>15||t<0||t>9||r<0||r>tf||i===8&&s!==1)return qt(e,dt);i===8&&(i=9);let a=new vf;return e.state=a,a.strm=e,a.status=bn,a.wrap=s,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=o+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+Q-1)/Q),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<o+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=t,a.strategy=r,a.method=n,js(e)},_f=(e,t)=>zs(e,t,_i,sf,af,nf),Af=(e,t)=>{if(Wn(e)||t>Os||t<0)return e?qt(e,dt):dt;let n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===Gn&&t!==qe)return qt(e,e.avail_out===0?Mo:dt);let i=n.last_flush;if(n.last_flush=t,n.pending!==0){if(Ne(e),e.avail_out===0)return n.last_flush=-1,Ae}else if(e.avail_in===0&&Bs(t)<=Bs(i)&&t!==qe)return qt(e,Mo);if(n.status===Gn&&e.avail_in!==0)return qt(e,Mo);if(n.status===bn&&n.wrap===0&&(n.status=Zt),n.status===bn){let o=_i+(n.w_bits-8<<4)<<8,r=-1;if(n.strategy>=xi||n.level<2?r=0:n.level<6?r=1:n.level===6?r=2:r=3,o|=r<<6,n.strstart!==0&&(o|=pf),o+=31-o%31,Vn(n,o),n.strstart!==0&&(Vn(n,e.adler>>>16),Vn(n,e.adler&65535)),e.adler=1,n.status=Zt,Ne(e),n.pending!==0)return n.last_flush=-1,Ae}if(n.status===Wo){if(e.adler=0,se(n,31),se(n,139),se(n,8),n.gzhead)se(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),se(n,n.gzhead.time&255),se(n,n.gzhead.time>>8&255),se(n,n.gzhead.time>>16&255),se(n,n.gzhead.time>>24&255),se(n,n.level===9?2:n.strategy>=xi||n.level<2?4:0),se(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(se(n,n.gzhead.extra.length&255),se(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Ot(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=$o;else if(se(n,0),se(n,0),se(n,0),se(n,0),se(n,0),se(n,n.level===9?2:n.strategy>=xi||n.level<2?4:0),se(n,mf),n.status=Zt,Ne(e),n.pending!==0)return n.last_flush=-1,Ae}if(n.status===$o){if(n.gzhead.extra){let o=n.pending,r=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex+=a,Ne(e),n.pending!==0)return n.last_flush=-1,Ae;o=0,r-=a}let s=new Uint8Array(n.gzhead.extra);n.pending_buf.set(s.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex=0}n.status=No}if(n.status===No){if(n.gzhead.name){let o=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),Ne(e),n.pending!==0)return n.last_flush=-1,Ae;o=0}n.gzindex<n.gzhead.name.length?r=n.gzhead.name.charCodeAt(n.gzindex++)&255:r=0,se(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex=0}n.status=Vo}if(n.status===Vo){if(n.gzhead.comment){let o=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),Ne(e),n.pending!==0)return n.last_flush=-1,Ae;o=0}n.gzindex<n.gzhead.comment.length?r=n.gzhead.comment.charCodeAt(n.gzindex++)&255:r=0,se(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o))}n.status=Go}if(n.status===Go){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Ne(e),n.pending!==0))return n.last_flush=-1,Ae;se(n,e.adler&255),se(n,e.adler>>8&255),e.adler=0}if(n.status=Zt,Ne(e),n.pending!==0)return n.last_flush=-1,Ae}if(e.avail_in!==0||n.lookahead!==0||t!==Rt&&n.status!==Gn){let o=n.level===0?Ms(n,t):n.strategy===xi?wf(n,t):n.strategy===ef?yf(n,t):Hn[n.level].func(n,t);if((o===Kt||o===Sn)&&(n.status=Gn),o===Ue||o===Kt)return e.avail_out===0&&(n.last_flush=-1),Ae;if(o===wn&&(t===qd?Xd(n):t!==Os&&(jo(n,0,0,!1),t===Kd&&(Lt(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Ne(e),e.avail_out===0))return n.last_flush=-1,Ae}return t!==qe?Ae:n.wrap<=0?Ls:(n.wrap===2?(se(n,e.adler&255),se(n,e.adler>>8&255),se(n,e.adler>>16&255),se(n,e.adler>>24&255),se(n,e.total_in&255),se(n,e.total_in>>8&255),se(n,e.total_in>>16&255),se(n,e.total_in>>24&255)):(Vn(n,e.adler>>>16),Vn(n,e.adler&65535)),Ne(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Ae:Ls)},kf=e=>{if(Wn(e))return dt;let t=e.state.status;return e.state=null,t===Zt?qt(e,Yd):Ae},If=(e,t)=>{let n=t.length;if(Wn(e))return dt;let i=e.state,o=i.wrap;if(o===2||o===1&&i.status!==bn||i.lookahead)return dt;if(o===1&&(e.adler=Us(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){o===0&&(Lt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let l=new Uint8Array(i.w_size);l.set(t.subarray(n-i.w_size,n),0),t=l,n=i.w_size}let r=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,yn(i);i.lookahead>=Q;){let l=i.strstart,c=i.lookahead-(Q-1);do i.ins_h=Mt(i,i.ins_h,i.window[l+Q-1]),i.prev[l&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=l,l++;while(--c);i.strstart=l,i.lookahead=Q-1,yn(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=Q-1,i.match_available=0,e.next_in=s,e.input=a,e.avail_in=r,i.wrap=o,Ae};ut.exports.deflateInit=_f;ut.exports.deflateInit2=zs;ut.exports.deflateReset=js;ut.exports.deflateResetKeep=Ts;ut.exports.deflateSetHeader=xf;ut.exports.deflate=Af;ut.exports.deflateEnd=kf;ut.exports.deflateSetDictionary=If;ut.exports.deflateInfo="pako deflate (from Nodeca project)"});var Zo=oe((Kp,Xo)=>{"use strict";var Df=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);Xo.exports.assign=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(let i in n)Df(n,i)&&(e[i]=n[i])}}return e};Xo.exports.flattenChunks=e=>{let t=0;for(let i=0,o=e.length;i<o;i++)t+=e[i].length;let n=new Uint8Array(t);for(let i=0,o=0,r=e.length;i<r;i++){let s=e[i];n.set(s,o),o+=s.length}return n}});var qo=oe((Yp,Ai)=>{"use strict";var Ns=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Ns=!1}var Xn=new Uint8Array(256);for(let e=0;e<256;e++)Xn[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Xn[254]=Xn[254]=1;Ai.exports.string2buf=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,i,o,r,s=e.length,a=0;for(o=0;o<s;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),o++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(a),r=0,o=0;r<a;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),o++)),n<128?t[r++]=n:n<2048?(t[r++]=192|n>>>6,t[r++]=128|n&63):n<65536?(t[r++]=224|n>>>12,t[r++]=128|n>>>6&63,t[r++]=128|n&63):(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63,t[r++]=128|n>>>6&63,t[r++]=128|n&63);return t};var Cf=(e,t)=>{if(t<65534&&e.subarray&&Ns)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n};Ai.exports.buf2string=(e,t)=>{let n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let i,o,r=new Array(n*2);for(o=0,i=0;i<n;){let s=e[i++];if(s<128){r[o++]=s;continue}let a=Xn[s];if(a>4){r[o++]=65533,i+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&i<n;)s=s<<6|e[i++]&63,a--;if(a>1){r[o++]=65533;continue}s<65536?r[o++]=s:(s-=65536,r[o++]=55296|s>>10&1023,r[o++]=56320|s&1023)}return Cf(r,o)};Ai.exports.utf8border=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+Xn[e[n]]>t?n:t}});var Ko=oe((Jp,Vs)=>{"use strict";function Pf(){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}Vs.exports=Pf});var Xs=oe((Qp,vn)=>{"use strict";var Zn=$s(),Gs=Zo(),Hs=qo(),Yo=vi(),Ef=Ko(),Ws=Object.prototype.toString,{Z_NO_FLUSH:Ff,Z_SYNC_FLUSH:Of,Z_FULL_FLUSH:Lf,Z_FINISH:Bf,Z_OK:ki,Z_STREAM_END:Uf,Z_DEFAULT_COMPRESSION:Rf,Z_DEFAULT_STRATEGY:Mf,Z_DEFLATED:Tf}=Ft();function qn(e){this.options=Gs.assign({level:Rf,method:Tf,chunkSize:16384,windowBits:15,memLevel:8,strategy:Mf},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ef,this.strm.avail_out=0;let n=Zn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ki)throw new Error(Yo[n]);if(t.header&&Zn.deflateSetHeader(this.strm,t.header),t.dictionary){let i;if(typeof t.dictionary=="string"?i=Hs.string2buf(t.dictionary):Ws.call(t.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(t.dictionary):i=t.dictionary,n=Zn.deflateSetDictionary(this.strm,i),n!==ki)throw new Error(Yo[n]);this._dict_set=!0}}qn.prototype.push=function(e,t){let n=this.strm,i=this.options.chunkSize,o,r;if(this.ended)return!1;for(t===~~t?r=t:r=t===!0?Bf:Ff,typeof e=="string"?n.input=Hs.string2buf(e):Ws.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),(r===Of||r===Lf)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(o=Zn.deflate(n,r),o===Uf)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),o=Zn.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===ki;if(n.avail_out===0){this.onData(n.output);continue}if(r>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};qn.prototype.onData=function(e){this.chunks.push(e)};qn.prototype.onEnd=function(e){e===ki&&(this.result=Gs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Jo(e,t){let n=new qn(t);if(n.push(e,!0),n.err)throw n.msg||Yo[n.err];return n.result}function jf(e,t){return t=t||{},t.raw=!0,Jo(e,t)}function zf(e,t){return t=t||{},t.gzip=!0,Jo(e,t)}vn.exports.Deflate=qn;vn.exports.deflate=Jo;vn.exports.deflateRaw=jf;vn.exports.gzip=zf;vn.exports.constants=Ft()});var qs=oe((em,Zs)=>{"use strict";Zs.exports=function(t,n){let i,o,r,s,a,l,c,d,u,f,h,p,S,m,g,v,x,_,I,P,k,E,O,U,M=t.state;i=t.next_in,O=t.input,o=i+(t.avail_in-5),r=t.next_out,U=t.output,s=r-(n-t.avail_out),a=r+(t.avail_out-257),l=M.dmax,c=M.wsize,d=M.whave,u=M.wnext,f=M.window,h=M.hold,p=M.bits,S=M.lencode,m=M.distcode,g=(1<<M.lenbits)-1,v=(1<<M.distbits)-1;e:do{p<15&&(h+=O[i++]<<p,p+=8,h+=O[i++]<<p,p+=8),x=S[h&g];t:for(;;){if(_=x>>>24,h>>>=_,p-=_,_=x>>>16&255,_===0)U[r++]=x&65535;else if(_&16){I=x&65535,_&=15,_&&(p<_&&(h+=O[i++]<<p,p+=8),I+=h&(1<<_)-1,h>>>=_,p-=_),p<15&&(h+=O[i++]<<p,p+=8,h+=O[i++]<<p,p+=8),x=m[h&v];n:for(;;){if(_=x>>>24,h>>>=_,p-=_,_=x>>>16&255,_&16){if(P=x&65535,_&=15,p<_&&(h+=O[i++]<<p,p+=8,p<_&&(h+=O[i++]<<p,p+=8)),P+=h&(1<<_)-1,P>l){t.msg="invalid distance too far back",M.mode=16209;break e}if(h>>>=_,p-=_,_=r-s,P>_){if(_=P-_,_>d&&M.sane){t.msg="invalid distance too far back",M.mode=16209;break e}if(k=0,E=f,u===0){if(k+=c-_,_<I){I-=_;do U[r++]=f[k++];while(--_);k=r-P,E=U}}else if(u<_){if(k+=c+u-_,_-=u,_<I){I-=_;do U[r++]=f[k++];while(--_);if(k=0,u<I){_=u,I-=_;do U[r++]=f[k++];while(--_);k=r-P,E=U}}}else if(k+=u-_,_<I){I-=_;do U[r++]=f[k++];while(--_);k=r-P,E=U}for(;I>2;)U[r++]=E[k++],U[r++]=E[k++],U[r++]=E[k++],I-=3;I&&(U[r++]=E[k++],I>1&&(U[r++]=E[k++]))}else{k=r-P;do U[r++]=U[k++],U[r++]=U[k++],U[r++]=U[k++],I-=3;while(I>2);I&&(U[r++]=U[k++],I>1&&(U[r++]=U[k++]))}}else if((_&64)===0){x=m[(x&65535)+(h&(1<<_)-1)];continue n}else{t.msg="invalid distance code",M.mode=16209;break e}break}}else if((_&64)===0){x=S[(x&65535)+(h&(1<<_)-1)];continue t}else if(_&32){M.mode=16191;break e}else{t.msg="invalid literal/length code",M.mode=16209;break e}break}}while(i<o&&r<a);I=p>>3,i-=I,p-=I<<3,h&=(1<<p)-1,t.next_in=i,t.next_out=r,t.avail_in=i<o?5+(o-i):5-(i-o),t.avail_out=r<a?257+(a-r):257-(r-a),M.hold=h,M.bits=p}});var Ys=oe((tm,Ks)=>{"use strict";var $f=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]),Nf=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]),Vf=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]),Gf=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]),Hf=(e,t,n,i,o,r,s,a)=>{let l=a.bits,c=0,d=0,u=0,f=0,h=0,p=0,S=0,m=0,g=0,v=0,x,_,I,P,k,E=null,O,U=new Uint16Array(16),M=new Uint16Array(16),le=null,me,T,W;for(c=0;c<=15;c++)U[c]=0;for(d=0;d<i;d++)U[t[n+d]]++;for(h=l,f=15;f>=1&&U[f]===0;f--);if(h>f&&(h=f),f===0)return o[r++]=1<<24|64<<16|0,o[r++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<f&&U[u]===0;u++);for(h<u&&(h=u),m=1,c=1;c<=15;c++)if(m<<=1,m-=U[c],m<0)return-1;if(m>0&&(e===0||f!==1))return-1;for(M[1]=0,c=1;c<15;c++)M[c+1]=M[c]+U[c];for(d=0;d<i;d++)t[n+d]!==0&&(s[M[t[n+d]]++]=d);if(e===0?(E=le=s,O=20):e===1?(E=$f,le=Nf,O=257):(E=Vf,le=Gf,O=0),v=0,d=0,c=u,k=r,p=h,S=0,I=-1,g=1<<h,P=g-1,e===1&&g>852||e===2&&g>592)return 1;for(;;){me=c-S,s[d]+1<O?(T=0,W=s[d]):s[d]>=O?(T=le[s[d]-O],W=E[s[d]-O]):(T=96,W=0),x=1<<c-S,_=1<<p,u=_;do _-=x,o[k+(v>>S)+_]=me<<24|T<<16|W|0;while(_!==0);for(x=1<<c-1;v&x;)x>>=1;if(x!==0?(v&=x-1,v+=x):v=0,d++,--U[c]===0){if(c===f)break;c=t[n+s[d]]}if(c>h&&(v&P)!==I){for(S===0&&(S=h),k+=u,p=c-S,m=1<<p;p+S<f&&(m-=U[p+S],!(m<=0));)p++,m<<=1;if(g+=1<<p,e===1&&g>852||e===2&&g>592)return 1;I=v&P,o[I]=h<<24|p<<16|k-r|0}}return v!==0&&(o[k+v]=c-S<<24|64<<16|0),a.bits=h,0};Ks.exports=Hf});var Oa=oe((nm,nt)=>{"use strict";var or=Uo(),ht=Ro(),Wf=qs(),Kn=Ys(),Xf=0,_a=1,Aa=2,{Z_FINISH:Js,Z_BLOCK:Zf,Z_TREES:Ii,Z_OK:Yt,Z_STREAM_END:qf,Z_NEED_DICT:Kf,Z_STREAM_ERROR:Ke,Z_DATA_ERROR:ka,Z_MEM_ERROR:rr,Z_BUF_ERROR:Yf,Z_DEFLATED:Qs}=Ft(),Ei=16180,ea=16181,ta=16182,na=16183,ia=16184,oa=16185,ra=16186,sa=16187,aa=16188,la=16189,Pi=16190,xt=16191,Qo=16192,ca=16193,er=16194,da=16195,fa=16196,ua=16197,ha=16198,Di=16199,Ci=16200,pa=16201,ma=16202,ga=16203,ba=16204,ya=16205,tr=16206,wa=16207,Sa=16208,be=16209,sr=16210,Ia=16211,Jf=852,Qf=592,eu=15,tu=eu,va=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function nu(){this.strm=null,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}var Jt=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<Ei||t.mode>Ia?1:0},Da=e=>{if(Jt(e))return Ke;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Ei,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Jf),t.distcode=t.distdyn=new Int32Array(Qf),t.sane=1,t.back=-1,Yt},Ca=e=>{if(Jt(e))return Ke;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Da(e)},Pa=(e,t)=>{let n;if(Jt(e))return Ke;let i=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Ke:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,Ca(e))},Ea=(e,t)=>{if(!e)return Ke;let n=new nu;e.state=n,n.strm=e,n.window=null,n.mode=Ei;let i=Pa(e,t);return i!==Yt&&(e.state=null),i},iu=e=>Ea(e,tu),xa=!0,nr,ir,ou=e=>{if(xa){nr=new Int32Array(512),ir=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Kn(_a,e.lens,0,288,nr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Kn(Aa,e.lens,0,32,ir,0,e.work,{bits:5}),xa=!1}e.lencode=nr,e.lenbits=9,e.distcode=ir,e.distbits=5},Fa=(e,t,n,i)=>{let o,r=e.state;return r.window===null&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),i>=r.wsize?(r.window.set(t.subarray(n-r.wsize,n),0),r.wnext=0,r.whave=r.wsize):(o=r.wsize-r.wnext,o>i&&(o=i),r.window.set(t.subarray(n-i,n-i+o),r.wnext),i-=o,i?(r.window.set(t.subarray(n-i,n),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=o,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=o))),0},ru=(e,t)=>{let n,i,o,r,s,a,l,c,d,u,f,h,p,S,m=0,g,v,x,_,I,P,k,E,O=new Uint8Array(4),U,M,le=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Jt(e)||!e.output||!e.input&&e.avail_in!==0)return Ke;n=e.state,n.mode===xt&&(n.mode=Qo),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=n.hold,d=n.bits,u=a,f=l,E=Yt;e:for(;;)switch(n.mode){case Ei:if(n.wrap===0){n.mode=Qo;break}for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.wrap&2&&c===35615){n.wbits===0&&(n.wbits=15),n.check=0,O[0]=c&255,O[1]=c>>>8&255,n.check=ht(n.check,O,2,0),c=0,d=0,n.mode=ea;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=be;break}if((c&15)!==Qs){e.msg="unknown compression method",n.mode=be;break}if(c>>>=4,d-=4,k=(c&15)+8,n.wbits===0&&(n.wbits=k),k>15||k>n.wbits){e.msg="invalid window size",n.mode=be;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=c&512?la:xt,c=0,d=0;break;case ea:for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.flags=c,(n.flags&255)!==Qs){e.msg="unknown compression method",n.mode=be;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=be;break}n.head&&(n.head.text=c>>8&1),n.flags&512&&n.wrap&4&&(O[0]=c&255,O[1]=c>>>8&255,n.check=ht(n.check,O,2,0)),c=0,d=0,n.mode=ta;case ta:for(;d<32;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.head&&(n.head.time=c),n.flags&512&&n.wrap&4&&(O[0]=c&255,O[1]=c>>>8&255,O[2]=c>>>16&255,O[3]=c>>>24&255,n.check=ht(n.check,O,4,0)),c=0,d=0,n.mode=na;case na:for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.head&&(n.head.xflags=c&255,n.head.os=c>>8),n.flags&512&&n.wrap&4&&(O[0]=c&255,O[1]=c>>>8&255,n.check=ht(n.check,O,2,0)),c=0,d=0,n.mode=ia;case ia:if(n.flags&1024){for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),n.flags&512&&n.wrap&4&&(O[0]=c&255,O[1]=c>>>8&255,n.check=ht(n.check,O,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=oa;case oa:if(n.flags&1024&&(h=n.length,h>a&&(h=a),h&&(n.head&&(k=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(r,r+h),k)),n.flags&512&&n.wrap&4&&(n.check=ht(n.check,i,h,r)),a-=h,r+=h,n.length-=h),n.length))break e;n.length=0,n.mode=ra;case ra:if(n.flags&2048){if(a===0)break e;h=0;do k=i[r+h++],n.head&&k&&n.length<65536&&(n.head.name+=String.fromCharCode(k));while(k&&h<a);if(n.flags&512&&n.wrap&4&&(n.check=ht(n.check,i,h,r)),a-=h,r+=h,k)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=sa;case sa:if(n.flags&4096){if(a===0)break e;h=0;do k=i[r+h++],n.head&&k&&n.length<65536&&(n.head.comment+=String.fromCharCode(k));while(k&&h<a);if(n.flags&512&&n.wrap&4&&(n.check=ht(n.check,i,h,r)),a-=h,r+=h,k)break e}else n.head&&(n.head.comment=null);n.mode=aa;case aa:if(n.flags&512){for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.wrap&4&&c!==(n.check&65535)){e.msg="header crc mismatch",n.mode=be;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=xt;break;case la:for(;d<32;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}e.adler=n.check=va(c),c=0,d=0,n.mode=Pi;case Pi:if(n.havedict===0)return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,n.hold=c,n.bits=d,Kf;e.adler=n.check=1,n.mode=xt;case xt:if(t===Zf||t===Ii)break e;case Qo:if(n.last){c>>>=d&7,d-=d&7,n.mode=tr;break}for(;d<3;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}switch(n.last=c&1,c>>>=1,d-=1,c&3){case 0:n.mode=ca;break;case 1:if(ou(n),n.mode=Di,t===Ii){c>>>=2,d-=2;break e}break;case 2:n.mode=fa;break;case 3:e.msg="invalid block type",n.mode=be}c>>>=2,d-=2;break;case ca:for(c>>>=d&7,d-=d&7;d<32;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=be;break}if(n.length=c&65535,c=0,d=0,n.mode=er,t===Ii)break e;case er:n.mode=da;case da:if(h=n.length,h){if(h>a&&(h=a),h>l&&(h=l),h===0)break e;o.set(i.subarray(r,r+h),s),a-=h,r+=h,l-=h,s+=h,n.length-=h;break}n.mode=xt;break;case fa:for(;d<14;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.nlen=(c&31)+257,c>>>=5,d-=5,n.ndist=(c&31)+1,c>>>=5,d-=5,n.ncode=(c&15)+4,c>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=be;break}n.have=0,n.mode=ua;case ua:for(;n.have<n.ncode;){for(;d<3;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.lens[le[n.have++]]=c&7,c>>>=3,d-=3}for(;n.have<19;)n.lens[le[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,U={bits:n.lenbits},E=Kn(Xf,n.lens,0,19,n.lencode,0,n.work,U),n.lenbits=U.bits,E){e.msg="invalid code lengths set",n.mode=be;break}n.have=0,n.mode=ha;case ha:for(;n.have<n.nlen+n.ndist;){for(;m=n.lencode[c&(1<<n.lenbits)-1],g=m>>>24,v=m>>>16&255,x=m&65535,!(g<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(x<16)c>>>=g,d-=g,n.lens[n.have++]=x;else{if(x===16){for(M=g+2;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(c>>>=g,d-=g,n.have===0){e.msg="invalid bit length repeat",n.mode=be;break}k=n.lens[n.have-1],h=3+(c&3),c>>>=2,d-=2}else if(x===17){for(M=g+3;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}c>>>=g,d-=g,k=0,h=3+(c&7),c>>>=3,d-=3}else{for(M=g+7;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}c>>>=g,d-=g,k=0,h=11+(c&127),c>>>=7,d-=7}if(n.have+h>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=be;break}for(;h--;)n.lens[n.have++]=k}}if(n.mode===be)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=be;break}if(n.lenbits=9,U={bits:n.lenbits},E=Kn(_a,n.lens,0,n.nlen,n.lencode,0,n.work,U),n.lenbits=U.bits,E){e.msg="invalid literal/lengths set",n.mode=be;break}if(n.distbits=6,n.distcode=n.distdyn,U={bits:n.distbits},E=Kn(Aa,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,U),n.distbits=U.bits,E){e.msg="invalid distances set",n.mode=be;break}if(n.mode=Di,t===Ii)break e;case Di:n.mode=Ci;case Ci:if(a>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,n.hold=c,n.bits=d,Wf(e,f),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=n.hold,d=n.bits,n.mode===xt&&(n.back=-1);break}for(n.back=0;m=n.lencode[c&(1<<n.lenbits)-1],g=m>>>24,v=m>>>16&255,x=m&65535,!(g<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(v&&(v&240)===0){for(_=g,I=v,P=x;m=n.lencode[P+((c&(1<<_+I)-1)>>_)],g=m>>>24,v=m>>>16&255,x=m&65535,!(_+g<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}c>>>=_,d-=_,n.back+=_}if(c>>>=g,d-=g,n.back+=g,n.length=x,v===0){n.mode=ya;break}if(v&32){n.back=-1,n.mode=xt;break}if(v&64){e.msg="invalid literal/length code",n.mode=be;break}n.extra=v&15,n.mode=pa;case pa:if(n.extra){for(M=n.extra;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=ma;case ma:for(;m=n.distcode[c&(1<<n.distbits)-1],g=m>>>24,v=m>>>16&255,x=m&65535,!(g<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if((v&240)===0){for(_=g,I=v,P=x;m=n.distcode[P+((c&(1<<_+I)-1)>>_)],g=m>>>24,v=m>>>16&255,x=m&65535,!(_+g<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}c>>>=_,d-=_,n.back+=_}if(c>>>=g,d-=g,n.back+=g,v&64){e.msg="invalid distance code",n.mode=be;break}n.offset=x,n.extra=v&15,n.mode=ga;case ga:if(n.extra){for(M=n.extra;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=be;break}n.mode=ba;case ba:if(l===0)break e;if(h=f-l,n.offset>h){if(h=n.offset-h,h>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=be;break}h>n.wnext?(h-=n.wnext,p=n.wsize-h):p=n.wnext-h,h>n.length&&(h=n.length),S=n.window}else S=o,p=s-n.offset,h=n.length;h>l&&(h=l),l-=h,n.length-=h;do o[s++]=S[p++];while(--h);n.length===0&&(n.mode=Ci);break;case ya:if(l===0)break e;o[s++]=n.length,l--,n.mode=Ci;break;case tr:if(n.wrap){for(;d<32;){if(a===0)break e;a--,c|=i[r++]<<d,d+=8}if(f-=l,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?ht(n.check,o,f,s-f):or(n.check,o,f,s-f)),f=l,n.wrap&4&&(n.flags?c:va(c))!==n.check){e.msg="incorrect data check",n.mode=be;break}c=0,d=0}n.mode=wa;case wa:if(n.wrap&&n.flags){for(;d<32;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.wrap&4&&c!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=be;break}c=0,d=0}n.mode=Sa;case Sa:E=qf;break e;case be:E=ka;break e;case sr:return rr;case Ia:default:return Ke}return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,n.hold=c,n.bits=d,(n.wsize||f!==e.avail_out&&n.mode<be&&(n.mode<tr||t!==Js))&&Fa(e,e.output,e.next_out,f-e.avail_out)?(n.mode=sr,rr):(u-=e.avail_in,f-=e.avail_out,e.total_in+=u,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?ht(n.check,o,f,e.next_out-f):or(n.check,o,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===xt?128:0)+(n.mode===Di||n.mode===er?256:0),(u===0&&f===0||t===Js)&&E===Yt&&(E=Yf),E)},su=e=>{if(Jt(e))return Ke;let t=e.state;return t.window&&(t.window=null),e.state=null,Yt},au=(e,t)=>{if(Jt(e))return Ke;let n=e.state;return(n.wrap&2)===0?Ke:(n.head=t,t.done=!1,Yt)},lu=(e,t)=>{let n=t.length,i,o,r;return Jt(e)||(i=e.state,i.wrap!==0&&i.mode!==Pi)?Ke:i.mode===Pi&&(o=1,o=or(o,t,n,0),o!==i.check)?ka:(r=Fa(e,t,n,n),r?(i.mode=sr,rr):(i.havedict=1,Yt))};nt.exports.inflateReset=Ca;nt.exports.inflateReset2=Pa;nt.exports.inflateResetKeep=Da;nt.exports.inflateInit=iu;nt.exports.inflateInit2=Ea;nt.exports.inflate=ru;nt.exports.inflateEnd=su;nt.exports.inflateGetHeader=au;nt.exports.inflateSetDictionary=lu;nt.exports.inflateInfo="pako inflate (from Nodeca project)"});var Ba=oe((im,La)=>{"use strict";function cu(){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}La.exports=cu});var Ta=oe((om,xn)=>{"use strict";var _t=Oa(),Ra=Zo(),cr=qo(),dr=vi(),du=Ko(),fu=Ba(),Ma=Object.prototype.toString,{Z_NO_FLUSH:uu,Z_FINISH:hu,Z_OK:Yn,Z_STREAM_END:ar,Z_NEED_DICT:lr,Z_STREAM_ERROR:pu,Z_DATA_ERROR:Ua,Z_MEM_ERROR:mu}=Ft();function Jn(e){this.options=Ra.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new du,this.strm.avail_out=0;let n=_t.inflateInit2(this.strm,t.windowBits);if(n!==Yn)throw new Error(dr[n]);if(this.header=new fu,_t.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=cr.string2buf(t.dictionary):Ma.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=_t.inflateSetDictionary(this.strm,t.dictionary),n!==Yn)))throw new Error(dr[n])}Jn.prototype.push=function(e,t){let n=this.strm,i=this.options.chunkSize,o=this.options.dictionary,r,s,a;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?hu:uu,Ma.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),r=_t.inflate(n,s),r===lr&&o&&(r=_t.inflateSetDictionary(n,o),r===Yn?r=_t.inflate(n,s):r===Ua&&(r=lr));n.avail_in>0&&r===ar&&n.state.wrap>0&&e[n.next_in]!==0;)_t.inflateReset(n),r=_t.inflate(n,s);switch(r){case pu:case Ua:case lr:case mu:return this.onEnd(r),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(n.avail_out===0||r===ar))if(this.options.to==="string"){let l=cr.utf8border(n.output,n.next_out),c=n.next_out-l,d=cr.buf2string(n.output,l);n.next_out=c,n.avail_out=i-c,c&&n.output.set(n.output.subarray(l,l+c),0),this.onData(d)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(r===Yn&&a===0)){if(r===ar)return r=_t.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Jn.prototype.onData=function(e){this.chunks.push(e)};Jn.prototype.onEnd=function(e){e===Yn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ra.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function fr(e,t){let n=new Jn(t);if(n.push(e),n.err)throw n.msg||dr[n.err];return n.result}function gu(e,t){return t=t||{},t.raw=!0,fr(e,t)}xn.exports.Inflate=Jn;xn.exports.inflate=fr;xn.exports.inflateRaw=gu;xn.exports.ungzip=fr;xn.exports.constants=Ft()});var ur=oe((rm,pt)=>{"use strict";var{Deflate:bu,deflate:yu,deflateRaw:wu,gzip:Su}=Xs(),{Inflate:vu,inflate:xu,inflateRaw:_u,ungzip:Au}=Ta(),ku=Ft();pt.exports.Deflate=bu;pt.exports.deflate=yu;pt.exports.deflateRaw=wu;pt.exports.gzip=Su;pt.exports.Inflate=vu;pt.exports.inflate=xu;pt.exports.inflateRaw=_u;pt.exports.ungzip=Au;pt.exports.constants=ku});var za=oe(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});pr.decodeJpeg=Ou;var Qn=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),Fi=4017,Oi=799,Li=3406,Bi=2276,Ui=1567,Ri=3784,_n=5793,Mi=2896,Iu=100,ja=64*1024*1024,hr=0;function An(e){let t=hr+e;if(t>ja){let n=Math.ceil((t-ja)/1024/1024);throw new Error(`Max memory limit exceeded by at least ${n}MB`)}hr=t}function Du(e,t){let n=16;for(;n>0&&!e[n-1];)n--;let i=[{children:[],index:0}],o=0,r=i[0];for(let s=0;s<n;s++){for(let a=0;a<e[s];a++){for(r=i.pop(),r.children[r.index]=t[o];r.index>0;){if(i.length===0)throw new Error("Could not recreate Huffman Table");r=i.pop()}for(r.index++,i.push(r);i.length<=s;){let l={children:[],index:0};i.push(l),r.children[r.index]=l.children,r=l}o++}if(s+1<n){let a={children:[],index:0};i.push(a),r.children[r.index]=a.children,r=a}}return i[0].children}function Cu(e,t,n,i,o,r,s,a,l){let c=n.mcusPerLine,d=n.progressive,u=t,f=0,h=0;function p(){if(h>0)return h--,f>>h&1;if(f=e[t++],f==255){let j=e[t++];if(j)throw new Error(`unexpected marker: ${(f<<8|j).toString(16)}`)}return h=7,f>>>7}function S(j){let R=j;for(;;){if(R=R[p()],typeof R=="number")return R;if(R===void 0)throw new Error("invalid huffman sequence")}}function m(j){let R=0;for(;j>0;)R=R<<1|p(),j--;return R}function g(j){let R=m(j);return R>=1<<j-1?R:R+(-1<<j)+1}function v(j,R){let V=S(j.huffmanTableDC),fe=V===0?0:g(V);R[0]=j.pred+=fe;let ie=1;for(;ie<64;){let he=S(j.huffmanTableAC),we=he&15,$e=he>>4;if(we===0){if($e<15)break;ie+=16;continue}ie+=$e;let at=Qn[ie];R[at]=g(we),ie++}}function x(j,R){let V=S(j.huffmanTableDC),fe=V===0?0:g(V)<<l;R[0]=j.pred+=fe}function _(j,R){R[0]|=p()<<l}let I=0;function P(j,R){if(I>0){I--;return}let V=r,fe=s;for(;V<=fe;){let ie=S(j.huffmanTableAC),he=ie&15,we=ie>>4;if(he===0){if(we<15){I=m(we)+(1<<we)-1;break}V+=16;continue}V+=we;let $e=Qn[V];R[$e]=g(he)*(1<<l),V++}}let k=0,E=0;function O(j,R){let V=r,fe=s,ie=0;for(;V<=fe;){let he=Qn[V],we=R[he]<0?-1:1;switch(k){case 0:let $e=S(j.huffmanTableAC),at=$e&15;if(ie=$e>>4,at===0)ie<15?(I=m(ie)+(1<<ie),k=4):(ie=16,k=1);else{if(at!==1)throw new Error("invalid ACn encoding");E=g(at),k=ie?2:3}continue;case 1:case 2:R[he]?R[he]+=(p()<<l)*we:(ie--,ie===0&&(k=k==2?3:0));break;case 3:R[he]?R[he]+=(p()<<l)*we:(R[he]=E<<l,k=0);break;case 4:R[he]&&(R[he]+=(p()<<l)*we);break}V++}k===4&&(I--,I===0&&(k=0))}function U(j,R,V,fe,ie){let he=V/c|0,we=V%c,$e=he*j.v+fe,at=we*j.h+ie;j.blocks[$e]!==void 0&&R(j,j.blocks[$e][at])}function M(j,R,V){let fe=V/j.blocksPerLine|0,ie=V%j.blocksPerLine;j.blocks[fe]!==void 0&&R(j,j.blocks[fe][ie])}let le=i.length,me,T;d?r===0?T=a===0?x:_:T=a===0?P:O:T=v;let W=0,te;le==1?te=i[0].blocksPerLine*i[0].blocksPerColumn:te=c*n.mcusPerColumn,o||(o=te);let ne,Pe,Ee;for(;W<te;){for(let j=0;j<le;j++)i[j].pred=0;if(I=0,le==1){me=i[0];for(let j=0;j<o;j++)M(me,T,W),W++}else for(let j=0;j<o;j++){for(let R=0;R<le;R++){me=i[R],ne=me.h,Pe=me.v;for(let V=0;V<Pe;V++)for(let fe=0;fe<ne;fe++)U(me,T,W,V,fe)}if(W++,W===te)break}if(W===te)do{if(e[t]===255&&e[t+1]!==0)break;t+=1}while(t<e.length-2);if(h=0,Ee=e[t]<<8|e[t+1],Ee<65280)throw new Error("marker was not found");if(Ee>=65488&&Ee<=65495)t+=2;else break}return t-u}function Pu(e){let t=[],n=e.blocksPerLine,i=e.blocksPerColumn,o=n<<3,r=new Int32Array(64),s=new Uint8Array(64);function a(l,c,d){let u=e.quantizationTable,f=d;for(let h=0;h<64;h++)f[h]=l[h]*u[h];for(let h=0;h<8;++h){let p=8*h;if(f[1+p]==0&&f[2+p]==0&&f[3+p]==0&&f[4+p]==0&&f[5+p]==0&&f[6+p]==0&&f[7+p]==0){let E=_n*f[0+p]+512>>10;f[0+p]=E,f[1+p]=E,f[2+p]=E,f[3+p]=E,f[4+p]=E,f[5+p]=E,f[6+p]=E,f[7+p]=E;continue}let S=_n*f[0+p]+128>>8,m=_n*f[4+p]+128>>8,g=f[2+p],v=f[6+p],x=Mi*(f[1+p]-f[7+p])+128>>8,_=Mi*(f[1+p]+f[7+p])+128>>8,I=f[3+p]<<4,P=f[5+p]<<4,k=S-m+1>>1;S=S+m+1>>1,m=k,k=g*Ri+v*Ui+128>>8,g=g*Ui-v*Ri+128>>8,v=k,k=x-P+1>>1,x=x+P+1>>1,P=k,k=_+I+1>>1,I=_-I+1>>1,_=k,k=S-v+1>>1,S=S+v+1>>1,v=k,k=m-g+1>>1,m=m+g+1>>1,g=k,k=x*Bi+_*Li+2048>>12,x=x*Li-_*Bi+2048>>12,_=k,k=I*Oi+P*Fi+2048>>12,I=I*Fi-P*Oi+2048>>12,P=k,f[0+p]=S+_,f[7+p]=S-_,f[1+p]=m+P,f[6+p]=m-P,f[2+p]=g+I,f[5+p]=g-I,f[3+p]=v+x,f[4+p]=v-x}for(let h=0;h<8;++h){let p=h;if(f[8+p]==0&&f[16+p]==0&&f[24+p]==0&&f[32+p]==0&&f[40+p]==0&&f[48+p]==0&&f[56+p]==0){let E=_n*d[h+0]+8192>>14;f[0+p]=E,f[8+p]=E,f[16+p]=E,f[24+p]=E,f[32+p]=E,f[40+p]=E,f[48+p]=E,f[56+p]=E;continue}let S=_n*f[0+p]+2048>>12,m=_n*f[32+p]+2048>>12,g=f[16+p],v=f[48+p],x=Mi*(f[8+p]-f[56+p])+2048>>12,_=Mi*(f[8+p]+f[56+p])+2048>>12,I=f[24+p],P=f[40+p],k=S-m+1>>1;S=S+m+1>>1,m=k,k=g*Ri+v*Ui+2048>>12,g=g*Ui-v*Ri+2048>>12,v=k,k=x-P+1>>1,x=x+P+1>>1,P=k,k=_+I+1>>1,I=_-I+1>>1,_=k,k=S-v+1>>1,S=S+v+1>>1,v=k,k=m-g+1>>1,m=m+g+1>>1,g=k,k=x*Bi+_*Li+2048>>12,x=x*Li-_*Bi+2048>>12,_=k,k=I*Oi+P*Fi+2048>>12,I=I*Fi-P*Oi+2048>>12,P=k,f[0+p]=S+_,f[56+p]=S-_,f[8+p]=m+P,f[48+p]=m-P,f[16+p]=g+I,f[40+p]=g-I,f[24+p]=v+x,f[32+p]=v-x}for(let h=0;h<64;++h){let p=128+(f[h]+8>>4);c[h]=p<0?0:p>255?255:p}}An(o*i*8);for(let l=0;l<i;l++){let c=l<<3;for(let d=0;d<8;d++)t.push(new Uint8Array(o));for(let d=0;d<n;d++){a(e.blocks[l][d],s,r);let u=0,f=d<<3;for(let h=0;h<8;h++){let p=t[c+h];for(let S=0;S<8;S++)p[f+S]=s[u++]}}}return t}function At(e){return e<0?0:e>255?255:e}function Eu(e){let t={width:0,height:0,adobe:void 0,components:[],exifBuffer:void 0,jfif:void 0},n=Iu*1e3*1e3,i=0;function o(){let g=e[i]<<8|e[i+1];return i+=2,g}function r(){let g=o(),v=e.subarray(i,i+g-2);return i+=v.length,v}function s(g){let v=0,x=0;for(let P in g.components)if(g.components.hasOwnProperty(P)){let k=g.components[P];v<k.h&&(v=k.h),x<k.v&&(x=k.v)}let _=Math.ceil(g.samplesPerLine/8/v),I=Math.ceil(g.scanLines/8/x);for(let P in g.components)if(g.components.hasOwnProperty(P)){let k=g.components[P],E=Math.ceil(Math.ceil(g.samplesPerLine/8)*k.h/v),O=Math.ceil(Math.ceil(g.scanLines/8)*k.v/x),U=_*k.h,M=I*k.v,le=M*U,me=[];An(le*256);for(let T=0;T<M;T++){let W=[];for(let te=0;te<U;te++)W.push(new Int32Array(64));me.push(W)}k.blocksPerLine=E,k.blocksPerColumn=O,k.blocks=me}g.maxH=v,g.maxV=x,g.mcusPerLine=_,g.mcusPerColumn=I}let a=null,l=null,c,d=0,u=[],f=[],h=[],p=[],S=o(),m=-1;if(S!=65496)throw new Error("SOI not found");for(S=o();S!=65497;){switch(S){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:{let g=r();S===65504&&g[0]===74&&g[1]===70&&g[2]===73&&g[3]===70&&g[4]===0&&(a={version:{major:g[5],minor:g[6]},densityUnits:g[7],xDensity:g[8]<<8|g[9],yDensity:g[10]<<8|g[11],thumbWidth:g[12],thumbHeight:g[13],thumbData:g.subarray(14,14+3*g[12]*g[13])}),S===65505&&g[0]===69&&g[1]===120&&g[2]===105&&g[3]===102&&g[4]===0&&(t.exifBuffer=g.subarray(5,g.length)),S===65518&&g[0]===65&&g[1]===100&&g[2]===111&&g[3]===98&&g[4]===101&&g[5]===0&&(l={version:g[6],flags0:g[7]<<8|g[8],flags1:g[9]<<8|g[10],transformCode:g[11]});break}case 65499:{let v=o()+i-2;for(;i<v;){let x=e[i++];An(256);let _=new Int32Array(64);if(x>>4===0)for(let I=0;I<64;I++){let P=Qn[I];_[P]=e[i++]}else if(x>>4===1)for(let I=0;I<64;I++){let P=Qn[I];_[P]=o()}else throw new Error("DQT: invalid table spec");u[x&15]=_}break}case 65472:case 65473:case 65474:{o(),c={extended:S===65473,progressive:S===65474,precision:e[i++],scanLines:o(),samplesPerLine:o(),components:{},componentsOrder:[],maxH:0,maxV:0,mcusPerLine:0,mcusPerColumn:0};let g=c.scanLines*c.samplesPerLine;if(g>n){let x=Math.ceil((g-n)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${x}MP`)}let v=e[i++];for(let x=0;x<v;x++){let _=e[i],I=e[i+1]>>4,P=e[i+1]&15,k=e[i+2];c.componentsOrder.push(_),c.components[_]={h:I,v:P,quantizationIdx:k,blocksPerColumn:0,blocksPerLine:0,blocks:[],pred:0},i+=3}s(c),f.push(c);break}case 65476:{let g=o();for(let v=2;v<g;){let x=e[i++],_=new Uint8Array(16),I=0;for(let O=0;O<16;O++,i++)I+=_[O]=e[i];An(16+I);let P=new Uint8Array(I);for(let O=0;O<I;O++,i++)P[O]=e[i];v+=17+I;let k=x&15,E=x>>4===0?p:h;E[k]=Du(_,P)}break}case 65501:o(),d=o();break;case 65500:o(),o();break;case 65498:{o();let g=e[i++],v=[];for(let k=0;k<g;k++){let E=c.components[e[i++]],O=e[i++];E.huffmanTableDC=p[O>>4],E.huffmanTableAC=h[O&15],v.push(E)}let x=e[i++],_=e[i++],I=e[i++],P=Cu(e,i,c,v,d,x,_,I>>4,I&15);i+=P;break}case 65535:e[i]!==255&&i--;break;default:{if(e[i-3]==255&&e[i-2]>=192&&e[i-2]<=254){i-=3;break}else if(S===224||S==225){if(m!==-1)throw new Error(`first unknown JPEG marker at offset ${m.toString(16)}, second unknown JPEG marker ${S.toString(16)} at offset ${(i-1).toString(16)}`);m=i-1;let g=o();if(e[i+g-2]===255){i+=g-2;break}}throw new Error("unknown JPEG marker "+S.toString(16))}}S=o()}if(f.length!=1)throw new Error("only single frame JPEGs supported");for(let g=0;g<f.length;g++){let v=f[g].components;for(let x in v)v[x].quantizationTable=u[v[x].quantizationIdx],delete v[x].quantizationIdx}t.width=c.samplesPerLine,t.height=c.scanLines,t.jfif=a,t.adobe=l,t.components=[];for(let g=0;g<c.componentsOrder.length;g++){let v=c.components[c.componentsOrder[g]];t.components.push({lines:Pu(v),scaleX:v.h/c.maxH,scaleY:v.v/c.maxV})}return t}function Fu(e){let t=0,n=!1,i=e.width,o=e.height,r=i*o*e.components.length;An(r);let s=new Uint8Array(r);switch(e.components.length){case 1:{let a=e.components[0];for(let l=0;l<o;l++){let c=a.lines[0|l*a.scaleY];for(let d=0;d<i;d++){let u=c[0|d*a.scaleX];s[t++]=u}}break}case 2:{let a=e.components[0],l=e.components[1];for(let c=0;c<o;c++){let d=a.lines[0|c*a.scaleY],u=l.lines[0|c*l.scaleY];for(let f=0;f<i;f++){let h=d[0|f*a.scaleX];s[t++]=h;let p=u[0|f*l.scaleX];s[t++]=p}}break}case 3:{n=!0,e.adobe&&e.adobe.transformCode&&(n=!0);let a=e.components[0],l=e.components[1],c=e.components[2];for(let d=0;d<o;d++){let u=a.lines[0|d*a.scaleY],f=l.lines[0|d*l.scaleY],h=c.lines[0|d*c.scaleY];for(let p=0;p<i;p++){let S,m,g,v,x,_;n?(S=u[0|p*a.scaleX],m=f[0|p*l.scaleX],g=h[0|p*c.scaleX],v=At(S+1.402*(g-128)),x=At(S-.3441363*(m-128)-.71413636*(g-128)),_=At(S+1.772*(m-128))):(v=u[0|p*a.scaleX],x=f[0|p*l.scaleX],_=h[0|p*c.scaleX]),s[t++]=v,s[t++]=x,s[t++]=_}}break}case 4:{if(!e.adobe)throw new Error("Unsupported color mode (4 components)");n=!1,e.adobe&&e.adobe.transformCode&&(n=!0);let a=e.components[0],l=e.components[1],c=e.components[2],d=e.components[3];for(let u=0;u<o;u++){let f=a.lines[0|u*a.scaleY],h=l.lines[0|u*l.scaleY],p=c.lines[0|u*c.scaleY],S=d.lines[0|u*d.scaleY];for(let m=0;m<i;m++){let g,v,x,_,I,P,k;n?(g=f[0|m*a.scaleX],v=h[0|m*l.scaleX],x=p[0|m*c.scaleX],_=S[0|m*d.scaleX],I=255-At(g+1.402*(x-128)),P=255-At(g-.3441363*(v-128)-.71413636*(x-128)),k=255-At(g+1.772*(v-128))):(I=f[0|m*a.scaleX],P=h[0|m*l.scaleX],k=p[0|m*c.scaleX],_=S[0|m*d.scaleX]),s[t++]=255-I,s[t++]=255-P,s[t++]=255-k,s[t++]=255-_}}break}default:throw new Error("Unsupported color mode")}return s}function Ou(e,t){if(hr=0,e.length===0)throw new Error("Empty jpeg buffer");let n=Eu(e);An(n.width*n.height*4);let i=Fu(n),o=t(n.width,n.height),r=o.width,s=o.height,a=o.data,l=0,c=0;switch(n.components.length){case 1:for(let d=0;d<s;d++)for(let u=0;u<r;u++){let f=i[l++];a[c++]=f,a[c++]=f,a[c++]=f,a[c++]=255}break;case 2:for(let d=0;d<s;d++)for(let u=0;u<r;u++){let f=i[l++],h=i[l++];a[c++]=f,a[c++]=f,a[c++]=f,a[c++]=h}break;case 3:for(let d=0;d<s;d++)for(let u=0;u<r;u++){let f=i[l++],h=i[l++],p=i[l++];a[c++]=f,a[c++]=h,a[c++]=p,a[c++]=255}break;case 4:for(let d=0;d<s;d++)for(let u=0;u<r;u++){let f=i[l++],h=i[l++],p=i[l++],S=i[l++],m=255-At(f*(1-S/255)+S),g=255-At(h*(1-S/255)+S),v=255-At(p*(1-S/255)+S);a[c++]=m,a[c++]=g,a[c++]=v,a[c++]=255}break;default:throw new Error("Unsupported color mode")}return o}});var Tt=oe(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.createImageData=G.createCanvas=G.MaskParams=G.LayerMaskFlags=G.ColorSpace=G.largeAdditionalInfoKeys=G.layerColors=G.toBlendMode=G.fromBlendMode=G.RAW_IMAGE_DATA=G.MOCK_HANDLERS=void 0;G.revMap=Ga;G.createEnum=Uu;G.offsetForChannel=Ru;G.clamp=Mu;G.hasAlpha=Tu;G.resetImageData=ju;G.imageDataToCanvas=zu;G.decodeBitmap=$u;G.writeDataRaw=Nu;G.writeDataRLE=Vu;G.writeDataZipWithoutPrediction=Gu;G.createCanvasFromData=Hu;G.initializeCanvas=Zu;var Lu=ur(),Bu=za();G.MOCK_HANDLERS=!1;G.RAW_IMAGE_DATA=!1;G.fromBlendMode={};G.toBlendMode={pass:"pass through",norm:"normal",diss:"dissolve",dark:"darken","mul ":"multiply",idiv:"color burn",lbrn:"linear burn",dkCl:"darker color",lite:"lighten",scrn:"screen","div ":"color dodge",lddg:"linear dodge",lgCl:"lighter color",over:"overlay",sLit:"soft light",hLit:"hard light",vLit:"vivid light",lLit:"linear light",pLit:"pin light",hMix:"hard mix",diff:"difference",smud:"exclusion",fsub:"subtract",fdiv:"divide","hue ":"hue","sat ":"saturation",colr:"color","lum ":"luminosity"};Object.keys(G.toBlendMode).forEach(e=>G.fromBlendMode[G.toBlendMode[e]]=e);G.layerColors=["none","red","orange","yellow","green","blue","violet","gray"];G.largeAdditionalInfoKeys=["LMsk","Lr16","Lr32","Layr","Mt16","Mt32","Mtrn","Alph","FMsk","lnk2","FEid","FXid","PxSD","cinf"];function Ga(e){let t={};return Object.keys(e).forEach(n=>t[e[n]]=n),t}function Uu(e,t,n){let i=Ga(n);return{decode:s=>{let a=s.split(".")[1];if(a&&!i[a]){if(Object.prototype.hasOwnProperty.call(n,a))return a;let l=a.replace(/([A-Z])/g," $1").toLowerCase();if(Object.prototype.hasOwnProperty.call(n,l))return l;throw new Error(`Unrecognized value for enum: '${s}'`)}return i[a]||t},encode:s=>{if(s&&!n[s])throw new Error(`Invalid value for enum: '${s}'`);return`${e}.${s?n[s]:n[t]}`}}}var $a;(function(e){e[e.RGB=0]="RGB",e[e.HSB=1]="HSB",e[e.CMYK=2]="CMYK",e[e.Lab=7]="Lab",e[e.Grayscale=8]="Grayscale"})($a||(G.ColorSpace=$a={}));var Na;(function(e){e[e.PositionRelativeToLayer=1]="PositionRelativeToLayer",e[e.LayerMaskDisabled=2]="LayerMaskDisabled",e[e.InvertLayerMaskWhenBlending=4]="InvertLayerMaskWhenBlending",e[e.LayerMaskFromRenderingOtherData=8]="LayerMaskFromRenderingOtherData",e[e.MaskHasParametersAppliedToIt=16]="MaskHasParametersAppliedToIt"})(Na||(G.LayerMaskFlags=Na={}));var Va;(function(e){e[e.UserMaskDensity=1]="UserMaskDensity",e[e.UserMaskFeather=2]="UserMaskFeather",e[e.VectorMaskDensity=4]="VectorMaskDensity",e[e.VectorMaskFeather=8]="VectorMaskFeather"})(Va||(G.MaskParams=Va={}));function Ru(e,t){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return t?3:e+1;case-1:return t?4:3;default:return e+1}}function Mu(e,t,n){return e<t?t:e>n?n:e}function Tu(e){let t=e.width*e.height*4;for(let n=3;n<t;n+=4)if(e.data[n]!==255)return!0;return!1}function ju({data:e}){let t=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let n=0,i=e.length|0;n<i;n=n+4|0)e[n+0]=0,e[n+1]=0,e[n+2]=0,e[n+3]=t}function zu(e){let t=(0,G.createCanvas)(e.width,e.height),n;if(e.data instanceof Uint8ClampedArray)n=e;else{n=(0,G.createImageData)(e.width,e.height);let i=e.data,o=n.data;if(i instanceof Float32Array)for(let r=0,s=i.length;r<s;r+=4)o[r+0]=Math.round(Math.pow(i[r+0],1/2.2)*255),o[r+1]=Math.round(Math.pow(i[r+1],1/2.2)*255),o[r+2]=Math.round(Math.pow(i[r+2],1/2.2)*255),o[r+3]=Math.round(i[r+3]*255);else{let r=i instanceof Uint16Array?8:0;for(let s=0,a=i.length;s<a;s++)o[s]=i[s]>>>r}}return t.getContext("2d").putImageData(n,0,0),t}function $u(e,t,n,i){if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray))throw new Error("Invalid bit depth");for(let o=0,r=0,s=0;o<i;o++)for(let a=0;a<n;){let l=e[s++];for(let c=0;c<8&&a<n;c++,a++,r+=4){let d=l&128?0:255;l=l<<1,t[r+0]=d,t[r+1]=d,t[r+2]=d,t[r+3]=255}}}function Nu(e,t,n,i){if(!n||!i)return;let o=new Uint8Array(n*i);for(let r=0;r<o.length;r++)o[r]=e.data[r*4+t];return o}function Vu(e,{data:t,width:n,height:i},o,r){if(!n||!i)return;let s=4*n|0,a=0,l=o.length*(r?4:2)*i|0;for(let c of o)for(let d=0,u=c|0;d<i;d++){let f=d*s|0,h=f+s|0,p=h+c-4|0,S=p-4|0,m=l;for(u=f+c|0;u<h;u=u+4|0)if(u<S){let v=t[u];u=u+4|0;let x=t[u];u=u+4|0;let _=t[u];if(v===x&&v===_){let I=3;for(;I<128&&u<p&&t[u+4|0]===v;)I=I+1|0,u=u+4|0;e[l++]=1-I,e[l++]=v}else{let I=l,P=!0,k=1;for(e[l++]=0,e[l++]=v;u<p&&k<128;)if(u=u+4|0,v=x,x=_,_=t[u],v===x&&v===_){u=u-12|0,P=!1;break}else k++,e[l++]=v;P&&(k<127?(e[l++]=x,e[l++]=_,k+=2):k<128?(e[l++]=x,k++,u=u-4|0):u=u-8|0),e[I]=k-1}}else u===p?(e[l++]=0,e[l++]=t[u]):(e[l++]=1,e[l++]=t[u],u=u+4|0,e[l++]=t[u]);let g=l-m;r&&(e[a++]=g>>24&255,e[a++]=g>>16&255),e[a++]=g>>8&255,e[a++]=g&255}return e.slice(0,l)}function Gu({data:e,width:t,height:n},i){let o=t*n,r=new Uint8Array(o),s=[],a=0;for(let l of i){for(let d=0,u=l;d<o;d++,u+=4)r[d]=e[u];let c=(0,Lu.deflate)(r);s.push(c),a+=c.byteLength}if(s.length>0){let l=new Uint8Array(a),c=0;for(let d of s)l.set(d,c),c+=d.byteLength;return l}else return s[0]}function Hu(e){let t=(0,G.createCanvas)(100,100);try{let n=t.getContext("2d"),i=(0,Bu.decodeJpeg)(e,(o,r)=>n.createImageData(o,r));t.width=i.width,t.height=i.height,n.putImageData(i,0,0)}catch(n){console.error("JPEG decompression error",n.message)}return t}var Wu=()=>{throw new Error("Canvas not initialized, use initializeCanvas method to set up createCanvas method")};G.createCanvas=Wu;var mr,Xu=(e,t)=>(mr||(mr=(0,G.createCanvas)(1,1)),mr.getContext("2d").createImageData(e,t));G.createImageData=Xu;typeof document<"u"&&(G.createCanvas=(e,t)=>{let n=document.createElement("canvas");return n.width=e,n.height=t,n});function Zu(e,t){G.createCanvas=e,G.createImageData=t||G.createImageData}});var ji=oe(Ti=>{"use strict";Ti.byteLength=Ku;Ti.toByteArray=Ju;Ti.fromByteArray=th;var mt=[],Ye=[],qu=typeof Uint8Array<"u"?Uint8Array:Array,gr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Qt=0,Ha=gr.length;Qt<Ha;++Qt)mt[Qt]=gr[Qt],Ye[gr.charCodeAt(Qt)]=Qt;var Qt,Ha;Ye[45]=62;Ye[95]=63;function Wa(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");n===-1&&(n=t);var i=n===t?0:4-n%4;return[n,i]}function Ku(e){var t=Wa(e),n=t[0],i=t[1];return(n+i)*3/4-i}function Yu(e,t,n){return(t+n)*3/4-n}function Ju(e){var t,n=Wa(e),i=n[0],o=n[1],r=new qu(Yu(e,i,o)),s=0,a=o>0?i-4:i,l;for(l=0;l<a;l+=4)t=Ye[e.charCodeAt(l)]<<18|Ye[e.charCodeAt(l+1)]<<12|Ye[e.charCodeAt(l+2)]<<6|Ye[e.charCodeAt(l+3)],r[s++]=t>>16&255,r[s++]=t>>8&255,r[s++]=t&255;return o===2&&(t=Ye[e.charCodeAt(l)]<<2|Ye[e.charCodeAt(l+1)]>>4,r[s++]=t&255),o===1&&(t=Ye[e.charCodeAt(l)]<<10|Ye[e.charCodeAt(l+1)]<<4|Ye[e.charCodeAt(l+2)]>>2,r[s++]=t>>8&255,r[s++]=t&255),r}function Qu(e){return mt[e>>18&63]+mt[e>>12&63]+mt[e>>6&63]+mt[e&63]}function eh(e,t,n){for(var i,o=[],r=t;r<n;r+=3)i=(e[r]<<16&16711680)+(e[r+1]<<8&65280)+(e[r+2]&255),o.push(Qu(i));return o.join("")}function th(e){for(var t,n=e.length,i=n%3,o=[],r=16383,s=0,a=n-i;s<a;s+=r)o.push(eh(e,s,s+r>a?a:s+r));return i===1?(t=e[n-1],o.push(mt[t>>2]+mt[t<<4&63]+"==")):i===2&&(t=(e[n-2]<<8)+e[n-1],o.push(mt[t>>10]+mt[t>>4&63]+mt[t<<2&63]+"=")),o.join("")}});var Ya=oe(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.stringLengthInBytes=qa;kn.encodeStringTo=Ka;kn.encodeString=ih;kn.decodeString=oh;function Xa(e){return(e&4294967168)===0?1:(e&4294965248)===0?2:(e&4294901760)===0?3:4}function Za(e,t){let n=e.charCodeAt(t);if(n>=55296&&n<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);if(i>=56320&&i<=57343)return{code:((n&1023)<<10)+(i&1023)+65536,size:2}}return n>=55296&&n<=57343?{code:65533,size:1}:{code:n,size:1}}function qa(e){let t=0;for(let n=0;n<e.length;){let{code:i,size:o}=Za(e,n);t+=Xa(i),n+=o}return t}function nh(e,t,n){let i=Xa(n);switch(i){case 1:e[t]=n;break;case 2:e[t]=n>>6&31|192,e[t+1]=n&63|128;break;case 3:e[t]=n>>12&15|224,e[t+1]=n>>6&63|128,e[t+2]=n&63|128;break;default:e[t]=n>>18&7|240,e[t+1]=n>>12&63|128,e[t+2]=n>>6&63|128,e[t+3]=n&63|128;break}return i}function Ka(e,t,n){for(let i=0;i<n.length;){let{code:o,size:r}=Za(n,i);t+=nh(e,t,o),i+=r}return t}function ih(e){if(e.length>1e3&&typeof TextEncoder<"u")return new TextEncoder().encode(e);let t=new Uint8Array(qa(e));return Ka(t,0,e),t}function oh(e){if(e.byteLength>1e3&&typeof TextDecoder<"u")return new TextDecoder().decode(e);let t=[];function n(l){l>65535&&(l-=65536,t.push(String.fromCharCode(l>>>10&1023|55296)),l=56320|l&1023),t.push(String.fromCharCode(l))}let i=0,o=0,r=0,s=128,a=191;for(let l=0;l<e.length;l++){let c=e[l];if(r===0){c<=127?n(c):c>=194&&c<=223?(r=1,i=c&31):c>=224&&c<=239?(c===224&&(s=160),c===237&&(a=159),r=2,i=c&15):c>=240&&c<=244?(c===240&&(s=144),c===244&&(a=143),r=3,i=c&7):n(65533);continue}if(c<s||c>a){i=0,r=0,o=0,s=128,a=191,n(65533),l--;continue}s=128,a=191,i=i<<6|c&63,o++,o===r&&(n(i),i=0,r=0,o=0)}return r!==0&&n(65533),t.join("")}});var Gi=oe(A=>{"use strict";var rh=A&&A.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]]);return n};Object.defineProperty(A,"__esModule",{value:!0});A.IntC=A.IntE=A.Drct=A.WndM=A.CntE=A.FlCl=A.ExtR=A.ExtT=A.DfsM=A.blurType=A.Lns=A.MztT=A.Chnl=A.Dstr=A.ZZTy=A.Wvtp=A.SphM=A.RplS=A.Cnvr=A.UndA=A.DspM=A.SmBQ=A.SmBM=A.BlrQ=A.BlrM=A.strokeStyleLineAlignment=A.strokeStyleLineJoinType=A.strokeStyleLineCapType=A.ESliceBGColorType=A.ESliceOrigin=A.ESliceVertAlign=A.ESliceHorzAlign=A.ESliceType=A.FrFl=A.FStl=A.ClrS=A.gradientInterpolationMethodType=A.stdTrackID=A.animInterpStyleEnum=A.GrdT=A.IGSr=A.BETE=A.BESs=A.bvlT=A.BESl=A.BlnM=A.warpStyle=A.Annt=A.Ornt=A.textGridding=void 0;A.presetKindType=A.prjM=A.FlMd=void 0;A.setLogErrors=ah;A.readAsciiStringOrClassId=gt;A.readDescriptorStructure=wr;A.writeDescriptorStructure=Sr;A.readVersionAndDescriptor=hh;A.writeVersionAndDescriptor=ph;A.horzVrtcToXY=$i;A.xyToHorzVrtc=Ni;A.descBoundsToBounds=mh;A.boundsToDescBounds=gh;A.serializeEffects=cl;A.parseEffects=dl;A.parseTrackList=bh;A.serializeTrackList=yh;A.parseVectorContent=wh;A.serializeVectorContent=Sh;A.parseColor=tn;A.serializeColor=nn;A.parseAngle=ni;A.parsePercent=_e;A.parsePercentOrAngle=bl;A.parseUnits=it;A.parseUnitsOrNumber=vh;A.parseUnitsToNumber=xh;A.unitsAngle=In;A.unitsPercent=ke;A.unitsPercentF=yr;A.unitsValue=bt;A.frac=_h;var $=Tt(),K=jt(),J=Dn();function sh(e){let t={};return Object.keys(e).forEach(n=>t[e[n]]=n),t}var ei={"#Ang":"Angle","#Rsl":"Density","#Rlt":"Distance","#Nne":"None","#Prc":"Percent","#Pxl":"Pixels","#Mlm":"Millimeters","#Pnt":"Points",RrPi:"Picas",RrIn:"Inches",RrCm:"Centimeters"},zi=sh(ei),ti=!1;function ah(e){ti=e}function F(e,t){return{name:e,classID:t}}var Y=F("","null"),br=!1,ol={strokeStyleContent:F("","solidColorLayer"),printProofSetup:F(br?"\u6821\u6837\u8BBE\u7F6E":"Proof Setup","proofSetup"),Grad:F(br?"\u6E10\u53D8":"Gradient","Grdn"),Trnf:F(br?"\u53D8\u6362":"Transform","Trnf"),patternFill:F("","patternFill"),ebbl:F("","ebbl"),SoFi:F("","SoFi"),GrFl:F("","GrFl"),sdwC:F("","RGBC"),hglC:F("","RGBC"),"Clr ":F("","RGBC"),tintColor:F("","RGBC"),Ofst:F("","Pnt "),ChFX:F("","ChFX"),MpgS:F("","ShpC"),DrSh:F("","DrSh"),IrSh:F("","IrSh"),OrGl:F("","OrGl"),IrGl:F("","IrGl"),TrnS:F("","ShpC"),Ptrn:F("","Ptrn"),FrFX:F("","FrFX"),phase:F("","Pnt "),frameStep:Y,duration:Y,workInTime:Y,workOutTime:Y,audioClipGroupList:Y,bounds:F("","Rctn"),customEnvelopeWarp:F("","customEnvelopeWarp"),warp:F("","warp"),"Sz ":F("","Pnt "),origin:F("","Pnt "),autoExpandOffset:F("","Pnt "),keyOriginShapeBBox:F("","unitRect"),Vrsn:Y,psVersion:Y,docDefaultNewArtboardBackgroundColor:F("","RGBC"),artboardRect:F("","classFloatRect"),keyOriginRRectRadii:F("","radii"),keyOriginBoxCorners:Y,rectangleCornerA:F("","Pnt "),rectangleCornerB:F("","Pnt "),rectangleCornerC:F("","Pnt "),rectangleCornerD:F("","Pnt "),compInfo:Y,quiltWarp:F("","quiltWarp"),generatorSettings:Y,crema:Y,FrIn:Y,blendOptions:Y,FXRf:Y,Lefx:Y,time:Y,animKey:Y,timeScope:Y,inTime:Y,outTime:Y,sheetStyle:Y,translation:Y,Skew:Y,boundingBox:F("","boundingBox"),"Lnk ":F("","ExternalFileLink"),frameReader:F("","FrameReader"),effectParams:F("","motionTrackEffectParams"),Impr:F("None","none"),Anch:F("","Pnt "),"Fwd ":F("","Pnt "),"Bwd ":F("","Pnt "),FlrC:F("","Pnt "),meshBoundaryPath:F("","pathClass"),filterFX:F("","filterFXStyle"),Fltr:F("","rigidTransform"),FrgC:F("","RGBC"),BckC:F("","RGBC"),sdwM:F("Parameters","adaptCorrectTones"),hglM:F("Parameters","adaptCorrectTones"),customShape:F("","customShape"),origFXRefPoint:Y,FXRefPoint:Y,ClMg:F("","ClMg")},rl={"Crv ":F("","CrPt"),Clrs:F("","Clrt"),Trns:F("","TrnS"),keyDescriptorList:Y,solidFillMulti:F("","SoFi"),gradientFillMulti:F("","GrFl"),dropShadowMulti:F("","DrSh"),innerShadowMulti:F("","IrSh"),frameFXMulti:F("","FrFX"),FrIn:Y,FSts:Y,LaSt:Y,sheetTimelineOptions:Y,trackList:F("","animationTrack"),globalTrackList:F("","animationTrack"),keyList:Y,audioClipGroupList:Y,audioClipList:Y,countObjectList:F("","countObject"),countGroupList:F("","countGroup"),slices:F("","slice"),"Pts ":F("","Pthp"),SbpL:F("","SbpL"),pathComponents:F("","PaCm"),filterFXList:F("","filterFX"),puppetShapeList:F("","puppetShape"),channelDenoise:F("","channelDenoiseParams"),ShrP:F("","Pnt "),layerSettings:Y,list:Y,Adjs:F("","CrvA")},Ja={TEXT:["Txt ","printerName","Nm ","Idnt","blackAndWhitePresetFileName","LUT3DFileName","presetFileName","curvesPresetFileName","mixerPresetFileName","placed","description","reason","artboardPresetName","json","clipID","relPath","fullPath","mediaDescriptor","Msge","altTag","url","cellText","preset","KnNm","FPth","comment","originalPath"],tdta:["EngineData","LUT3DFileData","indexArray","originalVertexArray","deformedVertexArray","LqMe"],long:["TextIndex","RndS","Mdpn","Smth","Lctn","strokeStyleVersion","LaID","Vrsn","Cnt ","Brgh","Cntr","means","vibrance","Strt","bwPresetKind","comp","compID","originalCompID","curvesPresetKind","mixerPresetKind","uOrder","vOrder","PgNm","totalPages","Crop","numerator","denominator","frameCount","Annt","keyOriginType","unitValueQuadVersion","keyOriginIndex","major","minor","fix","docDefaultNewArtboardBackgroundType","artboardBackgroundType","numModifyingFX","deformNumRows","deformNumCols","FrID","FrDl","FsID","LCnt","AFrm","AFSt","numBefore","numAfter","Spcn","minOpacity","maxOpacity","BlnM","sheetID","gblA","globalAltitude","descVersion","frameReaderType","LyrI","zoomOrigin","fontSize","Rds ","sliceID","topOutset","leftOutset","bottomOutset","rightOutset","filterID","meshQuality","meshExpansion","meshRigidity","VrsM","VrsN","NmbG","WLMn","WLMx","AmMn","AmMx","SclH","SclV","Lvl ","TlNm","TlOf","FlRs","Thsh","ShrS","ShrE","FlRs","Vrnc","Strg","ExtS","ExtD","HrzS","VrtS","NmbR","EdgF","Ang1","Ang2","Ang3","Ang4","lastAppliedComp","capturedInfo"],enum:["textGridding","Ornt","warpStyle","warpRotate","Inte","Bltn","ClrS","BlrQ","bvlT","bvlS","bvlD","Md ","glwS","GrdF","GlwT","RplS","BlrM","SmBM","strokeStyleLineCapType","strokeStyleLineJoinType","strokeStyleLineAlignment","strokeStyleBlendMode","PntT","Styl","lookupType","LUTFormat","dataOrder","tableOrder","enableCompCore","enableCompCoreGPU","compCoreSupport","compCoreGPUSupport","Engn","enableCompCoreThreads","gs99","FrDs","trackID","animInterpStyle","horzAlign","vertAlign","bgColorType","shapeOperation","UndA","Wvtp","Drct","WndM","Edg ","FlCl","IntE","IntC","Cnvr","Fl ","Dstr","MztT","Lns ","ExtT","DspM","ExtR","ZZTy","SphM","SmBQ","placedLayerOCIOConversion","gradientsInterpolationMethod"],bool:["PstS","printSixteenBit","masterFXSwitch","enab","uglg","antialiasGloss","useShape","useTexture","uglg","antialiasGloss","useShape","Vsbl","useTexture","Algn","Rvrs","Dthr","Invr","VctC","ShTr","layerConceals","strokeEnabled","fillEnabled","strokeStyleScaleLock","strokeStyleStrokeAdjust","hardProof","MpBl","paperWhite","useLegacy","Auto","Lab ","useTint","keyShapeInvalidated","autoExpandEnabled","autoNestEnabled","autoPositionEnabled","shrinkwrapOnSaveEnabled","present","showInDialog","overprint","sheetDisclosed","lightsDisclosed","meshesDisclosed","materialsDisclosed","hasMotion","muted","Effc","selected","autoScope","fillCanvas","cellTextIsHTML","Smoo","Clsp","validAtPosition","rigidType","hasoptions","filterMaskEnable","filterMaskLinked","filterMaskExtendWithWhite","removeJPEGArtifact","Mnch","ExtF","ExtM","moreAccurate","GpuY","LIWy","Cnty"],doub:["warpValue","warpPerspective","warpPerspectiveOther","Intr","Wdth","Hght","strokeStyleMiterLimit","strokeStyleResolution","layerTime","keyOriginResolution","xx","xy","yx","yy","tx","ty","FrGA","frameRate","audioLevel","rotation","X ","Y ","redFloat","greenFloat","blueFloat","imageResolution","PuX0","PuX1","PuX2","PuX3","PuY0","PuY1","PuY2","PuY3"],UntF:["sdwO","hglO","lagl","Lald","srgR","blur","Sftn","Opct","Dstn","Angl","Ckmt","Nose","Inpr","ShdN","strokeStyleLineWidth","strokeStyleLineDashOffset","strokeStyleOpacity","H ","Top ","Left","Btom","Rght","Rslt","topRight","topLeft","bottomLeft","bottomRight","ClNs","Shrp"],VlLs:["Crv ","Clrs","Mnm ","Mxm ","Trns","pathList","strokeStyleLineDashSet","FrLs","slices","LaSt","Trnf","nonAffineTransform","keyDescriptorList","guideIndeces","gradientFillMulti","solidFillMulti","frameFXMulti","innerShadowMulti","dropShadowMulti","FrIn","FSts","FsFr","sheetTimelineOptions","audioClipList","trackList","globalTrackList","keyList","audioClipList","warpValues","selectedPin","Pts ","SbpL","pathComponents","pinOffsets","posFinalPins","pinVertexIndices","PinP","PnRt","PnOv","PnDp","filterFXList","puppetShapeList","ShrP","channelDenoise","Mtrx","layerSettings","list","compList","Adjs"],ObAr:["meshPoints","quiltSliceX","quiltSliceY"],"obj ":["null","Chnl"],"Pth ":["DspF"]},lh=["Rd ","Grn ","Bl ","Yllw","Ylw ","Cyn ","Mgnt","Blck","Gry ","Lmnc","A ","B "],sl={"Mnm ":"long","Mxm ":"long",FrLs:"long",strokeStyleLineDashSet:"UntF",Trnf:"doub",nonAffineTransform:"doub",keyDescriptorList:"Objc",gradientFillMulti:"Objc",solidFillMulti:"Objc",frameFXMulti:"Objc",innerShadowMulti:"Objc",dropShadowMulti:"Objc",LaSt:"Objc",FrIn:"Objc",FSts:"Objc",FsFr:"long",blendOptions:"Objc",sheetTimelineOptions:"Objc",keyList:"Objc",warpValues:"doub",selectedPin:"long","Pts ":"Objc",SbpL:"Objc",pathComponents:"Objc",pinOffsets:"doub",posFinalPins:"doub",pinVertexIndices:"long",PinP:"doub",PnRt:"long",PnOv:"bool",PnDp:"doub",filterFXList:"Objc",puppetShapeList:"Objc",ShrP:"Objc",channelDenoise:"Objc",Mtrx:"long",compList:"long",Chnl:"enum"},Vi={};for(let e of Object.keys(Ja))for(let t of Ja[e])Vi[t]=e;for(let e of Object.keys(ol))Vi[e]||(Vi[e]="Objc");for(let e of Object.keys(rl))sl[e]="Objc";function ch(e,t,n,i){return e==="presetKind"?typeof t=="string"?"enum":"long":e==="null"&&n==="slices"?"TEXT":e==="groupID"?n==="slices"?"long":"TEXT":e==="Sz "?"Wdth"in t?"Objc":"units"in t?"UntF":"doub":e==="Type"?typeof t=="string"?"enum":"long":e==="AntA"?typeof t=="string"?"enum":"bool":(e==="Hrzn"||e==="Vrtc")&&(i.Type==="keyType.Pstn"||i._classID==="Ofst")?"long":e==="Hrzn"||e==="Vrtc"||e==="Top "||e==="Left"||e==="Btom"||e==="Rght"?n==="slices"?"long":typeof t=="number"?"doub":"UntF":e==="Vrsn"?typeof t=="number"?"long":"Objc":e==="Rd "||e==="Grn "||e==="Bl "?n==="artd"?"long":"doub":e==="Trnf"?Array.isArray(t)?"VlLs":"Objc":Vi[e]}function gt(e){let t=(0,K.readInt32)(e);return(0,K.readAsciiString)(e,t||4)}function kt(e,t){if(t.length===4&&t!=="warp"&&t!=="time"&&t!=="hold"&&t!=="list")(0,J.writeInt32)(e,0),(0,J.writeSignature)(e,t);else{(0,J.writeInt32)(e,t.length);for(let n=0;n<t.length;n++)(0,J.writeUint8)(e,t.charCodeAt(n))}}function wr(e,t){let n=en(e),i=t?{_name:n.name,_classID:n.classID}:{},o=(0,K.readUint32)(e);for(let r=0;r<o;r++){let s=gt(e),a=(0,K.readSignature)(e),l=al(e,a,t);i[s]=l}return i}function Sr(e,t,n,i,o){ti&&!n&&console.log("Missing classId for: ",t,n,i),(0,J.writeUnicodeStringWithPadding)(e,t),kt(e,n);let r=Object.keys(i),s=r.length;"_name"in i&&s--,"_classID"in i&&s--,(0,J.writeUint32)(e,s);for(let a of r){if(a==="_name"||a==="_classID")continue;let l=ch(a,i[a],o,i),c=ol[a];a==="bounds"&&o==="text"?c=F("","bounds"):a==="origin"?l=o==="slices"?"enum":"Objc":(a==="Cyn "||a==="Mgnt"||a==="Ylw "||a==="Blck")&&i._classID==="CMYC"?l="doub":/^PN[a-z][a-z]$/.test(a)?l="TEXT":/^PT[a-z][a-z]$/.test(a)?l="long":/^PF[a-z][a-z]$/.test(a)||(a==="Rds "||a==="Thsh")&&typeof i[a]=="number"&&i._classID==="SmrB"?l="doub":a==="ClSz"||a==="Rds "||a==="Amnt"?l=typeof i[a]=="number"?"long":"UntF":(a==="sdwM"||a==="hglM")&&typeof i[a]=="string"||a==="blur"&&typeof i[a]=="string"?l="enum":a==="Hght"&&typeof i[a]=="number"&&i._classID==="Embs"||a==="Angl"&&typeof i[a]=="number"&&(i._classID==="Embs"||i._classID==="smartSharpen"||i._classID==="Twrl"||i._classID==="MtnB")?l="long":a==="Angl"&&typeof i[a]=="number"?l="doub":a==="bounds"&&o==="slices"?(l="Objc",c=F("","Rct1")):a==="Scl "?typeof i[a]=="object"&&"Hrzn"in i[a]?(l="Objc",c=Y):typeof i[a]=="number"?l="long":l="UntF":a==="audioClipGroupList"&&r.length===1?l="VlLs":(a==="Strt"||a==="Brgh")&&"H "in i?l="doub":a==="Wdth"&&typeof i[a]=="object"?l="UntF":a==="Ofst"&&typeof i[a]=="number"?l="long":a==="Strt"&&typeof i[a]=="object"?(l="Objc",c=Y):lh.indexOf(a)!==-1?l=n==="RGBC"&&o!=="artd"?"doub":"long":a==="profile"?l=n==="printOutput"?"TEXT":"tdta":a==="strokeStyleContent"?i[a]["Clr "]?c=F("","solidColorLayer"):i[a].Grad?c=F("","gradientLayer"):i[a].Ptrn?c=F("","patternLayer"):ti&&console.log("Invalid strokeStyleContent value",i[a]):a==="bounds"&&o==="quiltWarp"&&(c=F("","classFloatRect")),c&&c.classID==="RGBC"&&"H "in i[a]&&(c={classID:"HSBC",name:""}),kt(e,a),(0,J.writeSignature)(e,l||"long"),ll(e,l||"long",i[a],a,c,o),ti&&!l&&console.log(`Missing descriptor field type for: '${a}' in`,i)}}function al(e,t,n){switch(t){case"obj ":return fh(e);case"Objc":case"GlbO":return wr(e,n);case"VlLs":{let i=(0,K.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=(0,K.readSignature)(e);o.push(al(e,s,n))}return o}case"doub":return(0,K.readFloat64)(e);case"UntF":{let i=(0,K.readSignature)(e),o=(0,K.readFloat64)(e);if(!ei[i])throw new Error(`Invalid units: ${i}`);return{units:ei[i],value:o}}case"UnFl":{let i=(0,K.readSignature)(e),o=(0,K.readFloat32)(e);if(!ei[i])throw new Error(`Invalid units: ${i}`);return{units:ei[i],value:o}}case"TEXT":return(0,K.readUnicodeString)(e);case"enum":{let i=gt(e),o=gt(e);return`${i}.${o}`}case"long":return(0,K.readInt32)(e);case"comp":{let i=(0,K.readUint32)(e),o=(0,K.readUint32)(e);return{low:i,high:o}}case"bool":return!!(0,K.readUint8)(e);case"type":case"GlbC":return en(e);case"alis":{let i=(0,K.readInt32)(e);return(0,K.readAsciiString)(e,i)}case"tdta":{let i=(0,K.readInt32)(e);return(0,K.readBytes)(e,i)}case"ObAr":{(0,K.readInt32)(e),(0,K.readUnicodeString)(e),gt(e);let i=(0,K.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=gt(e);(0,K.readSignature)(e),(0,K.readSignature)(e);let a=(0,K.readInt32)(e),l=[];for(let c=0;c<a;c++)l.push((0,K.readFloat64)(e));o.push({type:s,values:l})}return o}case"Pth ":{(0,K.readInt32)(e);let i=(0,K.readSignature)(e);(0,K.readInt32LE)(e);let o=(0,K.readInt32LE)(e),r=(0,K.readUnicodeStringWithLengthLE)(e,o);return{sig:i,path:r}}default:throw new Error(`Invalid TySh descriptor OSType: ${t} at ${e.offset.toString(16)}`)}}var dh={meshPoints:"rationalPoint",quiltSliceX:"UntF",quiltSliceY:"UntF"};function ll(e,t,n,i,o,r){switch(t){case"obj ":uh(e,i,n);break;case"Objc":case"GlbO":{if(typeof n!="object")throw new Error(`Invalid struct value: ${JSON.stringify(n)}, key: ${i}`);if(!o)throw new Error(`Missing ext type for: '${i}' (${JSON.stringify(n)})`);let s=n._name||o.name,a=n._classID||o.classID;Sr(e,s,a,n,r);break}case"VlLs":if(!Array.isArray(n))throw new Error(`Invalid list value: ${JSON.stringify(n)}, key: ${i}`);(0,J.writeInt32)(e,n.length);for(let s=0;s<n.length;s++){let a=sl[i];(0,J.writeSignature)(e,a||"long"),ll(e,a||"long",n[s],`${i}[]`,rl[i],r),ti&&!a&&console.log(`Missing descriptor array type for: '${i}' in`,n)}break;case"doub":if(typeof n!="number")throw new Error(`Invalid number value: ${JSON.stringify(n)}, key: ${i}`);(0,J.writeFloat64)(e,n);break;case"UntF":if(!zi[n.units])throw new Error(`Invalid units: ${n.units} in ${i}`);(0,J.writeSignature)(e,zi[n.units]),(0,J.writeFloat64)(e,n.value);break;case"UnFl":if(!zi[n.units])throw new Error(`Invalid units: ${n.units} in ${i}`);(0,J.writeSignature)(e,zi[n.units]),(0,J.writeFloat32)(e,n.value);break;case"TEXT":(0,J.writeUnicodeStringWithPadding)(e,n);break;case"enum":{if(typeof n!="string")throw new Error(`Invalid enum value: ${JSON.stringify(n)}, key: ${i}`);let[s,a]=n.split(".");kt(e,s),kt(e,a);break}case"long":if(typeof n!="number")throw new Error(`Invalid integer value: ${JSON.stringify(n)}, key: ${i}`);(0,J.writeInt32)(e,n);break;case"bool":if(typeof n!="boolean")throw new Error(`Invalid boolean value: ${JSON.stringify(n)}, key: ${i}`);(0,J.writeUint8)(e,n?1:0);break;case"tdta":(0,J.writeInt32)(e,n.byteLength),(0,J.writeBytes)(e,n);break;case"ObAr":{(0,J.writeInt32)(e,16),(0,J.writeUnicodeStringWithPadding)(e,"");let s=dh[i];if(!s)throw new Error(`Not implemented ObArType for: ${i}`);kt(e,s),(0,J.writeInt32)(e,n.length);for(let a=0;a<n.length;a++){kt(e,n[a].type),(0,J.writeSignature)(e,"UnFl"),(0,J.writeSignature)(e,"#Pxl"),(0,J.writeInt32)(e,n[a].values.length);for(let l=0;l<n[a].values.length;l++)(0,J.writeFloat64)(e,n[a].values[l])}break}case"Pth ":{let s=12+n.path.length*2;(0,J.writeInt32)(e,s),(0,J.writeSignature)(e,n.sig),(0,J.writeInt32LE)(e,s),(0,J.writeInt32LE)(e,n.path.length),(0,J.writeUnicodeStringWithoutLengthLE)(e,n.path);break}default:throw new Error(`Not implemented descriptor OSType: ${t}`)}}function fh(e){let t=(0,K.readInt32)(e),n=[];for(let i=0;i<t;i++){let o=(0,K.readSignature)(e);switch(o){case"prop":{en(e);let r=gt(e);n.push(r);break}case"Clss":n.push(en(e));break;case"Enmr":{en(e);let r=gt(e),s=gt(e);n.push(`${r}.${s}`);break}case"rele":{en(e),n.push((0,K.readUint32)(e));break}case"Idnt":n.push((0,K.readInt32)(e));break;case"indx":n.push((0,K.readInt32)(e));break;case"name":{en(e),n.push((0,K.readUnicodeString)(e));break}default:throw new Error(`Invalid descriptor reference type: ${o}`)}}return n}function uh(e,t,n){(0,J.writeInt32)(e,n.length);for(let i=0;i<n.length;i++){let o=n[i],r="unknown";switch(typeof o=="string"&&(/^[a-z ]+\.[a-z ]+$/i.test(o)?r="Enmr":r="name"),(0,J.writeSignature)(e,r),r){case"Enmr":{let[s,a]=o.split(".");Qa(e,"\0",s),kt(e,s),kt(e,a);break}case"name":{Qa(e,"\0","Lyr "),(0,J.writeUnicodeString)(e,o+"\0");break}default:throw new Error(`Invalid descriptor reference type: ${r}`)}}return n}function en(e){let t=(0,K.readUnicodeString)(e),n=gt(e);return{name:t,classID:n}}function Qa(e,t,n){(0,J.writeUnicodeString)(e,t),kt(e,n)}function hh(e,t=!1){let n=(0,K.readUint32)(e);if(n!==16)throw new Error(`Invalid descriptor version: ${n}`);return wr(e,t)}function ph(e,t,n,i,o=""){(0,J.writeUint32)(e,16),Sr(e,t,n,i,o)}function $i(e){return{x:e.Hrzn,y:e.Vrtc}}function Ni(e){return{Hrzn:e.x,Vrtc:e.y}}function mh(e){return{top:it(e["Top "]),left:it(e.Left),right:it(e.Rght),bottom:it(e.Btom)}}function gh(e){return{Left:bt(e.left,"bounds.left"),"Top ":bt(e.top,"bounds.top"),Rght:bt(e.right,"bounds.right"),Btom:bt(e.bottom,"bounds.bottom")}}function el(e){let t={enabled:!!e.enab,position:A.FStl.decode(e.Styl),fillType:A.FrFl.decode(e.PntT),blendMode:A.BlnM.decode(e["Md "]),opacity:_e(e.Opct),size:it(e["Sz "])};return e.present!==void 0&&(t.present=e.present),e.showInDialog!==void 0&&(t.showInDialog=e.showInDialog),e.overprint!==void 0&&(t.overprint=e.overprint),e["Clr "]&&(t.color=tn(e["Clr "])),e.Grad&&(t.gradient=hl(e)),e.Ptrn&&(t.pattern=pl(e)),t}function tl(e){let t={};return t.enab=!!e.enabled,e.present!==void 0&&(t.present=!!e.present),e.showInDialog!==void 0&&(t.showInDialog=!!e.showInDialog),t.Styl=A.FStl.encode(e.position),t.PntT=A.FrFl.encode(e.fillType),t["Md "]=A.BlnM.encode(e.blendMode),t.Opct=ke(e.opacity),t["Sz "]=bt(e.size,"size"),e.color&&(t["Clr "]=nn(e.color)),e.gradient&&(t=Object.assign(Object.assign({},t),ml(e.gradient))),e.pattern&&(t=Object.assign(Object.assign({},t),gl(e.pattern))),e.overprint!==void 0&&(t.overprint=!!e.overprint),t}function cl(e,t,n){var i,o,r;let s=n?{"Scl ":yr((i=e.scale)!==null&&i!==void 0?i:1),masterFXSwitch:!e.disabled}:{masterFXSwitch:!e.disabled,"Scl ":yr((o=e.scale)!==null&&o!==void 0?o:1)},a=["dropShadow","innerShadow","solidFill","gradientOverlay","stroke"];for(let d of a)if(e[d]&&!Array.isArray(e[d]))throw new Error(`${d} should be an array`);let l=d=>!!d&&d.length>1&&n,c=d=>!!d&&d.length>=1&&(!n||d.length===1);if(c(e.dropShadow)&&(s.DrSh=He(e.dropShadow[0],"dropShadow",t)),l(e.dropShadow)&&(s.dropShadowMulti=e.dropShadow.map(d=>He(d,"dropShadow",t))),c(e.innerShadow)&&(s.IrSh=He(e.innerShadow[0],"innerShadow",t)),l(e.innerShadow)&&(s.innerShadowMulti=e.innerShadow.map(d=>He(d,"innerShadow",t))),e.outerGlow&&(s.OrGl=He(e.outerGlow,"outerGlow",t)),l(e.solidFill)&&(s.solidFillMulti=e.solidFill.map(d=>He(d,"solidFill",t))),l(e.gradientOverlay)&&(s.gradientFillMulti=e.gradientOverlay.map(d=>He(d,"gradientOverlay",t))),l(e.stroke)&&(s.frameFXMulti=e.stroke.map(d=>tl(d))),e.innerGlow&&(s.IrGl=He(e.innerGlow,"innerGlow",t)),e.bevel&&(s.ebbl=He(e.bevel,"bevel",t)),c(e.solidFill)&&(s.SoFi=He(e.solidFill[0],"solidFill",t)),e.patternOverlay&&(s.patternFill=He(e.patternOverlay,"patternOverlay",t)),c(e.gradientOverlay)&&(s.GrFl=He(e.gradientOverlay[0],"gradientOverlay",t)),e.satin&&(s.ChFX=He(e.satin,"satin",t)),c(e.stroke)&&(s.FrFX=tl((r=e.stroke)===null||r===void 0?void 0:r[0])),n){s.numModifyingFX=0;for(let d of Object.keys(e)){let u=e[d];if(Array.isArray(u))for(let f of u)f.enabled&&s.numModifyingFX++;else u.enabled&&s.numModifyingFX++}}return s}function dl(e,t){let n={},{masterFXSwitch:i,DrSh:o,dropShadowMulti:r,IrSh:s,innerShadowMulti:a,OrGl:l,IrGl:c,ebbl:d,SoFi:u,solidFillMulti:f,patternFill:h,GrFl:p,gradientFillMulti:S,ChFX:m,FrFX:g,frameFXMulti:v,numModifyingFX:x}=e,_=rh(e,["masterFXSwitch","DrSh","dropShadowMulti","IrSh","innerShadowMulti","OrGl","IrGl","ebbl","SoFi","solidFillMulti","patternFill","GrFl","gradientFillMulti","ChFX","FrFX","frameFXMulti","numModifyingFX"]);return i||(n.disabled=!0),e["Scl "]&&(n.scale=_e(e["Scl "])),o&&(n.dropShadow=[Ge(o,t)]),r&&(n.dropShadow=r.map(I=>Ge(I,t))),s&&(n.innerShadow=[Ge(s,t)]),a&&(n.innerShadow=a.map(I=>Ge(I,t))),l&&(n.outerGlow=Ge(l,t)),c&&(n.innerGlow=Ge(c,t)),d&&(n.bevel=Ge(d,t)),u&&(n.solidFill=[Ge(u,t)]),f&&(n.solidFill=f.map(I=>Ge(I,t))),h&&(n.patternOverlay=Ge(h,t)),p&&(n.gradientOverlay=[Ge(p,t)]),S&&(n.gradientOverlay=S.map(I=>Ge(I,t))),m&&(n.satin=Ge(m,t)),g&&(n.stroke=[el(g)]),v&&(n.stroke=v.map(I=>el(I))),t&&Object.keys(_).length>1&&console.log("Unhandled effect keys:",_),n}function nl(e,t){let n=[];for(let i=0;i<e.length;i++){let o=e[i],{time:{denominator:r,numerator:s},selected:a,animKey:l}=o,c={numerator:s,denominator:r},d=A.animInterpStyleEnum.decode(o.animInterpStyle);switch(l.Type){case"keyType.Opct":n.push({interpolation:d,time:c,selected:a,type:"opacity",value:_e(l.Opct)});break;case"keyType.Pstn":n.push({interpolation:d,time:c,selected:a,type:"position",x:l.Hrzn,y:l.Vrtc});break;case"keyType.Trnf":n.push({interpolation:d,time:c,selected:a,type:"transform",scale:$i(l["Scl "]),skew:$i(l.Skew),rotation:l.rotation,translation:$i(l.translation)});break;case"keyType.sheetStyle":{let u={interpolation:d,time:c,selected:a,type:"style"};l.sheetStyle.Lefx&&(u.style=dl(l.sheetStyle.Lefx,t)),n.push(u);break}case"keyType.globalLighting":{n.push({interpolation:d,time:c,selected:a,type:"globalLighting",globalAngle:l.gblA,globalAltitude:l.globalAltitude});break}default:throw new Error("Unsupported keyType value")}}return n}function il(e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],{time:o,selected:r=!1,interpolation:s}=i,a=A.animInterpStyleEnum.encode(s),l;switch(i.type){case"opacity":l={Type:"keyType.Opct",Opct:ke(i.value)};break;case"position":l={Type:"keyType.Pstn",Hrzn:i.x,Vrtc:i.y};break;case"transform":l={Type:"keyType.Trnf","Scl ":Ni(i.scale),Skew:Ni(i.skew),rotation:i.rotation,translation:Ni(i.translation)};break;case"style":l={Type:"keyType.sheetStyle",sheetStyle:{Vrsn:1,blendOptions:{}}},i.style&&(l.sheetStyle={Vrsn:1,Lefx:cl(i.style,!1,!1),blendOptions:{}});break;case"globalLighting":{l={Type:"keyType.globalLighting",gblA:i.globalAngle,globalAltitude:i.globalAltitude};break}default:throw new Error("Unsupported keyType value")}t.push({Vrsn:1,animInterpStyle:a,time:o,animKey:l,selected:r})}return t}function bh(e,t){let n=[];for(let i=0;i<e.length;i++){let o=e[i],r={type:A.stdTrackID.decode(o.trackID),enabled:o.enab,keys:nl(o.keyList,t)};o.effectParams&&(r.effectParams={fillCanvas:o.effectParams.fillCanvas,zoomOrigin:o.effectParams.zoomOrigin,keys:nl(o.effectParams.keyList,t)}),n.push(r)}return n}function yh(e){let t=[];for(let n=0;n<e.length;n++){let i=e[n];t.push(Object.assign(Object.assign({trackID:A.stdTrackID.encode(i.type),Vrsn:1,enab:!!i.enabled,Effc:!!i.effectParams},i.effectParams?{effectParams:{keyList:il(i.keys),fillCanvas:i.effectParams.fillCanvas,zoomOrigin:i.effectParams.zoomOrigin}}:{}),{keyList:il(i.keys)}))}return t}function Ge(e,t){let n={};for(let i of Object.keys(e)){let o=e[i];switch(i){case"enab":n.enabled=!!o;break;case"uglg":n.useGlobalLight=!!o;break;case"AntA":n.antialiased=!!o;break;case"Algn":n.align=!!o;break;case"Dthr":n.dither=!!o;break;case"Invr":n.invert=!!o;break;case"Rvrs":n.reverse=!!o;break;case"Clr ":n.color=tn(o);break;case"hglC":n.highlightColor=tn(o);break;case"sdwC":n.shadowColor=tn(o);break;case"Styl":n.position=A.FStl.decode(o);break;case"Md ":n.blendMode=A.BlnM.decode(o);break;case"hglM":n.highlightBlendMode=A.BlnM.decode(o);break;case"sdwM":n.shadowBlendMode=A.BlnM.decode(o);break;case"bvlS":n.style=A.BESl.decode(o);break;case"bvlD":n.direction=A.BESs.decode(o);break;case"bvlT":n.technique=A.bvlT.decode(o);break;case"GlwT":n.technique=A.BETE.decode(o);break;case"glwS":n.source=A.IGSr.decode(o);break;case"Type":n.type=A.GrdT.decode(o);break;case"gs99":n.interpolationMethod=A.gradientInterpolationMethodType.decode(o);break;case"Opct":n.opacity=_e(o);break;case"hglO":n.highlightOpacity=_e(o);break;case"sdwO":n.shadowOpacity=_e(o);break;case"lagl":n.angle=ni(o);break;case"Angl":n.angle=ni(o);break;case"Lald":n.altitude=ni(o);break;case"Sftn":n.soften=it(o);break;case"srgR":n.strength=_e(o);break;case"blur":n.size=it(o);break;case"Nose":n.noise=_e(o);break;case"Inpr":n.range=_e(o);break;case"Ckmt":n.choke=it(o);break;case"ShdN":n.jitter=_e(o);break;case"Dstn":n.distance=it(o);break;case"Scl ":n.scale=_e(o);break;case"Ptrn":n.pattern={name:o["Nm "],id:o.Idnt};break;case"phase":n.phase={x:o.Hrzn,y:o.Vrtc};break;case"Ofst":n.offset={x:_e(o.Hrzn),y:_e(o.Vrtc)};break;case"MpgS":case"TrnS":n.contour={name:o["Nm "],curve:o["Crv "].map(r=>({x:r.Hrzn,y:r.Vrtc}))};break;case"Grad":n.gradient=fl(o);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":n[i]=o;break;case"_name":case"_classID":break;default:t&&console.log(`Invalid effect key: '${i}', value:`,o)}}return n}function He(e,t,n){let i={enab:!1};t==="dropShadow"&&(i.TrnS={"Nm ":"","Crv ":[]});for(let o of Object.keys(e)){let r=o,s=e[r];switch(r){case"enabled":i.enab=!!s;break;case"useGlobalLight":i.uglg=!!s;break;case"antialiased":i.AntA=!!s;break;case"align":i.Algn=!!s;break;case"dither":i.Dthr=!!s;break;case"invert":i.Invr=!!s;break;case"reverse":i.Rvrs=!!s;break;case"color":i["Clr "]=nn(s);break;case"highlightColor":i.hglC=nn(s);break;case"shadowColor":i.sdwC=nn(s);break;case"position":i.Styl=A.FStl.encode(s);break;case"blendMode":i["Md "]=A.BlnM.encode(s);break;case"highlightBlendMode":i.hglM=A.BlnM.encode(s);break;case"shadowBlendMode":i.sdwM=A.BlnM.encode(s);break;case"style":i.bvlS=A.BESl.encode(s);break;case"direction":i.bvlD=A.BESs.encode(s);break;case"technique":t==="bevel"?i.bvlT=A.bvlT.encode(s):i.GlwT=A.BETE.encode(s);break;case"source":i.glwS=A.IGSr.encode(s);break;case"type":i.Type=A.GrdT.encode(s);break;case"interpolationMethod":i.gs99=A.gradientInterpolationMethodType.encode(s);break;case"opacity":i.Opct=ke(s);break;case"highlightOpacity":i.hglO=ke(s);break;case"shadowOpacity":i.sdwO=ke(s);break;case"angle":t==="gradientOverlay"||t==="patternFill"?i.Angl=In(s):i.lagl=In(s);break;case"altitude":i.Lald=In(s);break;case"soften":i.Sftn=bt(s,r);break;case"strength":i.srgR=ke(s);break;case"size":i.blur=bt(s,r);break;case"noise":i.Nose=ke(s);break;case"range":i.Inpr=ke(s);break;case"choke":i.Ckmt=bt(s,r);break;case"jitter":i.ShdN=ke(s);break;case"distance":i.Dstn=bt(s,r);break;case"scale":i["Scl "]=ke(s);break;case"pattern":i.Ptrn={"Nm ":s.name,Idnt:s.id};break;case"phase":i.phase={Hrzn:s.x,Vrtc:s.y};break;case"offset":i.Ofst={Hrzn:ke(s.x),Vrtc:ke(s.y)};break;case"contour":{i[t==="satin"?"MpgS":"TrnS"]={"Nm ":s.name,"Crv ":s.curve.map(a=>({Hrzn:a.x,Vrtc:a.y}))};break}case"gradient":i.Grad=ul(s);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":i[r]=s;break;default:n&&console.log(`Invalid effect key: '${r}', value:`,s)}}return i}function fl(e){if(e.GrdF==="GrdF.CstS"){let t=e.Intr||4096;return{type:"solid",name:e["Nm "],smoothness:e.Intr/4096,colorStops:e.Clrs.map(n=>({color:tn(n["Clr "]),location:n.Lctn/t,midpoint:n.Mdpn/100})),opacityStops:e.Trns.map(n=>({opacity:_e(n.Opct),location:n.Lctn/t,midpoint:n.Mdpn/100}))}}else return{type:"noise",name:e["Nm "],roughness:e.Smth/4096,colorModel:A.ClrS.decode(e.ClrS),randomSeed:e.RndS,restrictColors:!!e.VctC,addTransparency:!!e.ShTr,min:e["Mnm "].map(t=>t/100),max:e["Mxm "].map(t=>t/100)}}function ul(e){var t,n;if(e.type==="solid"){let i=Math.round(((t=e.smoothness)!==null&&t!==void 0?t:1)*4096);return{"Nm ":e.name||"",GrdF:"GrdF.CstS",Intr:i,Clrs:e.colorStops.map(o=>{var r;return{"Clr ":nn(o.color),Type:"Clry.UsrS",Lctn:Math.round(o.location*i),Mdpn:Math.round(((r=o.midpoint)!==null&&r!==void 0?r:.5)*100)}}),Trns:e.opacityStops.map(o=>{var r;return{Opct:ke(o.opacity),Lctn:Math.round(o.location*i),Mdpn:Math.round(((r=o.midpoint)!==null&&r!==void 0?r:.5)*100)}})}}else return{GrdF:"GrdF.ClNs","Nm ":e.name||"",ShTr:!!e.addTransparency,VctC:!!e.restrictColors,ClrS:A.ClrS.encode(e.colorModel),RndS:e.randomSeed||0,Smth:Math.round(((n=e.roughness)!==null&&n!==void 0?n:1)*4096),"Mnm ":(e.min||[0,0,0,0]).map(i=>i*100),"Mxm ":(e.max||[1,1,1,1]).map(i=>i*100)}}function hl(e){let t=fl(e.Grad);return t.style=A.GrdT.decode(e.Type),e.Dthr!==void 0&&(t.dither=e.Dthr),e.gradientsInterpolationMethod!==void 0&&(t.interpolationMethod=A.gradientInterpolationMethodType.decode(e.gradientsInterpolationMethod)),e.Rvrs!==void 0&&(t.reverse=e.Rvrs),e.Angl!==void 0&&(t.angle=ni(e.Angl)),e["Scl "]!==void 0&&(t.scale=_e(e["Scl "])),e.Algn!==void 0&&(t.align=e.Algn),e.Ofst!==void 0&&(t.offset={x:_e(e.Ofst.Hrzn),y:_e(e.Ofst.Vrtc)}),t}function pl(e){let t={name:e.Ptrn["Nm "],id:e.Ptrn.Idnt};return e.Lnkd!==void 0&&(t.linked=e.Lnkd),e.phase!==void 0&&(t.phase={x:e.phase.Hrzn,y:e.phase.Vrtc}),t}function wh(e){if("Grad"in e)return hl(e);if("Ptrn"in e)return Object.assign({type:"pattern"},pl(e));if("Clr "in e)return{type:"color",color:tn(e["Clr "])};throw new Error("Invalid vector content")}function ml(e){let t={};return e.dither!==void 0&&(t.Dthr=e.dither),e.interpolationMethod!==void 0&&(t.gradientsInterpolationMethod=A.gradientInterpolationMethodType.encode(e.interpolationMethod)),e.reverse!==void 0&&(t.Rvrs=e.reverse),e.angle!==void 0&&(t.Angl=In(e.angle)),t.Type=A.GrdT.encode(e.style),e.align!==void 0&&(t.Algn=e.align),e.scale!==void 0&&(t["Scl "]=ke(e.scale)),e.offset&&(t.Ofst={Hrzn:ke(e.offset.x),Vrtc:ke(e.offset.y)}),t.Grad=ul(e),t}function gl(e){let t={Ptrn:{"Nm ":e.name||"",Idnt:e.id||""}};return e.linked!==void 0&&(t.Lnkd=!!e.linked),e.phase!==void 0&&(t.phase={Hrzn:e.phase.x,Vrtc:e.phase.y}),t}function Sh(e){return e.type==="color"?{key:"SoCo",descriptor:{"Clr ":nn(e.color)}}:e.type==="pattern"?{key:"PtFl",descriptor:gl(e)}:{key:"GdFl",descriptor:ml(e)}}function tn(e){if("H "in e)return{h:bl(e["H "]),s:e.Strt,b:e.Brgh};if("Rd "in e)return{r:e["Rd "],g:e["Grn "],b:e["Bl "]};if("Cyn "in e)return{c:e["Cyn "],m:e.Mgnt,y:e["Ylw "],k:e.Blck};if("Gry "in e)return{k:e["Gry "]};if("Lmnc"in e)return{l:e.Lmnc,a:e["A "],b:e["B "]};if("redFloat"in e)return{fr:e.redFloat,fg:e.greenFloat,fb:e.blueFloat};throw new Error("Unsupported color descriptor")}function nn(e){if(e){if("r"in e)return{_name:"",_classID:"RGBC","Rd ":e.r||0,"Grn ":e.g||0,"Bl ":e.b||0};if("fr"in e)return{_name:"",_classID:"RGBC",redFloat:e.fr,greenFloat:e.fg,blueFloat:e.fb};if("h"in e)return{_name:"",_classID:"HSBC","H ":In(e.h*360),Strt:e.s||0,Brgh:e.b||0};if("c"in e)return{_name:"",_classID:"CMYC","Cyn ":e.c||0,Mgnt:e.m||0,"Ylw ":e.y||0,Blck:e.k||0};if("l"in e)return{_name:"",_classID:"LABC",Lmnc:e.l||0,"A ":e.a||0,"B ":e.b||0};if("k"in e)return{_name:"",_classID:"GRYC","Gry ":e.k};throw new Error("Invalid color value")}else return{_name:"",_classID:"RGBC","Rd ":0,"Grn ":0,"Bl ":0}}function ni(e){if(e===void 0)return 0;if(e.units!=="Angle")throw new Error(`Invalid units: ${e.units}`);return e.value}function _e(e){if(e===void 0)return 1;if(e.units!=="Percent")throw new Error(`Invalid units: ${e.units}`);return e.value/100}function bl(e){if(e===void 0)return 1;if(e.units==="Percent")return e.value/100;if(e.units==="Angle")return e.value/360;throw new Error(`Invalid units: ${e.units}`)}function it({units:e,value:t}){if(e!=="Pixels"&&e!=="Millimeters"&&e!=="Points"&&e!=="None"&&e!=="Picas"&&e!=="Inches"&&e!=="Centimeters"&&e!=="Density")throw new Error(`Invalid units: ${JSON.stringify({units:e,value:t})}`);return{value:t,units:e}}function vh(e,t="Pixels"){return typeof e=="number"?{value:e,units:t}:it(e)}function xh({units:e,value:t},n){if(e!==n)throw new Error(`Invalid units: ${JSON.stringify({units:e,value:t})}`);return t}function In(e){return{units:"Angle",value:e||0}}function ke(e){return{units:"Percent",value:Math.round((e||0)*100)}}function yr(e){return{units:"Percent",value:(e||0)*100}}function bt(e,t){if(e==null)return{units:"Pixels",value:0};if(typeof e!="object")throw new Error(`Invalid value: ${JSON.stringify(e)} (key: ${t}) (should have value and units)`);let{units:n,value:i}=e;if(typeof i!="number")throw new Error(`Invalid value in ${JSON.stringify(e)} (key: ${t})`);if(n!=="Pixels"&&n!=="Millimeters"&&n!=="Points"&&n!=="None"&&n!=="Picas"&&n!=="Inches"&&n!=="Centimeters"&&n!=="Density")throw new Error(`Invalid units in ${JSON.stringify(e)} (key: ${t})`);return{units:n,value:i}}function _h({numerator:e,denominator:t}){return{numerator:e,denominator:t}}A.textGridding=(0,$.createEnum)("textGridding","none",{none:"None",round:"Rnd "});A.Ornt=(0,$.createEnum)("Ornt","horizontal",{horizontal:"Hrzn",vertical:"Vrtc"});A.Annt=(0,$.createEnum)("Annt","sharp",{none:"Anno",sharp:"antiAliasSharp",crisp:"AnCr",strong:"AnSt",smooth:"AnSm",platform:"antiAliasPlatformGray",platformLCD:"antiAliasPlatformLCD"});A.warpStyle=(0,$.createEnum)("warpStyle","none",{none:"warpNone",arc:"warpArc",arcLower:"warpArcLower",arcUpper:"warpArcUpper",arch:"warpArch",bulge:"warpBulge",shellLower:"warpShellLower",shellUpper:"warpShellUpper",flag:"warpFlag",wave:"warpWave",fish:"warpFish",rise:"warpRise",fisheye:"warpFisheye",inflate:"warpInflate",squeeze:"warpSqueeze",twist:"warpTwist",cylinder:"warpCylinder",custom:"warpCustom"});A.BlnM=(0,$.createEnum)("BlnM","normal",{normal:"Nrml",dissolve:"Dslv",darken:"Drkn",multiply:"Mltp","color burn":"CBrn","linear burn":"linearBurn","darker color":"darkerColor",lighten:"Lghn",screen:"Scrn","color dodge":"CDdg","linear dodge":"linearDodge","lighter color":"lighterColor",overlay:"Ovrl","soft light":"SftL","hard light":"HrdL","vivid light":"vividLight","linear light":"linearLight","pin light":"pinLight","hard mix":"hardMix",difference:"Dfrn",exclusion:"Xclu",subtract:"blendSubtraction",divide:"blendDivide",hue:"H ",saturation:"Strt",color:"Clr ",luminosity:"Lmns","linear height":"linearHeight",height:"Hght",subtraction:"Sbtr","pass through":"????"});A.BESl=(0,$.createEnum)("BESl","inner bevel",{"inner bevel":"InrB","outer bevel":"OtrB",emboss:"Embs","pillow emboss":"PlEb","stroke emboss":"strokeEmboss"});A.bvlT=(0,$.createEnum)("bvlT","smooth",{smooth:"SfBL","chisel hard":"PrBL","chisel soft":"Slmt"});A.BESs=(0,$.createEnum)("BESs","up",{up:"In ",down:"Out "});A.BETE=(0,$.createEnum)("BETE","softer",{softer:"SfBL",precise:"PrBL"});A.IGSr=(0,$.createEnum)("IGSr","edge",{edge:"SrcE",center:"SrcC"});A.GrdT=(0,$.createEnum)("GrdT","linear",{linear:"Lnr ",radial:"Rdl ",angle:"Angl",reflected:"Rflc",diamond:"Dmnd"});A.animInterpStyleEnum=(0,$.createEnum)("animInterpStyle","linear",{linear:"Lnr ",hold:"hold"});A.stdTrackID=(0,$.createEnum)("stdTrackID","opacity",{opacity:"opacityTrack",style:"styleTrack",sheetTransform:"sheetTransformTrack",sheetPosition:"sheetPositionTrack",globalLighting:"globalLightingTrack"});A.gradientInterpolationMethodType=(0,$.createEnum)("gradientInterpolationMethodType","perceptual",{perceptual:"Perc",linear:"Lnr ",classic:"Gcls",smooth:"Smoo"});A.ClrS=(0,$.createEnum)("ClrS","rgb",{rgb:"RGBC",hsb:"HSBl",lab:"LbCl",hsl:"HSLC"});A.FStl=(0,$.createEnum)("FStl","outside",{outside:"OutF",center:"CtrF",inside:"InsF"});A.FrFl=(0,$.createEnum)("FrFl","color",{color:"SClr",gradient:"GrFl",pattern:"Ptrn"});A.ESliceType=(0,$.createEnum)("ESliceType","image",{image:"Img ",noImage:"noImage"});A.ESliceHorzAlign=(0,$.createEnum)("ESliceHorzAlign","default",{default:"default"});A.ESliceVertAlign=(0,$.createEnum)("ESliceVertAlign","default",{default:"default"});A.ESliceOrigin=(0,$.createEnum)("ESliceOrigin","userGenerated",{userGenerated:"userGenerated",autoGenerated:"autoGenerated",layer:"layer"});A.ESliceBGColorType=(0,$.createEnum)("ESliceBGColorType","none",{none:"None",matte:"matte",color:"Clr "});A.strokeStyleLineCapType=(0,$.createEnum)("strokeStyleLineCapType","butt",{butt:"strokeStyleButtCap",round:"strokeStyleRoundCap",square:"strokeStyleSquareCap"});A.strokeStyleLineJoinType=(0,$.createEnum)("strokeStyleLineJoinType","miter",{miter:"strokeStyleMiterJoin",round:"strokeStyleRoundJoin",bevel:"strokeStyleBevelJoin"});A.strokeStyleLineAlignment=(0,$.createEnum)("strokeStyleLineAlignment","inside",{inside:"strokeStyleAlignInside",center:"strokeStyleAlignCenter",outside:"strokeStyleAlignOutside"});A.BlrM=(0,$.createEnum)("BlrM","spin",{spin:"Spn ",zoom:"Zm "});A.BlrQ=(0,$.createEnum)("BlrQ","good",{draft:"Drft",good:"Gd ",best:"Bst "});A.SmBM=(0,$.createEnum)("SmBM","normal",{normal:"SBMN","edge only":"SBME","overlay edge":"SBMO"});A.SmBQ=(0,$.createEnum)("SmBQ","medium",{low:"SBQL",medium:"SBQM",high:"SBQH"});A.DspM=(0,$.createEnum)("DspM","stretch to fit",{"stretch to fit":"StrF",tile:"Tile"});A.UndA=(0,$.createEnum)("UndA","repeat edge pixels",{"wrap around":"WrpA","repeat edge pixels":"RptE"});A.Cnvr=(0,$.createEnum)("Cnvr","rectangular to polar",{"rectangular to polar":"RctP","polar to rectangular":"PlrR"});A.RplS=(0,$.createEnum)("RplS","medium",{small:"Sml ",medium:"Mdm ",large:"Lrg "});A.SphM=(0,$.createEnum)("SphM","normal",{normal:"Nrml","horizontal only":"HrzO","vertical only":"VrtO"});A.Wvtp=(0,$.createEnum)("Wvtp","sine",{sine:"WvSn",triangle:"WvTr",square:"WvSq"});A.ZZTy=(0,$.createEnum)("ZZTy","pond ripples",{"around center":"ArnC","out from center":"OtFr","pond ripples":"PndR"});A.Dstr=(0,$.createEnum)("Dstr","uniform",{uniform:"Unfr",gaussian:"Gsn "});A.Chnl=(0,$.createEnum)("Chnl","composite",{red:"Rd ",green:"Grn ",blue:"Bl ",composite:"Cmps"});A.MztT=(0,$.createEnum)("MztT","fine dots",{"fine dots":"FnDt","medium dots":"MdmD","grainy dots":"GrnD","coarse dots":"CrsD","short lines":"ShrL","medium lines":"MdmL","long lines":"LngL","short strokes":"ShSt","medium strokes":"MdmS","long strokes":"LngS"});A.Lns=(0,$.createEnum)("Lns ","50-300mm zoom",{"50-300mm zoom":"Zm ","32mm prime":"Nkn ","105mm prime":"Nkn1","movie prime":"PnVs"});A.blurType=(0,$.createEnum)("blurType","gaussian blur",{"gaussian blur":"GsnB","lens blur":"lensBlur","motion blur":"MtnB"});A.DfsM=(0,$.createEnum)("DfsM","normal",{normal:"Nrml","darken only":"DrkO","lighten only":"LghO",anisotropic:"anisotropic"});A.ExtT=(0,$.createEnum)("ExtT","blocks",{blocks:"Blks",pyramids:"Pyrm"});A.ExtR=(0,$.createEnum)("ExtR","random",{random:"Rndm","level-based":"LvlB"});A.FlCl=(0,$.createEnum)("FlCl","background color",{"background color":"FlBc","foreground color":"FlFr","inverse image":"FlIn","unaltered image":"FlSm"});A.CntE=(0,$.createEnum)("CntE","upper",{lower:"Lwr ",upper:"Upr "});A.WndM=(0,$.createEnum)("WndM","wind",{wind:"Wnd ",blast:"Blst",stagger:"Stgr"});A.Drct=(0,$.createEnum)("Drct","right",{left:"Left",right:"Rght"});A.IntE=(0,$.createEnum)("IntE","odd lines",{"odd lines":"ElmO","even lines":"ElmE"});A.IntC=(0,$.createEnum)("IntC","interpolation",{duplication:"CrtD",interpolation:"CrtI"});A.FlMd=(0,$.createEnum)("FlMd","wrap around",{"set to transparent":"Bckg","repeat edge pixels":"Rpt ","wrap around":"Wrp "});A.prjM=(0,$.createEnum)("prjM","fisheye",{fisheye:"fisP",perspective:"perP",auto:"auto","full spherical":"fusP"});A.presetKindType=(0,$.createEnum)("presetKindType","custom",{custom:"presetKindCustom",default:"presetKindDefault"})});var _r=oe(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.resourceHandlersMap=zt.resourceHandlers=void 0;var Ah=ji(),D=jt(),C=Dn(),Ie=Tt(),Ki=Ya(),q=Gi();zt.resourceHandlers=[];zt.resourceHandlersMap={};function H(e,t,n,i){let o={key:e,has:t,read:n,write:i};zt.resourceHandlers.push(o),zt.resourceHandlersMap[o.key]=o}var Je=!1,Hi=[void 0,"PPI","PPCM"],Wi=[void 0,"Inches","Centimeters","Points","Picas","Columns"],yl="0123456789abcdef";function wl(e){return e<=57?e-48:e>=97?e-87:e-55}function kh(e,t){return wl(e.charCodeAt(t))<<4|wl(e.charCodeAt(t+1))}function vr(e,t){let n=(0,D.readBytes)(e,t);return(0,Ki.decodeString)(n)}function xr(e,t){let n=(0,Ki.encodeString)(t);(0,C.writeBytes)(e,n)}function Ih(e){let t=(0,D.readUint8)(e),n=(0,D.readBytes)(e,t),i=!1;for(let o=0;o<n.byteLength;o++)if(n[o]&128){i=!0;break}if(i)try{return new TextDecoder("gbk").decode(n)}catch{}return(0,Ki.decodeString)(n)}function Dh(e,t){let n="";for(let o=0,r=t.codePointAt(o++);r!==void 0;r=t.codePointAt(o++))n+=r>127?"?":String.fromCodePoint(r);let i=(0,Ki.encodeString)(n);(0,C.writeUint8)(e,i.byteLength),(0,C.writeBytes)(e,i)}Ie.MOCK_HANDLERS&&H(1028,e=>e._ir1028!==void 0,(e,t,n)=>{Je&&console.log("image resource 1028",n()),t._ir1028=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1028)});H(1061,e=>e.captionDigest!==void 0,(e,t)=>{let n="";for(let i=0;i<16;i++){let o=(0,D.readUint8)(e);n+=yl[o>>4],n+=yl[o&15]}t.captionDigest=n},(e,t)=>{for(let n=0;n<16;n++)(0,C.writeUint8)(e,kh(t.captionDigest,n*2))});H(1060,e=>e.xmpMetadata!==void 0,(e,t,n)=>{t.xmpMetadata=vr(e,n())},(e,t)=>{xr(e,t.xmpMetadata)});var Xi=(0,Ie.createEnum)("Inte","perceptual",{perceptual:"Img ",saturation:"Grp ","relative colorimetric":"Clrm","absolute colorimetric":"AClr"});Ie.MOCK_HANDLERS&&H(1085,e=>e._ir1085!==void 0,(e,t,n)=>{t._ir1085=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1085)});H(1082,e=>e.printInformation!==void 0,(e,t)=>{var n,i;let o=(0,q.readVersionAndDescriptor)(e);t.printInformation={printerName:o.printerName||"",renderingIntent:Xi.decode((n=o.Inte)!==null&&n!==void 0?n:"Inte.Img ")};let r=t.printInformation;o.PstS!==void 0&&(r.printerManagesColors=o.PstS),o["Nm "]!==void 0&&(r.printerProfile=o["Nm "]),o.MpBl!==void 0&&(r.blackPointCompensation=o.MpBl),o.printSixteenBit!==void 0&&(r.printSixteenBit=o.printSixteenBit),o.hardProof!==void 0&&(r.hardProof=o.hardProof),o.printProofSetup&&("Bltn"in o.printProofSetup?r.proofSetup={builtin:o.printProofSetup.Bltn.split(".")[1]}:r.proofSetup={profile:o.printProofSetup.profile,renderingIntent:Xi.decode((i=o.printProofSetup.Inte)!==null&&i!==void 0?i:"Inte.Img "),blackPointCompensation:!!o.printProofSetup.MpBl,paperWhite:!!o.printProofSetup.paperWhite})},(e,t)=>{var n,i;let o=t.printInformation,r={};o.printerManagesColors?r.PstS=!0:(o.hardProof!==void 0&&(r.hardProof=!!o.hardProof),r.ClrS="ClrS.RGBC",r["Nm "]=(n=o.printerProfile)!==null&&n!==void 0?n:"CIE RGB"),r.Inte=Xi.encode(o.renderingIntent),o.printerManagesColors||(r.MpBl=!!o.blackPointCompensation),r.printSixteenBit=!!o.printSixteenBit,r.printerName=o.printerName||"",o.proofSetup&&"profile"in o.proofSetup?r.printProofSetup={profile:o.proofSetup.profile||"",Inte:Xi.encode(o.proofSetup.renderingIntent),MpBl:!!o.proofSetup.blackPointCompensation,paperWhite:!!o.proofSetup.paperWhite}:r.printProofSetup={Bltn:!((i=o.proofSetup)===null||i===void 0)&&i.builtin?`builtinProof.${o.proofSetup.builtin}`:"builtinProof.proofCMYK"},(0,q.writeVersionAndDescriptor)(e,"","printOutput",r)});Ie.MOCK_HANDLERS&&H(1083,e=>e._ir1083!==void 0,(e,t,n)=>{Je&&console.log("image resource 1083",n()),t._ir1083=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1083)});H(1005,e=>e.resolutionInfo!==void 0,(e,t)=>{let n=(0,D.readFixedPoint32)(e),i=(0,D.readUint16)(e),o=(0,D.readUint16)(e),r=(0,D.readFixedPoint32)(e),s=(0,D.readUint16)(e),a=(0,D.readUint16)(e);t.resolutionInfo={horizontalResolution:n,horizontalResolutionUnit:Hi[i]||"PPI",widthUnit:Wi[o]||"Inches",verticalResolution:r,verticalResolutionUnit:Hi[s]||"PPI",heightUnit:Wi[a]||"Inches"}},(e,t)=>{let n=t.resolutionInfo;(0,C.writeFixedPoint32)(e,n.horizontalResolution||0),(0,C.writeUint16)(e,Math.max(1,Hi.indexOf(n.horizontalResolutionUnit))),(0,C.writeUint16)(e,Math.max(1,Wi.indexOf(n.widthUnit))),(0,C.writeFixedPoint32)(e,n.verticalResolution||0),(0,C.writeUint16)(e,Math.max(1,Hi.indexOf(n.verticalResolutionUnit))),(0,C.writeUint16)(e,Math.max(1,Wi.indexOf(n.heightUnit)))});var Sl=["centered","size to fit","user defined"];H(1062,e=>e.printScale!==void 0,(e,t)=>{t.printScale={style:Sl[(0,D.readInt16)(e)],x:(0,D.readFloat32)(e),y:(0,D.readFloat32)(e),scale:(0,D.readFloat32)(e)}},(e,t)=>{let{style:n,x:i,y:o,scale:r}=t.printScale;(0,C.writeInt16)(e,Math.max(0,Sl.indexOf(n))),(0,C.writeFloat32)(e,i||0),(0,C.writeFloat32)(e,o||0),(0,C.writeFloat32)(e,r||0)});H(1006,e=>e.alphaChannelNames!==void 0,(e,t,n)=>{if(t.alphaChannelNames)(0,D.skipBytes)(e,n());else for(t.alphaChannelNames=[];n()>0;){let i=Ih(e);t.alphaChannelNames.push(i)}},(e,t)=>{for(let n of t.alphaChannelNames)Dh(e,n)});H(1045,e=>e.alphaChannelNames!==void 0,(e,t,n)=>{for(t.alphaChannelNames=[];n()>0;)t.alphaChannelNames.push((0,D.readUnicodeString)(e))},(e,t)=>{for(let n of t.alphaChannelNames)(0,C.writeUnicodeStringWithPadding)(e,n)});Ie.MOCK_HANDLERS&&H(1077,e=>e._ir1077!==void 0,(e,t,n)=>{Je&&console.log("image resource 1077",n()),t._ir1077=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1077)});H(1053,e=>e.alphaIdentifiers!==void 0,(e,t,n)=>{for(t.alphaIdentifiers=[];n()>=4;)t.alphaIdentifiers.push((0,D.readUint32)(e))},(e,t)=>{for(let n of t.alphaIdentifiers)(0,C.writeUint32)(e,n)});H(1010,e=>e.backgroundColor!==void 0,(e,t)=>t.backgroundColor=(0,D.readColor)(e),(e,t)=>(0,C.writeColor)(e,t.backgroundColor));H(1037,e=>e.globalAngle!==void 0,(e,t)=>t.globalAngle=(0,D.readInt32)(e),(e,t)=>(0,C.writeInt32)(e,t.globalAngle));H(1049,e=>e.globalAltitude!==void 0,(e,t)=>t.globalAltitude=(0,D.readUint32)(e),(e,t)=>(0,C.writeUint32)(e,t.globalAltitude));H(1011,e=>e.printFlags!==void 0,(e,t)=>{t.printFlags={labels:!!(0,D.readUint8)(e),cropMarks:!!(0,D.readUint8)(e),colorBars:!!(0,D.readUint8)(e),registrationMarks:!!(0,D.readUint8)(e),negative:!!(0,D.readUint8)(e),flip:!!(0,D.readUint8)(e),interpolate:!!(0,D.readUint8)(e),caption:!!(0,D.readUint8)(e),printFlags:!!(0,D.readUint8)(e)}},(e,t)=>{let n=t.printFlags;(0,C.writeUint8)(e,n.labels?1:0),(0,C.writeUint8)(e,n.cropMarks?1:0),(0,C.writeUint8)(e,n.colorBars?1:0),(0,C.writeUint8)(e,n.registrationMarks?1:0),(0,C.writeUint8)(e,n.negative?1:0),(0,C.writeUint8)(e,n.flip?1:0),(0,C.writeUint8)(e,n.interpolate?1:0),(0,C.writeUint8)(e,n.caption?1:0),(0,C.writeUint8)(e,n.printFlags?1:0)});H(1034,e=>e.copyrighted!==void 0,(e,t)=>{t.copyrighted=!!(0,D.readUint8)(e)},(e,t)=>{(0,C.writeUint8)(e,t.copyrighted?1:0)});H(1035,e=>e.url!==void 0,(e,t,n)=>{t.url=(0,D.readAsciiString)(e,n())},(e,t)=>{(0,C.writeAsciiString)(e,t.url)});Ie.MOCK_HANDLERS&&H(1e4,e=>e._ir10000!==void 0,(e,t,n)=>{Je&&console.log("image resource 10000",n()),t._ir10000=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir10000)});Ie.MOCK_HANDLERS&&H(1013,e=>e._ir1013!==void 0,(e,t,n)=>{Je&&console.log("image resource 1013",n()),t._ir1013=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1013)});Ie.MOCK_HANDLERS&&H(1016,e=>e._ir1016!==void 0,(e,t,n)=>{Je&&console.log("image resource 1016",n()),t._ir1016=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1016)});H(1080,e=>e.countInformation!==void 0,(e,t)=>{let n=(0,q.readVersionAndDescriptor)(e);t.countInformation=n.countGroupList.map(i=>({color:{r:i["Rd "],g:i["Grn "],b:i["Bl "]},name:i["Nm "],size:i["Rds "],fontSize:i.fontSize,visible:i.Vsbl,points:i.countObjectList.map(o=>({x:o["X "],y:o["Y "]}))}))},(e,t)=>{let n={Vrsn:1,countGroupList:t.countInformation.map(i=>({"Rd ":i.color.r,"Grn ":i.color.g,"Bl ":i.color.b,"Nm ":i.name,"Rds ":i.size,fontSize:i.fontSize,Vsbl:i.visible,countObjectList:i.points.map(o=>({"X ":o.x,"Y ":o.y}))}))};(0,q.writeVersionAndDescriptor)(e,"","Cnt ",n)});H(1024,e=>e.layerState!==void 0,(e,t)=>t.layerState=(0,D.readUint16)(e),(e,t)=>(0,C.writeUint16)(e,t.layerState));H(1026,e=>e.layersGroup!==void 0,(e,t,n)=>{for(t.layersGroup=[];n()>0;)t.layersGroup.push((0,D.readUint16)(e))},(e,t)=>{for(let n of t.layersGroup)(0,C.writeUint16)(e,n)});H(1072,e=>e.layerGroupsEnabledId!==void 0,(e,t,n)=>{for(t.layerGroupsEnabledId=[];n()>0;)t.layerGroupsEnabledId.push((0,D.readUint8)(e))},(e,t)=>{for(let n of t.layerGroupsEnabledId)(0,C.writeUint8)(e,n)});H(1069,e=>e.layerSelectionIds!==void 0,(e,t)=>{let n=(0,D.readUint16)(e);for(t.layerSelectionIds=[];n--;)t.layerSelectionIds.push((0,D.readUint32)(e))},(e,t)=>{(0,C.writeUint16)(e,t.layerSelectionIds.length);for(let n of t.layerSelectionIds)(0,C.writeUint32)(e,n)});H(1032,e=>e.gridAndGuidesInformation!==void 0,(e,t)=>{let n=(0,D.readUint32)(e),i=(0,D.readUint32)(e),o=(0,D.readUint32)(e),r=(0,D.readUint32)(e);if(n!==1)throw new Error(`Invalid 1032 resource version: ${n}`);t.gridAndGuidesInformation={grid:{horizontal:i,vertical:o},guides:[]};for(let s=0;s<r;s++)t.gridAndGuidesInformation.guides.push({location:(0,D.readUint32)(e)/32,direction:(0,D.readUint8)(e)?"horizontal":"vertical"})},(e,t)=>{let n=t.gridAndGuidesInformation,i=n.grid||{horizontal:576,vertical:576},o=n.guides||[];(0,C.writeUint32)(e,1),(0,C.writeUint32)(e,i.horizontal),(0,C.writeUint32)(e,i.vertical),(0,C.writeUint32)(e,o.length);for(let r of o)(0,C.writeUint32)(e,r.location*32),(0,C.writeUint8)(e,r.direction==="horizontal"?1:0)});H(1065,e=>e.layerComps!==void 0,(e,t)=>{let n=(0,q.readVersionAndDescriptor)(e,!0);t.layerComps={list:[]};for(let i of n.list)t.layerComps.list.push({id:i.compID,name:i["Nm "],capturedInfo:i.capturedInfo}),"comment"in i&&(t.layerComps.list[t.layerComps.list.length-1].comment=i.comment);"lastAppliedComp"in n&&(t.layerComps.lastApplied=n.lastAppliedComp)},(e,t)=>{let n=t.layerComps,i={list:[]};for(let o of n.list){let r={};r._classID="Comp",r["Nm "]=o.name,"comment"in o&&(r.comment=o.comment),r.compID=o.id,r.capturedInfo=o.capturedInfo,i.list.push(r)}"lastApplied"in n&&(i.lastAppliedComp=n.lastApplied),(0,q.writeVersionAndDescriptor)(e,"","CompList",i)});Ie.MOCK_HANDLERS&&H(1092,e=>e._ir1092!==void 0,(e,t,n)=>{Je&&console.log("image resource 1092",n()),t._ir1092=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1092)});var vl=["normal",void 0,void 0,void 0,void 0,void 0,void 0,"multiply","screen",void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,"difference"];H(1078,e=>e.onionSkins!==void 0,(e,t)=>{let n=(0,q.readVersionAndDescriptor)(e);t.onionSkins={enabled:n.enab,framesBefore:n.numBefore,framesAfter:n.numAfter,frameSpacing:n.Spcn,minOpacity:n.minOpacity/100,maxOpacity:n.maxOpacity/100,blendMode:vl[n.BlnM]||"normal"}},(e,t)=>{let n=t.onionSkins,i={Vrsn:1,enab:n.enabled,numBefore:n.framesBefore,numAfter:n.framesAfter,Spcn:n.frameSpacing,minOpacity:n.minOpacity*100|0,maxOpacity:n.maxOpacity*100|0,BlnM:Math.max(0,vl.indexOf(n.blendMode))};(0,q.writeVersionAndDescriptor)(e,"","null",i)});H(1075,e=>e.timelineInformation!==void 0,(e,t)=>{var n,i;let o=(0,q.readVersionAndDescriptor)(e);t.timelineInformation={enabled:o.enab,frameStep:(0,q.frac)(o.frameStep),frameRate:o.frameRate,time:(0,q.frac)(o.time),duration:(0,q.frac)(o.duration),workInTime:(0,q.frac)(o.workInTime),workOutTime:(0,q.frac)(o.workOutTime),repeats:o.LCnt,hasMotion:o.hasMotion,globalTracks:(0,q.parseTrackList)(o.globalTrackList,!!e.logMissingFeatures)},!((i=(n=o.audioClipGroupList)===null||n===void 0?void 0:n.audioClipGroupList)===null||i===void 0)&&i.length&&(t.timelineInformation.audioClipGroups=o.audioClipGroupList.audioClipGroupList.map(r=>({id:r.groupID,muted:r.muted,audioClips:r.audioClipList.map(({clipID:s,timeScope:a,muted:l,audioLevel:c,frameReader:d})=>({id:s,start:(0,q.frac)(a.Strt),duration:(0,q.frac)(a.duration),inTime:(0,q.frac)(a.inTime),outTime:(0,q.frac)(a.outTime),muted:l,audioLevel:c,frameReader:{type:d.frameReaderType,mediaDescriptor:d.mediaDescriptor,link:{name:d["Lnk "]["Nm "],fullPath:d["Lnk "].fullPath,relativePath:d["Lnk "].relPath}}}))})))},(e,t)=>{var n;let i=t.timelineInformation,o={Vrsn:1,enab:i.enabled,frameStep:i.frameStep,frameRate:i.frameRate,time:i.time,duration:i.duration,workInTime:i.workInTime,workOutTime:i.workOutTime,LCnt:i.repeats,globalTrackList:(0,q.serializeTrackList)(i.globalTracks),audioClipGroupList:{audioClipGroupList:(n=i.audioClipGroups)===null||n===void 0?void 0:n.map(r=>({groupID:r.id,muted:r.muted,audioClipList:r.audioClips.map(s=>({clipID:s.id,timeScope:{Vrsn:1,Strt:s.start,duration:s.duration,inTime:s.inTime,outTime:s.outTime},frameReader:{frameReaderType:s.frameReader.type,descVersion:1,"Lnk ":{descVersion:1,"Nm ":s.frameReader.link.name,fullPath:s.frameReader.link.fullPath,relPath:s.frameReader.link.relativePath},mediaDescriptor:s.frameReader.mediaDescriptor},muted:s.muted,audioLevel:s.audioLevel}))}))},hasMotion:i.hasMotion};(0,q.writeVersionAndDescriptor)(e,"","null",o,"anim")});H(1076,e=>e.sheetDisclosure!==void 0,(e,t)=>{let n=(0,q.readVersionAndDescriptor)(e);t.sheetDisclosure={},n.sheetTimelineOptions&&(t.sheetDisclosure.sheetTimelineOptions=n.sheetTimelineOptions.map(i=>({sheetID:i.sheetID,sheetDisclosed:i.sheetDisclosed,lightsDisclosed:i.lightsDisclosed,meshesDisclosed:i.meshesDisclosed,materialsDisclosed:i.materialsDisclosed})))},(e,t)=>{let n=t.sheetDisclosure,i={Vrsn:1};n.sheetTimelineOptions&&(i.sheetTimelineOptions=n.sheetTimelineOptions.map(o=>({Vrsn:2,sheetID:o.sheetID,sheetDisclosed:o.sheetDisclosed,lightsDisclosed:o.lightsDisclosed,meshesDisclosed:o.meshesDisclosed,materialsDisclosed:o.materialsDisclosed}))),(0,q.writeVersionAndDescriptor)(e,"","null",i)});H(1054,e=>e.urlsList!==void 0,(e,t)=>{let n=(0,D.readUint32)(e);t.urlsList=[];for(let i=0;i<n;i++){if((0,D.readSignature)(e)!=="slic"&&e.throwForMissingFeatures)throw new Error("Unknown long");let r=(0,D.readUint32)(e),s=(0,D.readUnicodeString)(e);t.urlsList.push({id:r,url:s,ref:"slice"})}},(e,t)=>{let n=t.urlsList;(0,C.writeUint32)(e,n.length);for(let i=0;i<n.length;i++)(0,C.writeSignature)(e,"slic"),(0,C.writeUint32)(e,n[i].id),(0,C.writeUnicodeString)(e,n[i].url)});function xl(e){return{"Top ":e.top,Left:e.left,Btom:e.bottom,Rght:e.right}}function _l(e){return{top:e["Top "],left:e.Left,bottom:e.Btom,right:e.Rght}}function Zi(e,t){return e[Math.max(0,Math.min(e.length-1,t))]}var Al=["autoGenerated","layer","userGenerated"],kl=["noImage","image"],qi=["default"];H(1050,e=>e.slices?e.slices.length:0,(e,t)=>{let n=(0,D.readUint32)(e);if(n===6){t.slices||(t.slices=[]);let i=(0,D.readInt32)(e),o=(0,D.readInt32)(e),r=(0,D.readInt32)(e),s=(0,D.readInt32)(e),a=(0,D.readUnicodeString)(e),l=(0,D.readUint32)(e);t.slices.push({bounds:{top:i,left:o,bottom:r,right:s},groupName:a,slices:[]});let c=t.slices[t.slices.length-1].slices;for(let u=0;u<l;u++){let f=(0,D.readUint32)(e),h=(0,D.readUint32)(e),p=Zi(Al,(0,D.readUint32)(e)),S=p=="layer"?(0,D.readUint32)(e):0,m=(0,D.readUnicodeString)(e),g=Zi(kl,(0,D.readUint32)(e)),v=(0,D.readInt32)(e),x=(0,D.readInt32)(e),_=(0,D.readInt32)(e),I=(0,D.readInt32)(e),P=(0,D.readUnicodeString)(e),k=(0,D.readUnicodeString)(e),E=(0,D.readUnicodeString)(e),O=(0,D.readUnicodeString)(e),U=!!(0,D.readUint8)(e),M=(0,D.readUnicodeString)(e),le=Zi(qi,(0,D.readUint32)(e)),me=Zi(qi,(0,D.readUint32)(e)),T=(0,D.readUint8)(e),W=(0,D.readUint8)(e),te=(0,D.readUint8)(e),ne=(0,D.readUint8)(e),Pe=T+W+te+ne===0?"none":T===0?"matte":"color";c.push({id:f,groupId:h,origin:p,associatedLayerId:S,name:m,target:k,message:E,altTag:O,cellTextIsHTML:U,cellText:M,horizontalAlignment:le,verticalAlignment:me,type:g,url:P,bounds:{top:x,left:v,bottom:I,right:_},backgroundColorType:Pe,backgroundColor:{r:W,g:te,b:ne,a:T}})}(0,q.readVersionAndDescriptor)(e).slices.forEach(u=>{let f=c.find(h=>u.sliceID==h.id);f&&(f.topOutset=u.topOutset,f.leftOutset=u.leftOutset,f.bottomOutset=u.bottomOutset,f.rightOutset=u.rightOutset)})}else if(n===7||n===8){let i=(0,q.readVersionAndDescriptor)(e);t.slices||(t.slices=[]),t.slices.push({groupName:i.baseName,bounds:_l(i.bounds),slices:i.slices.map(o=>Object.assign(Object.assign({},o["Nm "]?{name:o["Nm "]}:{}),{id:o.sliceID,groupId:o.groupID,associatedLayerId:0,origin:q.ESliceOrigin.decode(o.origin),type:q.ESliceType.decode(o.Type),bounds:_l(o.bounds),url:o.url,target:o.null,message:o.Msge,altTag:o.altTag,cellTextIsHTML:o.cellTextIsHTML,cellText:o.cellText,horizontalAlignment:q.ESliceHorzAlign.decode(o.horzAlign),verticalAlignment:q.ESliceVertAlign.decode(o.vertAlign),backgroundColorType:q.ESliceBGColorType.decode(o.bgColorType),backgroundColor:o.bgColor?{r:o.bgColor["Rd "],g:o.bgColor["Grn "],b:o.bgColor["Bl "],a:o.bgColor.alpha}:{r:0,g:0,b:0,a:0},topOutset:o.topOutset||0,leftOutset:o.leftOutset||0,bottomOutset:o.bottomOutset||0,rightOutset:o.rightOutset||0}))})}else throw new Error(`Invalid slices version (${n})`)},(e,t,n)=>{let{bounds:i,groupName:o,slices:r}=t.slices[n];(0,C.writeUint32)(e,6),(0,C.writeInt32)(e,i.top),(0,C.writeInt32)(e,i.left),(0,C.writeInt32)(e,i.bottom),(0,C.writeInt32)(e,i.right),(0,C.writeUnicodeString)(e,o),(0,C.writeUint32)(e,r.length);for(let a=0;a<r.length;a++){let l=r[a],{a:c,r:d,g:u,b:f}=l.backgroundColor;l.backgroundColorType==="none"?c=d=u=f=0:l.backgroundColorType==="matte"&&(c=0,d=u=f=255),(0,C.writeUint32)(e,l.id),(0,C.writeUint32)(e,l.groupId),(0,C.writeUint32)(e,Al.indexOf(l.origin)),l.origin==="layer"&&(0,C.writeUint32)(e,l.associatedLayerId),(0,C.writeUnicodeString)(e,l.name||""),(0,C.writeUint32)(e,kl.indexOf(l.type)),(0,C.writeInt32)(e,l.bounds.left),(0,C.writeInt32)(e,l.bounds.top),(0,C.writeInt32)(e,l.bounds.right),(0,C.writeInt32)(e,l.bounds.bottom),(0,C.writeUnicodeString)(e,l.url),(0,C.writeUnicodeString)(e,l.target),(0,C.writeUnicodeString)(e,l.message),(0,C.writeUnicodeString)(e,l.altTag),(0,C.writeUint8)(e,l.cellTextIsHTML?1:0),(0,C.writeUnicodeString)(e,l.cellText),(0,C.writeUint32)(e,qi.indexOf(l.horizontalAlignment)),(0,C.writeUint32)(e,qi.indexOf(l.verticalAlignment)),(0,C.writeUint8)(e,c),(0,C.writeUint8)(e,d),(0,C.writeUint8)(e,u),(0,C.writeUint8)(e,f)}let s={bounds:xl(i),slices:[]};r.forEach(a=>{let l=Object.assign(Object.assign({sliceID:a.id,groupID:a.groupId,origin:q.ESliceOrigin.encode(a.origin),Type:q.ESliceType.encode(a.type),bounds:xl(a.bounds)},a.name?{"Nm ":a.name}:{}),{url:a.url,null:a.target,Msge:a.message,altTag:a.altTag,cellTextIsHTML:a.cellTextIsHTML,cellText:a.cellText,horzAlign:q.ESliceHorzAlign.encode(a.horizontalAlignment),vertAlign:q.ESliceVertAlign.encode(a.verticalAlignment),bgColorType:q.ESliceBGColorType.encode(a.backgroundColorType)});if(a.backgroundColorType==="color"){let{r:c,g:d,b:u,a:f}=a.backgroundColor;l.bgColor={"Rd ":c,"Grn ":d,"Bl ":u,alpha:f}}l.topOutset=a.topOutset||0,l.leftOutset=a.leftOutset||0,l.bottomOutset=a.bottomOutset||0,l.rightOutset=a.rightOutset||0,s.slices.push(l)}),(0,q.writeVersionAndDescriptor)(e,"","null",s,"slices")});H(1064,e=>e.pixelAspectRatio!==void 0,(e,t)=>{if((0,D.readUint32)(e)>2)throw new Error("Invalid pixelAspectRatio version");t.pixelAspectRatio={aspect:(0,D.readFloat64)(e)}},(e,t)=>{(0,C.writeUint32)(e,2),(0,C.writeFloat64)(e,t.pixelAspectRatio.aspect)});H(1041,e=>e.iccUntaggedProfile!==void 0,(e,t)=>{t.iccUntaggedProfile=!!(0,D.readUint8)(e)},(e,t)=>{(0,C.writeUint8)(e,t.iccUntaggedProfile?1:0)});Ie.MOCK_HANDLERS&&H(1039,e=>e._ir1039!==void 0,(e,t,n)=>{Je&&console.log("image resource 1039",n()),t._ir1039=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1039)});H(1044,e=>e.idsSeedNumber!==void 0,(e,t)=>t.idsSeedNumber=(0,D.readUint32)(e),(e,t)=>(0,C.writeUint32)(e,t.idsSeedNumber));H(1036,e=>e.thumbnail!==void 0||e.thumbnailRaw!==void 0,(e,t,n)=>{let i=(0,D.readUint32)(e),o=(0,D.readUint32)(e),r=(0,D.readUint32)(e);(0,D.readUint32)(e),(0,D.readUint32)(e),(0,D.readUint32)(e);let s=(0,D.readUint16)(e),a=(0,D.readUint16)(e);if(i!==1||s!==24||a!==1){e.logMissingFeatures&&e.log(`Invalid thumbnail data (format: ${i}, bitsPerPixel: ${s}, planes: ${a})`),(0,D.skipBytes)(e,n());return}let l=n(),c=(0,D.readBytes)(e,l);e.useRawThumbnail?t.thumbnailRaw={width:o,height:r,data:c}:c.byteLength&&(t.thumbnail=(0,Ie.createCanvasFromData)(c))},(e,t)=>{var n;let i=0,o=0,r=new Uint8Array(0);if(t.thumbnailRaw)i=t.thumbnailRaw.width,o=t.thumbnailRaw.height,r=t.thumbnailRaw.data;else try{let u=(n=t.thumbnail.toDataURL("image/jpeg",1))===null||n===void 0?void 0:n.substring(23);u&&(r=(0,Ah.toByteArray)(u),i=t.thumbnail.width,o=t.thumbnail.height)}catch{}let s=24,a=Math.floor((i*s+31)/32)*4,l=1,c=a*o*l,d=r.length;(0,C.writeUint32)(e,1),(0,C.writeUint32)(e,i),(0,C.writeUint32)(e,o),(0,C.writeUint32)(e,a),(0,C.writeUint32)(e,c),(0,C.writeUint32)(e,d),(0,C.writeUint16)(e,s),(0,C.writeUint16)(e,l),(0,C.writeBytes)(e,r)});H(1057,e=>e.versionInfo!==void 0,(e,t,n)=>{if((0,D.readUint32)(e)!==1)throw new Error("Invalid versionInfo version");t.versionInfo={hasRealMergedData:!!(0,D.readUint8)(e),writerName:(0,D.readUnicodeString)(e),readerName:(0,D.readUnicodeString)(e),fileVersion:(0,D.readUint32)(e)},(0,D.skipBytes)(e,n())},(e,t)=>{let n=t.versionInfo;(0,C.writeUint32)(e,1),(0,C.writeUint8)(e,n.hasRealMergedData?1:0),(0,C.writeUnicodeString)(e,n.writerName),(0,C.writeUnicodeString)(e,n.readerName),(0,C.writeUint32)(e,n.fileVersion)});Ie.MOCK_HANDLERS&&H(1058,e=>e._ir1058!==void 0,(e,t,n)=>{Je&&console.log("image resource 1058",n()),t._ir1058=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1058)});H(7e3,e=>e.imageReadyVariables!==void 0,(e,t,n)=>{t.imageReadyVariables=vr(e,n())},(e,t)=>{xr(e,t.imageReadyVariables)});H(7001,e=>e.imageReadyDataSets!==void 0,(e,t,n)=>{t.imageReadyDataSets=vr(e,n())},(e,t)=>{xr(e,t.imageReadyDataSets)});H(1088,e=>e.pathSelectionState!==void 0,(e,t,n)=>{let i=(0,q.readVersionAndDescriptor)(e);t.pathSelectionState=i.null},(e,t)=>{let n={null:t.pathSelectionState};(0,q.writeVersionAndDescriptor)(e,"","null",n)});Ie.MOCK_HANDLERS&&H(1025,e=>e._ir1025!==void 0,(e,t,n)=>{Je&&console.log("image resource 1025",n()),t._ir1025=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1025)});var Il=(0,Ie.createEnum)("FrmD","auto",{auto:"Auto",none:"None",dispose:"Disp"});H(4e3,e=>e.animations!==void 0,(e,t,n)=>{let i=(0,D.readSignature)(e);if(i==="mani")(0,D.checkSignature)(e,"IRFR"),(0,D.readSection)(e,1,o=>{for(;o()>0;){(0,D.checkSignature)(e,"8BIM");let r=(0,D.readSignature)(e);(0,D.readSection)(e,1,s=>{if(r==="AnDs"){let a=(0,q.readVersionAndDescriptor)(e);t.animations={frames:a.FrIn.map(l=>({id:l.FrID,delay:(l.FrDl||0)/100,dispose:l.FrDs?Il.decode(l.FrDs):"auto"})),animations:a.FSts.map(l=>({id:l.FsID,frames:l.FsFr,repeats:l.LCnt,activeFrame:l.AFrm||0}))}}else if(r==="Roll"){let a=(0,D.readBytes)(e,s());e.logDevFeatures&&e.log("#4000 Roll",a)}else e.logMissingFeatures&&e.log("Unhandled subsection in #4000",r)})}});else if(i==="mopt"){let o=(0,D.readBytes)(e,n());e.logDevFeatures&&e.log("#4000 mopt",o)}else e.logMissingFeatures&&e.log("Unhandled key in #4000:",i)},(e,t)=>{t.animations&&((0,C.writeSignature)(e,"mani"),(0,C.writeSignature)(e,"IRFR"),(0,C.writeSection)(e,1,()=>{(0,C.writeSignature)(e,"8BIM"),(0,C.writeSignature)(e,"AnDs"),(0,C.writeSection)(e,1,()=>{let n={FrIn:[],FSts:[]};for(let i=0;i<t.animations.frames.length;i++){let o=t.animations.frames[i],r={FrID:o.id};o.delay&&(r.FrDl=o.delay*100|0),r.FrDs=Il.encode(o.dispose),n.FrIn.push(r)}for(let i=0;i<t.animations.animations.length;i++){let o=t.animations.animations[i],r={FsID:o.id,AFrm:o.activeFrame|0,FsFr:o.frames,LCnt:o.repeats|0};n.FSts.push(r)}(0,q.writeVersionAndDescriptor)(e,"","null",n)})}))});Ie.MOCK_HANDLERS&&H(4001,e=>e._ir4001!==void 0,(e,t,n)=>{if(Ie.MOCK_HANDLERS){Je&&console.log("image resource 4001",n()),t._ir4001=(0,D.readBytes)(e,n());return}let i=(0,D.readSignature)(e);if(i==="mfri"){if((0,D.readUint32)(e)!==2)throw new Error("Invalid mfri version");let r=(0,D.readUint32)(e),s=(0,D.readBytes)(e,r);e.logDevFeatures&&e.log("mfri",s)}else if(i==="mset"){let o=(0,q.readVersionAndDescriptor)(e);e.logDevFeatures&&e.log("mset",o)}else e.logMissingFeatures&&e.log("Unhandled key in #4001",i)},(e,t)=>{(0,C.writeBytes)(e,t._ir4001)});Ie.MOCK_HANDLERS&&H(4002,e=>e._ir4002!==void 0,(e,t,n)=>{Je&&console.log("image resource 4002",n()),t._ir4002=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir4002)})});var jt=oe(N=>{"use strict";var Ch=N&&N.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]]);return n};Object.defineProperty(N,"__esModule",{value:!0});N.supportedColorModes=void 0;N.createReader=to;N.warnOrThrow=Qi;N.readUint8=ge;N.peekUint8=El;N.readInt16=Nt;N.readUint16=re;N.readUint16LE=Fl;N.readInt32=Re;N.readInt32LE=Lh;N.readUint32=pe;N.readFloat32=Bh;N.readFloat64=Ir;N.readFixedPoint32=Uh;N.readFixedPointPath32=Rh;N.readBytes=yt;N.readSignature=ii;N.validSignatureAt=Ol;N.readPascalString=no;N.readUnicodeString=Ll;N.readUnicodeStringWithLength=Bl;N.readUnicodeStringWithLengthLE=Mh;N.readAsciiString=Th;N.skipBytes=Se;N.checkSignature=Fr;N.readPsd=zh;N.readLayerInfo=Rl;N.getCompositeImageData=Ml;N.getCompositeCanvas=Hh;N.getLayerImageData=Tl;N.getLayerMaskImageData=jl;N.getLayerRealMaskImageData=zl;N.getLayerCanvas=Wh;N.getLayerMaskCanvas=Xh;N.getLayerRealMaskCanvas=Zh;N.decodeLayerPixels=qh;N.readGlobalLayerMaskInfo=Nl;N.readAdditionalLayerInfo=Or;N.readDataZip=Er;N.readDataRLE=$t;N.readSection=ot;N.readColor=e0;N.readPattern=t0;var Ph=ur(),De=Tt(),Eh=oo(),Fh=_r();N.supportedColorModes=[0,1,3,2];var Oh=["bitmap","grayscale","indexed","RGB","CMYK","","","multichannel","duotone","lab"];function Ji(e){let t=e.width*e.height*4;for(let n=0;n<t;n+=4){let i=e.data[n];e.data[n+1]=i,e.data[n+2]=i}}function to(e,t,n){return{view:new DataView(e,t,n),offset:0,strict:!1,debug:!1,large:!1,globalAlpha:!1,log:console.log}}function Qi(e,t){if(e.strict)throw new Error(t);e.debug&&e.log(t)}function ge(e){return e.offset+=1,e.view.getUint8(e.offset-1)}function El(e){return e.view.getUint8(e.offset)}function Nt(e){return e.offset+=2,e.view.getInt16(e.offset-2,!1)}function re(e){return e.offset+=2,e.view.getUint16(e.offset-2,!1)}function Fl(e){return e.offset+=2,e.view.getUint16(e.offset-2,!0)}function Re(e){return e.offset+=4,e.view.getInt32(e.offset-4,!1)}function Lh(e){return e.offset+=4,e.view.getInt32(e.offset-4,!0)}function pe(e){return e.offset+=4,e.view.getUint32(e.offset-4,!1)}function Bh(e){return e.offset+=4,e.view.getFloat32(e.offset-4,!1)}function Ir(e){return e.offset+=8,e.view.getFloat64(e.offset-8,!1)}function Uh(e){return Re(e)/65536}function Rh(e){return Re(e)/(1<<24)}function yt(e,t){let n=e.view.byteOffset+e.offset;if(e.offset+=t,n+t>e.view.buffer.byteLength){if(Qi(e,"Reading bytes exceeding buffer length"),t>100*1024*1024)throw new Error("Reading past end of file");let i=new Uint8Array(t),o=Math.min(t,e.view.byteLength-n);return o>0&&i.set(new Uint8Array(e.view.buffer,n,o)),i}else return new Uint8Array(e.view.buffer,n,t)}function ii(e){return Ul(e,4)}function Ol(e,t){let n=String.fromCharCode(e.view.getUint8(t))+String.fromCharCode(e.view.getUint8(t+1))+String.fromCharCode(e.view.getUint8(t+2))+String.fromCharCode(e.view.getUint8(t+3));return n=="8BIM"||n=="8B64"}function no(e,t){let n=ge(e),i=n?Ul(e,n):"";for(;++n%t;)e.offset++;return i}function Ll(e){let t=pe(e);return Bl(e,t)}function Bl(e,t){let n="";for(;t--;){let i=re(e);(i||t>0)&&(n+=String.fromCharCode(i))}return n}function Mh(e,t){let n="";for(;t--;){let i=Fl(e);(i||t>0)&&(n+=String.fromCharCode(i))}return n}function Th(e,t){let n="";for(;t--;)n+=String.fromCharCode(ge(e));return n}function Se(e,t){e.offset+=t}function Fr(e,t,n){let i=e.offset,o=ii(e);if(o!==t&&o!==n)throw new Error(`Invalid signature: '${o}' at 0x${i.toString(16)}`)}function Ul(e,t){let n=yt(e,t),i="";for(let o=0;o<n.length;o++)i+=String.fromCharCode(n[o]);return i}function jh(e){return e==="8BIM"||e==="MeSa"||e==="AgHg"||e==="PHUT"||e==="DCSR"}function zh(e,t={}){var n;Fr(e,"8BPS");let i=re(e);if(i!==1&&i!==2)throw new Error(`Invalid PSD file version: ${i}`);Se(e,6);let o=re(e),r=pe(e),s=pe(e),a=re(e),l=re(e),c=i===1?3e4:3e5;if(s>c||r>c)throw new Error(`Invalid size: ${s}x${r}`);if(o>16)throw new Error(`Invalid channel count: ${o}`);if(![1,8,16,32].includes(a))throw new Error(`Invalid bitsPerChannel: ${a}`);if(N.supportedColorModes.indexOf(l)===-1)throw new Error(`Color mode not supported: ${(n=Oh[l])!==null&&n!==void 0?n:l}`);let d={width:s,height:r,channels:o,bitsPerChannel:a,colorMode:l};Object.assign(e,t),e.large=i===2,e.globalAlpha=!1,"totalMemoryLimit"in e||(e.totalMemoryLimit=2*1024*1024*1024),ot(e,1,g=>{if(g()){if(l===2){if(g()!=768)throw new Error("Invalid color palette size");d.palette=[];for(let v=0;v<256;v++)d.palette.push({r:ge(e),g:0,b:0});for(let v=0;v<256;v++)d.palette[v].g=ge(e);for(let v=0;v<256;v++)d.palette[v].b=ge(e)}Se(e,g())}});let u={};ot(e,1,g=>{for(;g()>0;){Vl(e,jh);let v=re(e);no(e,2),ot(e,2,x=>{let _=Fh.resourceHandlersMap[v],I=v===1036&&!!e.skipThumbnail;if(_&&!I)try{_.read(e,u,x)}catch(P){if(e.throwForMissingFeatures)throw P;Se(e,x())}else Se(e,x())})}});let{layersGroup:f,layerGroupsEnabledId:h}=u,p=Ch(u,["layersGroup","layerGroupsEnabledId"]);Object.keys(p).length&&(d.imageResources=p),ot(e,1,g=>{if(ot(e,2,v=>{Rl(e,d,u),Se(e,v())},void 0,e.large),g()>0){let v=Nl(e);v&&(d.globalLayerMaskInfo=v)}else Se(e,g());for(;g()>0;){for(;g()&&El(e)===0;)Se(e,1);g()>=12?Or(e,d,d,u):Se(e,g())}},void 0,e.large);let S=d.children&&d.children.length;if(!(e.skipCompositeImageData&&(e.skipLayerImageData||S)))if(e.useRawData)d.rawCompositeData=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset);else{let g=Gl(e,d);e.useImageData?d.imageData=g:d.canvas=(0,De.imageDataToCanvas)(g)}return d}function Rl(e,t,n){var i,o;let{layersGroup:r=[],layerGroupsEnabledId:s=[]}=n,a=Nt(e);a<0&&(e.globalAlpha=!0,a=-a);let l=[],c=[];for(let u=0;u<a;u++){let{layer:f,channels:h}=$h(e,t,n);r[u]!==void 0&&(f.linkGroup=r[u]),s[u]!==void 0&&(f.linkGroupEnabled=!!s[u]),l.push(f),c.push(h)}for(let u=0;u<a;u++)Gh(e,t,l[u],c[u]);t.children||(t.children=[]);let d=[t];for(let u=l.length-1;u>=0;u--){let f=l[u],h=f.sectionDivider?f.sectionDivider.type:0;h===1||h===2?(f.opened=h===1,f.children=[],!((i=f.sectionDivider)===null||i===void 0)&&i.key&&(f.blendMode=(o=De.toBlendMode[f.sectionDivider.key])!==null&&o!==void 0?o:f.blendMode),d[d.length-1].children.unshift(f),d.push(f)):h===3?d.pop():d[d.length-1].children.unshift(f)}}function $h(e,t,n){let i={};if(i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!Dr(i,e))throw new Error("Invalid layer size");let o=re(e),r=[];for(let l=0;l<o;l++){let c=Nt(e),d=pe(e);if(e.large){if(d!==0)throw new Error("Sizes larger than 4GB are not supported");d=pe(e)}r.push({id:c,length:d})}Fr(e,"8BIM");let s=ii(e);if(!De.toBlendMode[s])throw new Error(`Invalid blend mode: '${s}'`);i.blendMode=De.toBlendMode[s],i.opacity=ge(e)/255,i.clipping=ge(e)===1;let a=ge(e);return i.transparencyProtected=(a&1)!==0,i.hidden=(a&2)!==0,a&32&&(i.effectsOpen=!0),Se(e,1),ot(e,1,l=>{Nh(e,i);let c=Vh(e);for(c&&(i.blendingRanges=c),i.name=no(e,1);l()>4&&!Ol(e,e.offset);)e.offset++;for(;l()>=12;)Or(e,i,t,n);Se(e,l())}),{layer:i,channels:r}}function Dr(e,t){let n=(e.right||0)-(e.left||0),i=(e.bottom||0)-(e.top||0),o=t.large?3e5:3e4;return n>=0&&i>=0&&n<=o&&i<=o}function Nh(e,t){return ot(e,1,n=>{if(!n())return;let i={};if(t.mask=i,i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!Dr(i,e))throw new Error("Invalid mask size");i.defaultColor=ge(e);let o=ge(e);if(i.positionRelativeToLayer=(o&1)!==0,i.disabled=(o&2)!==0,i.fromVectorData=(o&8)!==0,n()>=18){let r={};t.realMask=r;let s=ge(e);if(r.positionRelativeToLayer=(s&1)!==0,r.disabled=(s&2)!==0,r.fromVectorData=(s&8)!==0,r.defaultColor=ge(e),r.top=Re(e),r.left=Re(e),r.bottom=Re(e),r.right=Re(e),!Dr(r,e))throw new Error("Invalid realMask size")}if(o&16){let r=ge(e);r&1&&(i.userMaskDensity=ge(e)/255),r&2&&(i.userMaskFeather=Ir(e)),r&4&&(i.vectorMaskDensity=ge(e)/255),r&8&&(i.vectorMaskFeather=Ir(e))}Se(e,n())})}function Yi(e){return[ge(e),ge(e),ge(e),ge(e)]}function Vh(e){return ot(e,1,t=>{let n=Yi(e),i=Yi(e),o=[];for(;t()>0;){let r=Yi(e),s=Yi(e);o.push({sourceRange:r,destRange:s})}return{compositeGrayBlendSource:n,compositeGraphBlendDestinationRange:i,ranges:o}})}function Gh(e,t,n,i){if(e.skipLayerImageData)return;let{colorMode:o=3,bitsPerChannel:r=8}=t;n.rawData={colorMode:o,bitsPerChannel:r,channels:[],large:e.large};for(let s of i){let a=e.offset,l=0,c;if(s.length===1)throw new Error("Invalid channel length");if(s.length){if(l=re(e),l>3&&(e.offset-=1,l=re(e)),l>3&&(e.offset-=3,l=re(e)),l>3)throw new Error(`Invalid compression: ${l}`);s.length>2&&(c=yt(e,s.length-2))}e.offset=a+s.length,n.rawData.channels.push({id:s.id,compression:l,data:c})}e.useRawData||$l(n,e)}function Dl({data:e},t){let n=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255,i=(t?4:3)|0,o=e.length|0,r=(t?5:4)|0;for(let s=i;s<o;s=s+r|0)e[s]=n}function Ml(e){let t=e.rawCompositeData;if(!t)return;let n=to(t.buffer,t.byteOffset,t.byteLength);return Gl(n,e)}function Hh(e){return io(Ml(e))}function Tl(e){return Cn(e,We.Layer,!1,void 0)}function jl(e){return Cn(e,We.Mask,!1,void 0)}function zl(e){return Cn(e,We.RealMask,!1,void 0)}function Wh(e){return io(Tl(e))}function Xh(e){return io(jl(e))}function Zh(e){return io(zl(e))}function io(e){return e&&(0,De.imageDataToCanvas)(e)}function Ar(e,t,n){t&&(n?e.imageData=t:e.canvas=(0,De.imageDataToCanvas)(t))}function qh(e,t){$l(e,{useImageData:t})}function $l(e,t){var n,i,o;let{throwForMissingFeatures:r,useImageData:s}=t,a=Cn(e,We.Layer,r,t.totalMemoryLimit);if(Ar(e,a,s),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=(n=a?.data.byteLength)!==null&&n!==void 0?n:0),e.mask){let l=Cn(e,We.Mask,r,t.totalMemoryLimit);Ar(e.mask,l,s),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=(i=l?.data.byteLength)!==null&&i!==void 0?i:0)}if(e.realMask){let l=Cn(e,We.RealMask,r,t.totalMemoryLimit);Ar(e.realMask,l,s),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=(o=l?.data.byteLength)!==null&&o!==void 0?o:0)}delete e.rawData}var We;(function(e){e[e.Layer=0]="Layer",e[e.Mask=1]="Mask",e[e.RealMask=2]="RealMask"})(We||(We={}));function Cn(e,t,n,i){if(!e.rawData)return;let{colorMode:o,bitsPerChannel:r,channels:s,large:a}=e.rawData,l=Math.max(0,(e.right||0)-(e.left||0)),c=Math.max(0,(e.bottom||0)-(e.top||0)),d=o===4,u,f,h=!1;if(l&&c&&t===We.Layer)if(d){if(r!==8)throw new Error("bitsPerChannel Not supproted");u={width:l,height:c,data:new Uint8ClampedArray(l*c*5)}}else u=Cr(l,c,r,4,i);De.RAW_IMAGE_DATA&&(e.imageDataRaw=[],e.imageDataRawCompression=[]);for(let{id:p,compression:S,data:m}of s){if(!m)continue;let g=to(m.buffer,m.byteOffset,m.byteLength);if(p===-2||p===-3){if(p===-2&&t!==We.Mask||p===-3&&t!==We.RealMask)continue;let v=p===-2?e.mask:e.realMask;if(!v)throw new Error(`Missing layer ${p===-2?"mask":"real mask"} data`);let x=Math.max(0,(v.right||0)-(v.left||0)),_=Math.max(0,(v.bottom||0)-(v.top||0));x&&_&&(f=Cr(x,_,r,4,i),Cl(g,m.byteLength,f,S,x,_,r,0,a,4),De.RAW_IMAGE_DATA&&(p===-2?(e.maskDataRawCompression=S,e.maskDataRaw=m):(e.realMaskDataRawCompression=S,e.realMaskDataRaw=m)),Ji(f),Dl(f,!1))}else{if(t!==We.Layer)continue;let v=(0,De.offsetForChannel)(p,d),x=u;if(v<0&&(x=void 0,n))throw new Error(`Channel not supported: ${p}`);Cl(g,m.byteLength,x,S,l,c,r,v,a,d?5:4),De.RAW_IMAGE_DATA&&(e.imageDataRawCompression[p]=S,e.imageDataRaw[p]=m),x&&o===1&&Ji(x)}p===-1&&(h=!0)}if(u&&(h||Dl(u,d),d)){let p=u;u=(0,De.createImageData)(p.width,p.height),Hl(p,u,!1)}return t===We.Layer?u:f}function Cl(e,t,n,i,o,r,s,a,l,c){if(t)if(i===0){t!==o*r*Math.floor(s/8)&&e.log(`Invalid length (${t}, ${o*r*Math.floor(s/8)})`);let d=yt(e,t);Xl(d,n,s,c,a)}else if(i===1)$t(e,n,o,r,s,c,[a],l);else if(i===2){let d=yt(e,t);Er(d,n,o,r,s,c,a,!1)}else if(i===3){let d=yt(e,t);Er(d,n,o,r,s,c,a,!0)}else throw new Error(`Invalid Compression type: ${i}`)}function Nl(e){return ot(e,1,t=>{if(!t())return;let n=re(e),i=re(e),o=re(e),r=re(e),s=re(e),a=re(e)/255,l=ge(e);return Se(e,t()),{overlayColorSpace:n,colorSpace1:i,colorSpace2:o,colorSpace3:r,colorSpace4:s,opacity:a,kind:l}})}var Kh=[0,1,-1,2,-2,3,-3,4,-4];function Vl(e,t){let n=e.offset,i="";for(let o of Kh){try{e.offset=n+o,i=ii(e)}catch{}if(t(i))break}if(!t(i))throw new Error(`Invalid signature: '${i}' at 0x${n.toString(16)}`);return i}function Yh(e){return e==="8BIM"||e==="8B64"}function Or(e,t,n,i){let o=Vl(e,Yh),r=ii(e),s=o==="8B64"||e.large&&De.largeAdditionalInfoKeys.indexOf(r)!==-1;ot(e,2,a=>{let l=Eh.infoHandlersMap[r];if(l)try{l.read(e,t,a,n,i)}catch(c){if(e.throwForMissingFeatures)throw c}else e.logMissingFeatures&&e.log(`Unhandled additional info: ${r}`),Se(e,a());a()&&(e.logMissingFeatures&&e.log(`Unread ${a()} bytes left for additional info: ${r}`),Se(e,a()))},!1,s)}function Cr(e,t,n,i,o){let r=e*t*i*Math.max(1,n/8);if(o!==void 0&&r>o)throw new Error("Exceeded memory limit");if(n===1||n===8)return i===4?(0,De.createImageData)(e,t):{width:e,height:t,data:new Uint8ClampedArray(e*t*i)};if(n===16)return{width:e,height:t,data:new Uint16Array(e*t*i)};if(n===32)return{width:e,height:t,data:new Float32Array(e*t*i)};throw new Error(`Invalid bitDepth (${n})`)}function Gl(e,t){var n;let i=re(e),o=(n=t.bitsPerChannel)!==null&&n!==void 0?n:8;if(N.supportedColorModes.indexOf(t.colorMode)===-1)throw new Error(`Color mode not supported: ${t.colorMode}`);if(i!==0&&i!==1)throw new Error(`Compression type not supported: ${i}`);let r=Cr(t.width,t.height,o,4,e.totalMemoryLimit);switch(e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit-=r.data.byteLength),(0,De.resetImageData)(r),t.colorMode){case 0:{if(o!==1)throw new Error("Invalid bitsPerChannel for bitmap color mode");let s;if(i===0)s=yt(e,Math.ceil(t.width/8)*t.height);else if(i===1)s=new Uint8Array(t.width*t.height),$t(e,{data:s,width:t.width,height:t.height},t.width,t.height,8,1,[0],e.large);else throw new Error(`Compression not supported: ${i}`);(0,De.decodeBitmap)(s,r.data,t.width,t.height);break}case 3:case 1:{let s=t.colorMode===1?[0]:[0,1,2];if(t.channels&&t.channels>3)for(let a=3;a<t.channels;a++)s.push(a);else e.globalAlpha&&s.push(3);if(i===0)for(let a=0;a<s.length;a++){let l=yt(e,t.width*t.height*Math.floor(o/8));Xl(l,r,o,4,s[a])}else if(i===1){let a=e.offset;$t(e,r,t.width,t.height,o,4,s,e.large),De.RAW_IMAGE_DATA&&(t.imageDataRaw=new Uint8Array(e.view.buffer,e.view.byteOffset+a,e.offset-a))}else throw new Error(`Compression not supported: ${i}`);t.colorMode===1&&Ji(r);break}case 2:{if(o!==8)throw new Error("bitsPerChannel Not supproted");if(t.channels!==1)throw new Error("Invalid channel count");if(!t.palette)throw new Error("Missing color palette");if(i===0)throw new Error(`Compression not supported: ${i}`);if(i===1){let s={width:r.width,height:r.height,data:new Uint8Array(r.width*r.height)};$t(e,s,t.width,t.height,o,1,[0],e.large),Jh(s,r,t.palette)}else throw new Error(`Compression not supported: ${i}`);break}case 4:{if(o!==8)throw new Error("bitsPerChannel Not supproted");if(t.channels!==4)throw new Error("Invalid channel count");let s=[0,1,2,3];if(e.globalAlpha&&s.push(4),i===0)throw new Error(`Compression not supported: ${i}`);if(i===1){let a={width:r.width,height:r.height,data:new Uint8Array(r.width*r.height*5)},l=e.offset;$t(e,a,t.width,t.height,o,5,s,e.large),Hl(a,r,!0),De.RAW_IMAGE_DATA&&(t.imageDataRaw=new Uint8Array(e.view.buffer,e.view.byteOffset+l,e.offset-l))}else throw new Error(`Compression not supported: ${i}`);break}default:throw new Error(`Color mode not supported: ${t.colorMode}`)}if(e.globalAlpha){if(t.bitsPerChannel!==8)throw new Error("bitsPerChannel Not supproted");let s=r.data,a=r.width*r.height*4;for(let l=0;l<a;l+=4){let c=s[l+3];if(c!=0&&c!=255){let u=1/(c/255),f=255*(1-u);s[l+0]=s[l+0]*u+f,s[l+1]=s[l+1]*u+f,s[l+2]=s[l+2]*u+f}}}return r}function Hl(e,t,n){let i=t.width*t.height*4,o=e.data,r=t.data;for(let s=0,a=0;a<i;s+=5,a+=4){let l=o[s],c=o[s+1],d=o[s+2],u=o[s+3];r[a]=(l*u|0)/255|0,r[a+1]=(c*u|0)/255|0,r[a+2]=(d*u|0)/255|0,r[a+3]=n?255-o[s+4]:o[s+4]}}function Jh(e,t,n){let i=e.width*e.height,o=e.data,r=t.data;for(let s=0,a=0;s<i;s++,a+=4){let l=n[o[s]];r[a+0]=l.r,r[a+1]=l.g,r[a+2]=l.b,r[a+3]=255}}function Qh(e,t){if(e.byteLength/e.length!==t.byteLength/t.length)throw new Error("Invalid array types")}function Wl(e,t){if(t===8)return e;if(t===16){for(let n=0;n<e.byteLength;n+=2){let i=e[n];e[n]=e[n+1],e[n+1]=i}if(e.byteOffset%2){let n=new Uint16Array(e.byteLength/2);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength).set(e),n}else return new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2)}else if(t===32)if(e.byteOffset%4){let n=new Float32Array(e.byteLength/4);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength).set(e),n}else return new Float32Array(e.buffer,e.byteOffset,e.byteLength/4);else throw new Error(`Invalid bitDepth (${t})`)}function Pr(e,t,n,i){Qh(e.data,t);let o=e.width*e.height,r=e.data;for(let s=0,a=n|0;s<o;s++,a=a+i|0)r[a]=t[s]}function Xl(e,t,n,i,o){if(n==32)for(let s=0;s<e.byteLength;s+=4){let a=e[s+0],l=e[s+1],c=e[s+2],d=e[s+3];e[s+0]=d,e[s+1]=c,e[s+2]=l,e[s+3]=a}let r=Wl(e,n);t&&o<i&&Pr(t,r,o,i)}function kr(e,t,n,i){for(let o=0;o<n;o++){let r=o*t;for(let s=1,a=r+1;s<t;s++,a++)e[a]=(e[a-1]+e[a])%i}}function Er(e,t,n,i,o,r,s,a){let l=(0,Ph.inflate)(e);if(t&&s<r){let c=Wl(l,o);if(o===8)a&&kr(l,n,i,256),Pr(t,l,s,r);else if(o===16)a&&kr(c,n,i,65536),Pr(t,c,s,r);else if(o===32){a&&kr(l,n*4,i,256);let d=s,u=new Uint32Array(t.data.buffer,t.data.byteOffset,t.data.length);for(let f=0;f<i;f++){let h=n*4*f;for(let p=0;p<n;p++,h++,d+=r){let S=h+n,m=S+n,g=m+n;u[d]=(l[h]<<24|l[S]<<16|l[m]<<8|l[g])>>>0}}}else throw new Error("Invalid bitDepth")}}function $t(e,t,n,i,o,r,s,a){let l=t&&t.data,c;if(a){eo(e,s.length*i*4),c=new Uint32Array(s.length*i);for(let u=0,f=0;u<s.length;u++)for(let h=0;h<i;h++,f++)c[f]=pe(e)}else{eo(e,s.length*i*2),c=new Uint16Array(s.length*i);for(let u=0,f=0;u<s.length;u++)for(let h=0;h<i;h++,f++)c[f]=re(e)}let d=r-1|0;for(let u=0,f=0;u<s.length;u++){let h=s[u]|0,p=u>d||h>d;if(!l||p)for(let S=0;S<i;S++,f++)Se(e,c[f]);else for(let S=0,m=h|0;S<i;S++,f++){let g=c[f],v=yt(e,g);for(let x=0,_=0;x<g;x++){let I=v[x];if(I>128){let P=v[++x];I=256-I|0;for(let k=0;k<=I&&_<n;k=k+1|0,_=_+1|0)l[m]=P,m=m+r|0}else if(I<128)for(let P=0;P<=I&&_<n;P=P+1|0,_=_+1|0)l[m]=v[++x],m=m+r|0}}}Zl(e,c.byteLength)}function ot(e,t,n,i=!0,o=!1){let r=pe(e);if(o){if(r!==0)throw new Error("Sizes larger than 4GB are not supported");r=pe(e)}if(r<=0&&i)return;let s=e.offset+r;if(s>e.view.byteLength)throw new Error("Section exceeds file size");let a=n(()=>s-e.offset);for(e.offset!==s&&(e.offset>s?Qi(e,"Exceeded section limits"):Qi(e,"Unread section data"));r%t;)r++,s++;return e.offset=s,a}function e0(e){switch(re(e)){case 0:{let n=re(e)/257,i=re(e)/257,o=re(e)/257;return Se(e,2),{r:n,g:i,b:o}}case 1:{let n=re(e)/65535,i=re(e)/65535,o=re(e)/65535;return Se(e,2),{h:n,s:i,b:o}}case 2:{let n=re(e)/257,i=re(e)/257,o=re(e)/257,r=re(e)/257;return{c:n,m:i,y:o,k:r}}case 7:{let n=Nt(e)/1e4,i=Nt(e),o=Nt(e),r=i<0?i/12800:i/12700,s=o<0?o/12800:o/12700;return Se(e,2),{l:n,a:r,b:s}}case 8:{let n=re(e)*255/1e4;return Se(e,6),{k:n}}default:throw new Error("Invalid color space")}}function t0(e){let t=pe(e);for(;t%4;)t++;let n=e.offset+t,i=pe(e);if(i!==1)throw new Error(`Invalid pattern version: ${i}`);let o=pe(e),r=Nt(e),s=Nt(e);if(o!==3&&o!==1&&o!==2)throw new Error(`Unsupported pattern color mode: ${o}`);let a=Ll(e),l=no(e,1),c=[];if(o===2){for(let _=0;_<256;_++)c.push({r:ge(e),g:ge(e),b:ge(e)});Se(e,4)}let d=pe(e);if(d!==3)throw new Error(`Invalid pattern VMAL version: ${d}`);pe(e);let u=pe(e),f=pe(e),h=pe(e),p=pe(e),S=pe(e),m=p-f,g=h-u,v=m*g*4;eo(e,v);let x=new Uint8Array(v);for(let _=3;_<x.byteLength;_+=4)x[_]=255;for(let _=0,I=0;_<S+2;_++){if(!pe(e))continue;let k=pe(e),E=pe(e),O=pe(e),U=pe(e),M=pe(e),le=pe(e),me=re(e),T=ge(e),W=k-23,te=yt(e,W);if(E!==8||me!==8)throw new Error("16bit pixel depth not supported for patterns");let ne=le-U,Pe=M-O,Ee=U-f,j=O-u;if(T===0){if(o===3&&I<3)for(let R=0;R<Pe;R++)for(let V=0;V<ne;V++){let fe=V+R*ne,ie=(Ee+V+(R+j)*m)*4;x[ie+I]=te[fe]}else if(o===1&&I<1)for(let R=0;R<Pe;R++)for(let V=0;V<ne;V++){let fe=V+R*ne,ie=(Ee+V+(R+j)*m)*4,he=te[fe];x[ie+0]=he,x[ie+1]=he,x[ie+2]=he}else if(o===2)for(let R=0;R<Pe;R++)for(let V=0;V<ne;V++){let fe=V+R*ne,ie=(Ee+V+(R+j)*m)*4,he=te[fe],we=c[he];x[ie+0]=we.r,x[ie+1]=we.g,x[ie+2]=we.b}else if(e.throwForMissingFeatures)throw new Error("Invalid color pattern")}else if(T===1){eo(e,ne*Pe);let R={data:x,width:m,height:g},V={data:new Uint8Array(ne*Pe),width:ne,height:Pe},fe=to(te.buffer,te.byteOffset,te.byteLength);if(o===3&&I<3&&($t(fe,V,ne,Pe,8,1,[0],!1),Pl(V,R,Ee,j,I)),o===1&&I<1&&($t(fe,V,ne,Pe,8,1,[0],!1),Pl(V,R,Ee,j,0),Ji(R)),o===2)throw new Error("Indexed pattern color mode not implemented");Zl(e,ne*Pe)}else throw new Error("Invalid pattern compression mode");I++}return e.offset=n,{id:l,name:a,x:r,y:s,bounds:{x:f,y:u,w:m,h:g},data:x}}function Pl(e,t,n,i,o){let r=e.width,s=e.height,a=t.width;for(let l=0;l<s;l++)for(let c=0;c<r;c++){let d=c+l*r,u=(n+c+(l+i)*a)*4,f=e.data[d];t.data[u+o]=f}}function eo(e,t){if(e.totalMemoryLimit!==void 0){if(e.totalMemoryLimit<t)throw new Error("Exceeded memory limit");e.totalMemoryLimit-=t}}function Zl(e,t){e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit+=t)}});var Jl=oe(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.readEffects=n0;ro.writeEffects=i0;var Kl=Tt(),z=jt(),B=Dn(),Yl=[void 0,"outer bevel","inner bevel","emboss","pillow emboss","stroke emboss"];function Pn(e){return(0,z.checkSignature)(e,"8BIM"),Kl.toBlendMode[(0,z.readSignature)(e)]||"normal"}function Fn(e,t){(0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,Kl.fromBlendMode[t]||"norm")}function En(e){return(0,z.readUint8)(e)/255}function On(e,t){(0,B.writeUint8)(e,Math.round(t*255)|0)}function n0(e){let t=(0,z.readUint16)(e);if(t!==0)throw new Error(`Invalid effects layer version: ${t}`);let n=(0,z.readUint16)(e),i={};for(let o=0;o<n;o++){(0,z.checkSignature)(e,"8BIM");let r=(0,z.readSignature)(e);switch(r){case"cmnS":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e),l=!!(0,z.readUint8)(e);if((0,z.skipBytes)(e,2),s!==7||a!==0||!l)throw new Error("Invalid effects common state");break}case"dsdw":case"isdw":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==41&&s!==51)throw new Error(`Invalid shadow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid shadow version: ${a}`);let l=(0,z.readFixedPoint32)(e);(0,z.readFixedPoint32)(e);let c=(0,z.readFixedPoint32)(e),d=(0,z.readFixedPoint32)(e),u=(0,z.readColor)(e),f=Pn(e),h=!!(0,z.readUint8)(e),p=!!(0,z.readUint8)(e),S=En(e);s>=51&&(0,z.readColor)(e);let m={size:{units:"Pixels",value:l},distance:{units:"Pixels",value:d},angle:c,color:u,blendMode:f,enabled:h,useGlobalLight:p,opacity:S};r==="dsdw"?i.dropShadow=[m]:i.innerShadow=[m];break}case"oglw":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==32&&s!==42)throw new Error(`Invalid outer glow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid outer glow version: ${a}`);let l=(0,z.readFixedPoint32)(e);(0,z.readFixedPoint32)(e);let c=(0,z.readColor)(e),d=Pn(e),u=!!(0,z.readUint8)(e),f=En(e);s>=42&&(0,z.readColor)(e),i.outerGlow={size:{units:"Pixels",value:l},color:c,blendMode:d,enabled:u,opacity:f};break}case"iglw":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==32&&s!==43)throw new Error(`Invalid inner glow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid inner glow version: ${a}`);let l=(0,z.readFixedPoint32)(e);(0,z.readFixedPoint32)(e);let c=(0,z.readColor)(e),d=Pn(e),u=!!(0,z.readUint8)(e),f=En(e);s>=43&&((0,z.readUint8)(e),(0,z.readColor)(e)),i.innerGlow={size:{units:"Pixels",value:l},color:c,blendMode:d,enabled:u,opacity:f};break}case"bevl":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==58&&s!==78)throw new Error(`Invalid bevel size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid bevel version: ${a}`);let l=(0,z.readFixedPoint32)(e),c=(0,z.readFixedPoint32)(e),d=(0,z.readFixedPoint32)(e),u=Pn(e),f=Pn(e),h=(0,z.readColor)(e),p=(0,z.readColor)(e),S=Yl[(0,z.readUint8)(e)]||"inner bevel",m=En(e),g=En(e),v=!!(0,z.readUint8)(e),x=!!(0,z.readUint8)(e),_=(0,z.readUint8)(e)?"down":"up";s>=78&&((0,z.readColor)(e),(0,z.readColor)(e)),i.bevel={size:{units:"Pixels",value:d},angle:l,strength:c,highlightBlendMode:u,shadowBlendMode:f,highlightColor:h,shadowColor:p,style:S,highlightOpacity:m,shadowOpacity:g,enabled:v,useGlobalLight:x,direction:_};break}case"sofi":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==34)throw new Error(`Invalid effects solid fill info size: ${s}`);if(a!==2)throw new Error(`Invalid effects solid fill info version: ${a}`);let l=Pn(e),c=(0,z.readColor)(e),d=En(e),u=!!(0,z.readUint8)(e);(0,z.readColor)(e),i.solidFill=[{blendMode:l,color:c,opacity:d,enabled:u}];break}default:throw new Error(`Invalid effect type: '${r}'`)}}return i}function ql(e,t){var n;(0,B.writeUint32)(e,51),(0,B.writeUint32)(e,2),(0,B.writeFixedPoint32)(e,t.size&&t.size.value||0),(0,B.writeFixedPoint32)(e,0),(0,B.writeFixedPoint32)(e,t.angle||0),(0,B.writeFixedPoint32)(e,t.distance&&t.distance.value||0),(0,B.writeColor)(e,t.color),Fn(e,t.blendMode),(0,B.writeUint8)(e,t.enabled?1:0),(0,B.writeUint8)(e,t.useGlobalLight?1:0),On(e,(n=t.opacity)!==null&&n!==void 0?n:1),(0,B.writeColor)(e,t.color)}function i0(e,t){var n,i,o,r,s,a;let l=(n=t.dropShadow)===null||n===void 0?void 0:n[0],c=(i=t.innerShadow)===null||i===void 0?void 0:i[0],d=t.outerGlow,u=t.innerGlow,f=t.bevel,h=(o=t.solidFill)===null||o===void 0?void 0:o[0],p=1;if(l&&p++,c&&p++,d&&p++,u&&p++,f&&p++,h&&p++,(0,B.writeUint16)(e,0),(0,B.writeUint16)(e,p),(0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"cmnS"),(0,B.writeUint32)(e,7),(0,B.writeUint32)(e,0),(0,B.writeUint8)(e,1),(0,B.writeZeros)(e,2),l&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"dsdw"),ql(e,l)),c&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"isdw"),ql(e,c)),d&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"oglw"),(0,B.writeUint32)(e,42),(0,B.writeUint32)(e,2),(0,B.writeFixedPoint32)(e,((r=d.size)===null||r===void 0?void 0:r.value)||0),(0,B.writeFixedPoint32)(e,0),(0,B.writeColor)(e,d.color),Fn(e,d.blendMode),(0,B.writeUint8)(e,d.enabled?1:0),On(e,d.opacity||0),(0,B.writeColor)(e,d.color)),u&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"iglw"),(0,B.writeUint32)(e,43),(0,B.writeUint32)(e,2),(0,B.writeFixedPoint32)(e,((s=u.size)===null||s===void 0?void 0:s.value)||0),(0,B.writeFixedPoint32)(e,0),(0,B.writeColor)(e,u.color),Fn(e,u.blendMode),(0,B.writeUint8)(e,u.enabled?1:0),On(e,u.opacity||0),(0,B.writeUint8)(e,0),(0,B.writeColor)(e,u.color)),f){(0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"bevl"),(0,B.writeUint32)(e,78),(0,B.writeUint32)(e,2),(0,B.writeFixedPoint32)(e,f.angle||0),(0,B.writeFixedPoint32)(e,f.strength||0),(0,B.writeFixedPoint32)(e,((a=f.size)===null||a===void 0?void 0:a.value)||0),Fn(e,f.highlightBlendMode),Fn(e,f.shadowBlendMode),(0,B.writeColor)(e,f.highlightColor),(0,B.writeColor)(e,f.shadowColor);let S=Yl.indexOf(f.style);(0,B.writeUint8)(e,S<=0?1:S),On(e,f.highlightOpacity||0),On(e,f.shadowOpacity||0),(0,B.writeUint8)(e,f.enabled?1:0),(0,B.writeUint8)(e,f.useGlobalLight?1:0),(0,B.writeUint8)(e,f.direction==="down"?1:0),(0,B.writeColor)(e,f.highlightColor),(0,B.writeColor)(e,f.shadowColor)}h&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"sofi"),(0,B.writeUint32)(e,34),(0,B.writeUint32)(e,2),Fn(e,h.blendMode),(0,B.writeColor)(e,h.color),On(e,h.opacity||0),(0,B.writeUint8)(e,h.enabled?1:0),(0,B.writeColor)(e,h.color))}});var tc=oe(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.parseEngineData=o0;so.serializeEngineData=a0;function Ql(e){return e===32||e===10||e===13||e===9}function ec(e){return e>=48&&e<=57||e===46||e===45}function o0(e){let t=0;function n(){for(;t<e.length&&Ql(e[t]);)t++}function i(){let f=e[t];return t++,f===92&&(f=e[t],t++),f}function o(){let f="";if(e[t]===41)return t++,f;if(e[t]!==254||e[t+1]!==255)throw new Error("Invalid utf-16 BOM");for(t+=2;t<e.length&&e[t]!==41;){let h=i(),p=i(),S=h<<8|p;f+=String.fromCharCode(S)}return t++,f}let r=null,s=[];function a(f){s.length?(l(f),s.push(f)):(s.push(f),r=f)}function l(f){if(!s.length)throw new Error("Invalid data");let h=s[s.length-1];if(typeof h=="string")s[s.length-2][h]=f,d();else if(Array.isArray(h))h.push(f);else throw new Error("Invalid data")}function c(f){s.length||a({});let h=s[s.length-1];if(h&&typeof h=="string")l(f==="nil"?null:`/${f}`);else if(h&&typeof h=="object")s.push(f);else throw new Error("Invalid data")}function d(){if(!s.length)throw new Error("Invalid data");s.pop()}n();let u=e.length;for(;u>0&&e[u-1]===0;)u--;for(;t<u;){let f=t,h=e[f];if(h===60&&e[f+1]===60)t+=2,a({});else if(h===62&&e[f+1]===62)t+=2,d();else if(h===47){t+=1;let p=t;for(;t<e.length&&!Ql(e[t]);)t++;let S="";for(let m=p;m<t;m++)S+=String.fromCharCode(e[m]);c(S)}else if(h===40)t+=1,l(o());else if(h===91)t+=1,a([]);else if(h===93)t+=1,d();else if(h===110&&e[f+1]===117&&e[f+2]===108&&e[f+3]===108)t+=4,l(null);else if(h===116&&e[f+1]===114&&e[f+2]===117&&e[f+3]===101)t+=4,l(!0);else if(h===102&&e[f+1]===97&&e[f+2]===108&&e[f+3]===115&&e[f+4]===101)t+=5,l(!1);else if(ec(h)){let p="";for(;t<e.length&&ec(e[t]);)p+=String.fromCharCode(e[t]),t++;l(parseFloat(p))}else t+=1,console.log(`Invalid token '${String.fromCharCode(h)}' (${h}) at ${t}`);n()}return r}var r0=["Axis","XY","Zone","WordSpacing","FirstLineIndent","GlyphSpacing","StartIndent","EndIndent","SpaceBefore","SpaceAfter","LetterSpacing","Values","GridSize","GridLeading","PointBase","BoxBounds","TransformPoint0","TransformPoint1","TransformPoint2","FontSize","Leading","HorizontalScale","VerticalScale","BaselineShift","Tsume","OutlineWidth","AutoLeading"],s0=["RunLengthArray"];function a0(e,t=!1){let n=new Uint8Array(1024),i=0,o=0;function r(S){if(i>=n.length){let m=new Uint8Array(n.length*2);m.set(n),n=m}n[i]=S,i++}function s(S){for(let m=0;m<S.length;m++)r(S.charCodeAt(m))}function a(){if(t)s(" ");else for(let S=0;S<o;S++)s(" ")}function l(S,m){a(),s(`/${S}`),p(m,S,!0),t||s(`
2
+ `)}function c(S){return S.toString()}function d(S){return S.toFixed(5).replace(/(\d)0+$/g,"$1").replace(/^0+\.([1-9])/g,".$1").replace(/^-0+\.0(\d)/g,"-.0$1")}function u(S,m){return m&&r0.indexOf(m)!==-1||(S|0)!==S?d(S):c(S)}function f(S){let m=Object.keys(S);return m.indexOf("98")!==-1&&m.unshift(...m.splice(m.indexOf("98"),1)),m.indexOf("99")!==-1&&m.unshift(...m.splice(m.indexOf("99"),1)),m}function h(S){(S===40||S===41||S===92)&&r(92),r(S)}function p(S,m,g=!1){function v(){g?s(" "):a()}if(S===null)v(),s(t?"/nil":"null");else if(typeof S=="number")v(),s(u(S,m));else if(typeof S=="boolean")v(),s(S?"true":"false");else if(typeof S=="string")if(v(),(m==="99"||m==="98")&&S.charAt(0)==="/")s(S);else{s("("),r(254),r(255);for(let x=0;x<S.length;x++){let _=S.charCodeAt(x);h(_>>8&255),h(_&255)}s(")")}else if(Array.isArray(S))if(v(),S.every(x=>typeof x=="number")){s("[");let x=s0.indexOf(m)!==-1;for(let _ of S)s(" "),s(x?u(_):d(_));s(" ]")}else{s("["),t||s(`
3
+ `);for(let x of S)p(x,m),t||s(`
4
+ `);a(),s("]")}else if(typeof S=="object"){g&&!t&&s(`
5
+ `),a(),s("<<"),t||s(`
6
+ `),o++;for(let x of f(S))l(x,S[x]);o--,a(),s(">>")}}if(t){if(typeof e=="object")for(let S of f(e))l(S,e[S])}else s(`
7
+
8
+ `),p(e);return n.slice(0,i)}});var fc=oe(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.decodeEngineData=p0;co.encodeEngineData=m0;var rc={name:"MyriadPro-Regular",script:0,type:0,synthetic:0},ao={justification:"left",firstLineIndent:0,startIndent:0,endIndent:0,spaceBefore:0,spaceAfter:0,autoHyphenate:!0,hyphenatedWordSize:6,preHyphen:2,postHyphen:2,consecutiveHyphens:8,zone:36,wordSpacing:[.8,1,1.33],letterSpacing:[0,0,0],glyphSpacing:[1,1,1],autoLeading:1.2,leadingType:0,hanging:!1,burasagari:!1,kinsokuOrder:0,everyLineComposer:!1},l0={font:rc,fontSize:12,fauxBold:!1,fauxItalic:!1,autoLeading:!0,leading:0,horizontalScale:1,verticalScale:1,tracking:0,autoKerning:!0,kerning:0,baselineShift:0,fontCaps:0,fontBaseline:0,underline:!1,strikethrough:!1,ligatures:!0,dLigatures:!1,baselineDirection:2,tsume:0,styleRunAlignment:2,language:0,noBreak:!1,fillColor:{r:0,g:0,b:0},strokeColor:{r:0,g:0,b:0},fillFlag:!0,strokeFlag:!1,fillFirst:!0,yUnderline:1,outlineWidth:1,characterDirection:0,hindiNumbers:!1,kashida:1,diacriticPos:2},c0={isOn:!1,show:!1,size:18,leading:22,color:{r:0,g:0,b:255},leadingFillColor:{r:0,g:0,b:255},alignLineHeightToGridFlags:!1},Ur=["justification","firstLineIndent","startIndent","endIndent","spaceBefore","spaceAfter","autoHyphenate","hyphenatedWordSize","preHyphen","postHyphen","consecutiveHyphens","zone","wordSpacing","letterSpacing","glyphSpacing","autoLeading","leadingType","hanging","burasagari","kinsokuOrder","everyLineComposer"],Rr=["font","fontSize","fauxBold","fauxItalic","autoLeading","leading","horizontalScale","verticalScale","tracking","autoKerning","kerning","baselineShift","fontCaps","fontBaseline","underline","strikethrough","ligatures","dLigatures","baselineDirection","tsume","styleRunAlignment","language","noBreak","fillColor","strokeColor","fillFlag","strokeFlag","fillFirst","yUnderline","outlineWidth","characterDirection","hindiNumbers","kashida","diacriticPos"],sc=["none","crisp","strong","smooth","sharp"],ac=["left","right","center","justify-left","justify-right","justify-center","justify-all"];function lc(e){return e.substring(0,1).toUpperCase()+e.substring(1)}function d0(e){let t=e.Values;switch(e.Type){case 0:return{k:t[1]*255};case 1:return t[0]===1?{r:t[1]*255,g:t[2]*255,b:t[3]*255}:{r:t[1]*255,g:t[2]*255,b:t[3]*255,a:t[0]*255};case 2:return{c:t[1]*255,m:t[2]*255,y:t[3]*255,k:t[4]*255};default:throw new Error("Unknown color type in text layer")}}function Br(e){if(e){if("r"in e)return{Type:1,Values:["a"in e?e.a/255:1,e.r/255,e.g/255,e.b/255]};if("c"in e)return{Type:2,Values:[1,e.c/255,e.m/255,e.y/255,e.k/255]};if("k"in e)return{Type:0,Values:[1,e.k/255]};throw new Error("Invalid color type in text layer")}else return{Type:1,Values:[0,0,0,0]}}function nc(e,t){if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ic(e,t){if(!e||!t)return!1;for(let n of Object.keys(e))if(e[n]!==t[n])return!1;for(let n of Object.keys(t))if(e[n]!==t[n])return!1;return!0}function f0(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t.name)return n;return e.push(t),e.length-1}function cc(e,t,n){let i={};for(let o of t){let r=lc(o);e[r]!==void 0&&(o==="justification"?i[o]=ac[e[r]]:o==="font"?i[o]=n[e[r]]:o==="fillColor"||o==="strokeColor"?i[o]=d0(e[r]):i[o]=e[r])}return i}function dc(e,t,n){var i;let o={};for(let r of t){let s=lc(r);e[r]!==void 0&&(r==="justification"?o[s]=ac.indexOf((i=e[r])!==null&&i!==void 0?i:"left"):r==="font"?o[s]=f0(n,e[r]):r==="fillColor"||r==="strokeColor"?o[s]=Br(e[r]):o[s]=e[r])}return o}function u0(e,t){return cc(e,Ur,t)}function h0(e,t){return cc(e,Rr,t)}function lo(e,t){return dc(e,Ur,t)}function Lr(e,t){return dc(e,Rr,t)}function oc(e,t,n){if(t.length){for(let i of n){let o=t[0].style[i];if(o!==void 0){let s=!1;Array.isArray(o)?s=t.every(a=>nc(a.style[i],o)):typeof o=="object"?s=t.every(a=>ic(a.style[i],o)):s=t.every(a=>a.style[i]===o),s&&(e[i]=o)}if(e[i]!==void 0)for(let s of t){let a=!1;Array.isArray(o)?a=nc(s.style[i],o):typeof o=="object"?a=ic(s.style[i],o):a=s.style[i]===o,a&&delete s.style[i]}}t.every(i=>Object.keys(i.style).length===0)&&(t.length=0)}}function p0(e){var t,n,i,o,r,s;let a=e.EngineDict,l=e.ResourceDict,c=l.FontSet.map(m=>({name:m.Name,script:m.Script,type:m.FontType,synthetic:m.Synthetic})),d=a.Editor.Text.replace(/\r/g,`
9
+ `),u=0;for(;/\n$/.test(d);)d=d.substring(0,d.length-1),u++;let f={text:d,antiAlias:(t=sc[a.AntiAlias])!==null&&t!==void 0?t:"smooth",useFractionalGlyphWidths:!!a.UseFractionalGlyphWidths,superscriptSize:l.SuperscriptSize,superscriptPosition:l.SuperscriptPosition,subscriptSize:l.SubscriptSize,subscriptPosition:l.SubscriptPosition,smallCapSize:l.SmallCapSize},h=(s=(r=(o=(i=(n=a.Rendered)===null||n===void 0?void 0:n.Shapes)===null||i===void 0?void 0:i.Children)===null||o===void 0?void 0:o[0])===null||r===void 0?void 0:r.Cookie)===null||s===void 0?void 0:s.Photoshop;h&&(f.shapeType=h.ShapeType===1?"box":"point",h.PointBase&&(f.pointBase=h.PointBase),h.BoxBounds&&(f.boxBounds=h.BoxBounds));let p=a.ParagraphRun;f.paragraphStyle={},f.paragraphStyleRuns=[];for(let m=0;m<p.RunArray.length;m++){let g=p.RunArray[m],v=p.RunLengthArray[m],x=u0(g.ParagraphSheet.Properties,c);f.paragraphStyleRuns.push({length:v,style:x})}for(let m=u;f.paragraphStyleRuns.length&&m>0;m--)--f.paragraphStyleRuns[f.paragraphStyleRuns.length-1].length===0&&f.paragraphStyleRuns.pop();oc(f.paragraphStyle,f.paragraphStyleRuns,Ur),f.paragraphStyleRuns.length||delete f.paragraphStyleRuns;let S=a.StyleRun;f.style={},f.styleRuns=[];for(let m=0;m<S.RunArray.length;m++){let g=S.RunLengthArray[m],v=h0(S.RunArray[m].StyleSheet.StyleSheetData,c);v.font||(v.font=c[0]),f.styleRuns.push({length:g,style:v})}for(let m=u;f.styleRuns.length&&m>0;m--)--f.styleRuns[f.styleRuns.length-1].length===0&&f.styleRuns.pop();return oc(f.style,f.styleRuns,Rr),f.styleRuns.length||delete f.styleRuns,f}function m0(e){var t,n,i,o,r,s,a,l,c,d,u,f;let h=`${(e.text||"").replace(/\r?\n/g,"\r")}\r`,p=[{name:"AdobeInvisFont",script:0,type:0,synthetic:0}],S=((t=e.style)===null||t===void 0?void 0:t.font)||((i=(n=e.styleRuns)===null||n===void 0?void 0:n.find(W=>W.style.font))===null||i===void 0?void 0:i.style.font)||rc,m=[],g=[],v=e.paragraphStyleRuns;if(v&&v.length){let W=h.length;for(let te of v){let ne=Math.min(te.length,W);W-=ne,ne&&(W===1&&te===v[v.length-1]&&(ne++,W--),g.push(ne),m.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:lo(Object.assign(Object.assign(Object.assign({},ao),e.paragraphStyle),te.style),p)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}W&&(g.push(W),m.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:lo(Object.assign(Object.assign({},ao),e.paragraphStyle),p)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}else for(let W=0,te=0;W<h.length;W++)h.charCodeAt(W)===13&&(g.push(W-te+1),m.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:lo(Object.assign(Object.assign({},ao),e.paragraphStyle),p)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}),te=W+1);let x=Lr(Object.assign(Object.assign({},l0),{font:S}),p),_=e.styleRuns||[{length:h.length,style:e.style||{}}],I=[],P=[],k=h.length;for(let W of _){let te=Math.min(W.length,k);k-=te,te&&(k===1&&W===_[_.length-1]&&(te++,k--),P.push(te),I.push({StyleSheet:{StyleSheetData:Lr(Object.assign(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),W.style),p)}}))}k&&_.length&&(P.push(k),I.push({StyleSheet:{StyleSheetData:Lr(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),p)}}));let E=Object.assign(Object.assign({},c0),e.gridInfo),O=e.orientation==="vertical"?2:0,U=e.orientation==="vertical"?1:0,M=e.shapeType==="box"?1:0,le={ShapeType:M};M===0?le.PointBase=e.pointBase||[0,0]:le.BoxBounds=e.boxBounds||[0,0,0,0],le.Base={ShapeType:M,TransformPoint0:[1,0],TransformPoint1:[0,1],TransformPoint2:[0,0]};let me={KinsokuSet:[{Name:"PhotoshopKinsokuHard",NoStart:"\u3001\u3002\uFF0C\uFF0E\u30FB\uFF1A\uFF1B\uFF1F\uFF01\u30FC\u2015\u2019\u201D\uFF09\u3015\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u30FD\u30FE\u309D\u309E\u3005\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE\u30F5\u30F6\u309B\u309C?!)]},.:;\u2103\u2109\xA2\uFF05\u2030",NoEnd:"\u2018\u201C\uFF08\u3014\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010([{\uFFE5\uFF04\xA3\uFF20\xA7\u3012\uFF03",Keep:"\u2015\u2025",Hanging:"\u3001\u3002.,"},{Name:"PhotoshopKinsokuSoft",NoStart:"\u3001\u3002\uFF0C\uFF0E\u30FB\uFF1A\uFF1B\uFF1F\uFF01\u2019\u201D\uFF09\u3015\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u30FD\u30FE\u309D\u309E\u3005",NoEnd:"\u2018\u201C\uFF08\u3014\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010",Keep:"\u2015\u2025",Hanging:"\u3001\u3002.,"}],MojiKumiSet:[{InternalName:"Photoshop6MojiKumiSet1"},{InternalName:"Photoshop6MojiKumiSet2"},{InternalName:"Photoshop6MojiKumiSet3"},{InternalName:"Photoshop6MojiKumiSet4"}],TheNormalStyleSheet:0,TheNormalParagraphSheet:0,ParagraphSheetSet:[{Name:"Normal RGB",DefaultStyleSheet:0,Properties:lo(Object.assign(Object.assign({},ao),e.paragraphStyle),p)}],StyleSheetSet:[{Name:"Normal RGB",StyleSheetData:x}],FontSet:p.map(W=>({Name:W.name,Script:W.script||0,FontType:W.type||0,Synthetic:W.synthetic||0})),SuperscriptSize:(o=e.superscriptSize)!==null&&o!==void 0?o:.583,SuperscriptPosition:(r=e.superscriptPosition)!==null&&r!==void 0?r:.333,SubscriptSize:(s=e.subscriptSize)!==null&&s!==void 0?s:.583,SubscriptPosition:(a=e.subscriptPosition)!==null&&a!==void 0?a:.333,SmallCapSize:(l=e.smallCapSize)!==null&&l!==void 0?l:.7};return{EngineDict:{Editor:{Text:h},ParagraphRun:{DefaultRunData:{ParagraphSheet:{DefaultStyleSheet:0,Properties:{}},Adjustments:{Axis:[1,0,1],XY:[0,0]}},RunArray:m,RunLengthArray:g,IsJoinable:1},StyleRun:{DefaultRunData:{StyleSheet:{StyleSheetData:{}}},RunArray:I,RunLengthArray:P,IsJoinable:2},GridInfo:{GridIsOn:!!E.isOn,ShowGrid:!!E.show,GridSize:(c=E.size)!==null&&c!==void 0?c:18,GridLeading:(d=E.leading)!==null&&d!==void 0?d:22,GridColor:Br(E.color),GridLeadingFillColor:Br(E.color),AlignLineHeightToGridFlags:!!E.alignLineHeightToGridFlags},AntiAlias:sc.indexOf((u=e.antiAlias)!==null&&u!==void 0?u:"sharp"),UseFractionalGlyphWidths:(f=e.useFractionalGlyphWidths)!==null&&f!==void 0?f:!0,Rendered:{Version:1,Shapes:{WritingDirection:O,Children:[{ShapeType:M,Procession:U,Lines:{WritingDirection:O,Children:[]},Cookie:{Photoshop:le}}]}}},ResourceDict:Object.assign({},me),DocumentResources:Object.assign({},me)}}});var hc=oe(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});zr.decodeEngineData2=b0;var Mr={0:{uproot:!0,children:{0:{name:"Type"},1:{name:"Values"}}}},jr={0:{name:"Font"},1:{name:"FontSize"},2:{name:"FauxBold"},3:{name:"FauxItalic"},4:{name:"AutoLeading"},5:{name:"Leading"},6:{name:"HorizontalScale"},7:{name:"VerticalScale"},8:{name:"Tracking"},9:{name:"BaselineShift"},11:{name:"Kerning?"},12:{name:"FontCaps"},13:{name:"FontBaseline"},15:{name:"Strikethrough?"},16:{name:"Underline?"},18:{name:"Ligatures"},19:{name:"DLigatures"},23:{name:"Fractions"},24:{name:"Ordinals"},28:{name:"StylisticAlternates"},30:{name:"OldStyle?"},35:{name:"BaselineDirection"},38:{name:"Language"},52:{name:"NoBreak"},53:{name:"FillColor",children:Mr},54:{name:"StrokeColor",children:Mr},55:{children:{99:{uproot:!0}}},79:{children:Mr}},Tr={0:{name:"Justification"},1:{name:"FirstLineIndent"},2:{name:"StartIndent"},3:{name:"EndIndent"},4:{name:"SpaceBefore"},5:{name:"SpaceAfter"},7:{name:"AutoLeading"},9:{name:"AutoHyphenate"},10:{name:"HyphenatedWordSize"},11:{name:"PreHyphen"},12:{name:"PostHyphen"},13:{name:"ConsecutiveHyphens?"},14:{name:"Zone"},15:{name:"HypenateCapitalizedWords"},17:{name:"WordSpacing"},18:{name:"LetterSpacing"},19:{name:"GlyphSpacing"},32:{name:"StyleSheet",children:jr}},uc={name:"StyleSheetData",children:jr},g0={0:{name:"ResourceDict",children:{1:{name:"FontSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},2:{name:"FontType"}}}}}}}}},2:{name:"2",children:{}},3:{name:"MojiKumiSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"InternalName"}}}}}}},4:{name:"KinsokuSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},5:{uproot:!0,children:{0:{name:"NoStart"},1:{name:"NoEnd"},2:{name:"Keep"},3:{name:"Hanging"},4:{name:"Name"}}}}}}}}},5:{name:"StyleSheetSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},6:uc}}}}}},6:{name:"ParagraphSheetSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},5:{name:"Properties",children:Tr},6:{name:"DefaultStyleSheet"}}}}}}},8:{name:"TextFrameSet",children:{0:{uproot:!0,children:{0:{name:"path",children:{0:{name:"name"},1:{name:"bezierCurve",children:{0:{name:"controlPoints"}}},2:{name:"data",children:{0:{name:"type"},1:{name:"orientation"},2:{name:"frameMatrix"},4:{name:"4"},6:{name:"textRange"},7:{name:"rowGutter"},8:{name:"columnGutter"},9:{name:"9"},10:{name:"baselineAlignment",children:{0:{name:"flag"},1:{name:"min"}}},11:{name:"pathData",children:{1:{name:"1"},0:{name:"reversed"},2:{name:"2"},3:{name:"3"},4:{name:"spacing"},5:{name:"5"},6:{name:"6"},7:{name:"7"},18:{name:"18"}}},12:{name:"12"},13:{name:"13"}}},3:{name:"3"},97:{name:"uuid"}}}}}}},9:{name:"Predefined",children:{0:{children:{0:{uproot:!0}}},1:{children:{0:{uproot:!0}}}}}}},1:{name:"EngineDict",children:{0:{name:"0",children:{3:{name:"SuperscriptSize"},4:{name:"SuperscriptPosition"},5:{name:"SubscriptSize"},6:{name:"SubscriptPosition"},7:{name:"SmallCapSize"},8:{name:"UseFractionalGlyphWidths"},15:{children:{0:{uproot:!0}}}}},1:{name:"Editors?",children:{0:{name:"Editor",children:{0:{name:"Text"},5:{name:"ParagraphRun",children:{0:{name:"RunArray",children:{0:{name:"ParagraphSheet",children:{0:{uproot:!0,children:{0:{name:"0"},5:{name:"5",children:Tr},6:{name:"6"}}}}},1:{name:"RunLength"}}}}},6:{name:"StyleRun",children:{0:{name:"RunArray",children:{0:{name:"StyleSheet",children:{0:{uproot:!0,children:{6:uc}}}},1:{name:"RunLength"}}}}}}},1:{name:"FontVectorData ???"}}},2:{name:"StyleSheet",children:jr},3:{name:"ParagraphSheet",children:Tr}}}};function oi(e,t){var n,i;if(e===null)return e;if(Array.isArray(e))return e.map(r=>oi(r,t));if(typeof e!="object")return e;let o={};for(let r of Object.keys(e))if(t[r])if(t[r].uproot){r!=="99"&&(o=oi(e[r],(n=t[r].children)!==null&&n!==void 0?n:{})),e[99]&&(o._type=e[99]);break}else o[t[r].name||r]=oi(e[r],(i=t[r].children)!==null&&i!==void 0?i:{});else r==="99"?o._type=e[r]:o[r]=oi(e[r],{});return o}function b0(e){return oi(e,g0)}});var oo=oe(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.booleanOperations=Ce.infoHandlersMap=Ce.infoHandlers=void 0;Ce.readBezierKnot=_c;Ce.readVectorMask=Ac;Ce.hasMultiEffects=Zr;var pc=ji(),mc=Jl(),Ze=Tt(),b=jt(),y=Dn(),w=Gi(),Wr=tc(),gc=fc(),y0=hc(),Xe="abcdefghijklmnopqrstuvwxyz";Ce.infoHandlers=[];Ce.infoHandlersMap={};function L(e,t,n,i){let o={key:e,has:t,read:n,write:i};Ce.infoHandlers.push(o),Ce.infoHandlersMap[o.key]=o}function Gt(e,t){Ce.infoHandlersMap[e]=Ce.infoHandlersMap[t]}function ae(e){return t=>t[e]!==void 0}function $r(e){if((0,b.readUint32)(e))throw new Error(`Resource size above 4 GB limit at ${e.offset.toString(16)}`);return(0,b.readUint32)(e)}function Nr(e,t){(0,y.writeUint32)(e,0),(0,y.writeUint32)(e,t)}L("TySh",ae("text"),(e,t,n)=>{if((0,b.readInt16)(e)!==1)throw new Error("Invalid TySh version");let i=[];for(let s=0;s<6;s++)i.push((0,b.readFloat64)(e));if((0,b.readInt16)(e)!==50)throw new Error("Invalid TySh text version");let o=(0,w.readVersionAndDescriptor)(e);if((0,b.readInt16)(e)!==1)throw new Error("Invalid TySh warp version");let r=(0,w.readVersionAndDescriptor)(e);if(t.text={transform:i,left:(0,b.readFloat32)(e),top:(0,b.readFloat32)(e),right:(0,b.readFloat32)(e),bottom:(0,b.readFloat32)(e),text:o["Txt "].replace(/\r/g,`
10
+ `),index:o.TextIndex||0,gridding:w.textGridding.decode(o.textGridding),antiAlias:w.Annt.decode(o.AntA),orientation:w.Ornt.decode(o.Ornt),warp:{style:w.warpStyle.decode(r.warpStyle),value:r.warpValue||0,perspective:r.warpPerspective||0,perspectiveOther:r.warpPerspectiveOther||0,rotate:w.Ornt.decode(r.warpRotate)}},o.bounds&&(t.text.bounds=(0,w.descBoundsToBounds)(o.bounds)),o.boundingBox&&(t.text.boundingBox=(0,w.descBoundsToBounds)(o.boundingBox)),o.EngineData){let s=(0,Wr.parseEngineData)(o.EngineData),a=(0,gc.decodeEngineData)(s);t.text=Object.assign(Object.assign({},t.text),a)}(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.text,i=n.warp||{},o=n.transform||[1,0,0,1,0,0],r=Object.assign(Object.assign(Object.assign({"Txt ":(n.text||"").replace(/\r?\n/g,"\r"),textGridding:w.textGridding.encode(n.gridding),Ornt:w.Ornt.encode(n.orientation),AntA:w.Annt.encode(n.antiAlias)},n.bounds?{bounds:(0,w.boundsToDescBounds)(n.bounds)}:{}),n.boundingBox?{boundingBox:(0,w.boundsToDescBounds)(n.boundingBox)}:{}),{TextIndex:n.index||0,EngineData:(0,Wr.serializeEngineData)((0,gc.encodeEngineData)(n))});(0,y.writeInt16)(e,1);for(let s=0;s<6;s++)(0,y.writeFloat64)(e,o[s]);(0,y.writeInt16)(e,50),(0,w.writeVersionAndDescriptor)(e,"","TxLr",r,"text"),(0,y.writeInt16)(e,1),(0,w.writeVersionAndDescriptor)(e,"","warp",go(i)),(0,y.writeFloat32)(e,n.left),(0,y.writeFloat32)(e,n.top),(0,y.writeFloat32)(e,n.right),(0,y.writeFloat32)(e,n.bottom)});L("SoCo",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="color",(e,t)=>{let n=(0,w.readVersionAndDescriptor)(e);t.vectorFill=(0,w.parseVectorContent)(n)},(e,t)=>{let{descriptor:n}=(0,w.serializeVectorContent)(t.vectorFill);(0,w.writeVersionAndDescriptor)(e,"","null",n)});L("GdFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&(e.vectorFill.type==="solid"||e.vectorFill.type==="noise"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.vectorFill=(0,w.parseVectorContent)(i),(0,b.skipBytes)(e,n())},(e,t)=>{let{descriptor:n}=(0,w.serializeVectorContent)(t.vectorFill);(0,w.writeVersionAndDescriptor)(e,"","null",n)});L("PtFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="pattern",(e,t)=>{let n=(0,w.readVersionAndDescriptor)(e);t.vectorFill=(0,w.parseVectorContent)(n)},(e,t)=>{let{descriptor:n}=(0,w.serializeVectorContent)(t.vectorFill);(0,w.writeVersionAndDescriptor)(e,"","null",n)});L("vscg",e=>e.vectorFill!==void 0&&e.vectorStroke!==void 0,(e,t,n)=>{(0,b.readSignature)(e);let i=(0,w.readVersionAndDescriptor)(e);t.vectorFill=(0,w.parseVectorContent)(i),(0,b.skipBytes)(e,n())},(e,t)=>{let{descriptor:n,key:i}=(0,w.serializeVectorContent)(t.vectorFill);(0,y.writeSignature)(e,i),(0,w.writeVersionAndDescriptor)(e,"","null",n)});function _c(e,t,n){let i=(0,b.readFixedPointPath32)(e)*n,o=(0,b.readFixedPointPath32)(e)*t,r=(0,b.readFixedPointPath32)(e)*n,s=(0,b.readFixedPointPath32)(e)*t,a=(0,b.readFixedPointPath32)(e)*n,l=(0,b.readFixedPointPath32)(e)*t;return[o,i,s,r,l,a]}function w0(e,t,n,i){(0,y.writeFixedPointPath32)(e,t[1]/i),(0,y.writeFixedPointPath32)(e,t[0]/n),(0,y.writeFixedPointPath32)(e,t[3]/i),(0,y.writeFixedPointPath32)(e,t[2]/n),(0,y.writeFixedPointPath32)(e,t[5]/i),(0,y.writeFixedPointPath32)(e,t[4]/n)}Ce.booleanOperations=["exclude","combine","subtract","intersect"];function Ac(e,t,n,i,o){let r=e.offset+o,s=t.paths,a;for(;r-e.offset>=26;){let l=(0,b.readUint16)(e);switch(l){case 0:case 3:{(0,b.readUint16)(e);let c=(0,b.readInt16)(e),d=(0,b.readUint16)(e);(0,b.skipBytes)(e,18),a={open:l===3,knots:[],fillRule:d===2?"non-zero":"even-odd"},c!==-1&&(a.operation=Ce.booleanOperations[c]),s.push(a);break}case 1:case 2:case 4:case 5:a.knots.push({linked:l===1||l===4,points:_c(e,n,i)});break;case 6:(0,b.skipBytes)(e,24);break;case 7:{let c=(0,b.readFixedPointPath32)(e),d=(0,b.readFixedPointPath32)(e),u=(0,b.readFixedPointPath32)(e),f=(0,b.readFixedPointPath32)(e),h=(0,b.readFixedPointPath32)(e);(0,b.skipBytes)(e,4),t.clipboard={top:c,left:d,bottom:u,right:f,resolution:h};break}case 8:t.fillStartsWithAllPixels=!!(0,b.readUint16)(e),(0,b.skipBytes)(e,22);break;default:throw new Error("Invalid vmsk section")}}return s}L("vmsk",ae("vectorMask"),(e,t,n,{width:i,height:o})=>{if((0,b.readUint32)(e)!==3)throw new Error("Invalid vmsk version");t.vectorMask={paths:[]};let r=t.vectorMask,s=(0,b.readUint32)(e);r.invert=(s&1)!==0,r.notLink=(s&2)!==0,r.disable=(s&4)!==0,Ac(e,r,i,o,n()),(0,b.skipBytes)(e,n())},(e,t,{width:n,height:i})=>{let o=t.vectorMask,r=(o.invert?1:0)|(o.notLink?2:0)|(o.disable?4:0);(0,y.writeUint32)(e,3),(0,y.writeUint32)(e,r),(0,y.writeUint16)(e,6),(0,y.writeZeros)(e,24);let s=o.clipboard;s&&((0,y.writeUint16)(e,7),(0,y.writeFixedPointPath32)(e,s.top),(0,y.writeFixedPointPath32)(e,s.left),(0,y.writeFixedPointPath32)(e,s.bottom),(0,y.writeFixedPointPath32)(e,s.right),(0,y.writeFixedPointPath32)(e,s.resolution),(0,y.writeZeros)(e,4)),(0,y.writeUint16)(e,8),(0,y.writeUint16)(e,o.fillStartsWithAllPixels?1:0),(0,y.writeZeros)(e,22);for(let a of o.paths){(0,y.writeUint16)(e,a.open?3:0),(0,y.writeUint16)(e,a.knots.length),(0,y.writeUint16)(e,a.operation?Ce.booleanOperations.indexOf(a.operation):-1),(0,y.writeUint16)(e,a.fillRule==="non-zero"?2:1),(0,y.writeZeros)(e,18);let l=a.open?4:1,c=a.open?5:2;for(let{linked:d,points:u}of a.knots)(0,y.writeUint16)(e,d?l:c),w0(e,u,n,i)}});Gt("vsms","vmsk");L("vowv",ae("vowv"),(e,t)=>{t.vowv=(0,b.readUint32)(e)},(e,t)=>{(0,y.writeUint32)(e,t.vowv)});L("vogk",ae("vectorOrigination"),(e,t,n)=>{if((0,b.readInt32)(e)!==1)throw new Error("Invalid vogk version");let i=(0,w.readVersionAndDescriptor)(e);t.vectorOrigination={keyDescriptorList:[]};for(let o of i.keyDescriptorList){let r={};o.keyShapeInvalidated!=null&&(r.keyShapeInvalidated=o.keyShapeInvalidated),o.keyOriginType!=null&&(r.keyOriginType=o.keyOriginType),o.keyOriginResolution!=null&&(r.keyOriginResolution=o.keyOriginResolution),o.keyOriginShapeBBox&&(r.keyOriginShapeBoundingBox={top:(0,w.parseUnitsOrNumber)(o.keyOriginShapeBBox["Top "]),left:(0,w.parseUnitsOrNumber)(o.keyOriginShapeBBox.Left),bottom:(0,w.parseUnitsOrNumber)(o.keyOriginShapeBBox.Btom),right:(0,w.parseUnitsOrNumber)(o.keyOriginShapeBBox.Rght)});let s=o.keyOriginRRectRadii;s&&(r.keyOriginRRectRadii={topRight:(0,w.parseUnits)(s.topRight),topLeft:(0,w.parseUnits)(s.topLeft),bottomLeft:(0,w.parseUnits)(s.bottomLeft),bottomRight:(0,w.parseUnits)(s.bottomRight)});let a=o.keyOriginBoxCorners;a&&(r.keyOriginBoxCorners=[{x:a.rectangleCornerA.Hrzn,y:a.rectangleCornerA.Vrtc},{x:a.rectangleCornerB.Hrzn,y:a.rectangleCornerB.Vrtc},{x:a.rectangleCornerC.Hrzn,y:a.rectangleCornerC.Vrtc},{x:a.rectangleCornerD.Hrzn,y:a.rectangleCornerD.Vrtc}]);let l=o.Trnf;l&&(r.transform=[l.xx,l.xy,l.yx,l.yy,l.tx,l.ty]),t.vectorOrigination.keyDescriptorList.push(r)}(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.vectorOrigination,i={keyDescriptorList:[]};for(let o=0;o<n.keyDescriptorList.length;o++){let r=n.keyDescriptorList[o];i.keyDescriptorList.push({});let s=i.keyDescriptorList[i.keyDescriptorList.length-1];r.keyOriginType!=null&&(s.keyOriginType=r.keyOriginType),r.keyOriginResolution!=null&&(s.keyOriginResolution=r.keyOriginResolution);let a=r.keyOriginRRectRadii;a&&(s.keyOriginRRectRadii={unitValueQuadVersion:1,topRight:(0,w.unitsValue)(a.topRight,"topRight"),topLeft:(0,w.unitsValue)(a.topLeft,"topLeft"),bottomLeft:(0,w.unitsValue)(a.bottomLeft,"bottomLeft"),bottomRight:(0,w.unitsValue)(a.bottomRight,"bottomRight")});let l=r.keyOriginShapeBoundingBox;l&&(s.keyOriginShapeBBox={unitValueQuadVersion:1,"Top ":(0,w.unitsValue)(l.top,"top"),Left:(0,w.unitsValue)(l.left,"left"),Btom:(0,w.unitsValue)(l.bottom,"bottom"),Rght:(0,w.unitsValue)(l.right,"right")});let c=r.keyOriginBoxCorners;c&&c.length===4&&(s.keyOriginBoxCorners={rectangleCornerA:{Hrzn:c[0].x,Vrtc:c[0].y},rectangleCornerB:{Hrzn:c[1].x,Vrtc:c[1].y},rectangleCornerC:{Hrzn:c[2].x,Vrtc:c[2].y},rectangleCornerD:{Hrzn:c[3].x,Vrtc:c[3].y}});let d=r.transform;d&&d.length===6&&(s.Trnf={xx:d[0],xy:d[1],yx:d[2],yy:d[3],tx:d[4],ty:d[5]}),r.keyShapeInvalidated!=null&&(s.keyShapeInvalidated=r.keyShapeInvalidated),s.keyOriginIndex=o}(0,y.writeInt32)(e,1),(0,w.writeVersionAndDescriptor)(e,"","null",i)});L("lmfx",e=>e.effects!==void 0&&Zr(e.effects),(e,t,n)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lmfx version");let o=(0,w.readVersionAndDescriptor)(e);t.effects=(0,w.parseEffects)(o,!!e.logMissingFeatures),(0,b.skipBytes)(e,n())},(e,t,n,i)=>{let o=(0,w.serializeEffects)(t.effects,!!i.logMissingFeatures,!0);(0,y.writeUint32)(e,0),(0,w.writeVersionAndDescriptor)(e,"","null",o)});L("lrFX",ae("effects"),(e,t,n)=>{t.effects||(t.effects=(0,mc.readEffects)(e)),(0,b.skipBytes)(e,n())},(e,t)=>{(0,mc.writeEffects)(e,t.effects)});L("luni",ae("name"),(e,t,n)=>{if(n()>4){let i=(0,b.readUint32)(e);n()>=i*2?t.name=(0,b.readUnicodeStringWithLength)(e,i):e.logDevFeatures&&e.log("name in luni section is too long")}else e.logDevFeatures&&e.log("empty luni section");(0,b.skipBytes)(e,n())},(e,t)=>{(0,y.writeUnicodeString)(e,t.name)});L("lnsr",ae("nameSource"),(e,t)=>t.nameSource=(0,b.readSignature)(e),(e,t)=>(0,y.writeSignature)(e,t.nameSource));L("lyid",ae("id"),(e,t)=>{t.id=(0,b.readUint32)(e)},(e,t,n,i)=>{let o=t.id;for(;i.layerIds.has(o);)o+=100;(0,y.writeUint32)(e,o),i.layerIds.add(o),i.layerToId.set(t,o)});L("lsct",ae("sectionDivider"),(e,t,n)=>{t.sectionDivider={type:(0,b.readUint32)(e)},n()&&((0,b.checkSignature)(e,"8BIM"),t.sectionDivider.key=(0,b.readSignature)(e)),n()&&(t.sectionDivider.subType=(0,b.readUint32)(e))},(e,t)=>{(0,y.writeUint32)(e,t.sectionDivider.type),t.sectionDivider.key&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,t.sectionDivider.key),t.sectionDivider.subType!==void 0&&(0,y.writeUint32)(e,t.sectionDivider.subType))});Gt("lsdk","lsct");L("clbl",ae("blendClippendElements"),(e,t)=>{t.blendClippendElements=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.blendClippendElements?1:0),(0,y.writeZeros)(e,3)});L("infx",ae("blendInteriorElements"),(e,t)=>{t.blendInteriorElements=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.blendInteriorElements?1:0),(0,y.writeZeros)(e,3)});L("knko",ae("knockout"),(e,t)=>{t.knockout=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.knockout?1:0),(0,y.writeZeros)(e,3)});L("lmgm",ae("layerMaskAsGlobalMask"),(e,t)=>{t.layerMaskAsGlobalMask=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.layerMaskAsGlobalMask?1:0),(0,y.writeZeros)(e,3)});L("lspf",ae("protected"),(e,t)=>{let n=(0,b.readUint32)(e);t.protected={transparency:(n&1)!==0,composite:(n&2)!==0,position:(n&4)!==0},n&8&&(t.protected.artboards=!0)},(e,t)=>{let n=(t.protected.transparency?1:0)|(t.protected.composite?2:0)|(t.protected.position?4:0)|(t.protected.artboards?8:0);(0,y.writeUint32)(e,n)});L("lclr",ae("layerColor"),(e,t)=>{let n=(0,b.readUint16)(e);(0,b.skipBytes)(e,6),t.layerColor=Ze.layerColors[n]},(e,t)=>{let n=Ze.layerColors.indexOf(t.layerColor);(0,y.writeUint16)(e,n===-1?0:n),(0,y.writeZeros)(e,6)});L("shmd",e=>e.timestamp!==void 0||e.animationFrames!==void 0||e.animationFrameFlags!==void 0||e.timeline!==void 0||e.comps!==void 0,(e,t,n)=>{let i=(0,b.readUint32)(e);for(let o=0;o<i;o++){(0,b.checkSignature)(e,"8BIM");let r=(0,b.readSignature)(e);(0,b.readUint8)(e),(0,b.skipBytes)(e,3),(0,b.readSection)(e,1,s=>{if(r==="cust"){let a=(0,w.readVersionAndDescriptor)(e);a.layerTime!==void 0&&(t.timestamp=a.layerTime)}else if(r==="mlst"){let a=(0,w.readVersionAndDescriptor)(e);t.animationFrames=[];for(let l=0;l<a.LaSt.length;l++){let c=a.LaSt[l],d={frames:c.FrLs};c.enab!==void 0&&(d.enable=c.enab),c.Ofst&&(d.offset=(0,w.horzVrtcToXY)(c.Ofst)),c.FXRf&&(d.referencePoint=(0,w.horzVrtcToXY)(c.FXRf)),c.Lefx&&(d.effects=(0,w.parseEffects)(c.Lefx,!!e.logMissingFeatures)),c.blendOptions&&c.blendOptions.Opct&&(d.opacity=(0,w.parsePercent)(c.blendOptions.Opct)),t.animationFrames.push(d)}}else if(r==="mdyn"){(0,b.readUint16)(e);let a=(0,b.readUint8)(e),l=(0,b.readUint8)(e);t.animationFrameFlags={propagateFrameOne:!a,unifyLayerPosition:(l&1)!==0,unifyLayerStyle:(l&2)!==0,unifyLayerVisibility:(l&4)!==0}}else if(r==="tmln"){let a=(0,w.readVersionAndDescriptor)(e),l=a.timeScope,c={start:(0,w.frac)(l.Strt),duration:(0,w.frac)(l.duration),inTime:(0,w.frac)(l.inTime),outTime:(0,w.frac)(l.outTime),autoScope:a.autoScope,audioLevel:a.audioLevel};a.trackList&&(c.tracks=(0,w.parseTrackList)(a.trackList,!!e.logMissingFeatures)),t.timeline=c}else if(r==="cmls"){let a=(0,w.readVersionAndDescriptor)(e);t.comps={settings:[]},a.origFXRefPoint&&(t.comps.originalEffectsReferencePoint={x:a.origFXRefPoint.Hrzn,y:a.origFXRefPoint.Vrtc});for(let l of a.layerSettings){t.comps.settings.push({compList:l.compList});let c=t.comps.settings[t.comps.settings.length-1];"enab"in l&&(c.enabled=l.enab),l.Ofst&&(c.offset={x:l.Ofst.Hrzn,y:l.Ofst.Vrtc}),l.FXRefPoint&&(c.effectsReferencePoint={x:l.FXRefPoint.Hrzn,y:l.FXRefPoint.Vrtc})}}else r==="extn"&&(0,w.readVersionAndDescriptor)(e),e.logMissingFeatures&&e.log('Unhandled "shmd" section key',r);(0,b.skipBytes)(e,s())})}(0,b.skipBytes)(e,n())},(e,t,n,i)=>{let{animationFrames:o,animationFrameFlags:r,timestamp:s,timeline:a,comps:l}=t,c=0;o&&c++,r&&c++,a&&c++,s!==void 0&&c++,l&&c++,(0,y.writeUint32)(e,c),o&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"mlst"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{var d;let u={LaID:(d=t.id)!==null&&d!==void 0?d:0,LaSt:[]};for(let f=0;f<o.length;f++){let h=o[f],p={};h.enable!==void 0&&(p.enab=h.enable),p.FrLs=h.frames,h.offset&&(p.Ofst=(0,w.xyToHorzVrtc)(h.offset)),h.referencePoint&&(p.FXRf=(0,w.xyToHorzVrtc)(h.referencePoint)),h.effects&&(p.Lefx=(0,w.serializeEffects)(h.effects,!1,!1)),h.opacity!==void 0&&(p.blendOptions={Opct:(0,w.unitsPercent)(h.opacity)}),u.LaSt.push(p)}(0,w.writeVersionAndDescriptor)(e,"","null",u)},!0)),r&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"mdyn"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{(0,y.writeUint16)(e,0),(0,y.writeUint8)(e,r.propagateFrameOne?0:15),(0,y.writeUint8)(e,(r.unifyLayerPosition?1:0)|(r.unifyLayerStyle?2:0)|(r.unifyLayerVisibility?4:0))})),a&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"tmln"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{let d={Vrsn:1,timeScope:{Vrsn:1,Strt:a.start,duration:a.duration,inTime:a.inTime,outTime:a.outTime},autoScope:a.autoScope,audioLevel:a.audioLevel};a.tracks&&(d.trackList=(0,w.serializeTrackList)(a.tracks));let u=i.layerToId.get(t)||t.id;if(!u)throw new Error("You need to provide layer.id value whan writing document with animations");d.LyrI=u,(0,w.writeVersionAndDescriptor)(e,"","null",d,"anim")},!0)),s!==void 0&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"cust"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{let d={layerTime:s};(0,w.writeVersionAndDescriptor)(e,"","metadata",d)},!0)),l&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"cmls"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{let d=i.layerToId.get(t)||t.id;if(!d)throw new Error("You need to provide layer.id value whan writing document with layer comps");let u={};l.originalEffectsReferencePoint&&(u.origFXRefPoint={Hrzn:l.originalEffectsReferencePoint.x,Vrtc:l.originalEffectsReferencePoint.y}),u.LyrI=d,u.layerSettings=[];for(let f of l.settings){let h={};f.enabled!==void 0&&(h.enab=f.enabled),f.offset&&(h.Ofst={Hrzn:f.offset.x,Vrtc:f.offset.y}),f.effectsReferencePoint&&(h.FXRefPoint={Hrzn:f.effectsReferencePoint.x,Vrtc:f.effectsReferencePoint.y}),h.compList=f.compList,u.layerSettings.push(h)}(0,w.writeVersionAndDescriptor)(e,"","null",u)},!0))});L("PxSc",()=>!1,(e,t)=>{let n=(0,w.readVersionAndDescriptor)(e,!0);n.pixelSourceType===1986285651?t.pixelSource={type:"vdPS",origin:{x:n.origin.Hrzn,y:n.origin.Vrtc},interpretation:{interpretAlpha:n.interpretation.interpretAlpha.split(".")[1],profile:n.interpretation.profile},frameReader:{type:"QTFR",link:{name:n.frameReader["Lnk "]["Nm "],fullPath:n.frameReader["Lnk "].fullPath,originalPath:n.frameReader["Lnk "].originalPath,relativePath:n.frameReader["Lnk "].relPath,alias:n.frameReader["Lnk "].alis},mediaDescriptor:n.frameReader.mediaDescriptor},showAlteredVideo:n.showAlteredVideo}:e.log("Unknown pixelSourceType")},(e,t)=>{let n=t.pixelSource,i={_name:"",_classID:"PixelSource",pixelSourceType:1986285651,descVersion:1,origin:{Hrzn:n.origin.x,Vrtc:n.origin.y},interpretation:{_name:"",_classID:"footageInterpretation",Vrsn:1,interpretAlpha:`alphaInterpretation.${n.interpretation.interpretAlpha}`,profile:n.interpretation.profile},frameReader:{_name:"",_classID:"FrameReader",frameReaderType:1364477522,descVersion:1,"Lnk ":{_name:"",_classID:"ExternalFileLink",descVersion:2,"Nm ":n.frameReader.link.name,fullPath:n.frameReader.link.fullPath,originalPath:n.frameReader.link.originalPath,alis:n.frameReader.link.alias,relPath:n.frameReader.link.relativePath},mediaDescriptor:n.frameReader.mediaDescriptor},showAlteredVideo:n.showAlteredVideo};(0,w.writeVersionAndDescriptor)(e,"","PixelSource",i)});L("vstk",ae("vectorStroke"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.vectorStroke={strokeEnabled:i.strokeEnabled,fillEnabled:i.fillEnabled,lineWidth:(0,w.parseUnits)(i.strokeStyleLineWidth),lineDashOffset:(0,w.parseUnits)(i.strokeStyleLineDashOffset),miterLimit:i.strokeStyleMiterLimit,lineCapType:w.strokeStyleLineCapType.decode(i.strokeStyleLineCapType),lineJoinType:w.strokeStyleLineJoinType.decode(i.strokeStyleLineJoinType),lineAlignment:w.strokeStyleLineAlignment.decode(i.strokeStyleLineAlignment),scaleLock:i.strokeStyleScaleLock,strokeAdjust:i.strokeStyleStrokeAdjust,lineDashSet:i.strokeStyleLineDashSet.map(w.parseUnits),blendMode:w.BlnM.decode(i.strokeStyleBlendMode),opacity:(0,w.parsePercent)(i.strokeStyleOpacity),content:(0,w.parseVectorContent)(i.strokeStyleContent),resolution:i.strokeStyleResolution},(0,b.skipBytes)(e,n())},(e,t)=>{var n,i,o;let r=t.vectorStroke,s={strokeStyleVersion:2,strokeEnabled:!!r.strokeEnabled,fillEnabled:!!r.fillEnabled,strokeStyleLineWidth:r.lineWidth||{value:3,units:"Points"},strokeStyleLineDashOffset:r.lineDashOffset||{value:0,units:"Points"},strokeStyleMiterLimit:(n=r.miterLimit)!==null&&n!==void 0?n:100,strokeStyleLineCapType:w.strokeStyleLineCapType.encode(r.lineCapType),strokeStyleLineJoinType:w.strokeStyleLineJoinType.encode(r.lineJoinType),strokeStyleLineAlignment:w.strokeStyleLineAlignment.encode(r.lineAlignment),strokeStyleScaleLock:!!r.scaleLock,strokeStyleStrokeAdjust:!!r.strokeAdjust,strokeStyleLineDashSet:r.lineDashSet||[],strokeStyleBlendMode:w.BlnM.encode(r.blendMode),strokeStyleOpacity:(0,w.unitsPercent)((i=r.opacity)!==null&&i!==void 0?i:1),strokeStyleContent:(0,w.serializeVectorContent)(r.content||{type:"color",color:{r:0,g:0,b:0}}).descriptor,strokeStyleResolution:(o=r.resolution)!==null&&o!==void 0?o:72};(0,w.writeVersionAndDescriptor)(e,"","strokeStyle",s)});L("artb",ae("artboard"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e),o=i.artboardRect;t.artboard={rect:{top:o["Top "],left:o.Left,bottom:o.Btom,right:o.Rght},guideIndices:i.guideIndeces,presetName:i.artboardPresetName,color:(0,w.parseColor)(i["Clr "]),backgroundType:i.artboardBackgroundType},(0,b.skipBytes)(e,n())},(e,t)=>{var n;let i=t.artboard,o=i.rect,r={artboardRect:{"Top ":o.top,Left:o.left,Btom:o.bottom,Rght:o.right},guideIndeces:i.guideIndices||[],artboardPresetName:i.presetName||"","Clr ":(0,w.serializeColor)(i.color),artboardBackgroundType:(n=i.backgroundType)!==null&&n!==void 0?n:1};(0,w.writeVersionAndDescriptor)(e,"","artboard",r)});L("sn2P",ae("usingAlignedRendering"),(e,t)=>t.usingAlignedRendering=!!(0,b.readUint32)(e),(e,t)=>(0,y.writeUint32)(e,t.usingAlignedRendering?1:0));var Ln=["unknown","vector","raster","image stack"];function kc(e){var t,n,i,o,r,s;let a=Object.assign(Object.assign({style:w.warpStyle.decode(e.warpStyle)},e.warpValues?{values:e.warpValues}:{value:e.warpValue||0}),{perspective:e.warpPerspective||0,perspectiveOther:e.warpPerspectiveOther||0,rotate:w.Ornt.decode(e.warpRotate),bounds:e.bounds&&{top:(0,w.parseUnitsOrNumber)(e.bounds["Top "]),left:(0,w.parseUnitsOrNumber)(e.bounds.Left),bottom:(0,w.parseUnitsOrNumber)(e.bounds.Btom),right:(0,w.parseUnitsOrNumber)(e.bounds.Rght)},uOrder:e.uOrder,vOrder:e.vOrder});(e.deformNumRows!=null||e.deformNumCols!=null)&&(a.deformNumRows=e.deformNumRows,a.deformNumCols=e.deformNumCols);let l=e.customEnvelopeWarp;if(l){a.customEnvelopeWarp={meshPoints:[]};let c=((t=l.meshPoints.find(u=>u.type==="Hrzn"))===null||t===void 0?void 0:t.values)||[],d=((n=l.meshPoints.find(u=>u.type==="Vrtc"))===null||n===void 0?void 0:n.values)||[];for(let u=0;u<c.length;u++)a.customEnvelopeWarp.meshPoints.push({x:c[u],y:d[u]});(l.quiltSliceX||l.quiltSliceY)&&(a.customEnvelopeWarp.quiltSliceX=((o=(i=l.quiltSliceX)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.values)||[],a.customEnvelopeWarp.quiltSliceY=((s=(r=l.quiltSliceY)===null||r===void 0?void 0:r[0])===null||s===void 0?void 0:s.values)||[])}return a}function Xr(e){var t,n;return e.deformNumCols!=null||e.deformNumRows!=null||((t=e.customEnvelopeWarp)===null||t===void 0?void 0:t.quiltSliceX)||((n=e.customEnvelopeWarp)===null||n===void 0?void 0:n.quiltSliceY)}function go(e){let t=e.bounds,n=Object.assign(Object.assign({warpStyle:w.warpStyle.encode(e.style)},e.values?{warpValues:e.values}:{warpValue:e.value||0}),{warpPerspective:e.perspective||0,warpPerspectiveOther:e.perspectiveOther||0,warpRotate:w.Ornt.encode(e.rotate),bounds:{"Top ":(0,w.unitsValue)(t&&t.top||{units:"Pixels",value:0},"bounds.top"),Left:(0,w.unitsValue)(t&&t.left||{units:"Pixels",value:0},"bounds.left"),Btom:(0,w.unitsValue)(t&&t.bottom||{units:"Pixels",value:0},"bounds.bottom"),Rght:(0,w.unitsValue)(t&&t.right||{units:"Pixels",value:0},"bounds.right")},uOrder:e.uOrder||0,vOrder:e.vOrder||0}),i=Xr(e);if(i){let r=n;r.deformNumRows=e.deformNumRows||0,r.deformNumCols=e.deformNumCols||0}let o=e.customEnvelopeWarp;if(o){let r=o.meshPoints||[];if(i){let s=n;s.customEnvelopeWarp={_name:"",_classID:"customEnvelopeWarp",quiltSliceX:[{type:"quiltSliceX",values:o.quiltSliceX||[]}],quiltSliceY:[{type:"quiltSliceY",values:o.quiltSliceY||[]}],meshPoints:[{type:"Hrzn",values:r.map(a=>a.x)},{type:"Vrtc",values:r.map(a=>a.y)}]}}else n.customEnvelopeWarp={_name:"",_classID:"customEnvelopeWarp",meshPoints:[{type:"Hrzn",values:r.map(s=>s.x)},{type:"Vrtc",values:r.map(s=>s.y)}]}}return n}L("PlLd",ae("placedLayer"),(e,t,n)=>{if((0,b.readSignature)(e)!=="plcL")throw new Error("Invalid PlLd signature");if((0,b.readInt32)(e)!==3)throw new Error("Invalid PlLd version");let i=(0,b.readPascalString)(e,1),o=(0,b.readInt32)(e),r=(0,b.readInt32)(e);(0,b.readInt32)(e);let s=(0,b.readInt32)(e);if(!Ln[s])throw new Error("Invalid PlLd type");let a=[];for(let d=0;d<8;d++)a.push((0,b.readFloat64)(e));let l=(0,b.readInt32)(e);if(l!==0)throw new Error(`Invalid Warp version ${l}`);let c=(0,w.readVersionAndDescriptor)(e);t.placedLayer=t.placedLayer||{id:i,type:Ln[s],pageNumber:o,totalPages:r,transform:a,warp:kc(c)},(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.placedLayer;if((0,y.writeSignature)(e,"plcL"),(0,y.writeInt32)(e,3),!n.id||typeof n.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(n.id))throw new Error("Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,y.writePascalString)(e,n.id,1),(0,y.writeInt32)(e,n.pageNumber||1),(0,y.writeInt32)(e,n.totalPages||1),(0,y.writeInt32)(e,16),Ln.indexOf(n.type)===-1)throw new Error("Invalid placedLayer type");(0,y.writeInt32)(e,Ln.indexOf(n.type));for(let s=0;s<8;s++)(0,y.writeFloat64)(e,n.transform[s]);(0,y.writeInt32)(e,0);let i=Ic(n),r=Xr(i)?"quiltWarp":"warp";(0,w.writeVersionAndDescriptor)(e,"",r,go(i),r)});function S0(e){return new Float32Array(e.buffer.slice(e.byteOffset),0,e.byteLength/4)}function v0(e){return new Uint32Array(e.buffer.slice(e.byteOffset),0,e.byteLength/4)}function Vr(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function mo(e){let t=[];for(let n=0;n<e.length;n+=2)t.push({x:e[n],y:e[n+1]});return t}function ri(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].x,e[n].y);return t}function bc(e){return mo(S0(e))}function si(e){return{x:(0,w.parseUnits)(e.Hrzn),y:(0,w.parseUnits)(e.Vrtc)}}function ai(e){return{_name:"",_classID:"Pnt ",Hrzn:(0,w.unitsValue)(e.x,"x"),Vrtc:(0,w.unitsValue)(e.y,"y")}}function x0(e,t){let n={name:e["Nm "],opacity:(0,w.parsePercent)(e.blendOptions.Opct),blendMode:w.BlnM.decode(e.blendOptions["Md "]),enabled:e.enab,hasOptions:e.hasoptions,foregroundColor:(0,w.parseColor)(e.FrgC),backgroundColor:(0,w.parseColor)(e.BckC)};if("Fltr"in e)switch(e.Fltr._classID){case"boxblur":return Object.assign(Object.assign({},n),{type:"box blur",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"GsnB":return Object.assign(Object.assign({},n),{type:"gaussian blur",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"MtnB":return Object.assign(Object.assign({},n),{type:"motion blur",filter:{angle:e.Fltr.Angl,distance:(0,w.parseUnits)(e.Fltr.Dstn)}});case"RdlB":return Object.assign(Object.assign({},n),{type:"radial blur",filter:{amount:e.Fltr.Amnt,method:w.BlrM.decode(e.Fltr.BlrM),quality:w.BlrQ.decode(e.Fltr.BlrQ)}});case"shapeBlur":return Object.assign(Object.assign({},n),{type:"shape blur",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "]),customShape:{name:e.Fltr.customShape["Nm "],id:e.Fltr.customShape.Idnt}}});case"SmrB":return Object.assign(Object.assign({},n),{type:"smart blur",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh,quality:w.SmBQ.decode(e.Fltr.SmBQ),mode:w.SmBM.decode(e.Fltr.SmBM)}});case"surfaceBlur":return Object.assign(Object.assign({},n),{type:"surface blur",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dspl":return Object.assign(Object.assign({},n),{type:"displace",filter:{horizontalScale:e.Fltr.HrzS,verticalScale:e.Fltr.VrtS,displacementMap:w.DspM.decode(e.Fltr.DspM),undefinedAreas:w.UndA.decode(e.Fltr.UndA),displacementFile:{signature:e.Fltr.DspF.sig,path:e.Fltr.DspF.path}}});case"Pnch":return Object.assign(Object.assign({},n),{type:"pinch",filter:{amount:e.Fltr.Amnt}});case"Plr ":return Object.assign(Object.assign({},n),{type:"polar coordinates",filter:{conversion:w.Cnvr.decode(e.Fltr.Cnvr)}});case"Rple":return Object.assign(Object.assign({},n),{type:"ripple",filter:{amount:e.Fltr.Amnt,size:w.RplS.decode(e.Fltr.RplS)}});case"Shr ":return Object.assign(Object.assign({},n),{type:"shear",filter:{shearPoints:e.Fltr.ShrP.map(i=>({x:i.Hrzn,y:i.Vrtc})),shearStart:e.Fltr.ShrS,shearEnd:e.Fltr.ShrE,undefinedAreas:w.UndA.decode(e.Fltr.UndA)}});case"Sphr":return Object.assign(Object.assign({},n),{type:"spherize",filter:{amount:e.Fltr.Amnt,mode:w.SphM.decode(e.Fltr.SphM)}});case"Twrl":return Object.assign(Object.assign({},n),{type:"twirl",filter:{angle:e.Fltr.Angl}});case"Wave":return Object.assign(Object.assign({},n),{type:"wave",filter:{numberOfGenerators:e.Fltr.NmbG,type:w.Wvtp.decode(e.Fltr.Wvtp),wavelength:{min:e.Fltr.WLMn,max:e.Fltr.WLMx},amplitude:{min:e.Fltr.AmMn,max:e.Fltr.AmMx},scale:{x:e.Fltr.SclH,y:e.Fltr.SclV},randomSeed:e.Fltr.RndS,undefinedAreas:w.UndA.decode(e.Fltr.UndA)}});case"ZgZg":return Object.assign(Object.assign({},n),{type:"zigzag",filter:{amount:e.Fltr.Amnt,ridges:e.Fltr.NmbR,style:w.ZZTy.decode(e.Fltr.ZZTy)}});case"AdNs":return Object.assign(Object.assign({},n),{type:"add noise",filter:{amount:(0,w.parsePercent)(e.Fltr.Nose),distribution:w.Dstr.decode(e.Fltr.Dstr),monochromatic:e.Fltr.Mnch,randomSeed:e.Fltr.FlRs}});case"DstS":return Object.assign(Object.assign({},n),{type:"dust and scratches",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh}});case"Mdn ":return Object.assign(Object.assign({},n),{type:"median",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"denoise":return Object.assign(Object.assign({},n),{type:"reduce noise",filter:{preset:e.Fltr.preset,removeJpegArtifact:e.Fltr.removeJPEGArtifact,reduceColorNoise:(0,w.parsePercent)(e.Fltr.ClNs),sharpenDetails:(0,w.parsePercent)(e.Fltr.Shrp),channelDenoise:e.Fltr.channelDenoise.map(i=>Object.assign({channels:i.Chnl.map(w.Chnl.decode),amount:i.Amnt},i.EdgF?{preserveDetails:i.EdgF}:{}))}});case"ClrH":return Object.assign(Object.assign({},n),{type:"color halftone",filter:{radius:e.Fltr["Rds "],angle1:e.Fltr.Ang1,angle2:e.Fltr.Ang2,angle3:e.Fltr.Ang3,angle4:e.Fltr.Ang4}});case"Crst":return Object.assign(Object.assign({},n),{type:"crystallize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Mztn":return Object.assign(Object.assign({},n),{type:"mezzotint",filter:{type:w.MztT.decode(e.Fltr.MztT),randomSeed:e.Fltr.FlRs}});case"Msc ":return Object.assign(Object.assign({},n),{type:"mosaic",filter:{cellSize:(0,w.parseUnits)(e.Fltr.ClSz)}});case"Pntl":return Object.assign(Object.assign({},n),{type:"pointillize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Clds":return Object.assign(Object.assign({},n),{type:"clouds",filter:{randomSeed:e.Fltr.FlRs}});case"DfrC":return Object.assign(Object.assign({},n),{type:"difference clouds",filter:{randomSeed:e.Fltr.FlRs}});case"Fbrs":return Object.assign(Object.assign({},n),{type:"fibers",filter:{variance:e.Fltr.Vrnc,strength:e.Fltr.Strg,randomSeed:e.Fltr.RndS}});case"LnsF":return Object.assign(Object.assign({},n),{type:"lens flare",filter:{brightness:e.Fltr.Brgh,position:{x:e.Fltr.FlrC.Hrzn,y:e.Fltr.FlrC.Vrtc},lensType:w.Lns.decode(e.Fltr["Lns "])}});case"smartSharpen":return Object.assign(Object.assign({},n),{type:"smart sharpen",filter:{amount:(0,w.parsePercent)(e.Fltr.Amnt),radius:(0,w.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh,angle:e.Fltr.Angl,moreAccurate:e.Fltr.moreAccurate,blur:w.blurType.decode(e.Fltr.blur),preset:e.Fltr.preset,shadow:{fadeAmount:(0,w.parsePercent)(e.Fltr.sdwM.Amnt),tonalWidth:(0,w.parsePercent)(e.Fltr.sdwM.Wdth),radius:e.Fltr.sdwM["Rds "]},highlight:{fadeAmount:(0,w.parsePercent)(e.Fltr.hglM.Amnt),tonalWidth:(0,w.parsePercent)(e.Fltr.hglM.Wdth),radius:e.Fltr.hglM["Rds "]}}});case"UnsM":return Object.assign(Object.assign({},n),{type:"unsharp mask",filter:{amount:(0,w.parsePercent)(e.Fltr.Amnt),radius:(0,w.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dfs ":return Object.assign(Object.assign({},n),{type:"diffuse",filter:{mode:w.DfsM.decode(e.Fltr["Md "]),randomSeed:e.Fltr.FlRs}});case"Embs":return Object.assign(Object.assign({},n),{type:"emboss",filter:{angle:e.Fltr.Angl,height:e.Fltr.Hght,amount:e.Fltr.Amnt}});case"Extr":return Object.assign(Object.assign({},n),{type:"extrude",filter:{type:w.ExtT.decode(e.Fltr.ExtT),size:e.Fltr.ExtS,depth:e.Fltr.ExtD,depthMode:w.ExtR.decode(e.Fltr.ExtR),randomSeed:e.Fltr.FlRs,solidFrontFaces:e.Fltr.ExtF,maskIncompleteBlocks:e.Fltr.ExtM}});case"Tls ":return Object.assign(Object.assign({},n),{type:"tiles",filter:{numberOfTiles:e.Fltr.TlNm,maximumOffset:e.Fltr.TlOf,fillEmptyAreaWith:w.FlCl.decode(e.Fltr.FlCl),randomSeed:e.Fltr.FlRs}});case"TrcC":return Object.assign(Object.assign({},n),{type:"trace contour",filter:{level:e.Fltr["Lvl "],edge:w.CntE.decode(e.Fltr["Edg "])}});case"Wnd ":return Object.assign(Object.assign({},n),{type:"wind",filter:{method:w.WndM.decode(e.Fltr.WndM),direction:w.Drct.decode(e.Fltr.Drct)}});case"Dntr":return Object.assign(Object.assign({},n),{type:"de-interlace",filter:{eliminate:w.IntE.decode(e.Fltr.IntE),newFieldsBy:w.IntC.decode(e.Fltr.IntC)}});case"Cstm":return Object.assign(Object.assign({},n),{type:"custom",filter:{scale:e.Fltr["Scl "],offset:e.Fltr.Ofst,matrix:e.Fltr.Mtrx}});case"HghP":return Object.assign(Object.assign({},n),{type:"high pass",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"Mxm ":return Object.assign(Object.assign({},n),{type:"maximum",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"Mnm ":return Object.assign(Object.assign({},n),{type:"minimum",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"Ofst":return Object.assign(Object.assign({},n),{type:"offset",filter:{horizontal:e.Fltr.Hrzn,vertical:e.Fltr.Vrtc,undefinedAreas:w.FlMd.decode(e.Fltr["Fl "])}});case"rigidTransform":return Object.assign(Object.assign({},n),{type:"puppet",filter:{rigidType:e.Fltr.rigidType,bounds:[{x:e.Fltr.PuX0,y:e.Fltr.PuY0},{x:e.Fltr.PuX1,y:e.Fltr.PuY1},{x:e.Fltr.PuX2,y:e.Fltr.PuY2},{x:e.Fltr.PuX3,y:e.Fltr.PuY3}],puppetShapeList:e.Fltr.puppetShapeList.map(i=>({rigidType:i.rigidType,originalVertexArray:bc(i.originalVertexArray),deformedVertexArray:bc(i.deformedVertexArray),indexArray:Array.from(v0(i.indexArray)),pinOffsets:mo(i.pinOffsets),posFinalPins:mo(i.posFinalPins),pinVertexIndices:i.pinVertexIndices,selectedPin:i.selectedPin,pinPosition:mo(i.PinP),pinRotation:i.PnRt,pinOverlay:i.PnOv,pinDepth:i.PnDp,meshQuality:i.meshQuality,meshExpansion:i.meshExpansion,meshRigidity:i.meshRigidity,imageResolution:i.imageResolution,meshBoundaryPath:{pathComponents:i.meshBoundaryPath.pathComponents.map(o=>({shapeOperation:o.shapeOperation.split(".")[1],paths:o.SbpL.map(r=>({closed:r.Clsp,points:r["Pts "].map(s=>({anchor:si(s.Anch),forward:si(s["Fwd "]),backward:si(s["Bwd "]),smooth:s.Smoo}))}))}))}}))}});case"PbPl":{let i=[],o=e.Fltr;for(let r=0;r<Xe.length&&o[`PN${Xe[r]}a`];r++)for(let s=0;s<Xe.length&&o[`PN${Xe[r]}${Xe[s]}`];s++)i.push({name:o[`PN${Xe[r]}${Xe[s]}`],value:o[`PF${Xe[r]}${Xe[s]}`]});return Object.assign(Object.assign({},n),{type:"oil paint plugin",filter:{name:e.Fltr.KnNm,gpu:e.Fltr.GpuY,lighting:e.Fltr.LIWy,parameters:i}})}case"HsbP":return Object.assign(Object.assign({},n),{type:"hsb/hsl",filter:{inputMode:w.ClrS.decode(e.Fltr.Inpt),rowOrder:w.ClrS.decode(e.Fltr.Otpt)}});case"oilPaint":return Object.assign(Object.assign({},n),{type:"oil paint",filter:{lightingOn:e.Fltr.lightingOn,stylization:e.Fltr.stylization,cleanliness:e.Fltr.cleanliness,brushScale:e.Fltr.brushScale,microBrush:e.Fltr.microBrush,lightDirection:e.Fltr.LghD,specularity:e.Fltr.specularity}});case"LqFy":return Object.assign(Object.assign({},n),{type:"liquify",filter:{liquifyMesh:e.Fltr.LqMe}});case"perspectiveWarpTransform":return Object.assign(Object.assign({},n),{type:"perspective warp",filter:{vertices:e.Fltr.vertices.map(si),warpedVertices:e.Fltr.warpedVertices.map(si),quads:e.Fltr.quads.map(i=>i.indices)}});case"Crvs":return Object.assign(Object.assign({},n),{type:"curves",filter:Object.assign({presetKind:w.presetKindType.decode(e.Fltr.presetKind)},e.Fltr.Adjs?{adjustments:e.Fltr.Adjs.map(i=>{let o=i.Chnl.map(w.Chnl.decode);if(i["Crv "])return{channels:o,curve:i["Crv "].map(r=>{let s={x:r.Hrzn,y:r.Vrtc};return r.Cnty&&(s.curved=!0),s})};if(i.Mpng)return{channels:o,values:i.Mpng};throw new Error("Unknown curve adjustment")})}:{})});case"BrgC":return Object.assign(Object.assign({},n),{type:"brightness/contrast",filter:{brightness:e.Fltr.Brgh,contrast:e.Fltr.Cntr,useLegacy:!!e.Fltr.useLegacy}});default:if(t.throwForMissingFeatures)throw new Error(`Unknown filter classId: ${e.Fltr._classID}`);return}else switch(e.filterID){case 1098281575:return Object.assign(Object.assign({},n),{type:"average"});case 1114403360:return Object.assign(Object.assign({},n),{type:"blur"});case 1114403405:return Object.assign(Object.assign({},n),{type:"blur more"});case 1148416099:return Object.assign(Object.assign({},n),{type:"despeckle"});case 1180922912:return Object.assign(Object.assign({},n),{type:"facet"});case 1181902701:return Object.assign(Object.assign({},n),{type:"fragment"});case 1399353968:return Object.assign(Object.assign({},n),{type:"sharpen"});case 1399353925:return Object.assign(Object.assign({},n),{type:"sharpen edges"});case 1399353933:return Object.assign(Object.assign({},n),{type:"sharpen more"});case 1181639749:return Object.assign(Object.assign({},n),{type:"find edges"});case 1399616122:return Object.assign(Object.assign({},n),{type:"solarize"});case 1314149187:return Object.assign(Object.assign({},n),{type:"ntsc colors"});case 1231976050:return Object.assign(Object.assign({},n),{type:"invert"});default:if(t.throwForMissingFeatures)throw new Error(`Unknown filterID: ${e.filterID}`)}}function _0(e,t){return{enabled:e.enab,validAtPosition:e.validAtPosition,maskEnabled:e.filterMaskEnable,maskLinked:e.filterMaskLinked,maskExtendWithWhite:e.filterMaskExtendWithWhite,list:e.filterFXList.map(n=>x0(n,t)).filter(n=>!!n)}}function wt(e){return(0,w.unitsValue)(e.radius,"radius")}function A0(e){let t={_name:"",_classID:"filterFX","Nm ":e.name,blendOptions:{_name:"",_classID:"blendOptions",Opct:(0,w.unitsPercentF)(e.opacity),"Md ":w.BlnM.encode(e.blendMode)},enab:e.enabled,hasoptions:e.hasOptions,FrgC:(0,w.serializeColor)(e.foregroundColor),BckC:(0,w.serializeColor)(e.backgroundColor)};switch(e.type){case"average":return Object.assign(Object.assign({},t),{filterID:1098281575});case"blur":return Object.assign(Object.assign({},t),{filterID:1114403360});case"blur more":return Object.assign(Object.assign({},t),{filterID:1114403405});case"box blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Box Blur",_classID:"boxblur","Rds ":wt(e.filter)},filterID:697});case"gaussian blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Gaussian Blur",_classID:"GsnB","Rds ":wt(e.filter)},filterID:1198747202});case"motion blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Motion Blur",_classID:"MtnB",Angl:e.filter.angle,Dstn:(0,w.unitsValue)(e.filter.distance,"distance")},filterID:1299476034});case"radial blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Radial Blur",_classID:"RdlB",Amnt:e.filter.amount,BlrM:w.BlrM.encode(e.filter.method),BlrQ:w.BlrQ.encode(e.filter.quality)},filterID:1382313026});case"shape blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Shape Blur",_classID:"shapeBlur","Rds ":wt(e.filter),customShape:{_name:"",_classID:"customShape","Nm ":e.filter.customShape.name,Idnt:e.filter.customShape.id}},filterID:702});case"smart blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Smart Blur",_classID:"SmrB","Rds ":e.filter.radius,Thsh:e.filter.threshold,SmBQ:w.SmBQ.encode(e.filter.quality),SmBM:w.SmBM.encode(e.filter.mode)},filterID:1399681602});case"surface blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Surface Blur",_classID:"surfaceBlur","Rds ":wt(e.filter),Thsh:e.filter.threshold},filterID:701});case"displace":return Object.assign(Object.assign({},t),{Fltr:{_name:"Displace",_classID:"Dspl",HrzS:e.filter.horizontalScale,VrtS:e.filter.verticalScale,DspM:w.DspM.encode(e.filter.displacementMap),UndA:w.UndA.encode(e.filter.undefinedAreas),DspF:{sig:e.filter.displacementFile.signature,path:e.filter.displacementFile.path}},filterID:1148416108});case"pinch":return Object.assign(Object.assign({},t),{Fltr:{_name:"Pinch",_classID:"Pnch",Amnt:e.filter.amount},filterID:1349411688});case"polar coordinates":return Object.assign(Object.assign({},t),{Fltr:{_name:"Polar Coordinates",_classID:"Plr ",Cnvr:w.Cnvr.encode(e.filter.conversion)},filterID:1349284384});case"ripple":return Object.assign(Object.assign({},t),{Fltr:{_name:"Ripple",_classID:"Rple",Amnt:e.filter.amount,RplS:w.RplS.encode(e.filter.size)},filterID:1383099493});case"shear":return Object.assign(Object.assign({},t),{Fltr:{_name:"Shear",_classID:"Shr ",ShrP:e.filter.shearPoints.map(n=>({_name:"",_classID:"Pnt ",Hrzn:n.x,Vrtc:n.y})),UndA:w.UndA.encode(e.filter.undefinedAreas),ShrS:e.filter.shearStart,ShrE:e.filter.shearEnd},filterID:1399353888});case"spherize":return Object.assign(Object.assign({},t),{Fltr:{_name:"Spherize",_classID:"Sphr",Amnt:e.filter.amount,SphM:w.SphM.encode(e.filter.mode)},filterID:1399875698});case"twirl":return Object.assign(Object.assign({},t),{Fltr:{_name:"Twirl",_classID:"Twrl",Angl:e.filter.angle},filterID:1417114220});case"wave":return Object.assign(Object.assign({},t),{Fltr:{_name:"Wave",_classID:"Wave",Wvtp:w.Wvtp.encode(e.filter.type),NmbG:e.filter.numberOfGenerators,WLMn:e.filter.wavelength.min,WLMx:e.filter.wavelength.max,AmMn:e.filter.amplitude.min,AmMx:e.filter.amplitude.max,SclH:e.filter.scale.x,SclV:e.filter.scale.y,UndA:w.UndA.encode(e.filter.undefinedAreas),RndS:e.filter.randomSeed},filterID:1466005093});case"zigzag":return Object.assign(Object.assign({},t),{Fltr:{_name:"ZigZag",_classID:"ZgZg",Amnt:e.filter.amount,NmbR:e.filter.ridges,ZZTy:w.ZZTy.encode(e.filter.style)},filterID:1516722791});case"add noise":return Object.assign(Object.assign({},t),{Fltr:{_name:"Add Noise",_classID:"AdNs",Dstr:w.Dstr.encode(e.filter.distribution),Nose:(0,w.unitsPercentF)(e.filter.amount),Mnch:e.filter.monochromatic,FlRs:e.filter.randomSeed},filterID:1097092723});case"despeckle":return Object.assign(Object.assign({},t),{filterID:1148416099});case"dust and scratches":return Object.assign(Object.assign({},t),{Fltr:{_name:"Dust & Scratches",_classID:"DstS","Rds ":e.filter.radius,Thsh:e.filter.threshold},filterID:1148417107});case"median":return Object.assign(Object.assign({},t),{Fltr:{_name:"Median",_classID:"Mdn ","Rds ":wt(e.filter)},filterID:1298427424});case"reduce noise":return Object.assign(Object.assign({},t),{Fltr:{_name:"Reduce Noise",_classID:"denoise",ClNs:(0,w.unitsPercentF)(e.filter.reduceColorNoise),Shrp:(0,w.unitsPercentF)(e.filter.sharpenDetails),removeJPEGArtifact:e.filter.removeJpegArtifact,channelDenoise:e.filter.channelDenoise.map(n=>Object.assign({_name:"",_classID:"channelDenoiseParams",Chnl:n.channels.map(i=>w.Chnl.encode(i)),Amnt:n.amount},n.preserveDetails?{EdgF:n.preserveDetails}:{})),preset:e.filter.preset},filterID:633});case"color halftone":return Object.assign(Object.assign({},t),{Fltr:{_name:"Color Halftone",_classID:"ClrH","Rds ":e.filter.radius,Ang1:e.filter.angle1,Ang2:e.filter.angle2,Ang3:e.filter.angle3,Ang4:e.filter.angle4},filterID:1131180616});case"crystallize":return Object.assign(Object.assign({},t),{Fltr:{_name:"Crystallize",_classID:"Crst",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1131574132});case"facet":return Object.assign(Object.assign({},t),{filterID:1180922912});case"fragment":return Object.assign(Object.assign({},t),{filterID:1181902701});case"mezzotint":return Object.assign(Object.assign({},t),{Fltr:{_name:"Mezzotint",_classID:"Mztn",MztT:w.MztT.encode(e.filter.type),FlRs:e.filter.randomSeed},filterID:1299870830});case"mosaic":return Object.assign(Object.assign({},t),{Fltr:{_name:"Mosaic",_classID:"Msc ",ClSz:(0,w.unitsValue)(e.filter.cellSize,"cellSize")},filterID:1299407648});case"pointillize":return Object.assign(Object.assign({},t),{Fltr:{_name:"Pointillize",_classID:"Pntl",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1349416044});case"clouds":return Object.assign(Object.assign({},t),{Fltr:{_name:"Clouds",_classID:"Clds",FlRs:e.filter.randomSeed},filterID:1131177075});case"difference clouds":return Object.assign(Object.assign({},t),{Fltr:{_name:"Difference Clouds",_classID:"DfrC",FlRs:e.filter.randomSeed},filterID:1147564611});case"fibers":return Object.assign(Object.assign({},t),{Fltr:{_name:"Fibers",_classID:"Fbrs",Vrnc:e.filter.variance,Strg:e.filter.strength,RndS:e.filter.randomSeed},filterID:1180856947});case"lens flare":return Object.assign(Object.assign({},t),{Fltr:{_name:"Lens Flare",_classID:"LnsF",Brgh:e.filter.brightness,FlrC:{_name:"",_classID:"Pnt ",Hrzn:e.filter.position.x,Vrtc:e.filter.position.y},"Lns ":w.Lns.encode(e.filter.lensType)},filterID:1282306886});case"sharpen":return Object.assign(Object.assign({},t),{filterID:1399353968});case"sharpen edges":return Object.assign(Object.assign({},t),{filterID:1399353925});case"sharpen more":return Object.assign(Object.assign({},t),{filterID:1399353933});case"smart sharpen":return Object.assign(Object.assign({},t),{Fltr:{_name:"Smart Sharpen",_classID:"smartSharpen",Amnt:(0,w.unitsPercentF)(e.filter.amount),"Rds ":wt(e.filter),Thsh:e.filter.threshold,Angl:e.filter.angle,moreAccurate:e.filter.moreAccurate,blur:w.blurType.encode(e.filter.blur),preset:e.filter.preset,sdwM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,w.unitsPercentF)(e.filter.shadow.fadeAmount),Wdth:(0,w.unitsPercentF)(e.filter.shadow.tonalWidth),"Rds ":e.filter.shadow.radius},hglM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,w.unitsPercentF)(e.filter.highlight.fadeAmount),Wdth:(0,w.unitsPercentF)(e.filter.highlight.tonalWidth),"Rds ":e.filter.highlight.radius}},filterID:698});case"unsharp mask":return Object.assign(Object.assign({},t),{Fltr:{_name:"Unsharp Mask",_classID:"UnsM",Amnt:(0,w.unitsPercentF)(e.filter.amount),"Rds ":wt(e.filter),Thsh:e.filter.threshold},filterID:1433301837});case"diffuse":return Object.assign(Object.assign({},t),{Fltr:{_name:"Diffuse",_classID:"Dfs ","Md ":w.DfsM.encode(e.filter.mode),FlRs:e.filter.randomSeed},filterID:1147564832});case"emboss":return Object.assign(Object.assign({},t),{Fltr:{_name:"Emboss",_classID:"Embs",Angl:e.filter.angle,Hght:e.filter.height,Amnt:e.filter.amount},filterID:1164796531});case"extrude":return Object.assign(Object.assign({},t),{Fltr:{_name:"Extrude",_classID:"Extr",ExtS:e.filter.size,ExtD:e.filter.depth,ExtF:e.filter.solidFrontFaces,ExtM:e.filter.maskIncompleteBlocks,ExtT:w.ExtT.encode(e.filter.type),ExtR:w.ExtR.encode(e.filter.depthMode),FlRs:e.filter.randomSeed},filterID:1165522034});case"find edges":return Object.assign(Object.assign({},t),{filterID:1181639749});case"solarize":return Object.assign(Object.assign({},t),{filterID:1399616122});case"tiles":return Object.assign(Object.assign({},t),{Fltr:{_name:"Tiles",_classID:"Tls ",TlNm:e.filter.numberOfTiles,TlOf:e.filter.maximumOffset,FlCl:w.FlCl.encode(e.filter.fillEmptyAreaWith),FlRs:e.filter.randomSeed},filterID:1416393504});case"trace contour":return Object.assign(Object.assign({},t),{Fltr:{_name:"Trace Contour",_classID:"TrcC","Lvl ":e.filter.level,"Edg ":w.CntE.encode(e.filter.edge)},filterID:1416782659});case"wind":return Object.assign(Object.assign({},t),{Fltr:{_name:"Wind",_classID:"Wnd ",WndM:w.WndM.encode(e.filter.method),Drct:w.Drct.encode(e.filter.direction)},filterID:1466852384});case"de-interlace":return Object.assign(Object.assign({},t),{Fltr:{_name:"De-Interlace",_classID:"Dntr",IntE:w.IntE.encode(e.filter.eliminate),IntC:w.IntC.encode(e.filter.newFieldsBy)},filterID:1148089458});case"ntsc colors":return Object.assign(Object.assign({},t),{filterID:1314149187});case"invert":return Object.assign(Object.assign({},t),{filterID:1231976050});case"custom":return Object.assign(Object.assign({},t),{Fltr:{_name:"Custom",_classID:"Cstm","Scl ":e.filter.scale,Ofst:e.filter.offset,Mtrx:e.filter.matrix},filterID:1131639917});case"high pass":return Object.assign(Object.assign({},t),{Fltr:{_name:"High Pass",_classID:"HghP","Rds ":wt(e.filter)},filterID:1214736464});case"maximum":return Object.assign(Object.assign({},t),{Fltr:{_name:"Maximum",_classID:"Mxm ","Rds ":wt(e.filter)},filterID:1299737888});case"minimum":return Object.assign(Object.assign({},t),{Fltr:{_name:"Minimum",_classID:"Mnm ","Rds ":wt(e.filter)},filterID:1299082528});case"offset":return Object.assign(Object.assign({},t),{Fltr:{_name:"Offset",_classID:"Ofst",Hrzn:e.filter.horizontal,Vrtc:e.filter.vertical,"Fl ":w.FlMd.encode(e.filter.undefinedAreas)},filterID:1332114292});case"puppet":return Object.assign(Object.assign({},t),{Fltr:{_name:"Rigid Transform",_classID:"rigidTransform",null:["Ordn.Trgt"],rigidType:e.filter.rigidType,puppetShapeList:e.filter.puppetShapeList.map(n=>({_name:"",_classID:"puppetShape",rigidType:n.rigidType,VrsM:1,VrsN:0,originalVertexArray:Vr(new Float32Array(ri(n.originalVertexArray))),deformedVertexArray:Vr(new Float32Array(ri(n.deformedVertexArray))),indexArray:Vr(new Uint32Array(n.indexArray)),pinOffsets:ri(n.pinOffsets),posFinalPins:ri(n.posFinalPins),pinVertexIndices:n.pinVertexIndices,PinP:ri(n.pinPosition),PnRt:n.pinRotation,PnOv:n.pinOverlay,PnDp:n.pinDepth,meshQuality:n.meshQuality,meshExpansion:n.meshExpansion,meshRigidity:n.meshRigidity,imageResolution:n.imageResolution,meshBoundaryPath:{_name:"",_classID:"pathClass",pathComponents:n.meshBoundaryPath.pathComponents.map(i=>({_name:"",_classID:"PaCm",shapeOperation:`shapeOperation.${i.shapeOperation}`,SbpL:i.paths.map(o=>({_name:"",_classID:"Sbpl",Clsp:o.closed,"Pts ":o.points.map(r=>({_name:"",_classID:"Pthp",Anch:ai(r.anchor),"Fwd ":ai(r.forward),"Bwd ":ai(r.backward),Smoo:r.smooth}))}))}))},selectedPin:n.selectedPin})),PuX0:e.filter.bounds[0].x,PuX1:e.filter.bounds[1].x,PuX2:e.filter.bounds[2].x,PuX3:e.filter.bounds[3].x,PuY0:e.filter.bounds[0].y,PuY1:e.filter.bounds[1].y,PuY2:e.filter.bounds[2].y,PuY3:e.filter.bounds[3].y},filterID:991});case"oil paint plugin":{let n={};for(let i=0;i<e.filter.parameters.length;i++){let{name:o,value:r}=e.filter.parameters[i],s=`${Xe[Math.floor(i/Xe.length)]}${Xe[i%Xe.length]}`;n[`PN${s}`]=o,n[`PT${s}`]=0,n[`PF${s}`]=r}return Object.assign(Object.assign({},t),{Fltr:Object.assign({_name:"Oil Paint Plugin",_classID:"PbPl",KnNm:e.filter.name,GpuY:e.filter.gpu,LIWy:e.filter.lighting,FPth:"1"},n),filterID:1348620396})}case"oil paint":return Object.assign(Object.assign({},t),{Fltr:{_name:"Oil Paint",_classID:"oilPaint",lightingOn:e.filter.lightingOn,stylization:e.filter.stylization,cleanliness:e.filter.cleanliness,brushScale:e.filter.brushScale,microBrush:e.filter.microBrush,LghD:e.filter.lightDirection,specularity:e.filter.specularity},filterID:1122});case"liquify":return Object.assign(Object.assign({},t),{Fltr:{_name:"Liquify",_classID:"LqFy",LqMe:e.filter.liquifyMesh},filterID:1282492025});case"perspective warp":return Object.assign(Object.assign({},t),{Fltr:{_name:"Perspective Warp",_classID:"perspectiveWarpTransform",vertices:e.filter.vertices.map(ai),warpedVertices:e.filter.warpedVertices.map(ai),quads:e.filter.quads.map(n=>({indices:n}))},filterID:442});case"curves":return Object.assign(Object.assign({},t),{Fltr:Object.assign({_name:"Curves",_classID:"Crvs",presetKind:w.presetKindType.encode(e.filter.presetKind)},e.filter.adjustments?{Adjs:e.filter.adjustments.map(n=>"curve"in n?{_name:"",_classID:"CrvA",Chnl:n.channels.map(w.Chnl.encode),"Crv ":n.curve.map(i=>Object.assign({_name:"",_classID:"Pnt ",Hrzn:i.x,Vrtc:i.y},i.curved?{Cnty:!0}:{}))}:{_name:"",_classID:"CrvA",Chnl:n.channels.map(w.Chnl.encode),Mpng:n.values})}:{}),filterID:1131574899});case"brightness/contrast":return Object.assign(Object.assign({},t),{Fltr:{_name:"Brightness/Contrast",_classID:"BrgC",Brgh:e.filter.brightness,Cntr:e.filter.contrast,useLegacy:!!e.filter.useLegacy},filterID:1114793795});default:throw new Error(`Unknow filter type: ${e.type}`)}}function Ic(e){if(e.warp)return e.warp;if(!e.width||!e.height)throw new Error("You must provide width and height of the linked image in placedLayer");let t=e.width,n=e.height,i=0,o=t/3,r=t*2/3,s=t,a=0,l=n/3,c=n*2/3,d=n;return{style:"custom",value:0,perspective:0,perspectiveOther:0,rotate:"horizontal",bounds:{top:{value:0,units:"Pixels"},left:{value:0,units:"Pixels"},bottom:{value:n,units:"Pixels"},right:{value:t,units:"Pixels"}},uOrder:4,vOrder:4,customEnvelopeWarp:{meshPoints:[{x:i,y:a},{x:o,y:a},{x:r,y:a},{x:s,y:a},{x:i,y:l},{x:o,y:l},{x:r,y:l},{x:s,y:l},{x:i,y:c},{x:o,y:c},{x:r,y:c},{x:s,y:c},{x:i,y:d},{x:o,y:d},{x:r,y:d},{x:s,y:d}]}}}L("SoLd",ae("placedLayer"),(e,t,n)=>{if((0,b.readSignature)(e)!=="soLD")throw new Error("Invalid SoLd type");let i=(0,b.readInt32)(e);if(i!==4&&i!==5)throw new Error("Invalid SoLd version");let o=(0,w.readVersionAndDescriptor)(e,!0);t.placedLayer={id:o.Idnt,placed:o.placed,type:Ln[o.Type],pageNumber:o.PgNm,totalPages:o.totalPages,frameStep:(0,w.frac)(o.frameStep),duration:(0,w.frac)(o.duration),frameCount:o.frameCount,transform:o.Trnf,width:o["Sz "].Wdth,height:o["Sz "].Hght,resolution:(0,w.parseUnits)(o.Rslt),warp:kc(o.quiltWarp||o.warp)},o.nonAffineTransform&&o.nonAffineTransform.some((r,s)=>r!==o.Trnf[s])&&(t.placedLayer.nonAffineTransform=o.nonAffineTransform),o.Crop&&(t.placedLayer.crop=o.Crop),o.comp&&(t.placedLayer.comp=o.comp),o.compInfo&&(t.placedLayer.compInfo={compID:o.compInfo.compID,originalCompID:o.compInfo.originalCompID}),o.filterFX&&(t.placedLayer.filter=_0(o.filterFX,e)),(0,b.skipBytes)(e,n())},(e,t)=>{var n,i;(0,y.writeSignature)(e,"soLD"),(0,y.writeInt32)(e,4);let o=t.placedLayer;if(!o.id||typeof o.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(o.id))throw new Error("Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");let r=Object.assign(Object.assign({Idnt:o.id,placed:(n=o.placed)!==null&&n!==void 0?n:o.id,PgNm:o.pageNumber||1,totalPages:o.totalPages||1},o.crop?{Crop:o.crop}:{}),{frameStep:o.frameStep||{numerator:0,denominator:600},duration:o.duration||{numerator:0,denominator:600},frameCount:o.frameCount||0,Annt:16,Type:Ln.indexOf(o.type),Trnf:o.transform,nonAffineTransform:(i=o.nonAffineTransform)!==null&&i!==void 0?i:o.transform,warp:go(Ic(o)),"Sz ":{_name:"",_classID:"Pnt ",Wdth:o.width||0,Hght:o.height||0},Rslt:o.resolution?(0,w.unitsValue)(o.resolution,"resolution"):{units:"Density",value:72}});if(o.filter&&(r.filterFX={_name:"",_classID:"filterFXStyle",enab:o.filter.enabled,validAtPosition:o.filter.validAtPosition,filterMaskEnable:o.filter.maskEnabled,filterMaskLinked:o.filter.maskLinked,filterMaskExtendWithWhite:o.filter.maskExtendWithWhite,filterFXList:o.filter.list.map(s=>A0(s))}),o.warp&&Xr(o.warp)){let s=go(o.warp);r.quiltWarp=s,r.warp={warpStyle:"warpStyle.warpNone",warpValue:s.warpValue,warpPerspective:s.warpPerspective,warpPerspectiveOther:s.warpPerspectiveOther,warpRotate:s.warpRotate,bounds:s.bounds,uOrder:s.uOrder,vOrder:s.vOrder}}else delete r.quiltWarp;o.comp&&(r.comp=o.comp),o.compInfo&&(r.compInfo=o.compInfo),(0,w.writeVersionAndDescriptor)(e,"","null",r,r.quiltWarp?"quiltWarp":"warp")});Gt("SoLE","SoLd");L("fxrp",ae("referencePoint"),(e,t)=>{t.referencePoint={x:(0,b.readFloat64)(e),y:(0,b.readFloat64)(e)}},(e,t)=>{(0,y.writeFloat64)(e,t.referencePoint.x),(0,y.writeFloat64)(e,t.referencePoint.y)});L("Lr16",()=>!1,(e,t,n,i,o)=>{(0,b.readLayerInfo)(e,i,o)},(e,t)=>{});L("Lr32",()=>!1,(e,t,n,i,o)=>{(0,b.readLayerInfo)(e,i,o)},(e,t)=>{});L("LMsk",ae("userMask"),(e,t)=>{if(t.userMask={colorSpace:(0,b.readColor)(e),opacity:(0,b.readUint16)(e)/255},(0,b.readUint8)(e)!==128)throw new Error("Invalid flag value");(0,b.skipBytes)(e,1)},(e,t)=>{let n=t.userMask;(0,y.writeColor)(e,n.colorSpace),(0,y.writeUint16)(e,(0,Ze.clamp)(n.opacity,0,1)*255),(0,y.writeUint8)(e,128),(0,y.writeZeros)(e,1)});Ze.MOCK_HANDLERS?L("Patt",e=>e._Patt!==void 0,(e,t,n)=>{t._Patt=(0,b.readBytes)(e,n())},(e,t)=>!1):L("Patt",e=>!!(e.patterns&&e.patterns.length>0),(e,t,n)=>{for(;n()>0;){let i=(0,b.readPattern)(e);t.patterns===void 0&&(t.patterns=[]),t.patterns.push(i)}},(e,t,n,i)=>{let o=t.patterns||[];for(let r of o)(0,y.writePattern)(e,r)});Gt("Pat2","Patt");Gt("Pat3","Patt");Ze.MOCK_HANDLERS&&L("CAI ",e=>e._CAI_!==void 0,(e,t,n)=>{t._CAI_=(0,b.readBytes)(e,n())},(e,t)=>{(0,y.writeBytes)(e,t._CAI_)});Ze.MOCK_HANDLERS&&L("OCIO",e=>e._OCIO!==void 0,(e,t,n)=>{t._OCIO=(0,b.readBytes)(e,n())},(e,t)=>{(0,y.writeBytes)(e,t._OCIO)});Ze.MOCK_HANDLERS&&L("GenI",e=>e._GenI!==void 0,(e,t,n)=>{t._GenI=(0,b.readBytes)(e,n())},(e,t)=>{(0,y.writeBytes)(e,t._GenI)});function yc(e){let t=(0,b.readInt32)(e),n=(0,b.readInt32)(e),i=(0,b.readInt32)(e),o=(0,b.readInt32)(e);return{top:t,left:n,bottom:i,right:o}}function wc(e,t){(0,y.writeInt32)(e,t.top),(0,y.writeInt32)(e,t.left),(0,y.writeInt32)(e,t.bottom),(0,y.writeInt32)(e,t.right)}L("Anno",e=>e.annotations!==void 0,(e,t,n)=>{let i=(0,b.readUint16)(e),o=(0,b.readUint16)(e);if(i!==2||o!==1)throw new Error("Invalid Anno version");let r=(0,b.readUint32)(e),s=[];for(let a=0;a<r;a++){(0,b.readUint32)(e);let l=(0,b.readSignature)(e),c=!!(0,b.readUint8)(e);(0,b.readUint8)(e),(0,b.readUint16)(e);let d=yc(e),u=yc(e),f=(0,b.readColor)(e),h=(0,b.readPascalString)(e,2),p=(0,b.readPascalString)(e,2),S=(0,b.readPascalString)(e,2);(0,b.readUint32)(e),(0,b.readSignature)(e);let m=(0,b.readUint32)(e),g;if(l==="txtA")m>=2&&(0,b.readUint16)(e)===65279?g=(0,b.readUnicodeStringWithLength)(e,(m-2)/2):(e.offset-=2,g=(0,b.readAsciiString)(e,m)),g=g.replace(/\r/g,`
11
+ `);else if(l==="sndA")g=(0,b.readBytes)(e,m);else throw new Error("Unknown annotation type");s.push({type:l==="txtA"?"text":"sound",open:c,iconLocation:d,popupLocation:u,color:f,author:h,name:p,date:S,data:g})}t.annotations=s,(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.annotations;(0,y.writeUint16)(e,2),(0,y.writeUint16)(e,1),(0,y.writeUint32)(e,n.length);for(let i of n){let o=i.type==="sound";if(o&&!(i.data instanceof Uint8Array))throw new Error("Sound annotation data should be Uint8Array");if(!o&&typeof i.data!="string")throw new Error("Text annotation data should be string");let r=e.offset;(0,y.writeUint32)(e,0),(0,y.writeSignature)(e,o?"sndA":"txtA"),(0,y.writeUint8)(e,i.open?1:0),(0,y.writeUint8)(e,28),(0,y.writeUint16)(e,1),wc(e,i.iconLocation),wc(e,i.popupLocation),(0,y.writeColor)(e,i.color),(0,y.writePascalString)(e,i.author||"",2),(0,y.writePascalString)(e,i.name||"",2),(0,y.writePascalString)(e,i.date||"",2);let s=e.offset;(0,y.writeUint32)(e,0),(0,y.writeSignature)(e,o?"sndM":"txtC"),(0,y.writeUint32)(e,0);let a=e.offset;if(o)(0,y.writeBytes)(e,i.data);else{(0,y.writeUint16)(e,65279);let l=i.data.replace(/\n/g,"\r");for(let c=0;c<l.length;c++)(0,y.writeUint16)(e,l.charCodeAt(c))}e.view.setUint32(r,e.offset-r,!1),e.view.setUint32(s,e.offset-s,!1),e.view.setUint32(a-4,e.offset-a,!1)}});function Dc(e){L(e,t=>{let n=t;return!(!n.linkedFiles||!n.linkedFiles.length||e==="lnkE"&&!n.linkedFiles.some(i=>i.linkedFile))},(t,n,i,o)=>{let r=n;for(r.linkedFiles=r.linkedFiles||[];i()>8;){let s=$r(t),a=t.offset,l=(0,b.readSignature)(t),c=(0,b.readInt32)(t),d=(0,b.readPascalString)(t,1),u=(0,b.readUnicodeString)(t),f=(0,b.readSignature)(t).trim(),h=(0,b.readSignature)(t).trim(),p=$r(t),m=(0,b.readUint8)(t)?(0,w.readVersionAndDescriptor)(t):void 0,g=l==="liFE"?(0,w.readVersionAndDescriptor)(t):void 0,v={id:d,name:u};if(f&&(v.type=f),h&&(v.creator=h),m&&(v.descriptor={compInfo:{compID:m.compInfo.compID,originalCompID:m.compInfo.originalCompID}}),l==="liFE"&&c>3){let _=(0,b.readInt32)(t),I=(0,b.readUint8)(t),P=(0,b.readUint8)(t),k=(0,b.readUint8)(t),E=(0,b.readUint8)(t),O=(0,b.readFloat64)(t),U=Math.floor(O),M=(O-U)*1e3;v.time=new Date(Date.UTC(_,I,P,k,E,U,M)).toISOString()}let x=l==="liFE"?$r(t):0;for(l==="liFA"&&(0,b.skipBytes)(t,8),l==="liFD"&&(v.data=(0,b.readBytes)(t,p)),c>=5&&(v.childDocumentID=(0,b.readUnicodeString)(t)),c>=6&&(v.assetModTime=(0,b.readFloat64)(t)),c>=7&&(v.assetLockedState=(0,b.readUint8)(t)),l==="liFE"&&c===2&&(v.data=(0,b.readBytes)(t,x)),t.skipLinkedFilesData&&(v.data=void 0),e==="lnkE"&&(v.linkedFile={fileSize:x,name:g?.["Nm "]||"",fullPath:g?.fullPath||"",originalPath:g?.originalPath||"",relativePath:g?.relPath||""}),r.linkedFiles.push(v);s%4;)s++;t.offset=a+s}(0,b.skipBytes)(t,i())},(t,n)=>{var i,o,r,s,a,l,c,d,u;let f=n;for(let h of f.linkedFiles){if(e==="lnkE"!=!!h.linkedFile)continue;let p=2;h.assetLockedState!=null?p=7:h.assetModTime!=null?p=6:h.childDocumentID!=null?p=5:e==="lnkE"&&(p=3),Nr(t,0);let S=t.offset;if((0,y.writeSignature)(t,e==="lnkE"?"liFE":h.data?"liFD":"liFA"),(0,y.writeInt32)(t,p),!h.id||typeof h.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(h.id))throw new Error("Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,y.writePascalString)(t,h.id,1),(0,y.writeUnicodeStringWithPadding)(t,h.name||""),(0,y.writeSignature)(t,h.type?`${h.type} `.substring(0,4):" "),(0,y.writeSignature)(t,h.creator?`${h.creator} `.substring(0,4):"\0\0\0\0"),Nr(t,h.data?h.data.byteLength:0),h.descriptor&&h.descriptor.compInfo){let g={compInfo:{compID:h.descriptor.compInfo.compID,originalCompID:h.descriptor.compInfo.originalCompID}};(0,y.writeUint8)(t,1),(0,w.writeVersionAndDescriptor)(t,"","null",g)}else(0,y.writeUint8)(t,0);if(e==="lnkE"){let g={descVersion:2,"Nm ":(o=(i=h.linkedFile)===null||i===void 0?void 0:i.name)!==null&&o!==void 0?o:"",fullPath:(s=(r=h.linkedFile)===null||r===void 0?void 0:r.fullPath)!==null&&s!==void 0?s:"",originalPath:(l=(a=h.linkedFile)===null||a===void 0?void 0:a.originalPath)!==null&&l!==void 0?l:"",relPath:(d=(c=h.linkedFile)===null||c===void 0?void 0:c.relativePath)!==null&&d!==void 0?d:""};(0,w.writeVersionAndDescriptor)(t,"","ExternalFileLink",g);let v=h.time?new Date(h.time):new Date;(0,y.writeInt32)(t,v.getUTCFullYear()),(0,y.writeUint8)(t,v.getUTCMonth()),(0,y.writeUint8)(t,v.getUTCDate()),(0,y.writeUint8)(t,v.getUTCHours()),(0,y.writeUint8)(t,v.getUTCMinutes()),(0,y.writeFloat64)(t,v.getUTCSeconds()+v.getUTCMilliseconds()/1e3)}h.data?(0,y.writeBytes)(t,h.data):Nr(t,((u=h.linkedFile)===null||u===void 0?void 0:u.fileSize)||0),p>=5&&(0,y.writeUnicodeStringWithPadding)(t,h.childDocumentID||""),p>=6&&(0,y.writeFloat64)(t,h.assetModTime||0),p>=7&&(0,y.writeUint8)(t,h.assetLockedState||0);let m=t.offset-S;for(t.view.setUint32(S-4,m,!1);m%4;)m++,(0,y.writeUint8)(t,0)}})}Dc("lnk2");Dc("lnkE");Gt("lnkD","lnk2");Gt("lnk3","lnk2");L("pths",ae("pathList"),(e,t)=>{(0,w.readVersionAndDescriptor)(e,!0),t.pathList=[]},(e,t)=>{let n={pathList:[]};(0,w.writeVersionAndDescriptor)(e,"","pathsDataClass",n)});L("lyvr",ae("version"),(e,t)=>t.version=(0,b.readUint32)(e),(e,t)=>(0,y.writeUint32)(e,t.version));L("lfxs",()=>!1,(e,t,n)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lfxs version");let o=(0,w.readVersionAndDescriptor)(e);t.effects=(0,w.parseEffects)(o,!!e.logMissingFeatures),(0,b.skipBytes)(e,n())},(e,t,n,i)=>{let o=(0,w.serializeEffects)(t.effects,!!i.logMissingFeatures,!0);(0,y.writeUint32)(e,0),(0,w.writeVersionAndDescriptor)(e,"","null",o)});function Fe(e){return t=>!!t.adjustment&&t.adjustment.type===e}L("brit",Fe("brightness/contrast"),(e,t,n)=>{t.adjustment||(t.adjustment={type:"brightness/contrast",brightness:(0,b.readInt16)(e),contrast:(0,b.readInt16)(e),meanValue:(0,b.readInt16)(e),labColorOnly:!!(0,b.readUint8)(e),useLegacy:!0}),(0,b.skipBytes)(e,n())},(e,t)=>{var n;let i=t.adjustment;(0,y.writeInt16)(e,i.brightness||0),(0,y.writeInt16)(e,i.contrast||0),(0,y.writeInt16)(e,(n=i.meanValue)!==null&&n!==void 0?n:127),(0,y.writeUint8)(e,i.labColorOnly?1:0),(0,y.writeZeros)(e,1)});function fo(e){let t=(0,b.readInt16)(e),n=(0,b.readInt16)(e),i=(0,b.readInt16)(e),o=(0,b.readInt16)(e),r=(0,b.readInt16)(e)/100;return{shadowInput:t,highlightInput:n,shadowOutput:i,highlightOutput:o,midtoneInput:r}}function li(e,t){(0,y.writeInt16)(e,t.shadowInput),(0,y.writeInt16)(e,t.highlightInput),(0,y.writeInt16)(e,t.shadowOutput),(0,y.writeInt16)(e,t.highlightOutput),(0,y.writeInt16)(e,Math.round(t.midtoneInput*100))}L("levl",Fe("levels"),(e,t,n)=>{if((0,b.readUint16)(e)!==2)throw new Error("Invalid levl version");t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:"levels",rgb:fo(e),red:fo(e),green:fo(e),blue:fo(e)}),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,i={shadowInput:0,highlightInput:255,shadowOutput:0,highlightOutput:255,midtoneInput:1};(0,y.writeUint16)(e,2),li(e,n.rgb||i),li(e,n.red||i),li(e,n.green||i),li(e,n.blue||i);for(let o=0;o<59;o++)li(e,i)});function uo(e){let t=(0,b.readUint16)(e),n=[];for(let i=0;i<t;i++){let o=(0,b.readInt16)(e),r=(0,b.readInt16)(e);n.push({input:r,output:o})}return n}function Vt(e,t){(0,y.writeUint16)(e,t.length);for(let n of t)(0,y.writeUint16)(e,n.output),(0,y.writeUint16)(e,n.input)}L("curv",Fe("curves"),(e,t,n)=>{if((0,b.readUint8)(e),(0,b.readUint16)(e)!==1)throw new Error("Invalid curv version");(0,b.readUint16)(e);let i=(0,b.readUint16)(e),o={type:"curves"};i&1&&(o.rgb=uo(e)),i&2&&(o.red=uo(e)),i&4&&(o.green=uo(e)),i&8&&(o.blue=uo(e)),t.adjustment=Object.assign(Object.assign({},t.adjustment),o),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,{rgb:i,red:o,green:r,blue:s}=n,a=0,l=0;i&&i.length&&(a|=1,l++),o&&o.length&&(a|=2,l++),r&&r.length&&(a|=4,l++),s&&s.length&&(a|=8,l++),(0,y.writeUint8)(e,0),(0,y.writeUint16)(e,1),(0,y.writeUint16)(e,0),(0,y.writeUint16)(e,a),i&&i.length&&Vt(e,i),o&&o.length&&Vt(e,o),r&&r.length&&Vt(e,r),s&&s.length&&Vt(e,s),(0,y.writeSignature)(e,"Crv "),(0,y.writeUint16)(e,4),(0,y.writeUint16)(e,0),(0,y.writeUint16)(e,l),i&&i.length&&((0,y.writeUint16)(e,0),Vt(e,i)),o&&o.length&&((0,y.writeUint16)(e,1),Vt(e,o)),r&&r.length&&((0,y.writeUint16)(e,2),Vt(e,r)),s&&s.length&&((0,y.writeUint16)(e,3),Vt(e,s))});L("expA",Fe("exposure"),(e,t,n)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid expA version");t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:"exposure",exposure:(0,b.readFloat32)(e),offset:(0,b.readFloat32)(e),gamma:(0,b.readFloat32)(e)}),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,1),(0,y.writeFloat32)(e,n.exposure),(0,y.writeFloat32)(e,n.offset),(0,y.writeFloat32)(e,n.gamma),(0,y.writeZeros)(e,2)});L("vibA",Fe("vibrance"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.adjustment={type:"vibrance"},i.vibrance!==void 0&&(t.adjustment.vibrance=i.vibrance),i.Strt!==void 0&&(t.adjustment.saturation=i.Strt),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,i={};n.vibrance!==void 0&&(i.vibrance=n.vibrance),n.saturation!==void 0&&(i.Strt=n.saturation),(0,w.writeVersionAndDescriptor)(e,"","null",i)});function on(e){return{a:(0,b.readInt16)(e),b:(0,b.readInt16)(e),c:(0,b.readInt16)(e),d:(0,b.readInt16)(e),hue:(0,b.readInt16)(e),saturation:(0,b.readInt16)(e),lightness:(0,b.readInt16)(e)}}function rn(e,t){let n=t||{};(0,y.writeInt16)(e,n.a||0),(0,y.writeInt16)(e,n.b||0),(0,y.writeInt16)(e,n.c||0),(0,y.writeInt16)(e,n.d||0),(0,y.writeInt16)(e,n.hue||0),(0,y.writeInt16)(e,n.saturation||0),(0,y.writeInt16)(e,n.lightness||0)}L("hue2",Fe("hue/saturation"),(e,t,n)=>{if((0,b.readUint16)(e)!==2)throw new Error("Invalid hue2 version");t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:"hue/saturation",master:on(e),reds:on(e),yellows:on(e),greens:on(e),cyans:on(e),blues:on(e),magentas:on(e)}),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,2),rn(e,n.master),rn(e,n.reds),rn(e,n.yellows),rn(e,n.greens),rn(e,n.cyans),rn(e,n.blues),rn(e,n.magentas)});function Gr(e){return{cyanRed:(0,b.readInt16)(e),magentaGreen:(0,b.readInt16)(e),yellowBlue:(0,b.readInt16)(e)}}function Hr(e,t){(0,y.writeInt16)(e,t.cyanRed||0),(0,y.writeInt16)(e,t.magentaGreen||0),(0,y.writeInt16)(e,t.yellowBlue||0)}L("blnc",Fe("color balance"),(e,t,n)=>{t.adjustment={type:"color balance",shadows:Gr(e),midtones:Gr(e),highlights:Gr(e),preserveLuminosity:!!(0,b.readUint8)(e)},(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;Hr(e,n.shadows||{}),Hr(e,n.midtones||{}),Hr(e,n.highlights||{}),(0,y.writeUint8)(e,n.preserveLuminosity?1:0),(0,y.writeZeros)(e,1)});L("blwh",Fe("black & white"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.adjustment={type:"black & white",reds:i["Rd "],yellows:i.Yllw,greens:i["Grn "],cyans:i["Cyn "],blues:i["Bl "],magentas:i.Mgnt,useTint:!!i.useTint,presetKind:i.bwPresetKind,presetFileName:i.blackAndWhitePresetFileName},i.tintColor!==void 0&&(t.adjustment.tintColor=(0,w.parseColor)(i.tintColor)),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,i={"Rd ":n.reds||0,Yllw:n.yellows||0,"Grn ":n.greens||0,"Cyn ":n.cyans||0,"Bl ":n.blues||0,Mgnt:n.magentas||0,useTint:!!n.useTint,tintColor:(0,w.serializeColor)(n.tintColor),bwPresetKind:n.presetKind||0,blackAndWhitePresetFileName:n.presetFileName||""};(0,w.writeVersionAndDescriptor)(e,"","null",i)});L("phfl",Fe("photo filter"),(e,t,n)=>{let i=(0,b.readUint16)(e);if(i!==2&&i!==3)throw new Error("Invalid phfl version");let o;i===2?o=(0,b.readColor)(e):o={l:(0,b.readInt32)(e)/100,a:(0,b.readInt32)(e)/100,b:(0,b.readInt32)(e)/100},t.adjustment={type:"photo filter",color:o,density:(0,b.readUint32)(e)/100,preserveLuminosity:!!(0,b.readUint8)(e)},(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,2),(0,y.writeColor)(e,n.color||{l:0,a:0,b:0}),(0,y.writeUint32)(e,(n.density||0)*100),(0,y.writeUint8)(e,n.preserveLuminosity?1:0),(0,y.writeZeros)(e,3)});function ho(e){let t=(0,b.readInt16)(e),n=(0,b.readInt16)(e),i=(0,b.readInt16)(e);(0,b.skipBytes)(e,2);let o=(0,b.readInt16)(e);return{red:t,green:n,blue:i,constant:o}}function ci(e,t){let n=t||{};(0,y.writeInt16)(e,n.red),(0,y.writeInt16)(e,n.green),(0,y.writeInt16)(e,n.blue),(0,y.writeZeros)(e,2),(0,y.writeInt16)(e,n.constant)}L("mixr",Fe("channel mixer"),(e,t,n)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid mixr version");let i=t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:"channel mixer",monochrome:!!(0,b.readUint16)(e)});i.monochrome||(i.red=ho(e),i.green=ho(e),i.blue=ho(e)),i.gray=ho(e),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,1),(0,y.writeUint16)(e,n.monochrome?1:0),n.monochrome?(ci(e,n.gray),(0,y.writeZeros)(e,30)):(ci(e,n.red),ci(e,n.green),ci(e,n.blue),ci(e,n.gray))});var Sc=(0,Ze.createEnum)("colorLookupType","3dlut",{"3dlut":"3DLUT",abstractProfile:"abstractProfile",deviceLinkProfile:"deviceLinkProfile"}),vc=(0,Ze.createEnum)("LUTFormatType","look",{look:"LUTFormatLOOK",cube:"LUTFormatCUBE","3dl":"LUTFormat3DL"}),po=(0,Ze.createEnum)("colorLookupOrder","rgb",{rgb:"rgbOrder",bgr:"bgrOrder"});L("clrL",Fe("color lookup"),(e,t,n)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid clrL version");let i=(0,w.readVersionAndDescriptor)(e);t.adjustment={type:"color lookup"};let o=t.adjustment;i.lookupType!==void 0&&(o.lookupType=Sc.decode(i.lookupType)),i["Nm "]!==void 0&&(o.name=i["Nm "]),i.Dthr!==void 0&&(o.dither=i.Dthr),i.profile!==void 0&&(o.profile=i.profile),i.LUTFormat!==void 0&&(o.lutFormat=vc.decode(i.LUTFormat)),i.dataOrder!==void 0&&(o.dataOrder=po.decode(i.dataOrder)),i.tableOrder!==void 0&&(o.tableOrder=po.decode(i.tableOrder)),i.LUT3DFileData!==void 0&&(o.lut3DFileData=i.LUT3DFileData),i.LUT3DFileName!==void 0&&(o.lut3DFileName=i.LUT3DFileName),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,i={};n.lookupType!==void 0&&(i.lookupType=Sc.encode(n.lookupType)),n.name!==void 0&&(i["Nm "]=n.name),n.dither!==void 0&&(i.Dthr=n.dither),n.profile!==void 0&&(i.profile=n.profile),n.lutFormat!==void 0&&(i.LUTFormat=vc.encode(n.lutFormat)),n.dataOrder!==void 0&&(i.dataOrder=po.encode(n.dataOrder)),n.tableOrder!==void 0&&(i.tableOrder=po.encode(n.tableOrder)),n.lut3DFileData!==void 0&&(i.LUT3DFileData=n.lut3DFileData),n.lut3DFileName!==void 0&&(i.LUT3DFileName=n.lut3DFileName),(0,y.writeUint16)(e,1),(0,w.writeVersionAndDescriptor)(e,"","null",i)});L("nvrt",Fe("invert"),(e,t,n)=>{t.adjustment={type:"invert"},(0,b.skipBytes)(e,n())},()=>{});L("post",Fe("posterize"),(e,t,n)=>{t.adjustment={type:"posterize",levels:(0,b.readUint16)(e)},(0,b.skipBytes)(e,n())},(e,t)=>{var n;let i=t.adjustment;(0,y.writeUint16)(e,(n=i.levels)!==null&&n!==void 0?n:4),(0,y.writeZeros)(e,2)});L("thrs",Fe("threshold"),(e,t,n)=>{t.adjustment={type:"threshold",level:(0,b.readUint16)(e)},(0,b.skipBytes)(e,n())},(e,t)=>{var n;let i=t.adjustment;(0,y.writeUint16)(e,(n=i.level)!==null&&n!==void 0?n:128),(0,y.writeZeros)(e,2)});var xc=["","","","rgb","hsb","","lab"];L("grdm",Fe("gradient map"),(e,t,n)=>{let i=(0,b.readUint16)(e);if(i!==1&&i!==3)throw new Error("Invalid grdm version");let o={type:"gradient map",gradientType:"solid"};o.reverse=!!(0,b.readUint8)(e),o.dither=!!(0,b.readUint8)(e);let r=!!(0,b.readUint8)(e);if(e.offset--,r){let u=(0,b.readSignature)(e);o.method=w.gradientInterpolationMethodType.decode(u)}o.name=(0,b.readUnicodeString)(e),o.colorStops=[],o.opacityStops=[];let s=(0,b.readUint16)(e);for(let u=0;u<s;u++)o.colorStops.push({location:(0,b.readUint32)(e),midpoint:(0,b.readUint32)(e)/100,color:(0,b.readColor)(e)}),(0,b.skipBytes)(e,2);let a=(0,b.readUint16)(e);for(let u=0;u<a;u++)o.opacityStops.push({location:(0,b.readUint32)(e),midpoint:(0,b.readUint32)(e)/100,opacity:(0,b.readUint16)(e)/255});if((0,b.readUint16)(e)!==2)throw new Error("Invalid grdm expansion count");let c=(0,b.readUint16)(e);if(o.smoothness=c/4096,(0,b.readUint16)(e)!==32)throw new Error("Invalid grdm length");o.gradientType=(0,b.readUint16)(e)?"noise":"solid",o.randomSeed=(0,b.readUint32)(e),o.addTransparency=!!(0,b.readUint16)(e),o.restrictColors=!!(0,b.readUint16)(e),o.roughness=(0,b.readUint32)(e)/4096,o.colorModel=xc[(0,b.readUint16)(e)]||"rgb",o.min=[(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768],o.max=[(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768],(0,b.skipBytes)(e,n());for(let u of o.colorStops)u.location/=c;for(let u of o.opacityStops)u.location/=c;t.adjustment=o},(e,t)=>{var n,i,o;let r=t.adjustment;(0,y.writeUint16)(e,r.method!==void 0?3:1),(0,y.writeUint8)(e,r.reverse?1:0),(0,y.writeUint8)(e,r.dither?1:0),r.method!==void 0&&(0,y.writeSignature)(e,w.gradientInterpolationMethodType.encode(r.method)),(0,y.writeUnicodeStringWithPadding)(e,r.name||""),(0,y.writeUint16)(e,r.colorStops&&r.colorStops.length||0);let s=Math.round(((n=r.smoothness)!==null&&n!==void 0?n:1)*4096);for(let l of r.colorStops||[])(0,y.writeUint32)(e,Math.round(l.location*s)),(0,y.writeUint32)(e,Math.round(l.midpoint*100)),(0,y.writeColor)(e,l.color),(0,y.writeZeros)(e,2);(0,y.writeUint16)(e,r.opacityStops&&r.opacityStops.length||0);for(let l of r.opacityStops||[])(0,y.writeUint32)(e,Math.round(l.location*s)),(0,y.writeUint32)(e,Math.round(l.midpoint*100)),(0,y.writeUint16)(e,Math.round(l.opacity*255));(0,y.writeUint16)(e,2),(0,y.writeUint16)(e,s),(0,y.writeUint16)(e,32),(0,y.writeUint16)(e,r.gradientType==="noise"?1:0),(0,y.writeUint32)(e,r.randomSeed||0),(0,y.writeUint16)(e,r.addTransparency?1:0),(0,y.writeUint16)(e,r.restrictColors?1:0),(0,y.writeUint32)(e,Math.round(((i=r.roughness)!==null&&i!==void 0?i:1)*4096));let a=xc.indexOf((o=r.colorModel)!==null&&o!==void 0?o:"rgb");(0,y.writeUint16)(e,a===-1?3:a);for(let l=0;l<4;l++)(0,y.writeUint16)(e,Math.round((r.min&&r.min[l]||0)*32768));for(let l=0;l<4;l++)(0,y.writeUint16)(e,Math.round((r.max&&r.max[l]||0)*32768));(0,y.writeZeros)(e,4)});function It(e){return{c:(0,b.readInt16)(e),m:(0,b.readInt16)(e),y:(0,b.readInt16)(e),k:(0,b.readInt16)(e)}}function Dt(e,t){let n=t||{};(0,y.writeInt16)(e,n.c),(0,y.writeInt16)(e,n.m),(0,y.writeInt16)(e,n.y),(0,y.writeInt16)(e,n.k)}L("selc",Fe("selective color"),(e,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid selc version");let n=(0,b.readUint16)(e)?"absolute":"relative";(0,b.skipBytes)(e,8),t.adjustment={type:"selective color",mode:n,reds:It(e),yellows:It(e),greens:It(e),cyans:It(e),blues:It(e),magentas:It(e),whites:It(e),neutrals:It(e),blacks:It(e)}},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,1),(0,y.writeUint16)(e,n.mode==="absolute"?1:0),(0,y.writeZeros)(e,8),Dt(e,n.reds),Dt(e,n.yellows),Dt(e,n.greens),Dt(e,n.cyans),Dt(e,n.blues),Dt(e,n.magentas),Dt(e,n.whites),Dt(e,n.neutrals),Dt(e,n.blacks)});L("CgEd",e=>{let t=e.adjustment;return t?t.type==="brightness/contrast"&&!t.useLegacy||(t.type==="levels"||t.type==="curves"||t.type==="exposure"||t.type==="channel mixer"||t.type==="hue/saturation")&&t.presetFileName!==void 0:!1},(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);if(i.Vrsn!==1)throw new Error("Invalid CgEd version");"presetFileName"in i?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:i.presetKind,presetFileName:i.presetFileName}):"curvesPresetFileName"in i?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:i.curvesPresetKind,presetFileName:i.curvesPresetFileName}):"mixerPresetFileName"in i?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:i.mixerPresetKind,presetFileName:i.mixerPresetFileName}):t.adjustment={type:"brightness/contrast",brightness:i.Brgh,contrast:i.Cntr,meanValue:i.means,useLegacy:!!i.useLegacy,labColorOnly:!!i["Lab "],auto:!!i.Auto},(0,b.skipBytes)(e,n())},(e,t)=>{var n,i,o,r;let s=t.adjustment;if(s.type==="levels"||s.type==="exposure"||s.type==="hue/saturation"){let a={Vrsn:1,presetKind:(n=s.presetKind)!==null&&n!==void 0?n:1,presetFileName:s.presetFileName||""};(0,w.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="curves"){let a={Vrsn:1,curvesPresetKind:(i=s.presetKind)!==null&&i!==void 0?i:1,curvesPresetFileName:s.presetFileName||""};(0,w.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="channel mixer"){let a={Vrsn:1,mixerPresetKind:(o=s.presetKind)!==null&&o!==void 0?o:1,mixerPresetFileName:s.presetFileName||""};(0,w.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="brightness/contrast"){let a={Vrsn:1,Brgh:s.brightness||0,Cntr:s.contrast||0,means:(r=s.meanValue)!==null&&r!==void 0?r:127,"Lab ":!!s.labColorOnly,useLegacy:!!s.useLegacy,Auto:!!s.auto};(0,w.writeVersionAndDescriptor)(e,"","null",a)}else throw new Error("Unhandled CgEd case")});function k0(e){let t=[];function n(i){var o;if(i.children)for(let r of i.children)((o=r.text)===null||o===void 0?void 0:o.index)!==void 0&&(t[r.text.index]=r),n(r)}return n(e),t}L("Txt2",ae("engineData"),(e,t,n,i)=>{let o=(0,b.readBytes)(e,n());t.engineData=(0,pc.fromByteArray)(o);let r=k0(i),s=(0,Wr.parseEngineData)(o),l=(0,y0.decodeEngineData2)(s).ResourceDict.TextFrameSet;if(l)for(let c=0;c<l.length;c++){let d=r[c];l[c].path&&d?.text&&(d.text.textPath=l[c].path)}},(e,t)=>{let n=(0,pc.toByteArray)(t.engineData);(0,y.writeBytes)(e,n)});L("FEid",ae("filterEffectsMasks"),(e,t,n)=>{let i=(0,b.readInt32)(e);if(i<1||i>3)throw new Error(`Invalid filterEffects version ${i}`);for(t.filterEffectsMasks=[];n()>8;){if((0,b.readUint32)(e))throw new Error("filterEffects: 64 bit length is not supported");let o=(0,b.readUint32)(e),r=e.offset+o,s=(0,b.readPascalString)(e,1),a=(0,b.readInt32)(e);if(a!==1)throw new Error(`Invalid filterEffect version ${a}`);if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");(0,b.readUint32)(e);let l=(0,b.readInt32)(e),c=(0,b.readInt32)(e),d=(0,b.readInt32)(e),u=(0,b.readInt32)(e),f=(0,b.readInt32)(e),h=(0,b.readInt32)(e),p=[];for(let m=0;m<h+2;m++)if((0,b.readInt32)(e)){if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let v=(0,b.readUint32)(e);if(!v)throw new Error("filterEffect: Empty channel");let x=(0,b.readUint16)(e),_=(0,b.readBytes)(e,v-2);p.push({compressionMode:x,data:_})}else p.push(void 0);if(t.filterEffectsMasks.push({id:s,top:l,left:c,bottom:d,right:u,depth:f,channels:p}),e.offset<r&&(0,b.readUint8)(e)){let m=(0,b.readInt32)(e),g=(0,b.readInt32)(e),v=(0,b.readInt32)(e),x=(0,b.readInt32)(e);if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let _=(0,b.readUint32)(e),I=(0,b.readUint16)(e),P=(0,b.readBytes)(e,_-2);t.filterEffectsMasks[t.filterEffectsMasks.length-1].extra={top:m,left:g,bottom:v,right:x,compressionMode:I,data:P}}e.offset=r;let S=o;for(;S%4;)e.offset++,S++}},(e,t)=>{var n;(0,y.writeInt32)(e,3);for(let i of t.filterEffectsMasks){(0,y.writeUint32)(e,0),(0,y.writeUint32)(e,0);let o=e.offset;(0,y.writePascalString)(e,i.id,1),(0,y.writeInt32)(e,1),(0,y.writeUint32)(e,0),(0,y.writeUint32)(e,0);let r=e.offset;(0,y.writeInt32)(e,i.top),(0,y.writeInt32)(e,i.left),(0,y.writeInt32)(e,i.bottom),(0,y.writeInt32)(e,i.right),(0,y.writeInt32)(e,i.depth);let s=Math.max(0,i.channels.length-2);(0,y.writeInt32)(e,s);for(let c=0;c<s+2;c++){let d=i.channels[c];(0,y.writeInt32)(e,d?1:0),d&&((0,y.writeUint32)(e,0),(0,y.writeUint32)(e,d.data.length+2),(0,y.writeUint16)(e,d.compressionMode),(0,y.writeBytes)(e,d.data))}e.view.setUint32(r-4,e.offset-r,!1);let a=(n=t.filterEffectsMasks[t.filterEffectsMasks.length-1])===null||n===void 0?void 0:n.extra;a&&((0,y.writeUint8)(e,1),(0,y.writeInt32)(e,a.top),(0,y.writeInt32)(e,a.left),(0,y.writeInt32)(e,a.bottom),(0,y.writeInt32)(e,a.right),(0,y.writeUint32)(e,0),(0,y.writeUint32)(e,a.data.byteLength+2),(0,y.writeUint16)(e,a.compressionMode),(0,y.writeBytes)(e,a.data));let l=e.offset-o;for(e.view.setUint32(o-4,l,!1);l%4;)(0,y.writeZeros)(e,1),l++}});Gt("FXid","FEid");L("FMsk",ae("filterMask"),(e,t)=>{t.filterMask={colorSpace:(0,b.readColor)(e),opacity:(0,b.readUint16)(e)/255}},(e,t)=>{var n;(0,y.writeColor)(e,t.filterMask.colorSpace),(0,y.writeUint16)(e,(0,Ze.clamp)((n=t.filterMask.opacity)!==null&&n!==void 0?n:1,0,1)*255)});L("artd",e=>e.artboards!==void 0,(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.artboards={count:i["Cnt "],autoExpandOffset:{horizontal:i.autoExpandOffset.Hrzn,vertical:i.autoExpandOffset.Vrtc},origin:{horizontal:i.origin.Hrzn,vertical:i.origin.Vrtc},autoExpandEnabled:i.autoExpandEnabled,autoNestEnabled:i.autoNestEnabled,autoPositionEnabled:i.autoPositionEnabled,shrinkwrapOnSaveEnabled:!!i.shrinkwrapOnSaveEnabled,docDefaultNewArtboardBackgroundColor:(0,w.parseColor)(i.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:i.docDefaultNewArtboardBackgroundType},(0,b.skipBytes)(e,n())},(e,t)=>{var n,i,o,r,s;let a=t.artboards,l={"Cnt ":a.count,autoExpandOffset:a.autoExpandOffset?{Hrzn:a.autoExpandOffset.horizontal,Vrtc:a.autoExpandOffset.vertical}:{Hrzn:0,Vrtc:0},origin:a.origin?{Hrzn:a.origin.horizontal,Vrtc:a.origin.vertical}:{Hrzn:0,Vrtc:0},autoExpandEnabled:(n=a.autoExpandEnabled)!==null&&n!==void 0?n:!0,autoNestEnabled:(i=a.autoNestEnabled)!==null&&i!==void 0?i:!0,autoPositionEnabled:(o=a.autoPositionEnabled)!==null&&o!==void 0?o:!0,shrinkwrapOnSaveEnabled:(r=a.shrinkwrapOnSaveEnabled)!==null&&r!==void 0?r:!0,docDefaultNewArtboardBackgroundColor:(0,w.serializeColor)(a.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:(s=a.docDefaultNewArtboardBackgroundType)!==null&&s!==void 0?s:1};(0,w.writeVersionAndDescriptor)(e,"","null",l,"artd")});function Zr(e){return Object.keys(e).map(t=>e[t]).some(t=>Array.isArray(t)&&t.length>1)}L("lfx2",e=>e.effects!==void 0&&!Zr(e.effects),(e,t,n)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lfx2 version");let o=(0,w.readVersionAndDescriptor)(e);t.effects=(0,w.parseEffects)(o,!!e.logMissingFeatures),(0,b.skipBytes)(e,n())},(e,t,n,i)=>{let o=(0,w.serializeEffects)(t.effects,!!i.logMissingFeatures,!0);(0,y.writeUint32)(e,0),(0,w.writeVersionAndDescriptor)(e,"","null",o)});L("cinf",ae("compositorUsed"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);function o(r){return r.split(".")[1]}t.compositorUsed={description:i.description,reason:i.reason,engine:o(i.Engn)},i.Vrsn&&(t.compositorUsed.version=i.Vrsn),i.psVersion&&(t.compositorUsed.photoshopVersion=i.psVersion),i.enableCompCore&&(t.compositorUsed.enableCompCore=o(i.enableCompCore)),i.enableCompCoreGPU&&(t.compositorUsed.enableCompCoreGPU=o(i.enableCompCoreGPU)),i.enableCompCoreThreads&&(t.compositorUsed.enableCompCoreThreads=o(i.enableCompCoreThreads)),i.compCoreSupport&&(t.compositorUsed.compCoreSupport=o(i.compCoreSupport)),i.compCoreGPUSupport&&(t.compositorUsed.compCoreGPUSupport=o(i.compCoreGPUSupport)),(0,b.skipBytes)(e,n())},(e,t)=>{let n=t.compositorUsed,i={Vrsn:n.version||{major:1,minor:0,fix:0}};n.photoshopVersion&&(i.psVersion=n.photoshopVersion),i.description=n.description,i.reason=n.reason,i.Engn=`Engn.${n.engine}`,n.enableCompCore&&(i.enableCompCore=`enable.${n.enableCompCore}`),n.enableCompCoreGPU&&(i.enableCompCoreGPU=`enable.${n.enableCompCoreGPU}`),n.enableCompCoreThreads&&(i.enableCompCoreThreads=`enable.${n.enableCompCoreThreads}`),n.compCoreSupport&&(i.compCoreSupport=`reason.${n.compCoreSupport}`),n.compCoreGPUSupport&&(i.compCoreGPUSupport=`reason.${n.compCoreGPUSupport}`),(0,w.writeVersionAndDescriptor)(e,"","null",i)});L("extn",e=>e._extn!==void 0,(e,t)=>{let n=(0,w.readVersionAndDescriptor)(e);Ze.MOCK_HANDLERS&&(t._extn=n)},(e,t)=>{Ze.MOCK_HANDLERS&&(0,w.writeVersionAndDescriptor)(e,"","null",t._extn)});L("iOpa",ae("fillOpacity"),(e,t)=>{t.fillOpacity=(0,b.readUint8)(e)/255,(0,b.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.fillOpacity*255),(0,y.writeZeros)(e,3)});L("brst",ae("channelBlendingRestrictions"),(e,t,n)=>{for(t.channelBlendingRestrictions=[];n()>4;)t.channelBlendingRestrictions.push((0,b.readInt32)(e))},(e,t)=>{for(let n of t.channelBlendingRestrictions)(0,y.writeInt32)(e,n)});L("tsly",ae("transparencyShapesLayer"),(e,t)=>{t.transparencyShapesLayer=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.transparencyShapesLayer?1:0),(0,y.writeZeros)(e,3)})});var Dn=oe(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.createWriter=C0;ce.getWriterBuffer=P0;ce.getWriterBufferNoCopy=E0;ce.writeUint8=de;ce.writeInt16=Ht;ce.writeUint16=Z;ce.writeUint16LE=Fc;ce.writeInt32=Me;ce.writeInt32LE=F0;ce.writeUint32=ue;ce.writeFloat32=O0;ce.writeFloat64=Kr;ce.writeFixedPoint32=L0;ce.writeFixedPointPath32=B0;ce.writeBytes=fi;ce.writeZeros=sn;ce.writeSignature=an;ce.writeAsciiString=U0;ce.writePascalString=yo;ce.writeUnicodeStringWithoutLength=Oc;ce.writeUnicodeStringWithoutLengthLE=R0;ce.writeUnicodeString=Lc;ce.writeUnicodeStringWithPadding=M0;ce.writeSection=rt;ce.writePsd=T0;ce.writeColor=q0;ce.writePattern=K0;var ve=Tt(),I0=oo(),D0=_r();function C0(e=4096){let t=new ArrayBuffer(e),n=new DataView(t);return{buffer:t,view:n,offset:0,tempBuffer:void 0}}function P0(e){return e.buffer.slice(0,e.offset)}function E0(e){return new Uint8Array(e.buffer,0,e.offset)}function de(e,t){let n=Ct(e,1);e.view.setUint8(n,t)}function Ht(e,t){let n=Ct(e,2);e.view.setInt16(n,t,!1)}function Z(e,t){let n=Ct(e,2);e.view.setUint16(n,t,!1)}function Fc(e,t){let n=Ct(e,2);e.view.setUint16(n,t,!0)}function Me(e,t){let n=Ct(e,4);e.view.setInt32(n,t,!1)}function F0(e,t){let n=Ct(e,4);e.view.setInt32(n,t,!0)}function ue(e,t){let n=Ct(e,4);e.view.setUint32(n,t,!1)}function O0(e,t){let n=Ct(e,4);e.view.setFloat32(n,t,!1)}function Kr(e,t){let n=Ct(e,8);e.view.setFloat64(n,t,!1)}function L0(e,t){Me(e,t*65536)}function B0(e,t){Me(e,t*(1<<24))}function fi(e,t){t&&(Tc(e,e.offset+t.length),new Uint8Array(e.buffer).set(t,e.offset),e.offset+=t.length)}function sn(e,t){for(let n=0;n<t;n++)de(e,0)}function an(e,t){if(t.length!==4)throw new Error(`Invalid signature: '${t}'`);for(let n=0;n<4;n++)de(e,t.charCodeAt(n))}function U0(e,t){for(let n=0;n<t.length;n++)de(e,t.charCodeAt(n))}function yo(e,t,n){let i=t.length;if(i>255)throw new Error("String too long");de(e,i);for(let o=0;o<i;o++){let r=t.charCodeAt(o);de(e,r<128?r:63)}for(;++i%n;)de(e,0)}function Oc(e,t){for(let n=0;n<t.length;n++)Z(e,t.charCodeAt(n))}function R0(e,t){for(let n=0;n<t.length;n++)Fc(e,t.charCodeAt(n))}function Lc(e,t){ue(e,t.length),Oc(e,t)}function M0(e,t){ue(e,t.length+1);for(let n=0;n<t.length;n++)Z(e,t.charCodeAt(n));Z(e,0)}function Bc(e=[]){let t=0;for(let n of e){let{width:i,height:o}=di(n);if(t=Math.max(t,2*o+2*i*o),n.mask){let{width:r,height:s}=di(n.mask);t=Math.max(t,2*s+2*r*s)}if(n.realMask){let{width:r,height:s}=di(n.realMask);t=Math.max(t,2*s+2*r*s)}n.children&&(t=Math.max(t,Bc(n.children)))}return t}function rt(e,t,n,i=!1,o=!1){o&&ue(e,0);let r=e.offset;ue(e,0),n();let s=e.offset-r-4,a=s;for(;a%t;)de(e,0),a++;i&&(s=a),e.view.setUint32(r,s,!1)}function Uc(e){var t;(t=e.children)===null||t===void 0||t.forEach(Uc);let n=e.imageData;if(n&&(n.data instanceof Uint32Array||n.data instanceof Uint16Array))throw new Error("imageData has incorrect bitDepth");if("mask"in e&&e.mask){let i=e.mask.imageData;if(i&&(i.data instanceof Uint32Array||i.data instanceof Uint16Array))throw new Error("mask imageData has incorrect bitDepth")}}function T0(e,t,n={}){var i;if(!(+t.width>0&&+t.height>0))throw new Error("Invalid document size");if((t.width>3e4||t.height>3e4)&&!n.psb)throw new Error("Document size is too large (max is 30000x30000, use PSB format instead)");let o=(i=t.bitsPerChannel)!==null&&i!==void 0?i:8;if(o!==8)throw new Error("bitsPerChannel other than 8 are not supported for writing");Uc(t);let r=Object.assign({},t.imageResources),s=Object.assign(Object.assign({},n),{layerIds:new Set,layerToId:new Map});s.generateThumbnail&&(r.thumbnail=G0(t));let a=t.imageData;if(!a&&t.canvas&&(a=t.canvas.getContext("2d").getImageData(0,0,t.canvas.width,t.canvas.height)),a&&(t.width!==a.width||t.height!==a.height))throw new Error("Document canvas must have the same size as document");let l=!!a&&(0,ve.hasAlpha)(a),c=Math.max(Bc(t.children),8*t.width*t.height+2*t.height);e.tempBuffer=new Uint8Array(c),an(e,"8BPS"),Z(e,n.psb?2:1),sn(e,6),Z(e,l?4:3),ue(e,t.height),ue(e,t.width),Z(e,o),Z(e,3),rt(e,1,()=>{var S,m,g;if(t.palette){for(let v=0;v<256;v++)de(e,((S=t.palette[v])===null||S===void 0?void 0:S.r)||0);for(let v=0;v<256;v++)de(e,((m=t.palette[v])===null||m===void 0?void 0:m.g)||0);for(let v=0;v<256;v++)de(e,((g=t.palette[v])===null||g===void 0?void 0:g.b)||0)}});let d=[];Mc(d,t.children),d.length||d.push({}),r.layersGroup=d.map(S=>S.linkGroup||0),r.layerGroupsEnabledId=d.map(S=>S.linkGroupEnabled==!1?0:1),rt(e,1,()=>{for(let S of D0.resourceHandlers){let m=S.has(r),g=m===!1?0:m===!0?1:m;for(let v=0;v<g;v++)an(e,"8BIM"),Z(e,S.key),yo(e,"",2),rt(e,2,()=>S.write(e,r,v))}}),rt(e,2,()=>{j0(e,d,t,l,s),N0(e,t.globalLayerMaskInfo),Rc(e,t,t,s)},void 0,!!s.psb);let u=l?[0,1,2,3]:[0,1,2],f=a?a.width:t.width,h=a?a.height:t.height,p={data:new Uint8Array(f*h*4),width:f,height:h};if(Z(e,1),ve.RAW_IMAGE_DATA&&t.imageDataRaw)console.log("writing raw image data"),fi(e,t.imageDataRaw);else{if(a&&p.data.set(new Uint8Array(a.data.buffer,a.data.byteOffset,a.data.byteLength)),l){let S=p.width*p.height*4,m=p.data;for(let g=0;g<S;g+=4){let v=m[g+3];if(v!=0&&v!=255){let x=v/255,_=255*(1-x);m[g+0]=m[g+0]*x+_,m[g+1]=m[g+1]*x+_,m[g+2]=m[g+2]*x+_}}}fi(e,(0,ve.writeDataRLE)(e.tempBuffer,p,u,!!n.psb))}}function j0(e,t,n,i,o){rt(e,4,()=>{var r;Ht(e,i?-t.length:t.length);let s=t.map((a,l)=>H0(e.tempBuffer,a,l===0,o));for(let a of s){let{layer:l,top:c,left:d,bottom:u,right:f,channels:h}=a;Me(e,c),Me(e,d),Me(e,u),Me(e,f),Z(e,h.length);for(let S of h)Ht(e,S.id),o.psb&&ue(e,0),ue(e,S.length);an(e,"8BIM"),an(e,ve.fromBlendMode[l.blendMode]||"norm"),de(e,Math.round((0,ve.clamp)((r=l.opacity)!==null&&r!==void 0?r:1,0,1)*255)),de(e,l.clipping?1:0);let p=8;l.transparencyProtected&&(p|=1),l.hidden&&(p|=2),(l.vectorMask||l.sectionDivider&&l.sectionDivider.type!==0||l.adjustment)&&(p|=16),l.effectsOpen&&(p|=32),de(e,p),de(e,0),rt(e,1,()=>{z0(e,l,a),$0(e,l),yo(e,(l.name||"").substring(0,255),4),Rc(e,l,n,o)})}for(let a of s)for(let l of a.channels)Z(e,l.compression),l.data&&fi(e,l.data)},!0,o.psb)}function z0(e,{mask:t,realMask:n},i){rt(e,1,()=>{if(!t&&!n)return;let o=0,r=0,s=0;t&&(t.userMaskDensity!==void 0&&(o|=1),t.userMaskFeather!==void 0&&(o|=2),t.vectorMaskDensity!==void 0&&(o|=4),t.vectorMaskFeather!==void 0&&(o|=8),t.disabled&&(r|=2),t.positionRelativeToLayer&&(r|=1),t.fromVectorData&&(r|=8),o&&(r|=16));let a=i.mask||{};if(Me(e,a.top||0),Me(e,a.left||0),Me(e,a.bottom||0),Me(e,a.right||0),de(e,t&&t.defaultColor||0),de(e,r),n){n.disabled&&(s|=2),n.positionRelativeToLayer&&(s|=1),n.fromVectorData&&(s|=8);let l=i.realMask||{};de(e,s),de(e,n.defaultColor||0),Me(e,l.top||0),Me(e,l.left||0),Me(e,l.bottom||0),Me(e,l.right||0)}o&&t&&(de(e,o),t.userMaskDensity!==void 0&&de(e,Math.round(t.userMaskDensity*255)),t.userMaskFeather!==void 0&&Kr(e,t.userMaskFeather),t.vectorMaskDensity!==void 0&&de(e,Math.round(t.vectorMaskDensity*255)),t.vectorMaskFeather!==void 0&&Kr(e,t.vectorMaskFeather)),sn(e,2)})}function bo(e,t){de(e,t[0]),de(e,t[1]),de(e,t[2]),de(e,t[3])}function $0(e,t){rt(e,1,()=>{let n=t.blendingRanges;if(n){bo(e,n.compositeGrayBlendSource),bo(e,n.compositeGraphBlendDestinationRange);for(let i of n.ranges)bo(e,i.sourceRange),bo(e,i.destRange)}})}function N0(e,t){rt(e,1,()=>{t&&(Z(e,t.overlayColorSpace),Z(e,t.colorSpace1),Z(e,t.colorSpace2),Z(e,t.colorSpace3),Z(e,t.colorSpace4),Z(e,Math.round(t.opacity*255)),de(e,t.kind),sn(e,3))})}function Rc(e,t,n,i){for(let o of I0.infoHandlers){let r=o.key;if(!(r==="Txt2"&&i.invalidateTextLayers)&&(r==="vmsk"&&i.psb&&(r="vsms"),o.has(t))){let s=i.psb&&ve.largeAdditionalInfoKeys.indexOf(r)!==-1,a=r!=="Txt2"&&r!=="cinf"&&r!=="extn"&&r!=="CAI "&&r!=="OCIO",l=r==="Txt2"||r==="luni"||r==="vmsk"||r==="artb"||r==="artd"||r==="vogk"||r==="SoLd"||r==="lnk2"||r==="vscg"||r==="vsms"||r==="GdFl"||r==="lmfx"||r==="lrFX"||r==="cinf"||r==="PlLd"||r==="Anno"||r==="CAI "||r==="OCIO"||r==="GenI"||r==="FEid"||r==="curv"||r==="CgEd"||r==="vibA"||r==="blwh"||r==="grdm";an(e,s?"8B64":"8BIM"),an(e,r),rt(e,l?4:2,()=>{o.write(e,t,n,i)},a,s)}}}function Mc(e,t){if(t)for(let n of t){if(n.children&&n.canvas)throw new Error("Invalid layer, cannot have both 'canvas' and 'children' properties");if(n.children&&n.imageData)throw new Error("Invalid layer, cannot have both 'imageData' and 'children' properties");n.children?(e.push({name:"</Layer group>",sectionDivider:{type:3}}),Mc(e,n.children),e.push(Object.assign(Object.assign({},n),{blendMode:n.blendMode==="pass through"?"normal":n.blendMode,sectionDivider:{type:n.opened===!1?2:1,key:ve.fromBlendMode[n.blendMode]||"pass",subType:0}}))):e.push(Object.assign({},n))}}function V0(e,t){let n=e.buffer.byteLength;do n*=2;while(t>n);let i=new ArrayBuffer(n),o=new Uint8Array(i),r=new Uint8Array(e.buffer);o.set(r),e.buffer=i,e.view=new DataView(e.buffer)}function Tc(e,t){t>e.buffer.byteLength&&V0(e,t)}function Ct(e,t){let n=e.offset;return Tc(e,e.offset+=t),n}function G0(e){let t=(0,ve.createCanvas)(10,10),n=1;e.width>e.height?(t.width=160,t.height=Math.floor(e.height*(t.width/e.width)),n=t.width/e.width):(t.height=160,t.width=Math.floor(e.width*(t.height/e.height)),n=t.height/e.height);let i=t.getContext("2d");return i.scale(n,n),e.imageData?i.drawImage((0,ve.imageDataToCanvas)(e.imageData),0,0):e.canvas&&i.drawImage(e.canvas,0,0),t}function Cc(e,t,n,i,o,r){let s=i.top|0,a=i.left|0,l=i.right|0,c=i.bottom|0,{width:d,height:u}=di(i),f=i.imageData;if(!f&&i.canvas&&d&&u&&(f=i.canvas.getContext("2d").getImageData(0,0,d,u)),f&&(f.width!==d||f.height!==u))throw new Error("Invalid imageData dimentions");l=a+d,c=s+u;let h,p;ve.RAW_IMAGE_DATA&&n[r?"realMaskDataRaw":"maskDataRaw"]?(h=n[r?"realMaskDataRaw":"maskDataRaw"],p=n[r?"realMaskDataRawCompression":"maskDataRawCompression"]):f?o.compress?(h=(0,ve.writeDataZipWithoutPrediction)(f,[0]),p=2):(h=(0,ve.writeDataRLE)(e,f,[0],!!o.psb),p=1):(h=new Uint8Array(0),p=1),t.channels.push({id:r?-3:-2,compression:p,data:h,length:2+h.length}),t[r?"realMask":"mask"]={top:s,left:a,right:l,bottom:c}}function qr(e){return e?{top:e.top||0,left:e.left||0,right:e.right||0,bottom:e.bottom||0}:void 0}function H0(e,t,n,i){if(t.rawData)return Object.assign(Object.assign({layer:t,channels:t.rawData.channels.map(r=>{var s,a;return Object.assign(Object.assign({},r),{length:2+((a=(s=r.data)===null||s===void 0?void 0:s.byteLength)!==null&&a!==void 0?a:0)})})},qr(t)),{mask:qr(t.mask),realMask:qr(t.realMask)});let o=X0(e,t,n,i);return t.mask&&Cc(e,o,t,t.mask,i,!1),t.realMask&&Cc(e,o,t,t.realMask,i,!0),o}function di({canvas:e,imageData:t}){var n,i,o,r;let s=(i=(n=t?.width)!==null&&n!==void 0?n:e?.width)!==null&&i!==void 0?i:0,a=(r=(o=t?.height)!==null&&o!==void 0?o:e?.height)!==null&&r!==void 0?r:0;return{width:s,height:a}}function W0(e,t,n,i,o){if(e.data instanceof Uint32Array||e.data instanceof Uint16Array)throw new Error("imageData has incorrect bit depth");let r=(0,ve.createImageData)(i,o),s=e.data,a=r.data;for(let l=0;l<o;l++)for(let c=0;c<i;c++){let d=(c+t+(l+n)*e.width)*4,u=(c+l*i)*4;a[u]=s[d],a[u+1]=s[d+1],a[u+2]=s[d+2],a[u+3]=s[d+3]}return r}function X0(e,t,n,i){var o;let r=t.top|0,s=t.left|0,a=t.right|0,l=t.bottom|0,c=[{id:-1,compression:0,data:void 0,length:2},{id:0,compression:0,data:void 0,length:2},{id:1,compression:0,data:void 0,length:2},{id:2,compression:0,data:void 0,length:2}],{width:d,height:u}=di(t);if(!(t.canvas||t.imageData)||!d||!u)return a=s,l=r,{layer:t,top:r,left:s,right:a,bottom:l,channels:c};a=s+d,l=r+u;let f=t.imageData||t.canvas.getContext("2d").getImageData(0,0,d,u);if(i.trimImageData){let p=Z0(f);if(p.left!==0||p.top!==0||p.right!==f.width||p.bottom!==f.height){if(s+=p.left,r+=p.top,a-=f.width-p.right,l-=f.height-p.bottom,d=a-s,u=l-r,!d||!u)return{layer:t,top:r,left:s,right:a,bottom:l,channels:c};f=W0(f,p.left,p.top,d,u)}}let h=[0,1,2];return(!n||i.noBackground||t.mask||(0,ve.hasAlpha)(f)||ve.RAW_IMAGE_DATA&&(!((o=t.imageDataRaw)===null||o===void 0)&&o[-1]))&&h.unshift(-1),c=h.map(p=>{let S=(0,ve.offsetForChannel)(p,!1),m,g;return ve.RAW_IMAGE_DATA&&t.imageDataRaw?(m=t.imageDataRaw[p],g=t.imageDataRawCompression[p]):i.compress?(m=(0,ve.writeDataZipWithoutPrediction)(f,[S]),g=2):(m=(0,ve.writeDataRLE)(e,f,[S],!!i.psb),g=1),{id:p,compression:g,data:m,length:2+m.length}}),{layer:t,top:r,left:s,right:a,bottom:l,channels:c}}function Pc({data:e,width:t},n,i,o){let r=(n*t+i)*4+3|0,s=r+(o-i)*4|0;for(let a=r;a<s;a=a+4|0)if(e[a]!==0)return!1;return!0}function Ec({data:e,width:t},n,i,o){let r=t*4|0,s=i*r+n*4+3|0;for(let a=i,l=s;a<o;a++,l=l+r|0)if(e[l]!==0)return!1;return!0}function Z0(e){let t=0,n=0,i=e.width,o=e.height;for(;t<o&&Pc(e,t,n,i);)t++;for(;o>t&&Pc(e,o-1,n,i);)o--;for(;n<i&&Ec(e,n,t,o);)n++;for(;i>n&&Ec(e,i-1,t,o);)i--;return{top:t,left:n,right:i,bottom:o}}function q0(e,t){t?"r"in t?(Z(e,0),Z(e,Math.round(t.r*257)),Z(e,Math.round(t.g*257)),Z(e,Math.round(t.b*257)),Z(e,0)):"fr"in t?(Z(e,0),Z(e,Math.round(t.fr*255*257)),Z(e,Math.round(t.fg*255*257)),Z(e,Math.round(t.fb*255*257)),Z(e,0)):"l"in t?(Z(e,7),Ht(e,Math.round(t.l*1e4)),Ht(e,Math.round(t.a<0?t.a*12800:t.a*12700)),Ht(e,Math.round(t.b<0?t.b*12800:t.b*12700)),Z(e,0)):"h"in t?(Z(e,1),Z(e,Math.round(t.h*65535)),Z(e,Math.round(t.s*65535)),Z(e,Math.round(t.b*65535)),Z(e,0)):"c"in t?(Z(e,2),Z(e,Math.round(t.c*257)),Z(e,Math.round(t.m*257)),Z(e,Math.round(t.y*257)),Z(e,Math.round(t.k*257))):(Z(e,8),Z(e,Math.round(t.k*1e4/255)),sn(e,6)):(Z(e,0),sn(e,8))}function K0(e,t){let n=t.bounds.w,i=t.bounds.h,o={width:n,height:i,data:t.data};ue(e,0);let r=e.offset;ue(e,1),ue(e,3),Ht(e,t.x),Ht(e,t.y),Lc(e,t.name+"\0"),yo(e,t.id,1),ue(e,3),ue(e,0);let s=e.offset,a=t.bounds.y,l=t.bounds.x,c=a+i,d=l+n;ue(e,a),ue(e,l),ue(e,c),ue(e,d),ue(e,24);for(let h=0;h<26;h++){let p=h<3?h:h===25?3:-1;if(p<0){ue(e,0);continue}let S=new Uint8Array(n*i+2*i+2*n+16),m=(0,ve.writeDataRLE)(S,o,[p],!1);ue(e,1),ue(e,m.length+4+16+2+1),ue(e,8),ue(e,a),ue(e,l),ue(e,c),ue(e,d),Z(e,8),de(e,1),fi(e,m)}let u=e.offset-s,f=e.offset-r;for(;f%4;)sn(e,1),f++;e.view.setUint32(s-4,u,!1),e.view.setUint32(r-4,f,!1)}});var $c=oe(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.readAbr=tp;var X=Gi(),xe=jt(),Y0=["off","fade","pen pressure","pen tilt","stylus wheel","initial direction","direction","initial rotation","rotation"],jc=["round point","round blunt","round curve","round angle","round fan","flat point","flat blunt","flat curve","flat angle","flat fan"],J0=["erodible point","erodible flat","erodible round","erodible square","erodible triangle","custom"],Q0={_:"brush",MixB:"mixer brush",SmTl:"smudge brush"};function Oe(e){return{control:Y0[e.bVTy],steps:e.fStp,jitter:(0,X.parsePercent)(e.jitter),minimum:(0,X.parsePercent)(e["Mnm "])}}function zc(e){switch(e._classID){case"computedBrush":return{type:"computed",size:(0,X.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,X.parseAngle)(e.Angl),roundness:(0,X.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,X.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,hardness:(0,X.parsePercent)(e.Hrdn)};case"sampledBrush":return{type:"sampled",size:(0,X.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,X.parseAngle)(e.Angl),roundness:(0,X.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,X.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,name:e["Nm "],sampledData:e.sampledData};case"dBrush":return{type:"dynamic",shape:jc[e["Shp "]],angle:(0,X.parseAngle)(e.Angl),size:(0,X.parseUnitsToNumber)(e.Dmtr,"Pixels"),density:(0,X.parsePercent)(e.Dnst),length:(0,X.parsePercent)(e.Lngt),clumping:(0,X.parsePercent)(e.clumping),thickness:(0,X.parsePercent)(e.thickness),stiffness:(0,X.parsePercent)(e.stiffness),physics:e.physics,spacing:(0,X.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY};case"dTips":return Object.assign(Object.assign({type:"tips",angle:(0,X.parseAngle)(e.Angl),size:(0,X.parseUnitsToNumber)(e.Dmtr,"Pixels"),shape:jc[e["Shp "]],physics:e.physics,spacing:(0,X.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY,tipsType:J0[e.dtipsType],tipsLengthRatio:(0,X.parsePercent)(e.dtipsLengthRatio),tipsHardness:(0,X.parsePercent)(e.dtipsHardness)},e.dtipsGridSize&&e.dtipsErodibleTipHeightMap?{tipsGridSize:e.dtipsGridSize,tipsErodibleTipHeightMap:ep(e.dtipsErodibleTipHeightMap)}:{}),{tipsAirbrushCutoffAngle:e.dtipsAirbrushCutoffAngle,tipsAirbrushGranularity:(0,X.parsePercent)(e.dtipsAirbrushGranularity),tipsAirbrushStreakiness:(0,X.parsePercent)(e.dtipsAirbrushStreakiness),tipsAirbrushSplatSize:(0,X.parsePercent)(e.dtipsAirbrushSplatSize),tipsAirbrushSplatCount:e.dtipsAirbrushSplatCount});default:throw new Error(`Unknown brush classId: ${e._classID}`)}}function ep(e){let t=[];for(let n=0;n<e.byteLength;n++)t.push(e[n]);return t}function tp(e,t={}){var n,i,o,r;let s=(0,xe.createReader)(e.buffer,e.byteOffset,e.byteLength),a=(0,xe.readInt16)(s),l=[],c=[],d=[];if(a===1||a===2)throw new Error(`Unsupported ABR version (${a})`);if(a===6||a===7||a===9||a===10){let u=(0,xe.readInt16)(s);if(u!==1&&u!==2)throw new Error("Unsupported ABR minor version");for(;s.offset<s.view.byteLength;){(0,xe.checkSignature)(s,"8BIM");let f=(0,xe.readSignature)(s),h=(0,xe.readUint32)(s),p=s.offset+h;switch(f){case"samp":{for(;s.offset<p;){let S=(0,xe.readUint32)(s);for(;S&3;)S++;let m=s.offset+S,g=(0,xe.readPascalString)(s,1);(0,xe.skipBytes)(s,u===1?10:264);let v=(0,xe.readInt32)(s),x=(0,xe.readInt32)(s),_=(0,xe.readInt32)(s)-v,I=(0,xe.readInt32)(s)-x;if(I<=0||_<=0)throw new Error("Invalid bounds");let P=(0,xe.readInt16)(s),k=(0,xe.readUint8)(s),E=new Uint8Array(I*_);if(P===8)if(k===0)E.set((0,xe.readBytes)(s,E.byteLength));else if(k===1)(0,xe.readDataRLE)(s,{width:I,height:_,data:E},I,_,P,1,[0],!1);else throw new Error("Invalid compression");else if(P===16)if(k===0)for(let O=0;O<E.byteLength;O++)E[O]=(0,xe.readUint16)(s)>>8;else throw k===1?new Error("not implemented (16bit RLE)"):new Error("Invalid compression");else throw new Error("Invalid depth");l.push({id:g,bounds:{x,y:v,w:I,h:_},alpha:E}),s.offset=m}break}case"desc":{let S=(0,X.readVersionAndDescriptor)(s,!0);for(let m of S.Brsh){let g={name:m["Nm "],shape:zc(m.Brsh),spacing:(0,X.parsePercent)(m.Spcn),wetEdges:m.Wtdg,noise:m.Nose,useBrushSize:m.useBrushSize};m.interpretation!=null&&(g.interpretation=m.interpretation),m.protectTexture!=null&&(g.protectTexture=m.protectTexture),m.useTipDynamics&&(g.shapeDynamics={tiltScale:(0,X.parsePercent)(m.tiltScale),sizeDynamics:Oe(m.szVr),angleDynamics:Oe(m.angleDynamics),roundnessDynamics:Oe(m.roundnessDynamics),flipX:m.flipX,flipY:m.flipY,brushProjection:m.brushProjection,minimumDiameter:(0,X.parsePercent)(m.minimumDiameter),minimumRoundness:(0,X.parsePercent)(m.minimumRoundness)}),m.useScatter&&(g.scatter={count:m["Cnt "],bothAxes:m.bothAxes,countDynamics:Oe(m.countDynamics),scatterDynamics:Oe(m.scatterDynamics)}),m.useTexture&&m.Txtr&&(g.texture={id:m.Txtr.Idnt,name:m.Txtr["Nm "],blendMode:X.BlnM.decode(m.textureBlendMode),depth:(0,X.parsePercent)(m.textureDepth),depthMinimum:(0,X.parsePercent)(m.minimumDepth),depthDynamics:Oe(m.textureDepthDynamics),scale:(0,X.parsePercent)(m.textureScale),invert:m.InvT,brightness:m.textureBrightness,contrast:m.textureContrast,textureEachTip:!!m.TxtC});let v=m.dualBrush;v&&v.useDualBrush&&(g.dualBrush={flip:v.Flip,shape:zc(v.Brsh),blendMode:X.BlnM.decode(v.BlnM),useScatter:v.useScatter,spacing:(0,X.parsePercent)(v.Spcn),count:v["Cnt "],bothAxes:v.bothAxes,countDynamics:Oe(v.countDynamics),scatterDynamics:Oe(v.scatterDynamics)}),m.useColorDynamics&&(g.colorDynamics={foregroundBackground:Oe(m.clVr),hue:(0,X.parsePercent)(m["H "]),saturation:(0,X.parsePercent)(m.Strt),brightness:(0,X.parsePercent)(m.Brgh),purity:(0,X.parsePercent)(m.purity),perTip:m.colorDynamicsPerTip}),m.usePaintDynamics&&(g.transfer={flowDynamics:Oe(m.prVr),opacityDynamics:Oe(m.opVr),wetnessDynamics:Oe(m.wtVr),mixDynamics:Oe(m.mxVr)}),m.useBrushPose&&(g.brushPose={overrideAngle:m.overridePoseAngle,overrideTiltX:m.overridePoseTiltX,overrideTiltY:m.overridePoseTiltY,overridePressure:m.overridePosePressure,pressure:(0,X.parsePercent)(m.brushPosePressure),tiltX:m.brushPoseTiltX,tiltY:m.brushPoseTiltY,angle:m.brushPoseAngle});let x=m.toolOptions;x&&(g.toolOptions={type:Q0[x._classID]||"brush",brushPreset:x.brushPreset,flow:(n=x.flow)!==null&&n!==void 0?n:100,smooth:(i=x.Smoo)!==null&&i!==void 0?i:0,mode:X.BlnM.decode(x["Md "]||"BlnM.Nrml"),opacity:(o=x.Opct)!==null&&o!==void 0?o:100,smoothing:!!x.smoothing,smoothingValue:x.smoothingValue||0,smoothingRadiusMode:!!x.smoothingRadiusMode,smoothingCatchup:!!x.smoothingCatchup,smoothingCatchupAtEnd:!!x.smoothingCatchupAtEnd,smoothingZoomCompensation:!!x.smoothingZoomCompensation,pressureSmoothing:!!x.pressureSmoothing,usePressureOverridesSize:!!x.usePressureOverridesSize,usePressureOverridesOpacity:!!x.usePressureOverridesOpacity,useLegacy:!!x.useLegacy},x.prVr&&(g.toolOptions.flowDynamics=Oe(x.prVr)),x.opVr&&(g.toolOptions.opacityDynamics=Oe(x.opVr)),x.szVr&&(g.toolOptions.sizeDynamics=Oe(x.szVr)),"wetness"in x&&(g.toolOptions.wetness=x.wetness),"dryness"in x&&(g.toolOptions.dryness=x.dryness),"mix"in x&&(g.toolOptions.mix=x.mix),"autoFill"in x&&(g.toolOptions.autoFill=x.autoFill),"autoClean"in x&&(g.toolOptions.autoClean=x.autoClean),"loadSolidColorOnly"in x&&(g.toolOptions.loadSolidColorOnly=x.loadSolidColorOnly),"sampleAllLayers"in x&&(g.toolOptions.sampleAllLayers=x.sampleAllLayers),"SmdF"in x&&(g.toolOptions.smudgeFingerPainting=x.SmdF),"SmdS"in x&&(g.toolOptions.smudgeSampleAllLayers=x.SmdS),"Prs "in x&&(g.toolOptions.strength=x["Prs "])),c.push(g)}break}case"patt":{for(;s.offset<p;)d.push((0,xe.readPattern)(s));s.offset=p;break}case"phry":{let S=(0,X.readVersionAndDescriptor)(s);t.logMissingFeatures&&!((r=S.hierarchy)===null||r===void 0)&&r.length;break}default:throw new Error(`Invalid brush type: ${f}`)}for(;h%4;)s.offset++,h++}}else throw new Error(`Unsupported ABR version (${a})`);return{samples:l,patterns:d,brushes:c}}});var Nc=oe(Jr=>{"use strict";Object.defineProperty(Jr,"__esModule",{value:!0});Jr.readCsh=ip;var np=oo(),Qe=jt();function ip(e){let t=(0,Qe.createReader)(e.buffer,e.byteOffset,e.byteLength),n={shapes:[]};if((0,Qe.checkSignature)(t,"cush"),(0,Qe.readUint32)(t)!==2)throw new Error("Invalid version");let i=(0,Qe.readUint32)(t);for(let o=0;o<i;o++){let r=(0,Qe.readUnicodeString)(t);for(;t.offset%4;)t.offset++;if((0,Qe.readUint32)(t)!==1)throw new Error("Invalid shape version");let s=(0,Qe.readUint32)(t),a=t.offset+s,l=(0,Qe.readPascalString)(t,1),c=(0,Qe.readUint32)(t),d=(0,Qe.readUint32)(t),u=(0,Qe.readUint32)(t),h=(0,Qe.readUint32)(t)-d,p=u-c,S={paths:[]};(0,np.readVectorMask)(t,S,h,p,a-t.offset),n.shapes.push(Object.assign({name:r,id:l,width:h,height:p},S)),t.offset=a}return n}});var Zc=oe(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.Compression=et.ChannelID=et.LayerCompCapturedInfo=et.SectionDividerType=et.ColorMode=void 0;var Vc;(function(e){e[e.Bitmap=0]="Bitmap",e[e.Grayscale=1]="Grayscale",e[e.Indexed=2]="Indexed",e[e.RGB=3]="RGB",e[e.CMYK=4]="CMYK",e[e.Multichannel=7]="Multichannel",e[e.Duotone=8]="Duotone",e[e.Lab=9]="Lab"})(Vc||(et.ColorMode=Vc={}));var Gc;(function(e){e[e.Other=0]="Other",e[e.OpenFolder=1]="OpenFolder",e[e.ClosedFolder=2]="ClosedFolder",e[e.BoundingSectionDivider=3]="BoundingSectionDivider"})(Gc||(et.SectionDividerType=Gc={}));var Hc;(function(e){e[e.None=0]="None",e[e.Visibility=1]="Visibility",e[e.Position=2]="Position",e[e.Appearance=4]="Appearance"})(Hc||(et.LayerCompCapturedInfo=Hc={}));var Wc;(function(e){e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.Transparency=-1]="Transparency",e[e.UserMask=-2]="UserMask",e[e.RealUserMask=-3]="RealUserMask"})(Wc||(et.ChannelID=Wc={}));var Xc;(function(e){e[e.RawData=0]="RawData",e[e.RleCompressed=1]="RleCompressed",e[e.ZipWithoutPrediction=2]="ZipWithoutPrediction",e[e.ZipWithPrediction=3]="ZipWithPrediction"})(Xc||(et.Compression=Xc={}))});var Kc=oe(ee=>{"use strict";var op=ee&&ee.__createBinding||(Object.create?(function(e,t,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,o)}):(function(e,t,n,i){i===void 0&&(i=n),e[i]=t[n]})),Qr=ee&&ee.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&op(t,e,n)};Object.defineProperty(ee,"__esModule",{value:!0});ee.getCompositeCanvas=ee.getCompositeImageData=ee.getLayerRealMaskCanvas=ee.getLayerMaskCanvas=ee.getLayerCanvas=ee.getLayerRealMaskImageData=ee.getLayerMaskImageData=ee.getLayerImageData=ee.decodeLayerPixels=ee.byteArrayToBase64=ee.initializeCanvas=void 0;ee.readPsd=ap;ee.writePsd=lp;ee.writePsdUint8Array=qc;ee.writePsdBuffer=cp;var Bn=Dn(),tt=jt();Object.defineProperty(ee,"decodeLayerPixels",{enumerable:!0,get:function(){return tt.decodeLayerPixels}});Object.defineProperty(ee,"getLayerImageData",{enumerable:!0,get:function(){return tt.getLayerImageData}});Object.defineProperty(ee,"getLayerMaskImageData",{enumerable:!0,get:function(){return tt.getLayerMaskImageData}});Object.defineProperty(ee,"getLayerRealMaskImageData",{enumerable:!0,get:function(){return tt.getLayerRealMaskImageData}});Object.defineProperty(ee,"getLayerCanvas",{enumerable:!0,get:function(){return tt.getLayerCanvas}});Object.defineProperty(ee,"getLayerMaskCanvas",{enumerable:!0,get:function(){return tt.getLayerMaskCanvas}});Object.defineProperty(ee,"getLayerRealMaskCanvas",{enumerable:!0,get:function(){return tt.getLayerRealMaskCanvas}});Object.defineProperty(ee,"getCompositeImageData",{enumerable:!0,get:function(){return tt.getCompositeImageData}});Object.defineProperty(ee,"getCompositeCanvas",{enumerable:!0,get:function(){return tt.getCompositeCanvas}});var rp=ji();Qr($c(),ee);Qr(Nc(),ee);var sp=Tt();Object.defineProperty(ee,"initializeCanvas",{enumerable:!0,get:function(){return sp.initializeCanvas}});Qr(Zc(),ee);ee.byteArrayToBase64=rp.fromByteArray;function ap(e,t){let n="buffer"in e?(0,tt.createReader)(e.buffer,e.byteOffset,e.byteLength):(0,tt.createReader)(e);return(0,tt.readPsd)(n,t)}function lp(e,t){let n=(0,Bn.createWriter)();return(0,Bn.writePsd)(n,e,t),(0,Bn.getWriterBuffer)(n)}function qc(e,t){let n=(0,Bn.createWriter)();return(0,Bn.writePsd)(n,e,t),(0,Bn.getWriterBufferNoCopy)(n)}function cp(e,t){if(typeof Buffer>"u")throw new Error("Buffer not supported on this platform");return Buffer.from(qc(e,t))}});var vo=_d(Kc(),1);var So=class{view;offset=0;constructor(t){this.view=new DataView(t)}get length(){return this.view.byteLength}ensure(t,n=this.length,i="Adobe resource"){if(!Number.isSafeInteger(t)||t<0||this.offset+t>n||n>this.length)throw new Error(`${i} is truncated or has an invalid length.`)}u8(t,n){return this.ensure(1,t,n),this.view.getUint8(this.offset++)}i16(t,n){this.ensure(2,t,n);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u16(t,n){this.ensure(2,t,n);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i32(t,n){this.ensure(4,t,n);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}u32(t,n){this.ensure(4,t,n);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32le(t,n){this.ensure(4,t,n);let i=this.view.getInt32(this.offset,!0);return this.offset+=4,i}ascii(t,n,i){this.ensure(t,n,i);let o="";for(let r=0;r<t;r+=1)o+=String.fromCharCode(this.view.getUint8(this.offset++));return o}skip(t,n,i){this.ensure(t,n,i),this.offset+=t}},es=e=>{let t=e+3&-4;if(!Number.isSafeInteger(t)||t<e)throw new Error("Adobe resource alignment overflowed.");return t},St=(e,t,n)=>{let i=e*t;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${n} overflows the safe integer range.`);return i},Yc=(e,t,n)=>{if(e.byteLength>t.maxFileBytes)throw new Error(`${n.toUpperCase()} source exceeds the ${t.maxFileBytes}-byte safety limit.`)},cn=(e,t,n)=>{if(!Number.isSafeInteger(e)||e<0||e>t.maxResourceItems)throw new Error(`${n} exceeds the ${t.maxResourceItems}-item safety limit.`)},Jc=(e,t,n,i)=>{cn(t,n,i),e.descriptorItems+=t;let o=Math.min(1e6,n.maxResourceItems*64);if(e.descriptorItems>o)throw new Error(`Adobe descriptor complexity exceeds the ${o}-record safety limit.`)},Qc=(e,t,n,i,o)=>{if(t<=0||t>i.maxResourcePreviewPixels)throw new Error(`${o} exceeds the ${i.maxResourcePreviewPixels}-pixel preview limit.`);if(e.previewPixels+=t,e.decodedBytes+=n,e.previewPixels>i.maxResourcePreviewPixels)throw new Error(`Adobe resource previews exceed the ${i.maxResourcePreviewPixels}-pixel collection limit.`);if(e.decodedBytes>i.maxDecodedBytes)throw new Error(`Adobe resource decoding exceeds the ${i.maxDecodedBytes}-byte safety limit.`)},Un=(e,t,n,i)=>{let o=e.u32(t,i);if(o>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(St(o,2,`${i} length`),t,i)},ts=(e,t,n,i)=>{let o=e.u8(t,i);if(o>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(o,t,i)},Pt=(e,t,n,i)=>{let o=e.i32(t,i);if(o<0)throw new Error(`${i} has a negative string length.`);let r=o||4;if(r>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-character identifier limit.`);e.skip(r,t,i)},ln=(e,t,n,i)=>{Un(e,t,n,`${i} name`),Pt(e,t,n,`${i} class id`)},wo=(e,t,n,i,o)=>{let r=e.i32(t,o);if(r<0)throw new Error(`${o} has a negative item count.`);return Jc(n,r,i,o),r},ed=(e,t,n,i,o,r)=>{if(i>r.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${r.maxNestingDepth}-level safety limit.`);switch(n){case"obj ":{let s=wo(e,t,o,r,"Adobe descriptor reference");for(let a=0;a<s;a+=1){let l=e.ascii(4,t,"Adobe descriptor reference type");if(l==="prop")ln(e,t,r,"Adobe property reference"),Pt(e,t,r,"Adobe property key");else if(l==="Clss")ln(e,t,r,"Adobe class reference");else if(l==="Enmr")ln(e,t,r,"Adobe enum reference"),Pt(e,t,r,"Adobe enum type"),Pt(e,t,r,"Adobe enum value");else if(l==="rele")ln(e,t,r,"Adobe offset reference"),e.skip(4,t,"Adobe offset reference");else if(l==="Idnt"||l==="indx")e.skip(4,t,"Adobe integer reference");else if(l==="name")ln(e,t,r,"Adobe name reference"),Un(e,t,r,"Adobe reference name");else throw new Error(`Unsupported Adobe descriptor reference type ${JSON.stringify(l)}.`)}return}case"Objc":case"GlbO":td(e,t,i+1,o,r);return;case"VlLs":{let s=wo(e,t,o,r,"Adobe descriptor list");for(let a=0;a<s;a+=1){let l=e.ascii(4,t,"Adobe descriptor list type");ed(e,t,l,i+1,o,r)}return}case"doub":e.skip(8,t,"Adobe double");return;case"UntF":e.skip(12,t,"Adobe unit double");return;case"UnFl":e.skip(8,t,"Adobe unit float");return;case"TEXT":Un(e,t,r,"Adobe descriptor text");return;case"enum":Pt(e,t,r,"Adobe enum type"),Pt(e,t,r,"Adobe enum value");return;case"long":e.skip(4,t,"Adobe integer");return;case"comp":e.skip(8,t,"Adobe large integer");return;case"bool":e.skip(1,t,"Adobe boolean");return;case"type":case"GlbC":ln(e,t,r,"Adobe descriptor class");return;case"alis":case"tdta":{let s=e.i32(t,"Adobe descriptor data length");if(s<0||s>r.maxDecodedBytes)throw new Error(`Adobe descriptor data exceeds the ${r.maxDecodedBytes}-byte safety limit.`);e.skip(s,t,"Adobe descriptor data");return}case"ObAr":{e.skip(4,t,"Adobe object-array version"),Un(e,t,r,"Adobe object-array name"),Pt(e,t,r,"Adobe object-array class");let s=wo(e,t,o,r,"Adobe object array");for(let a=0;a<s;a+=1){Pt(e,t,r,"Adobe object-array item type");let l=e.ascii(4,t,"Adobe object-array value type");if(l!=="UnFl")throw new Error(`Unsupported Adobe object-array value type ${JSON.stringify(l)}.`);e.skip(4,t,"Adobe object-array units");let c=wo(e,t,o,r,"Adobe object-array values");e.skip(St(c,8,"Adobe object-array values"),t,"Adobe object-array values")}return}case"Pth ":{let s=e.i32(t,"Adobe path length");if(s<0||s>r.maxDecodedBytes)throw new Error("Adobe descriptor path length is invalid.");e.skip(4,t,"Adobe path signature");let a=e.i32le(t,"Adobe path size"),l=e.i32le(t,"Adobe path character count");if(a<0||l<0||l>r.maxResourceNameCodeUnits)throw new Error("Adobe descriptor path exceeds its bounded string limits.");e.skip(St(l,2,"Adobe path characters"),t,"Adobe descriptor path");return}default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(n)}.`)}},td=(e,t,n,i,o)=>{if(n>o.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${o.maxNestingDepth}-level safety limit.`);ln(e,t,o,"Adobe descriptor");let r=e.u32(t,"Adobe descriptor item count");Jc(i,r,o,"Adobe descriptor item count");for(let s=0;s<r;s+=1){Pt(e,t,o,"Adobe descriptor key");let a=e.ascii(4,t,"Adobe descriptor value type");ed(e,t,a,n+1,i,o)}},dp=(e,t,n,i)=>{let o=e.u32(t,"Adobe descriptor version");if(o!==16)throw new Error(`Unsupported Adobe descriptor version ${o}.`);td(e,t,0,n,i)},nd=(e,t,n,i,o)=>{let r=St(i,2,`${o} row table`);e.ensure(r,t,o);let s=Array.from({length:i},()=>e.u16(t,`${o} row length`));for(let a=0;a<i;a+=1){let l=e.offset+s[a];if(l>t)throw new Error(`${o} compressed row ${a} is truncated.`);let c=0;for(;e.offset<l;){let d=e.u8(l,`${o} PackBits header`);if(d<=127){let u=d+1;e.skip(u,l,`${o} PackBits literal`),c+=u}else d>=129&&(e.skip(1,l,`${o} PackBits repeat value`),c+=257-d);if(c>n)throw new Error(`${o} PackBits row ${a} expands beyond its declared width.`)}if(c!==n)throw new Error(`${o} PackBits row ${a} does not expand to its declared width.`)}},fp=(e,t,n,i,o)=>{let r=0;for(;e.offset<t;){cn(++r,o,"ABR sample count");let s=e.u32(t,"ABR sample length"),a=e.offset,l=a+s,c=a+es(s);if(l>t||c>t)throw new Error("ABR sample record is truncated.");ts(e,l,o,"ABR sample id"),e.skip(n===1?10:264,l,"ABR sample header");let d=e.i32(l,"ABR sample top"),u=e.i32(l,"ABR sample left"),f=e.i32(l,"ABR sample bottom"),p=e.i32(l,"ABR sample right")-u,S=f-d;if(p<=0||S<=0||p>o.maxCanvasDimension||S>o.maxCanvasDimension)throw new Error(`ABR sample dimensions exceed the ${o.maxCanvasDimension}-pixel side limit.`);let m=St(p,S,"ABR sample pixels"),g=e.i16(l,"ABR sample depth"),v=e.u8(l,"ABR sample compression");if(g!==8&&g!==16)throw new Error(`Unsupported ABR sample depth ${g}.`);if(v!==0&&v!==1)throw new Error(`Unsupported ABR sample compression ${v}.`);if(g===16&&v===1)throw new Error("ABR 16-bit RLE samples are not supported by the decoding engine.");if(Qc(i,m,m,o,"ABR sample"),v===0?e.skip(St(m,g/8,"ABR raw sample bytes"),l,"ABR raw sample"):nd(e,l,p,S,"ABR sample"),e.offset>l)throw new Error("ABR sample payload exceeded its declared record boundary.");e.offset=l,e.offset=c}return r},up=(e,t,n,i)=>{let o=e.u32(t,"ABR pattern length"),s=e.offset+es(o);if(s>t)throw new Error("ABR pattern record is truncated.");if(e.u32(s,"ABR pattern version")!==1)throw new Error("Unsupported ABR pattern version.");let a=e.u32(s,"ABR pattern color mode");if(a!==1&&a!==2&&a!==3)throw new Error(`Unsupported ABR pattern color mode ${a}.`);if(e.skip(4,s,"ABR pattern origin"),Un(e,s,i,"ABR pattern name"),ts(e,s,i,"ABR pattern id"),a===2&&e.skip(772,s,"ABR indexed palette"),e.u32(s,"ABR pattern VMAL version")!==3)throw new Error("Unsupported ABR pattern VMAL version.");e.u32(s,"ABR pattern VMAL length");let l=e.u32(s,"ABR pattern top"),c=e.u32(s,"ABR pattern left"),d=e.u32(s,"ABR pattern bottom"),u=e.u32(s,"ABR pattern right"),f=e.u32(s,"ABR pattern channel count");if(d<=l||u<=c||f>16)throw new Error("ABR pattern bounds or channel count is invalid.");let h=u-c,p=d-l;if(h>i.maxCanvasDimension||p>i.maxCanvasDimension)throw new Error(`ABR pattern dimensions exceed the ${i.maxCanvasDimension}-pixel side limit.`);let S=St(h,p,"ABR pattern pixels");Qc(n,S,St(S,4,"ABR pattern RGBA bytes"),i,"ABR pattern");for(let m=0;m<f+2;m+=1){if(!e.u32(s,"ABR pattern channel presence"))continue;let v=e.u32(s,"ABR pattern channel length");if(v<23)throw new Error("ABR pattern channel length is invalid.");let x=e.offset+v;if(x>s)throw new Error("ABR pattern channel is truncated.");let _=e.u32(x,"ABR pattern channel depth"),I=e.u32(x,"ABR pattern channel top"),P=e.u32(x,"ABR pattern channel left"),k=e.u32(x,"ABR pattern channel bottom"),E=e.u32(x,"ABR pattern channel right"),O=e.u16(x,"ABR pattern channel depth duplicate"),U=e.u8(x,"ABR pattern channel compression");if(_!==8||O!==8||U!==0&&U!==1)throw new Error("ABR pattern channel uses an unsupported depth or compression mode.");if(k<I||E<P||I<l||P<c||k>d||E>u)throw new Error("ABR pattern channel bounds are invalid.");let M=E-P,le=k-I,me=St(M,le,"ABR pattern channel pixels");if(U===0){if(x-e.offset!==me)throw new Error("ABR raw pattern channel length does not match its dimensions.");e.skip(me,x,"ABR raw pattern channel")}else if(nd(e,x,M,le,"ABR pattern channel"),e.offset!==x)throw new Error("ABR RLE pattern channel has trailing bytes.")}e.offset=s},id=(e,t)=>{Yc(e,t,"ABR");let n=new So(e),i=n.i16(void 0,"ABR version");if(i!==6&&i!==7&&i!==9&&i!==10)throw new Error(`Unsupported ABR version ${i}; the browser engine supports modern ABR versions 6, 7, 9, and 10.`);let o=n.i16(void 0,"ABR minor version");if(o!==1&&o!==2)throw new Error(`Unsupported ABR minor version ${o}.`);let r={descriptorItems:0,previewPixels:0,decodedBytes:0},s=0,a=0,l=0;for(;n.offset<n.length;){if(cn(++s,t,"ABR section count"),n.ascii(4,void 0,"ABR section signature")!=="8BIM")throw new Error("Invalid ABR section signature.");let c=n.ascii(4,void 0,"ABR section type"),d=n.u32(void 0,"ABR section length"),u=n.offset,f=u+d,h=u+es(d);if(f>n.length||h>n.length)throw new Error("ABR section is truncated.");if(c==="samp")a+=fp(n,f,o,r,t);else if(c==="desc"||c==="phry"){if(dp(n,f,r,t),n.offset!==f)throw new Error(`ABR ${c} descriptor does not consume its declared section.`)}else if(c==="patt")for(;n.offset<f;)cn(++l,t,"ABR pattern count"),up(n,f,r,t);else throw new Error(`Unsupported ABR section type ${JSON.stringify(c)}.`);if(n.offset>f)throw new Error(`ABR ${c} section exceeded its declared boundary.`);n.offset=h}return cn(a+l,t,"ABR decoded resource count"),{format:"abr",majorVersion:i,minorVersion:o,sections:s,samples:a,patterns:l,previewPixels:r.previewPixels,decodedBytes:r.decodedBytes}},od=(e,t)=>{Yc(e,t,"CSH");let n=new So(e);if(n.ascii(4,void 0,"CSH signature")!=="cush")throw new Error("Invalid CSH signature.");let i=n.u32(void 0,"CSH version");if(i!==2)throw new Error(`Unsupported CSH version ${i}; version 2 is required.`);let o=n.u32(void 0,"CSH shape count");cn(o,t,"CSH shape count");let r=0,s=0,a=Math.min(1e6,t.maxResourceItems*64);for(let l=0;l<o;l+=1){for(Un(n,n.length,t,`CSH shape ${l} name`);n.offset%4;)n.skip(1,n.length,"CSH name padding");if(n.u32(void 0,"CSH shape version")!==1)throw new Error("Unsupported CSH shape record version.");let c=n.u32(void 0,"CSH shape record length"),d=n.offset+c;if(d>n.length)throw new Error("CSH shape record is truncated.");ts(n,d,t,`CSH shape ${l} id`);let u=n.u32(d,"CSH shape top"),f=n.u32(d,"CSH shape left"),h=n.u32(d,"CSH shape bottom"),p=n.u32(d,"CSH shape right");if(h<=u||p<=f)throw new Error("CSH shape bounds are invalid.");let S=p-f,m=h-u;if(S>t.maxCanvasDimension||m>t.maxCanvasDimension)throw new Error(`CSH shape dimensions exceed the ${t.maxCanvasDimension}-pixel side limit.`);let g=St(S,m,"CSH shape preview pixels");if(s+=g,s>t.maxResourcePreviewPixels)throw new Error(`CSH previews exceed the ${t.maxResourcePreviewPixels}-pixel collection limit.`);if((d-n.offset)%26!==0)throw new Error("CSH vector record section is not aligned to 26-byte path records.");let v=0,x=0,_=!1;for(;n.offset<d;){if(r+=1,r>a)throw new Error(`CSH path complexity exceeds the ${a}-record safety limit.`);let I=n.u16(d,"CSH vector selector");if(I===0||I===3){if(_&&x!==v)throw new Error("CSH path knot count does not match its declared count.");v=n.u16(d,"CSH path knot count"),cn(v,t,"CSH path knot count");let P=n.i16(d,"CSH path boolean operation");if(P<-1||P>3)throw new Error("CSH path boolean operation is invalid.");n.skip(20,d,"CSH path header"),x=0,_=!0}else if(I===1||I===2||I===4||I===5){if(!_)throw new Error("CSH knot appears before a path header.");if(n.skip(24,d,"CSH Bezier knot"),x+=1,x>v)throw new Error("CSH path contains more knots than declared.")}else if(I===6||I===7||I===8)n.skip(24,d,"CSH vector metadata record");else throw new Error(`Unsupported CSH vector selector ${I}.`)}if(_&&x!==v)throw new Error("CSH path knot count does not match its declared count.")}if(n.offset!==n.length)throw new Error("CSH file has trailing bytes outside its declared shapes.");return{format:"csh",version:2,shapes:o,pathRecords:r,previewPixels:s}};var Et=(e,t)=>{if(!Number.isFinite(e))throw new Error(`${t} is not finite.`);return e},dn=(e,t,n)=>{if(e.length>t.maxResourceNameCodeUnits)throw new Error(`${n} exceeds the ${t.maxResourceNameCodeUnits}-code-unit name limit.`);return e},hp=(e,t,n)=>{let i=Et(e.size,`${n} size`),o=Et(e.angle,`${n} angle`);if(i<0||i>t.maxCanvasDimension)throw new Error(`${n} size exceeds the ${t.maxCanvasDimension}-pixel side limit.`);let r={type:e.type,size:i,angle:o};return"roundness"in e&&(r.roundness=Et(e.roundness,`${n} roundness`)),"hardness"in e&&(r.hardness=Et(e.hardness,`${n} hardness`)),"spacing"in e&&(r.spacing=Et(e.spacing,`${n} spacing`)),e.type==="sampled"&&(r.sampledDataId=dn(e.sampledData,t,`${n} sampled-data id`)),r},pp=(e,t)=>({name:dn(e.name,t,"ABR brush name"),shape:hp(e.shape,t,`ABR brush ${JSON.stringify(e.name)}`),hasDynamics:!!(e.shapeDynamics||e.scatter||e.colorDynamics||e.transfer||e.brushPose),hasTexture:!!e.texture,hasDualBrush:!!e.dualBrush,...e.toolOptions?.type?{toolType:e.toolOptions.type}:{}}),mp=(e,t)=>{let n=id(e,t),i=(0,vo.readAbr)(new Uint8Array(e),{logMissingFeatures:!1});if(i.brushes.length+i.samples.length+i.patterns.length>t.maxResourceItems)throw new Error(`ABR decoded resources exceed the ${t.maxResourceItems}-item safety limit.`);let r=0,s=0,a=i.samples.map((c,d)=>{let{w:u,h:f,x:h,y:p}=c.bounds,S=u*f;if(!Number.isSafeInteger(S)||S<=0||c.alpha.byteLength!==S)throw new Error(`ABR sample ${d} returned inconsistent decoded pixels.`);return s+=S,r+=c.alpha.byteLength,{id:dn(c.id,t,`ABR sample ${d} id`),x:Et(h,`ABR sample ${d} x`),y:Et(p,`ABR sample ${d} y`),width:u,height:f,alpha:c.alpha}}),l=i.patterns.map((c,d)=>{let{w:u,h:f,x:h,y:p}=c.bounds,S=u*f;if(!Number.isSafeInteger(S)||S<=0||c.data.byteLength!==S*4)throw new Error(`ABR pattern ${d} returned inconsistent decoded pixels.`);return s+=S,r+=c.data.byteLength,{id:dn(c.id,t,`ABR pattern ${d} id`),name:dn(c.name,t,`ABR pattern ${d} name`),x:Et(h,`ABR pattern ${d} x`),y:Et(p,`ABR pattern ${d} y`),width:u,height:f,rgba:c.data}});if(s!==n.previewPixels||s>t.maxResourcePreviewPixels)throw new Error("ABR decoded preview pixels do not match the bounded preflight result.");if(r!==n.decodedBytes||r>t.maxDecodedBytes)throw new Error("ABR decoded byte count does not match the bounded preflight result.");return{format:"abr",version:`${n.majorVersion}.${n.minorVersion}`,engine:"ag-psd",fidelity:"decoded-tip-and-metadata-preview",brushes:i.brushes.map(c=>pp(c,t)),samples:a,patterns:l,limitations:["The preview shows decoded tip alpha, embedded pattern pixels, and preset metadata; it does not simulate a painted stroke.","Legacy ABR versions 1 and 2 and 16-bit RLE brush samples are rejected because the decoding engine does not implement them."]}},ze=e=>{let t=Math.abs(e)<1e-9?0:e;return Number(t.toFixed(4)).toString()},gp=(e,t)=>{if(!e.knots.length)return{d:"",fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}};let n=e.knots.map((r,s)=>{if(r.points.length!==6||r.points.some(a=>!Number.isFinite(a)))throw new Error(`${t} knot ${s} has invalid Bezier coordinates.`);return r.points}),i=n[0],o=`M ${ze(i[2])} ${ze(i[3])}`;for(let r=1;r<n.length;r+=1){let s=n[r-1],a=n[r];o+=` C ${ze(s[4])} ${ze(s[5])} ${ze(a[0])} ${ze(a[1])} ${ze(a[2])} ${ze(a[3])}`}if(!e.open){let r=n.at(-1);o+=` C ${ze(r[4])} ${ze(r[5])} ${ze(i[0])} ${ze(i[1])} ${ze(i[2])} ${ze(i[3])} Z`}return{d:o,fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}}},bp=(e,t)=>{let n=od(e,t),i=(0,vo.readCsh)(new Uint8Array(e));if(i.shapes.length!==n.shapes)throw new Error("CSH decoded shape count does not match its bounded preflight result.");let o=0,r=0,s=Math.min(1e6,t.maxResourceItems*64);return{format:"csh",version:"2",engine:"ag-psd",fidelity:"vector-path-preview",shapes:i.shapes.map((l,c)=>{if(!Number.isSafeInteger(l.width)||!Number.isSafeInteger(l.height)||l.width<=0||l.height<=0)throw new Error(`CSH shape ${c} has invalid dimensions.`);o+=l.paths.length;let d=l.paths.map((u,f)=>(r+=u.knots.length,gp(u,`CSH shape ${c} path ${f}`)));if(o+r>s)throw new Error(`CSH decoded path complexity exceeds the ${s}-record safety limit.`);return{id:dn(l.id,t,`CSH shape ${c} id`),name:dn(l.name,t,`CSH shape ${c} name`),width:l.width,height:l.height,paths:d,hasUnsupportedBooleanComposition:l.paths.some(u=>u.operation&&u.operation!=="combine")}}),limitations:["Bezier geometry is preserved, but Photoshop exclude/subtract/intersect path operations are exposed as metadata rather than rasterized with Photoshop composition semantics.","The preview does not include Photoshop tool presets, fills, strokes, or effects because CSH stores custom-shape paths rather than a styled document."]}},rd=(e,t,n)=>t==="abr"?mp(e,n):bp(e,n);var yp=(e,t,n)=>{let i=e*t;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${n} exceeds the safe integer range.`);return i},wp=(e,t)=>{if(!Number.isFinite(e))throw new Error(`${t} is not finite.`);return e},Rn=class{bytes;view;offset=0;constructor(t){this.bytes=t instanceof Uint8Array?t:new Uint8Array(t),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength)}get length(){return this.bytes.byteLength}get remaining(){return this.length-this.offset}ensure(t,n=this.length,i="Adobe binary data"){if(!Number.isSafeInteger(t)||t<0||this.offset>n||t>n-this.offset)throw new Error(`${i} is truncated.`)}u8(t=this.length,n){return this.ensure(1,t,n),this.view.getUint8(this.offset++)}u16(t=this.length,n){this.ensure(2,t,n);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i16(t=this.length,n){this.ensure(2,t,n);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u32(t=this.length,n){this.ensure(4,t,n);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32(t=this.length,n){this.ensure(4,t,n);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}i64(t=this.length,n){this.ensure(8,t,n);let i=this.view.getBigInt64(this.offset,!1);return this.offset+=8,i}f64(t=this.length,n){this.ensure(8,t,n);let i=this.view.getFloat64(this.offset,!1);return this.offset+=8,wp(i,n||"Adobe double")}ascii(t,n=this.length,i="Adobe ASCII data"){this.ensure(t,n,i);let o="";for(let r=0;r<t;r+=1)o+=String.fromCharCode(this.bytes[this.offset+r]);return this.offset+=t,o}slice(t,n=this.length,i="Adobe binary data"){this.ensure(t,n,i);let o=this.bytes.subarray(this.offset,this.offset+t);return this.offset+=t,o}skip(t,n=this.length,i="Adobe binary data"){this.ensure(t,n,i),this.offset+=t}},hi=(e,t,n,i)=>{let o=e.u32(t,`${i} length`);if(o>n.maxResourceNameCodeUnits+1)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-code-unit safety limit.`);let r=e.slice(yp(o,2,`${i} bytes`),t,i),s="";for(let a=0;a<o;a+=1){let l=r[a*2]<<8|r[a*2+1];if(!(l===0&&a===o-1))if(l>=55296&&l<=56319){if(a+1>=o)throw new Error(`${i} ends with an unpaired UTF-16 surrogate.`);let c=r[(a+1)*2]<<8|r[(a+1)*2+1];if(c<56320||c>57343)throw new Error(`${i} contains an invalid UTF-16 surrogate pair.`);s+=String.fromCodePoint(65536+(l-55296<<10)+(c-56320)),a+=1}else{if(l>=56320&&l<=57343)throw new Error(`${i} contains an unpaired UTF-16 surrogate.`);s+=String.fromCharCode(l)}}if(s.length>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-code-unit safety limit.`);return s},Wt=(e,t,n,i)=>{let o=e.u32(t,`${i} length`),r=o===0?4:o;if(r===0||r>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-byte safety limit.`);return e.ascii(r,t,i)},ui=(e,t,n)=>{if(!Number.isSafeInteger(t)||t<0||t>e.maximum-e.values)throw new Error(`${n} exceeds the ${e.maximum}-value descriptor safety limit.`);e.values+=t},sd=(e,t,n,i)=>({name:hi(e,t,n,`${i} name`),classId:Wt(e,t,n,`${i} id`)}),Sp=(e,t,n,i)=>{let o=e.u32(t,"Adobe reference count");ui(i,o,"Adobe reference count");let r=[];for(let s=0;s<o;s+=1){let a=e.ascii(4,t,"Adobe reference form"),{name:l,classId:c}=sd(e,t,n,"Adobe reference class"),d={form:a,className:l,classId:c};if(a==="prop")d.property=Wt(e,t,n,"Adobe reference property");else if(a==="Enmr")d.enumType=Wt(e,t,n,"Adobe reference enum type"),d.enumValue=Wt(e,t,n,"Adobe reference enum value");else if(a==="rele"||a==="Idnt"||a==="indx")d.index=e.i32(t,"Adobe reference index");else if(a==="name")d.name=hi(e,t,n,"Adobe reference name");else if(a!=="Clss")throw new Error(`Unsupported Adobe reference form ${JSON.stringify(a)}.`);r.push(d)}return r},vp=(e,t,n)=>{let i=e.u32(t,"Adobe descriptor path length");if(i>n.maxDecodedBytes)throw new Error(`Adobe descriptor path exceeds the ${n.maxDecodedBytes}-byte safety limit.`);return e.skip(i,t,"Adobe descriptor path"),{type:"path",length:i}},ad=(e,t,n,i,o,r)=>{if(r>i.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${i.maxNestingDepth}-level safety limit.`);switch(n){case"bool":return{type:"boolean",value:e.u8(t,"Adobe boolean")!==0};case"long":return{type:"integer",value:e.i32(t,"Adobe integer")};case"comp":return{type:"large-integer",value:e.i64(t,"Adobe large integer")};case"doub":return{type:"double",value:e.f64(t,"Adobe double")};case"UntF":return{type:"unit-double",unit:e.ascii(4,t,"Adobe unit"),value:e.f64(t,"Adobe unit double")};case"TEXT":return{type:"text",value:hi(e,t,i,"Adobe descriptor text")};case"enum":return{type:"enum",enumType:Wt(e,t,i,"Adobe enum type"),value:Wt(e,t,i,"Adobe enum value")};case"Objc":case"GlbO":return{type:"object",value:fn(e,t,i,o,r+1)};case"VlLs":{let s=e.u32(t,"Adobe list count");ui(o,s,"Adobe list count");let a=[];for(let l=0;l<s;l+=1)a.push(ad(e,t,e.ascii(4,t,"Adobe list value type"),i,o,r+1));return{type:"list",value:a}}case"alis":case"tdta":{let s=e.u32(t,"Adobe raw data length");if(s>i.maxDecodedBytes)throw new Error(`Adobe raw data exceeds the ${i.maxDecodedBytes}-byte safety limit.`);return e.skip(s,t,"Adobe raw data"),{type:"raw",length:s,alias:n==="alis"}}case"type":case"GlbC":{let s=sd(e,t,i,"Adobe class reference");return{type:"class",name:s.name,classId:s.classId}}case"UnFl":{let s=e.ascii(4,t,"Adobe unit-float-array unit"),a=e.u32(t,"Adobe unit-float-array count");ui(o,a,"Adobe unit-float-array count");let l=Array.from({length:a},()=>e.f64(t,"Adobe unit-float-array value"));return{type:"unit-double-array",unit:s,value:l}}case"ObAr":{let s=e.u32(t,"Adobe object-array count");return ui(o,s,"Adobe object-array count"),{type:"object-array",count:s,value:fn(e,t,i,o,r+1)}}case"obj ":return{type:"reference",value:Sp(e,t,i,o)};case"Pth ":return vp(e,t,i);default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(n)}.`)}},pi=e=>{let t=Number.isSafeInteger(e.maxResourceItems)&&e.maxResourceItems>0?Math.min(1e6,e.maxResourceItems):1;return{values:0,maximum:t>3906?1e6:t*256}},fn=(e,t,n,i=pi(n),o=0)=>{if(o>n.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${n.maxNestingDepth}-level safety limit.`);let r=hi(e,t,n,"Adobe descriptor name"),s=Wt(e,t,n,"Adobe descriptor class"),a=e.u32(t,"Adobe descriptor item count");ui(i,a,"Adobe descriptor item count");let l=new Map,c=[];for(let d=0;d<a;d+=1){let u=Wt(e,t,n,"Adobe descriptor key");if(l.has(u))throw new Error(`Adobe descriptor contains duplicate key ${JSON.stringify(u)}.`);let f=e.ascii(4,t,"Adobe descriptor value type");l.set(u,ad(e,t,f,n,i,o+1)),c.push(u)}return{name:r,classId:s,entries:l,keys:c}},Le=(e,t)=>e?.entries.get(t),mi=(e,t)=>{let n=Le(e,t);return n?.type==="object"?n.value:void 0},un=(e,t)=>{let n=Le(e,t);return n?.type==="text"?n.value:void 0},gi=(e,t)=>{let n=Le(e,t);return n?.type==="enum"?n.value:void 0},bi=(e,t,n=!1)=>{let i=Le(e,t);return i?.type==="boolean"?i.value:n},ye=(e,t,n=0)=>{let i=Le(e,t);return i?i.type==="integer"||i.type==="double"||i.type==="unit-double"?i.value:i.type==="large-integer"?Number(i.value):n:n},ld=hi;var xp=["maxFileBytes","maxCanvasPixels","maxCanvasDimension","maxLayers","maxNestingDepth","maxLayerPixels","maxDecodedBytes","maxLayerCacheBytes","maxResourceItems","maxResourceNameCodeUnits","maxResourcePreviewPixels"],_p=e=>{for(let t of xp){let n=e[t];if(!Number.isSafeInteger(n)||n<=0)throw new Error(`Invalid Adobe preset safety limit ${t}.`)}},ud=e=>e+3&-4,st=(e,t,n)=>{let i=e+t;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${n} exceeds the safe integer range.`);return i},_o=(e,t,n)=>{let i=e*t;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${n} exceeds the safe integer range.`);return i},is=(e,t,n)=>{if(e.byteLength>t.maxFileBytes)throw new Error(`${n} source exceeds the ${t.maxFileBytes}-byte safety limit.`);if(!e.byteLength)throw new Error(`${n} source is empty.`)},hd=(e,t,n,i,o)=>{if(e.previewPixels=st(e.previewPixels,t,`${o} preview pixels`),e.decodedBytes=st(e.decodedBytes,n,`${o} decoded bytes`),e.previewPixels>i.maxResourcePreviewPixels)throw new Error(`${o} exceeds the ${i.maxResourcePreviewPixels}-pixel preview safety limit.`);if(e.decodedBytes>i.maxDecodedBytes)throw new Error(`${o} exceeds the ${i.maxDecodedBytes}-byte decoded-data safety limit.`)},Ap=(e,t,n,i)=>{let o=e.u8(t,`${i} length`);if(o>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-byte safety limit.`);return e.ascii(o,t,i).replace(/\0+$/u,"")},kp=(e,t,n,i,o,r)=>{let s=Array.from({length:i},(l,c)=>e.u16(t,`${r} row ${c} length`)),a=o?new Uint8Array(_o(n,i,`${r} pixels`)):void 0;for(let l=0;l<i;l+=1){let c=st(e.offset,s[l],`${r} row ${l} end`);if(c>t)throw new Error(`${r} compressed row ${l} is truncated.`);let d=0;for(;e.offset<c;){let u=e.u8(c,`${r} PackBits header`);if(u<=127){let f=u+1,h=e.slice(f,c,`${r} PackBits literal`);if(d+f>n)throw new Error(`${r} row ${l} expands beyond its declared width.`);a&&a.set(h,l*n+d),d+=f}else if(u>=129){let f=257-u,h=e.u8(c,`${r} PackBits repeat value`);if(d+f>n)throw new Error(`${r} row ${l} expands beyond its declared width.`);a?.fill(h,l*n+d,l*n+d+f),d+=f}}if(d!==n)throw new Error(`${r} row ${l} expands to ${d} instead of ${n} pixels.`)}if(e.offset!==t)throw new Error(`${r} has trailing compressed bytes.`);return a},Ip=(e,t,n,i,o,r,s)=>{let a=_o(n,i,`${s} pixels`);if(o===0){if(e.offset+a!==t)throw new Error(`${s} raw byte length does not match its dimensions.`);return r?Uint8Array.from(e.slice(a,t,s)):(e.skip(a,t,s),void 0)}if(o===1)return kp(e,t,n,i,r,s);throw new Error(`${s} uses unsupported compression mode ${o}.`)},cd=(e,t,n,i,o,r,s,a)=>{for(let l=0;l<i.height;l+=1)for(let c=0;c<i.width;c+=1){let d=l*i.width+c,u=((i.top-t.top+l)*t.width+i.left-t.left+c)*4,f=n[d];r===1&&o===0?(e[u]=f,e[u+1]=f,e[u+2]=f):r===2&&o===0&&s?(e[u]=s[f*3],e[u+1]=s[f*3+1],e[u+2]=s[f*3+2],a&&(a[(i.top-t.top+l)*t.width+i.left-t.left+c]=f)):e[u+o]=f}},pd=(e,t,n,i,o,r)=>{if(e.u32(t,`PAT pattern ${r} version`)!==1)throw new Error(`PAT pattern ${r} uses an unsupported record version.`);let s=e.u32(t,`PAT pattern ${r} color mode`);if(s!==1&&s!==2&&s!==3)throw new Error(`PAT pattern ${r} uses unsupported color mode ${s}; only 8-bit grayscale, indexed, and RGB tiles are decoded.`);let a=e.i16(t,`PAT pattern ${r} vertical value`),l=e.i16(t,`PAT pattern ${r} horizontal value`),c=ld(e,t,n,`PAT pattern ${r} name`),d=Ap(e,t,n,`PAT pattern ${r} id`);if(!d)throw new Error(`PAT pattern ${r} has an empty unique id.`);let u,f=65535;if(s===2&&(u=Uint8Array.from(e.slice(768,t,`PAT pattern ${r} indexed palette`)),o?(e.u16(t,`PAT pattern ${r} indexed color count`),f=e.u16(t,`PAT pattern ${r} transparent palette index`)):e.skip(4,t,`PAT pattern ${r} indexed footer`)),e.u32(t,`PAT pattern ${r} VMAL version`)!==3)throw new Error(`PAT pattern ${r} uses an unsupported VMAL version.`);let h=e.u32(t,`PAT pattern ${r} VMAL length`),p=st(e.offset,h,`PAT pattern ${r} VMAL end`);if(p>t)throw new Error(`PAT pattern ${r} VMAL is truncated.`);let S=e.i32(p,`PAT pattern ${r} top`),m=e.i32(p,`PAT pattern ${r} left`),g=e.i32(p,`PAT pattern ${r} bottom`),v=e.i32(p,`PAT pattern ${r} right`),x=v-m,_=g-S,I=e.u32(p,`PAT pattern ${r} channel count`);if(x<=0||_<=0||x>n.maxCanvasDimension||_>n.maxCanvasDimension)throw new Error(`PAT pattern ${r} dimensions exceed the ${n.maxCanvasDimension}-pixel side safety limit.`);if(o&&(l!==x||a!==_))throw new Error(`PAT pattern ${r} header dimensions disagree with its decoded VMAL bounds.`);if(I>64)throw new Error(`PAT pattern ${r} channel count exceeds the 64-channel safety limit.`);let P=_o(x,_,`PAT pattern ${r} pixels`);hd(i,P,_o(P,4,`PAT pattern ${r} RGBA bytes`),n,`PAT pattern ${r}`);let k=new Uint8Array(P*4);for(let T=3;T<k.length;T+=4)k[T]=255;let E=s===2?new Uint8Array(P):void 0,O=s===3?3:1,U=new Set,M=!1,le={top:S,left:m,width:x,height:_};for(let T=0;T<I+2;T+=1){let W=e.u32(p,`PAT pattern ${r} channel ${T} presence`);if(!W)continue;if(W!==1)throw new Error(`PAT pattern ${r} channel ${T} has an invalid presence marker.`);let te=e.u32(p,`PAT pattern ${r} channel ${T} length`);if(te<23)throw new Error(`PAT pattern ${r} channel ${T} is shorter than its header.`);let ne=st(e.offset,te,`PAT pattern ${r} channel ${T} end`);if(ne>p)throw new Error(`PAT pattern ${r} channel ${T} is truncated.`);let Pe=e.u32(ne,`PAT pattern ${r} channel ${T} depth`),Ee=e.i32(ne,`PAT pattern ${r} channel ${T} top`),j=e.i32(ne,`PAT pattern ${r} channel ${T} left`),R=e.i32(ne,`PAT pattern ${r} channel ${T} bottom`),V=e.i32(ne,`PAT pattern ${r} channel ${T} right`),fe=e.u16(ne,`PAT pattern ${r} channel ${T} depth copy`),ie=e.u8(ne,`PAT pattern ${r} channel ${T} compression`);if(Pe!==8||fe!==8)throw new Error(`PAT pattern ${r} channel ${T} is not 8-bit.`);if(Ee<S||j<m||R>g||V>v||R<=Ee||V<=j)throw new Error(`PAT pattern ${r} channel ${T} bounds are outside the tile.`);let he=V-j,we=R-Ee,$e=T<O,at=T===I+1,yi=Ip(e,ne,he,we,ie,$e||at,`PAT pattern ${r} channel ${T}`);yi&&$e?(U.add(T),cd(k,le,yi,{top:Ee,left:j,width:he,height:we},T,s,u,E)):yi&&at&&(M=!0,cd(k,le,yi,{top:Ee,left:j,width:he,height:we},3,s))}if(e.offset!==p)throw new Error(`PAT pattern ${r} VMAL has trailing or unparsed bytes.`);if(U.size!==O)throw new Error(`PAT pattern ${r} is missing one or more required color planes.`);if(s===2&&!M&&f<256&&E)for(let T=0;T<E.length;T+=1)E[T]===f&&(k[T*4+3]=0);let me=!1;for(let T=0;T<P;T+=1)if(k[T*4+3]!==255){me=!0;break}return{name:c||`Pattern ${r}`,id:d,width:x,height:_,colorMode:s===1?"grayscale":s===2?"indexed":"rgb",rgba:k,hasTransparency:me}},Dp=(e,t,n,i)=>{let o=[];for(;e.offset<t;){if(o.length>=n.maxResourceItems)throw new Error(`Embedded pattern count exceeds the ${n.maxResourceItems}-item safety limit.`);let r=e.u32(t,"Embedded PAT record length"),s=st(e.offset,r,"Embedded PAT record end"),a=st(e.offset,ud(r),"Embedded PAT padded end");if(!r||s>t||a>t)throw new Error("Embedded PAT record is truncated.");if(o.push(pd(e,s,n,i,!1,o.length+1)),e.offset!==s)throw new Error(`Embedded PAT pattern ${o.length} length does not match its decoded payload.`);for(let l of e.slice(a-s,a,"Embedded PAT padding"))if(l!==0)throw new Error(`Embedded PAT pattern ${o.length} has non-zero alignment bytes.`)}if(e.offset!==t)throw new Error("Embedded PAT block length is invalid.");return o},Cp=(e,t)=>{is(e,t,"PAT");let n=new Rn(e);if(n.ascii(4,n.length,"PAT signature")!=="8BPT")throw new Error("Invalid Photoshop PAT signature.");if(n.u16(n.length,"PAT version")!==1)throw new Error("Unsupported Photoshop PAT version; expected version 1.");let i=n.u32(n.length,"PAT pattern count");if(!i||i>t.maxResourceItems)throw new Error(`PAT pattern count must be between 1 and ${t.maxResourceItems}.`);let o={previewPixels:0,decodedBytes:0},r=Array.from({length:i},(s,a)=>pd(n,n.length,t,o,!0,a+1));return rs(n,t,pi(t),r.length),{format:"pat",version:"1",engine:"file-viewer-native",fidelity:"decoded-pattern-tile",patterns:r,limitations:["The renderer decodes Photoshop PAT v1 grayscale, indexed, and RGB tiles with 8-bit raw or PackBits planes; CMYK, Lab, multichannel, 16-bit, and 32-bit pattern records are rejected.","Tile pixels and transparency are preserved. Photoshop pattern transforms, fills, layer blending, and color-management behavior are outside a standalone PAT library."]}},Be=(e,t,n,i)=>{if(!Number.isFinite(e)||e<t||e>n)throw new Error(`${i} is outside ${t}\u2026${n}.`);return e},Te=e=>Math.max(0,Math.min(255,Math.round(e))),Pp=(e,t,n)=>{let i=(e%360+360)%360/60,o=Math.max(0,Math.min(1,t/100)),r=Math.max(0,Math.min(1,n/100)),s=r*o,a=s*(1-Math.abs(i%2-1)),l=r-s;return(i<1?[s,a,0]:i<2?[a,s,0]:i<3?[0,s,a]:i<4?[0,a,s]:i<5?[a,0,s]:[s,0,a]).map(d=>Te((d+l)*255))},Ep=(e,t,n)=>{let i=.20689655172413793,o=h=>h>i?h**3:3*i*i*(h-4/29),r=(e+16)/116,s=.96422*o(r+t/500),a=o(r),l=.82521*o(r-n/200),c=.9555766*s-.0230393*a+.0631636*l,d=-.0282895*s+1.0099416*a+.0210077*l,u=.0122982*s-.020483*a+1.3299098*l;return[3.2404542*c-1.5371385*d-.4985314*u,-.969266*c+1.8760108*d+.041556*u,.0556434*c-.2040259*d+1.0572252*u].map(h=>Te((h<=.0031308?12.92*h:1.055*Math.max(0,h)**(1/2.4)-.055)*255))},Fp=e=>{if(!e)return{rgb:[0,0,0],colorSpace:"unknown"};if(e.classId==="RGBC")return{rgb:[Te(ye(e,"Rd ")),Te(ye(e,"Grn ")),Te(ye(e,"Bl "))],colorSpace:"rgb"};if(e.classId==="Grsc"){let t=Te(Be(ye(e,"Gry "),0,100,"GRD gray")*2.55);return{rgb:[t,t,t],colorSpace:"gray"}}if(e.classId==="HSBC"||e.classId==="HSBl")return{rgb:Pp(ye(e,"H "),ye(e,"Strt"),ye(e,"Brgh")),colorSpace:"hsb"};if(e.classId==="LbCl")return{rgb:Ep(ye(e,"Lmnc"),ye(e,"A "),ye(e,"B ")),colorSpace:"lab"};if(e.classId==="CMYC"){let t=Be(ye(e,"Cyn "),0,100,"GRD cyan")/100,n=Be(ye(e,"Mgnt"),0,100,"GRD magenta")/100,i=Be(ye(e,"Ylw "),0,100,"GRD yellow")/100,o=Be(ye(e,"Blck"),0,100,"GRD black")/100;return{rgb:[Te((1-t)*(1-o)*255),Te((1-n)*(1-o)*255),Te((1-i)*(1-o)*255)],colorSpace:"cmyk"}}return{rgb:[0,0,0],colorSpace:"unknown"}},ns=(e,t,n)=>{if(!e||e.type!=="list")throw new Error(`${t} list is missing.`);if(e.value.length>n)throw new Error(`${t} exceeds the ${n}-item safety limit.`);return e.value.map((i,o)=>{if(i.type!=="object")throw new Error(`${t} item ${o+1} is not an object.`);return i.value})},Op=(e,t)=>e<=t?t<=0?.5:.5*e/t:t>=1?.5:.5+.5*(e-t)/(1-t),dd=(e,t,n)=>{if(t<=e[0].location)return e[0].value;if(t>=e.at(-1).location)return e.at(-1).value;let i=e.findIndex(l=>l.location>=t),o=e[i-1],r=e[i],s=Math.max(1e-9,r.location-o.location),a=Op((t-o.location)/s,Math.max(.001,Math.min(.999,o.midpoint)));return Array.from({length:n},(l,c)=>o.value[c]+(r.value[c]-o.value[c])*a)},Lp=(e,t)=>{let n=new Uint8Array(1024),i=e.map(r=>({location:r.location,midpoint:r.midpoint,value:r.rgb})),o=t.map(r=>({location:r.location,midpoint:r.midpoint,value:[r.opacity]}));for(let r=0;r<256;r+=1){let s=r/255,a=dd(i,s,3),l=dd(o,s,1)[0];n.set([Te(a[0]),Te(a[1]),Te(a[2]),Te(l*255)],r*4)}return n},fd=(e,t,n)=>{let i=Le(e,t),o=i?.type==="list"?i.value:[];return[0,1,2,3].map(r=>{let s=o[r];return s?.type==="integer"?Be(s.value,0,100,`GRD ${t} range`):n})},Bp=(e,t,n,i)=>{let o=new Uint8Array(1024),r=e>>>0||2654435769,s=()=>(r^=r<<13,r^=r>>>17,r^=r<<5,(r>>>0)/4294967295);for(let a=0;a<256;a+=1){for(let l=0;l<3;l+=1)o[a*4+l]=Te((t[l]+s()*(n[l]-t[l]))*2.55);o[a*4+3]=i?Te((t[3]+s()*(n[3]-t[3]))*2.55):255}return o},os=e=>{if(!e.startsWith("$$$/"))return e;let t=e.lastIndexOf("=");if(t>=0&&t+1<e.length)return e.slice(t+1);let n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Up=(e,t,n,i)=>{hd(i,256,1024,n,`GRD gradient ${t}`);let o=mi(e,"Grad")||e,r=os(un(o,"Nm ")||`Gradient ${t}`),s=gi(o,"GrdF")||"CstS";if(s==="ClNs"){let u=fd(o,"Mnm ",0),f=fd(o,"Mxm ",100);f.forEach((v,x)=>{if(v<u[x])throw new Error(`${r}: noise maximum is below its minimum.`)});let h=Be(ye(o,"RndS",0),0,4294967295,`${r} random seed`),p=Be(ye(o,"Smth",2048),0,4096,`${r} roughness`),S=gi(o,"ClrS")||"RGBC",m=S==="HSBl"||S==="HSBC"?"hsb":S==="LbCl"||S==="LABC"?"lab":"rgb",g=bi(o,"ShTr",!1);return{name:r,definition:{form:"noise",seed:h,roughness:p,colorModel:m,restrictColors:bi(o,"VctC",!0),addTransparency:g,minimum:u,maximum:f},previewRgba:Bp(h,u,f,g)}}if(s!=="CstS")throw new Error(`${r}: unsupported GRD gradient form ${JSON.stringify(s)}.`);let l=ns(Le(o,"Clrs"),`${r} color stops`,Math.min(256,n.maxResourceItems)).map((u,f)=>{let h=Be(ye(u,"Lctn")/4096,0,1,`${r} color stop ${f+1} location`),p=Be(ye(u,"Mdpn",50)/100,0,1,`${r} color stop ${f+1} midpoint`),S=gi(u,"Type")||"UsrS",m=S==="FrgC"?"foreground":S==="BckC"?"background":"user",g=m==="foreground"?{rgb:[0,0,0],colorSpace:"unknown"}:m==="background"?{rgb:[255,255,255],colorSpace:"unknown"}:Fp(mi(u,"Clr "));if(m==="user"&&g.colorSpace==="unknown")throw new Error(`${r} color stop ${f+1} uses an unsupported color object.`);return{location:h,midpoint:p,kind:m,...g}}).sort((u,f)=>u.location-f.location);if(l.length<2)throw new Error(`${r} has fewer than two usable color stops.`);let c=Le(o,"Trns"),d=c?ns(c,`${r} transparency stops`,Math.min(256,n.maxResourceItems)).map((u,f)=>({location:Be(ye(u,"Lctn")/4096,0,1,`${r} alpha stop ${f+1} location`),midpoint:Be(ye(u,"Mdpn",50)/100,0,1,`${r} alpha stop ${f+1} midpoint`),opacity:Be(ye(u,"Opct",100)/100,0,1,`${r} alpha stop ${f+1} opacity`)})).sort((u,f)=>u.location-f.location):[{location:0,midpoint:.5,opacity:1},{location:1,midpoint:.5,opacity:1}];if(!d.length)throw new Error(`${r} declares an empty transparency-stop list.`);return{name:r,definition:{form:"solid",smoothness:Be(ye(o,"Intr",4096),0,4096,`${r} smoothness`),colorStops:l,alphaStops:d},previewRgba:Lp(l,d)}},Rp=(e,t)=>{let n=Le(e,"hierarchy");if(!n||n.type!=="list")return Array.from({length:t},()=>"");let i=Array.from({length:t},()=>""),o=[],r=0;for(let s of n.value)s.type==="object"&&(s.value.classId==="Grup"?o.push(os(un(s.value,"Nm ")||"")):s.value.classId==="groupEnd"?o.pop():s.value.classId==="preset"&&r<i.length&&(i[r++]=o.filter(Boolean).join(" / ")));return i},rs=(e,t,n,i)=>{if(!e.remaining)return Array.from({length:i},()=>"");if(e.remaining<12||e.ascii(4,e.length,"Adobe hierarchy signature")!=="8BIM"||e.ascii(4,e.length,"Adobe hierarchy key")!=="phry")throw new Error("Adobe preset file has unrecognized trailing data.");let o=e.u32(e.length,"Adobe hierarchy length"),r=st(e.offset,o,"Adobe hierarchy end");if(r>e.length)throw new Error("Adobe hierarchy data is truncated.");if(e.u32(r,"Adobe hierarchy descriptor version")!==16)throw new Error("Unsupported Adobe hierarchy descriptor version.");let s=fn(e,r,t,n);if(e.offset!==r)throw new Error("Adobe hierarchy descriptor has trailing bytes.");if(e.remaining)throw new Error("Adobe preset file has bytes after its hierarchy data.");return Rp(s,i)},Mp=(e,t)=>{is(e,t,"GRD");let n=new Rn(e);if(n.ascii(4,n.length,"GRD signature")!=="8BGR")throw new Error("Invalid Photoshop GRD signature.");if(n.u16(n.length,"GRD version")!==5)throw new Error("Unsupported Photoshop GRD version; only descriptor-based version 5 is decoded.");if(n.u32(n.length,"GRD descriptor version")!==16)throw new Error("Unsupported GRD Action Descriptor version.");let i=pi(t),o=fn(n,n.length,t,i),r={previewPixels:0,decodedBytes:0},s=ns(Le(o,"GrdL"),"GRD gradients",t.maxResourceItems).map((l,c)=>Up(l,c+1,t,r));if(!s.length)throw new Error("GRD file contains no gradients.");let a=rs(n,t,i,s.length);return s.forEach((l,c)=>{a[c]&&(l.folder=a[c])}),{format:"grd",version:"5",engine:"file-viewer-native",fidelity:"solid-stop-preview-noise-approximation",gradients:s,limitations:["Solid-gradient stops, midpoint positions, transparency, names, and folders are preserved. Foreground/background stops use black/white because their final colors depend on Photoshop application state.","Noise-gradient metadata is preserved, but the thumbnail is a deterministic approximation; Photoshop does not publish its exact noise synthesis and color-management pipeline."]}},Tp=[{single:"DrSh",multi:"dropShadowMulti",kind:"drop-shadow"},{single:"IrSh",multi:"innerShadowMulti",kind:"inner-shadow"},{single:"OrGl",multi:"outerGlowMulti",kind:"outer-glow"},{single:"IrGl",multi:"innerGlowMulti",kind:"inner-glow"},{single:"ChFX",multi:"chromeFXMulti",kind:"satin"},{single:"ebbl",multi:"bevelEmbossMulti",kind:"bevel-emboss"},{single:"SoFi",multi:"solidFillMulti",kind:"color-overlay"},{single:"GrFl",multi:"gradientFillMulti",kind:"gradient-overlay"},{single:"patternFill",multi:"patternFillMulti",kind:"pattern-overlay"},{single:"FrFX",multi:"frameFXMulti",kind:"stroke"}],jp=e=>{if(!e)return[];let t=[];for(let n of Tp){let i=Le(e,n.single),o=Le(e,n.multi),r=[];if(i?.type==="object"&&r.push(i.value),o?.type==="list")for(let s of o.value)s.type==="object"&&r.push(s.value);r.length&&t.push({kind:n.kind,enabled:r.some(s=>bi(s,"enab",!0)),instances:r.length})}return t},xo=(e,t)=>{if(e.type==="object"){t(e.value);for(let n of e.value.entries.values())xo(n,t)}else if(e.type==="list")e.value.forEach(n=>xo(n,t));else if(e.type==="object-array"){t(e.value);for(let n of e.value.entries.values())xo(n,t)}},zp=e=>{let t=new Map;if(!e)return[];let n=i=>{if(i.classId!=="Ptrn"&&!i.entries.has("Idnt"))return;let o=un(i,"Idnt")||"",r=un(i,"Nm ")||"";o&&t.set(o,{name:r,id:o})};n(e);for(let i of e.entries.values())xo(i,n);return[...t.values()]},$p=(e,t,n,i,o)=>{if(e.u32(t,`ASL style ${o} identity descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported identity descriptor version.`);let r=fn(e,t,n,i),s=os(un(r,"Nm ")||""),a=un(r,"Idnt")||"";if(!s||!a)throw new Error(`ASL style ${o} is missing its name or unique id.`);if(e.u32(t,`ASL style ${o} effect descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported effect descriptor version.`);let l=fn(e,t,n,i),c=mi(l,"Lefx"),d=mi(l,"blendOptions"),u=Le(d,"Blnd"),f={name:s,id:a,effectsVisible:bi(c,"masterFXSwitch",!0),effects:jp(c),blendIfChannels:u?.type==="list"?u.value.length:0,referencedPatterns:zp(c)},h=gi(d,"Md ");h&&(f.blendMode=h);let p=Le(d,"Opct");(p?.type==="unit-double"||p?.type==="double"||p?.type==="integer")&&(f.opacity=Be(p.value,0,100,`${s} opacity`));let S=Le(d,"fillOpacity");if((S?.type==="unit-double"||S?.type==="double"||S?.type==="integer")&&(f.fillOpacity=Be(S.value,0,100,`${s} fill opacity`)),!f.effects.length&&!d)throw new Error(`${s} contains no supported effect graph or blending options.`);return f},Np=(e,t)=>{is(e,t,"ASL");let n=new Rn(e);if(n.u16(n.length,"ASL version")!==2)throw new Error("Unsupported Photoshop ASL version; expected version 2.");if(n.ascii(4,n.length,"ASL signature")!=="8BSL")throw new Error("Invalid Photoshop ASL signature.");if(n.u16(n.length,"ASL pattern section version")!==3)throw new Error("Unsupported ASL embedded-pattern section version.");let i=n.u32(n.length,"ASL embedded-pattern section length"),o=st(n.offset,i,"ASL embedded-pattern section end");if(o>n.length)throw new Error("ASL embedded-pattern section is truncated.");let s=i?Dp(n,o,t,{previewPixels:0,decodedBytes:0}):[],a=n.u32(n.length,"ASL style count");if(!a||a>t.maxResourceItems)throw new Error(`ASL style count must be between 1 and ${t.maxResourceItems}.`);let l=pi(t),c=[];for(let d=0;d<a;d+=1){let u=n.u32(n.length,`ASL style ${d+1} length`),f=st(n.offset,u,`ASL style ${d+1} end`),h=st(n.offset,ud(u),`ASL style ${d+1} padded end`);if(!u||f>n.length||h>n.length)throw new Error(`ASL style ${d+1} record is truncated.`);c.push($p(n,f,t,l,d+1));for(let p of n.slice(f-n.offset,f,`ASL style ${d+1} padding`))if(p!==0)throw new Error(`ASL style ${d+1} has unparsed non-zero bytes.`);for(let p of n.slice(h-f,h,`ASL style ${d+1} alignment`))if(p!==0)throw new Error(`ASL style ${d+1} has non-zero alignment bytes.`)}return rs(n,t,l,c.length),{format:"asl",version:"2",engine:"file-viewer-native",fidelity:"effect-graph-metadata-preview",styles:c,patterns:s,limitations:["Names, ids, effect graph presence, multi-effect counts, blending options, pattern references, and embedded pattern tiles are decoded. The preview does not claim Photoshop layer rasterization.","Exact layer-style appearance depends on Photoshop contours, blend modes, global light, color management, target-layer pixels, and undocumented renderer behavior; unsupported descriptor value types are rejected rather than ignored."]}},md=(e,t,n)=>{if(_p(n),t==="pat")return Cp(e,n);if(t==="grd")return Mp(e,n);if(t==="asl")return Np(e,n);throw new Error(`Unsupported Adobe preset format ${JSON.stringify(t)}.`)};var Ao=self,gd=e=>e.format==="abr"?[...e.samples.map(t=>t.alpha.buffer),...e.patterns.map(t=>t.rgba.buffer)].filter(t=>t instanceof ArrayBuffer):e.format==="pat"?e.patterns.map(t=>t.rgba.buffer).filter(t=>t instanceof ArrayBuffer):e.format==="grd"?e.gradients.map(t=>t.previewRgba.buffer).filter(t=>t instanceof ArrayBuffer):e.format==="asl"?e.patterns.map(t=>t.rgba.buffer).filter(t=>t instanceof ArrayBuffer):[];Ao.addEventListener("message",e=>{let t=e.data;try{if(!t||t.type!=="parse"&&t.type!=="parse-preset")throw new Error("Invalid Adobe resource Worker request.");if(t.type==="parse-preset"){let n=md(t.buffer,t.format,t.limits),i={id:t.id,ok:!0,result:n};Ao.postMessage(i,gd(n))}else{let n=rd(t.buffer,t.format,t.limits),i={id:t.id,ok:!0,result:n};Ao.postMessage(i,gd(n))}}catch(n){let i={id:t?.id??0,ok:!1,error:{name:n instanceof Error?n.name:"Error",message:n instanceof Error?n.message:String(n)}};Ao.postMessage(i)}});