@file-viewer/assets-design 3.3.5 → 3.3.7

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.
@@ -1,12 +1,12 @@
1
- var fu=Object.create;var ia=Object.defineProperty;var du=Object.getOwnPropertyDescriptor;var uu=Object.getOwnPropertyNames;var pu=Object.getPrototypeOf,hu=Object.prototype.hasOwnProperty;var ae=(e,n)=>()=>{try{return n||e((n={exports:{}}).exports,n),n.exports}catch(t){throw n=0,t}};var gu=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of uu(n))!hu.call(e,o)&&o!==t&&ia(e,o,{get:()=>n[o],enumerable:!(i=du(n,o))||i.enumerable});return e};var mu=(e,n,t)=>(t=e!=null?fu(pu(e)):{},gu(n||!e||!e.__esModule?ia(t,"default",{value:e,enumerable:!0}):t,e));var _a=ae((By,bn)=>{"use strict";function yn(e){let n=e.length;for(;--n>=0;)e[n]=0}var yu=0,ca=1,bu=2,wu=3,vu=258,qo=29,Qn=256,Zn=Qn+1+qo,mn=30,Zo=19,fa=2*Zn+1,Yt=15,Vo=16,Su=7,Ko=256,da=16,ua=17,pa=18,Wo=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]),Li=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]),xu=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ha=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ku=512,At=new Array((Zn+2)*2);yn(At);var qn=new Array(mn*2);yn(qn);var Kn=new Array(ku);yn(Kn);var Yn=new Array(vu-wu+1);yn(Yn);var Yo=new Array(qo);yn(Yo);var Mi=new Array(mn);yn(Mi);function No(e,n,t,i,o){this.static_tree=e,this.extra_bits=n,this.extra_base=t,this.elems=i,this.max_length=o,this.has_stree=e&&e.length}var ga,ma,ya;function Go(e,n){this.dyn_tree=e,this.max_code=0,this.stat_desc=n}var ba=e=>e<256?Kn[e]:Kn[256+(e>>>7)],Jn=(e,n)=>{e.pending_buf[e.pending++]=n&255,e.pending_buf[e.pending++]=n>>>8&255},Ve=(e,n,t)=>{e.bi_valid>Vo-t?(e.bi_buf|=n<<e.bi_valid&65535,Jn(e,e.bi_buf),e.bi_buf=n>>Vo-e.bi_valid,e.bi_valid+=t-Vo):(e.bi_buf|=n<<e.bi_valid&65535,e.bi_valid+=t)},ft=(e,n,t)=>{Ve(e,t[n*2],t[n*2+1])},wa=(e,n)=>{let t=0;do t|=e&1,e>>>=1,t<<=1;while(--n>0);return t>>>1},_u=e=>{e.bi_valid===16?(Jn(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)},Au=(e,n)=>{let t=n.dyn_tree,i=n.max_code,o=n.stat_desc.static_tree,r=n.stat_desc.has_stree,s=n.stat_desc.extra_bits,a=n.stat_desc.extra_base,l=n.stat_desc.max_length,c,f,u,d,p,h,m=0;for(d=0;d<=Yt;d++)e.bl_count[d]=0;for(t[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<fa;c++)f=e.heap[c],d=t[t[f*2+1]*2+1]+1,d>l&&(d=l,m++),t[f*2+1]=d,!(f>i)&&(e.bl_count[d]++,p=0,f>=a&&(p=s[f-a]),h=t[f*2],e.opt_len+=h*(d+p),r&&(e.static_len+=h*(o[f*2+1]+p)));if(m!==0){do{for(d=l-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[l]--,m-=2}while(m>0);for(d=l;d!==0;d--)for(f=e.bl_count[d];f!==0;)u=e.heap[--c],!(u>i)&&(t[u*2+1]!==d&&(e.opt_len+=(d-t[u*2+1])*t[u*2],t[u*2+1]=d),f--)}},va=(e,n,t)=>{let i=new Array(Yt+1),o=0,r,s;for(r=1;r<=Yt;r++)o=o+t[r-1]<<1,i[r]=o;for(s=0;s<=n;s++){let a=e[s*2+1];a!==0&&(e[s*2]=wa(i[a]++,a))}},Iu=()=>{let e,n,t,i,o,r=new Array(Yt+1);for(t=0,i=0;i<qo-1;i++)for(Yo[i]=t,e=0;e<1<<Wo[i];e++)Yn[t++]=i;for(Yn[t-1]=i,o=0,i=0;i<16;i++)for(Mi[i]=o,e=0;e<1<<Li[i];e++)Kn[o++]=i;for(o>>=7;i<mn;i++)for(Mi[i]=o<<7,e=0;e<1<<Li[i]-7;e++)Kn[256+o++]=i;for(n=0;n<=Yt;n++)r[n]=0;for(e=0;e<=143;)At[e*2+1]=8,e++,r[8]++;for(;e<=255;)At[e*2+1]=9,e++,r[9]++;for(;e<=279;)At[e*2+1]=7,e++,r[7]++;for(;e<=287;)At[e*2+1]=8,e++,r[8]++;for(va(At,Zn+1,r),e=0;e<mn;e++)qn[e*2+1]=5,qn[e*2]=wa(e,5);ga=new No(At,Wo,Qn+1,Zn,Yt),ma=new No(qn,Li,0,mn,Yt),ya=new No(new Array(0),xu,0,Zo,Su)},Sa=e=>{let n;for(n=0;n<Zn;n++)e.dyn_ltree[n*2]=0;for(n=0;n<mn;n++)e.dyn_dtree[n*2]=0;for(n=0;n<Zo;n++)e.bl_tree[n*2]=0;e.dyn_ltree[Ko*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},xa=e=>{e.bi_valid>8?Jn(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},oa=(e,n,t,i)=>{let o=n*2,r=t*2;return e[o]<e[r]||e[o]===e[r]&&i[n]<=i[t]},Ho=(e,n,t)=>{let i=e.heap[t],o=t<<1;for(;o<=e.heap_len&&(o<e.heap_len&&oa(n,e.heap[o+1],e.heap[o],e.depth)&&o++,!oa(n,i,e.heap[o],e.depth));)e.heap[t]=e.heap[o],t=o,o<<=1;e.heap[t]=i},ra=(e,n,t)=>{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?ft(e,o,n):(s=Yn[o],ft(e,s+Qn+1,n),a=Wo[s],a!==0&&(o-=Yo[s],Ve(e,o,a)),i--,s=ba(i),ft(e,s,t),a=Li[s],a!==0&&(i-=Mi[s],Ve(e,i,a)));while(r<e.sym_next);ft(e,Ko,n)},Xo=(e,n)=>{let t=n.dyn_tree,i=n.stat_desc.static_tree,o=n.stat_desc.has_stree,r=n.stat_desc.elems,s,a,l=-1,c;for(e.heap_len=0,e.heap_max=fa,s=0;s<r;s++)t[s*2]!==0?(e.heap[++e.heap_len]=l=s,e.depth[s]=0):t[s*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,t[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=i[c*2+1]);for(n.max_code=l,s=e.heap_len>>1;s>=1;s--)Ho(e,t,s);c=r;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ho(e,t,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,t[c*2]=t[s*2]+t[a*2],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,t[s*2+1]=t[a*2+1]=c,e.heap[1]=c++,Ho(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Au(e,n),va(t,l,e.bl_count)},sa=(e,n,t)=>{let i,o=-1,r,s=n[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),n[(t+1)*2+1]=65535,i=0;i<=t;i++)r=s,s=n[(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[da*2]++):a<=10?e.bl_tree[ua*2]++:e.bl_tree[pa*2]++,a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4))},aa=(e,n,t)=>{let i,o=-1,r,s=n[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),i=0;i<=t;i++)if(r=s,s=n[(i+1)*2+1],!(++a<l&&r===s)){if(a<c)do ft(e,r,e.bl_tree);while(--a!==0);else r!==0?(r!==o&&(ft(e,r,e.bl_tree),a--),ft(e,da,e.bl_tree),Ve(e,a-3,2)):a<=10?(ft(e,ua,e.bl_tree),Ve(e,a-3,3)):(ft(e,pa,e.bl_tree),Ve(e,a-11,7));a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4)}},Cu=e=>{let n;for(sa(e,e.dyn_ltree,e.l_desc.max_code),sa(e,e.dyn_dtree,e.d_desc.max_code),Xo(e,e.bl_desc),n=Zo-1;n>=3&&e.bl_tree[ha[n]*2+1]===0;n--);return e.opt_len+=3*(n+1)+5+5+4,n},Pu=(e,n,t,i)=>{let o;for(Ve(e,n-257,5),Ve(e,t-1,5),Ve(e,i-4,4),o=0;o<i;o++)Ve(e,e.bl_tree[ha[o]*2+1],3);aa(e,e.dyn_ltree,n-1),aa(e,e.dyn_dtree,t-1)},Du=e=>{let n=4093624447,t;for(t=0;t<=31;t++,n>>>=1)if(n&1&&e.dyn_ltree[t*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(t=32;t<Qn;t++)if(e.dyn_ltree[t*2]!==0)return 1;return 0},la=!1,Ou=e=>{la||(Iu(),la=!0),e.l_desc=new Go(e.dyn_ltree,ga),e.d_desc=new Go(e.dyn_dtree,ma),e.bl_desc=new Go(e.bl_tree,ya),e.bi_buf=0,e.bi_valid=0,Sa(e)},ka=(e,n,t,i)=>{Ve(e,(yu<<1)+(i?1:0),3),xa(e),Jn(e,t),Jn(e,~t),t&&e.pending_buf.set(e.window.subarray(n,n+t),e.pending),e.pending+=t},Eu=e=>{Ve(e,ca<<1,3),ft(e,Ko,At),_u(e)},Fu=(e,n,t,i)=>{let o,r,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=Du(e)),Xo(e,e.l_desc),Xo(e,e.d_desc),s=Cu(e),o=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=o&&(o=r)):o=r=t+5,t+4<=o&&n!==-1?ka(e,n,t,i):e.strategy===4||r===o?(Ve(e,(ca<<1)+(i?1:0),3),ra(e,At,qn)):(Ve(e,(bu<<1)+(i?1:0),3),Pu(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),ra(e,e.dyn_ltree,e.dyn_dtree)),Sa(e),i&&xa(e)},Lu=(e,n,t)=>(e.pending_buf[e.sym_buf+e.sym_next++]=n,e.pending_buf[e.sym_buf+e.sym_next++]=n>>8,e.pending_buf[e.sym_buf+e.sym_next++]=t,n===0?e.dyn_ltree[t*2]++:(e.matches++,n--,e.dyn_ltree[(Yn[t]+Qn+1)*2]++,e.dyn_dtree[ba(n)*2]++),e.sym_next===e.sym_end);bn.exports._tr_init=Ou;bn.exports._tr_stored_block=ka;bn.exports._tr_flush_block=Fu;bn.exports._tr_tally=Lu;bn.exports._tr_align=Eu});var Jo=ae((Ry,Aa)=>{"use strict";var Mu=(e,n,t,i)=>{let o=e&65535|0,r=e>>>16&65535|0,s=0;for(;t!==0;){s=t>2e3?2e3:t,t-=s;do o=o+n[i++]|0,r=r+o|0;while(--s);o%=65521,r%=65521}return o|r<<16|0};Aa.exports=Mu});var Qo=ae((Ty,Ia)=>{"use strict";var Uu=()=>{let e,n=[];for(var t=0;t<256;t++){e=t;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;n[t]=e}return n},Bu=new Uint32Array(Uu()),Ru=(e,n,t,i)=>{let o=Bu,r=i+t;e^=-1;for(let s=i;s<r;s++)e=e>>>8^o[(e^n[s])&255];return e^-1};Ia.exports=Ru});var Ui=ae((jy,Ca)=>{"use strict";Ca.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 zt=ae((zy,Pa)=>{"use strict";Pa.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 Ta=ae(($y,ht)=>{"use strict";var{_tr_init:Tu,_tr_stored_block:nr,_tr_flush_block:ju,_tr_tally:Gt,_tr_align:zu}=_a(),Fa=Jo(),$t=Qo(),$u=Ui(),{Z_NO_FLUSH:Ht,Z_PARTIAL_FLUSH:Vu,Z_FULL_FLUSH:Nu,Z_FINISH:Ye,Z_BLOCK:Da,Z_OK:Oe,Z_STREAM_END:Oa,Z_STREAM_ERROR:ut,Z_DATA_ERROR:Gu,Z_BUF_ERROR:er,Z_DEFAULT_COMPRESSION:Hu,Z_FILTERED:Wu,Z_HUFFMAN_ONLY:Bi,Z_RLE:Xu,Z_FIXED:qu,Z_DEFAULT_STRATEGY:Zu,Z_UNKNOWN:Ku,Z_DEFLATED:Ri}=zt(),Yu=9,Ju=15,Qu=8,e0=29,t0=256,ir=t0+1+e0,n0=30,i0=19,o0=2*ir+1,r0=15,oe=3,Nt=258,pt=Nt+oe+1,s0=32,vn=42,cr=57,or=69,rr=73,sr=91,ar=103,Jt=113,ti=666,Be=1,xn=2,en=3,kn=4,a0=3,Qt=(e,n)=>(e.msg=$u[n],n),Ea=e=>e*2-(e>4?9:0),Vt=e=>{let n=e.length;for(;--n>=0;)e[n]=0},l0=e=>{let n,t,i,o=e.w_size;n=e.hash_size,i=n;do t=e.head[--i],e.head[i]=t>=o?t-o:0;while(--n);n=o,i=n;do t=e.prev[--i],e.prev[i]=t>=o?t-o:0;while(--n)},c0=(e,n,t)=>(n<<e.hash_shift^t)&e.hash_mask,Wt=c0,Ge=e=>{let n=e.state,t=n.pending;t>e.avail_out&&(t=e.avail_out),t!==0&&(e.output.set(n.pending_buf.subarray(n.pending_out,n.pending_out+t),e.next_out),e.next_out+=t,n.pending_out+=t,e.total_out+=t,e.avail_out-=t,n.pending-=t,n.pending===0&&(n.pending_out=0))},He=(e,n)=>{ju(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,n),e.block_start=e.strstart,Ge(e.strm)},fe=(e,n)=>{e.pending_buf[e.pending++]=n},ei=(e,n)=>{e.pending_buf[e.pending++]=n>>>8&255,e.pending_buf[e.pending++]=n&255},lr=(e,n,t,i)=>{let o=e.avail_in;return o>i&&(o=i),o===0?0:(e.avail_in-=o,n.set(e.input.subarray(e.next_in,e.next_in+o),t),e.state.wrap===1?e.adler=Fa(e.adler,n,o,t):e.state.wrap===2&&(e.adler=$t(e.adler,n,o,t)),e.next_in+=o,e.total_in+=o,o)},La=(e,n)=>{let t=e.max_chain_length,i=e.strstart,o,r,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-pt?e.strstart-(e.w_size-pt):0,c=e.window,f=e.w_mask,u=e.prev,d=e.strstart+Nt,p=c[i+s-1],h=c[i+s];e.prev_length>=e.good_match&&(t>>=2),a>e.lookahead&&(a=e.lookahead);do if(o=n,!(c[o+s]!==h||c[o+s-1]!==p||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<d);if(r=Nt-(d-i),i=d-Nt,r>s){if(e.match_start=n,s=r,r>=a)break;p=c[i+s-1],h=c[i+s]}}while((n=u[n&f])>l&&--t!==0);return s<=e.lookahead?s:e.lookahead},Sn=e=>{let n=e.w_size,t,i,o;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=n+(n-pt)&&(e.window.set(e.window.subarray(n,n+n-i),0),e.match_start-=n,e.strstart-=n,e.block_start-=n,e.insert>e.strstart&&(e.insert=e.strstart),l0(e),i+=n),e.strm.avail_in===0)break;if(t=lr(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=t,e.lookahead+e.insert>=oe)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=Wt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=Wt(e,e.ins_h,e.window[o+oe-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<oe)););}while(e.lookahead<pt&&e.strm.avail_in!==0)},Ma=(e,n)=>{let t=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<t&&(i===0&&n!==Ye||n===Ht||i!==o+e.strm.avail_in)))break;s=n===Ye&&i===o+e.strm.avail_in?1:0,nr(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,Ge(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&&(lr(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?kn:n!==Ht&&n!==Ye&&e.strm.avail_in===0&&e.strstart===e.block_start?xn:(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&&(lr(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,t=r>e.w_size?e.w_size:r,o=e.strstart-e.block_start,(o>=t||(o||n===Ye)&&n!==Ht&&e.strm.avail_in===0&&o<=r)&&(i=o>r?r:o,s=n===Ye&&e.strm.avail_in===0&&i===o?1:0,nr(e,e.block_start,i,s),e.block_start+=i,Ge(e.strm)),s?en:Be)},tr=(e,n)=>{let t,i;for(;;){if(e.lookahead<pt){if(Sn(e),e.lookahead<pt&&n===Ht)return Be;if(e.lookahead===0)break}if(t=0,e.lookahead>=oe&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),t!==0&&e.strstart-t<=e.w_size-pt&&(e.match_length=La(e,t)),e.match_length>=oe)if(i=Gt(e,e.strstart-e.match_start,e.match_length-oe),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=oe){e.match_length--;do e.strstart++,e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=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=Wt(e,e.ins_h,e.window[e.strstart+1]);else i=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=e.strstart<oe-1?e.strstart:oe-1,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},wn=(e,n)=>{let t,i,o;for(;;){if(e.lookahead<pt){if(Sn(e),e.lookahead<pt&&n===Ht)return Be;if(e.lookahead===0)break}if(t=0,e.lookahead>=oe&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=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=oe-1,t!==0&&e.prev_length<e.max_lazy_match&&e.strstart-t<=e.w_size-pt&&(e.match_length=La(e,t),e.match_length<=5&&(e.strategy===Wu||e.match_length===oe&&e.strstart-e.match_start>4096)&&(e.match_length=oe-1)),e.prev_length>=oe&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-oe,i=Gt(e,e.strstart-1-e.prev_match,e.prev_length-oe),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=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=oe-1,e.strstart++,i&&(He(e,!1),e.strm.avail_out===0))return Be}else if(e.match_available){if(i=Gt(e,0,e.window[e.strstart-1]),i&&He(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Be}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Gt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<oe-1?e.strstart:oe-1,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},f0=(e,n)=>{let t,i,o,r,s=e.window;for(;;){if(e.lookahead<=Nt){if(Sn(e),e.lookahead<=Nt&&n===Ht)return Be;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=oe&&e.strstart>0&&(o=e.strstart-1,i=s[o],i===s[++o]&&i===s[++o]&&i===s[++o])){r=e.strstart+Nt;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=Nt-(r-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=oe?(t=Gt(e,1,e.match_length-oe),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=0,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},d0=(e,n)=>{let t;for(;;){if(e.lookahead===0&&(Sn(e),e.lookahead===0)){if(n===Ht)return Be;break}if(e.match_length=0,t=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=0,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn};function dt(e,n,t,i,o){this.good_length=e,this.max_lazy=n,this.nice_length=t,this.max_chain=i,this.func=o}var ni=[new dt(0,0,0,0,Ma),new dt(4,4,8,4,tr),new dt(4,5,16,8,tr),new dt(4,6,32,32,tr),new dt(4,4,16,16,wn),new dt(8,16,32,32,wn),new dt(8,16,128,128,wn),new dt(8,32,128,256,wn),new dt(32,128,258,1024,wn),new dt(32,258,258,4096,wn)],u0=e=>{e.window_size=2*e.w_size,Vt(e.head),e.max_lazy_match=ni[e.level].max_lazy,e.good_match=ni[e.level].good_length,e.nice_match=ni[e.level].nice_length,e.max_chain_length=ni[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=oe-1,e.match_available=0,e.ins_h=0};function p0(){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=Ri,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(o0*2),this.dyn_dtree=new Uint16Array((2*n0+1)*2),this.bl_tree=new Uint16Array((2*i0+1)*2),Vt(this.dyn_ltree),Vt(this.dyn_dtree),Vt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(r0+1),this.heap=new Uint16Array(2*ir+1),Vt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*ir+1),Vt(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 ii=e=>{if(!e)return 1;let n=e.state;return!n||n.strm!==e||n.status!==vn&&n.status!==cr&&n.status!==or&&n.status!==rr&&n.status!==sr&&n.status!==ar&&n.status!==Jt&&n.status!==ti?1:0},Ua=e=>{if(ii(e))return Qt(e,ut);e.total_in=e.total_out=0,e.data_type=Ku;let n=e.state;return n.pending=0,n.pending_out=0,n.wrap<0&&(n.wrap=-n.wrap),n.status=n.wrap===2?cr:n.wrap?vn:Jt,e.adler=n.wrap===2?0:1,n.last_flush=-2,Tu(n),Oe},Ba=e=>{let n=Ua(e);return n===Oe&&u0(e.state),n},h0=(e,n)=>ii(e)||e.state.wrap!==2?ut:(e.state.gzhead=n,Oe),Ra=(e,n,t,i,o,r)=>{if(!e)return ut;let s=1;if(n===Hu&&(n=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),o<1||o>Yu||t!==Ri||i<8||i>15||n<0||n>9||r<0||r>qu||i===8&&s!==1)return Qt(e,ut);i===8&&(i=9);let a=new p0;return e.state=a,a.strm=e,a.status=vn,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+oe-1)/oe),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=n,a.strategy=r,a.method=t,Ba(e)},g0=(e,n)=>Ra(e,n,Ri,Ju,Qu,Zu),m0=(e,n)=>{if(ii(e)||n>Da||n<0)return e?Qt(e,ut):ut;let t=e.state;if(!e.output||e.avail_in!==0&&!e.input||t.status===ti&&n!==Ye)return Qt(e,e.avail_out===0?er:ut);let i=t.last_flush;if(t.last_flush=n,t.pending!==0){if(Ge(e),e.avail_out===0)return t.last_flush=-1,Oe}else if(e.avail_in===0&&Ea(n)<=Ea(i)&&n!==Ye)return Qt(e,er);if(t.status===ti&&e.avail_in!==0)return Qt(e,er);if(t.status===vn&&t.wrap===0&&(t.status=Jt),t.status===vn){let o=Ri+(t.w_bits-8<<4)<<8,r=-1;if(t.strategy>=Bi||t.level<2?r=0:t.level<6?r=1:t.level===6?r=2:r=3,o|=r<<6,t.strstart!==0&&(o|=s0),o+=31-o%31,ei(t,o),t.strstart!==0&&(ei(t,e.adler>>>16),ei(t,e.adler&65535)),e.adler=1,t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(t.status===cr){if(e.adler=0,fe(t,31),fe(t,139),fe(t,8),t.gzhead)fe(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),fe(t,t.gzhead.time&255),fe(t,t.gzhead.time>>8&255),fe(t,t.gzhead.time>>16&255),fe(t,t.gzhead.time>>24&255),fe(t,t.level===9?2:t.strategy>=Bi||t.level<2?4:0),fe(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(fe(t,t.gzhead.extra.length&255),fe(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(e.adler=$t(e.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=or;else if(fe(t,0),fe(t,0),fe(t,0),fe(t,0),fe(t,0),fe(t,t.level===9?2:t.strategy>=Bi||t.level<2?4:0),fe(t,a0),t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(t.status===or){if(t.gzhead.extra){let o=t.pending,r=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+r>t.pending_buf_size;){let a=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex+=a,Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0,r-=a}let s=new Uint8Array(t.gzhead.extra);t.pending_buf.set(s.subarray(t.gzindex,t.gzindex+r),t.pending),t.pending+=r,t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex=0}t.status=rr}if(t.status===rr){if(t.gzhead.name){let o=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0}t.gzindex<t.gzhead.name.length?r=t.gzhead.name.charCodeAt(t.gzindex++)&255:r=0,fe(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex=0}t.status=sr}if(t.status===sr){if(t.gzhead.comment){let o=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0}t.gzindex<t.gzhead.comment.length?r=t.gzhead.comment.charCodeAt(t.gzindex++)&255:r=0,fe(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o))}t.status=ar}if(t.status===ar){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(Ge(e),t.pending!==0))return t.last_flush=-1,Oe;fe(t,e.adler&255),fe(t,e.adler>>8&255),e.adler=0}if(t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(e.avail_in!==0||t.lookahead!==0||n!==Ht&&t.status!==ti){let o=t.level===0?Ma(t,n):t.strategy===Bi?d0(t,n):t.strategy===Xu?f0(t,n):ni[t.level].func(t,n);if((o===en||o===kn)&&(t.status=ti),o===Be||o===en)return e.avail_out===0&&(t.last_flush=-1),Oe;if(o===xn&&(n===Vu?zu(t):n!==Da&&(nr(t,0,0,!1),n===Nu&&(Vt(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),Ge(e),e.avail_out===0))return t.last_flush=-1,Oe}return n!==Ye?Oe:t.wrap<=0?Oa:(t.wrap===2?(fe(t,e.adler&255),fe(t,e.adler>>8&255),fe(t,e.adler>>16&255),fe(t,e.adler>>24&255),fe(t,e.total_in&255),fe(t,e.total_in>>8&255),fe(t,e.total_in>>16&255),fe(t,e.total_in>>24&255)):(ei(t,e.adler>>>16),ei(t,e.adler&65535)),Ge(e),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Oe:Oa)},y0=e=>{if(ii(e))return ut;let n=e.state.status;return e.state=null,n===Jt?Qt(e,Gu):Oe},b0=(e,n)=>{let t=n.length;if(ii(e))return ut;let i=e.state,o=i.wrap;if(o===2||o===1&&i.status!==vn||i.lookahead)return ut;if(o===1&&(e.adler=Fa(e.adler,n,t,0)),i.wrap=0,t>=i.w_size){o===0&&(Vt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let l=new Uint8Array(i.w_size);l.set(n.subarray(t-i.w_size,t),0),n=l,t=i.w_size}let r=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=t,e.next_in=0,e.input=n,Sn(i);i.lookahead>=oe;){let l=i.strstart,c=i.lookahead-(oe-1);do i.ins_h=Wt(i,i.ins_h,i.window[l+oe-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=oe-1,Sn(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=oe-1,i.match_available=0,e.next_in=s,e.input=a,e.avail_in=r,i.wrap=o,Oe};ht.exports.deflateInit=g0;ht.exports.deflateInit2=Ra;ht.exports.deflateReset=Ba;ht.exports.deflateResetKeep=Ua;ht.exports.deflateSetHeader=h0;ht.exports.deflate=m0;ht.exports.deflateEnd=y0;ht.exports.deflateSetDictionary=b0;ht.exports.deflateInfo="pako deflate (from Nodeca project)"});var dr=ae((Vy,fr)=>{"use strict";var w0=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);fr.exports.assign=function(e){let n=Array.prototype.slice.call(arguments,1);for(;n.length;){let t=n.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(let i in t)w0(t,i)&&(e[i]=t[i])}}return e};fr.exports.flattenChunks=e=>{let n=0;for(let i=0,o=e.length;i<o;i++)n+=e[i].length;let t=new Uint8Array(n);for(let i=0,o=0,r=e.length;i<r;i++){let s=e[i];t.set(s,o),o+=s.length}return t}});var ur=ae((Ny,Ti)=>{"use strict";var ja=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{ja=!1}var oi=new Uint8Array(256);for(let e=0;e<256;e++)oi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;oi[254]=oi[254]=1;Ti.exports.string2buf=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let n,t,i,o,r,s=e.length,a=0;for(o=0;o<s;o++)t=e.charCodeAt(o),(t&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),o++)),a+=t<128?1:t<2048?2:t<65536?3:4;for(n=new Uint8Array(a),r=0,o=0;r<a;o++)t=e.charCodeAt(o),(t&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),o++)),t<128?n[r++]=t:t<2048?(n[r++]=192|t>>>6,n[r++]=128|t&63):t<65536?(n[r++]=224|t>>>12,n[r++]=128|t>>>6&63,n[r++]=128|t&63):(n[r++]=240|t>>>18,n[r++]=128|t>>>12&63,n[r++]=128|t>>>6&63,n[r++]=128|t&63);return n};var v0=(e,n)=>{if(n<65534&&e.subarray&&ja)return String.fromCharCode.apply(null,e.length===n?e:e.subarray(0,n));let t="";for(let i=0;i<n;i++)t+=String.fromCharCode(e[i]);return t};Ti.exports.buf2string=(e,n)=>{let t=n||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,n));let i,o,r=new Array(t*2);for(o=0,i=0;i<t;){let s=e[i++];if(s<128){r[o++]=s;continue}let a=oi[s];if(a>4){r[o++]=65533,i+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&i<t;)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 v0(r,o)};Ti.exports.utf8border=(e,n)=>{n=n||e.length,n>e.length&&(n=e.length);let t=n-1;for(;t>=0&&(e[t]&192)===128;)t--;return t<0||t===0?n:t+oi[e[t]]>n?t:n}});var pr=ae((Gy,za)=>{"use strict";function S0(){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}za.exports=S0});var Ga=ae((Hy,_n)=>{"use strict";var ri=Ta(),$a=dr(),Va=ur(),hr=Ui(),x0=pr(),Na=Object.prototype.toString,{Z_NO_FLUSH:k0,Z_SYNC_FLUSH:_0,Z_FULL_FLUSH:A0,Z_FINISH:I0,Z_OK:ji,Z_STREAM_END:C0,Z_DEFAULT_COMPRESSION:P0,Z_DEFAULT_STRATEGY:D0,Z_DEFLATED:O0}=zt();function si(e){this.options=$a.assign({level:P0,method:O0,chunkSize:16384,windowBits:15,memLevel:8,strategy:D0},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new x0,this.strm.avail_out=0;let t=ri.deflateInit2(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(t!==ji)throw new Error(hr[t]);if(n.header&&ri.deflateSetHeader(this.strm,n.header),n.dictionary){let i;if(typeof n.dictionary=="string"?i=Va.string2buf(n.dictionary):Na.call(n.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(n.dictionary):i=n.dictionary,t=ri.deflateSetDictionary(this.strm,i),t!==ji)throw new Error(hr[t]);this._dict_set=!0}}si.prototype.push=function(e,n){let t=this.strm,i=this.options.chunkSize,o,r;if(this.ended)return!1;for(n===~~n?r=n:r=n===!0?I0:k0,typeof e=="string"?t.input=Va.string2buf(e):Na.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),(r===_0||r===A0)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(o=ri.deflate(t,r),o===C0)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),o=ri.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===ji;if(t.avail_out===0){this.onData(t.output);continue}if(r>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};si.prototype.onData=function(e){this.chunks.push(e)};si.prototype.onEnd=function(e){e===ji&&(this.result=$a.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function gr(e,n){let t=new si(n);if(t.push(e,!0),t.err)throw t.msg||hr[t.err];return t.result}function E0(e,n){return n=n||{},n.raw=!0,gr(e,n)}function F0(e,n){return n=n||{},n.gzip=!0,gr(e,n)}_n.exports.Deflate=si;_n.exports.deflate=gr;_n.exports.deflateRaw=E0;_n.exports.gzip=F0;_n.exports.constants=zt()});var Wa=ae((Wy,Ha)=>{"use strict";Ha.exports=function(n,t){let i,o,r,s,a,l,c,f,u,d,p,h,m,y,g,k,x,S,A,D,C,O,E,L,M=n.state;i=n.next_in,E=n.input,o=i+(n.avail_in-5),r=n.next_out,L=n.output,s=r-(t-n.avail_out),a=r+(n.avail_out-257),l=M.dmax,c=M.wsize,f=M.whave,u=M.wnext,d=M.window,p=M.hold,h=M.bits,m=M.lencode,y=M.distcode,g=(1<<M.lenbits)-1,k=(1<<M.distbits)-1;e:do{h<15&&(p+=E[i++]<<h,h+=8,p+=E[i++]<<h,h+=8),x=m[p&g];t:for(;;){if(S=x>>>24,p>>>=S,h-=S,S=x>>>16&255,S===0)L[r++]=x&65535;else if(S&16){A=x&65535,S&=15,S&&(h<S&&(p+=E[i++]<<h,h+=8),A+=p&(1<<S)-1,p>>>=S,h-=S),h<15&&(p+=E[i++]<<h,h+=8,p+=E[i++]<<h,h+=8),x=y[p&k];n:for(;;){if(S=x>>>24,p>>>=S,h-=S,S=x>>>16&255,S&16){if(D=x&65535,S&=15,h<S&&(p+=E[i++]<<h,h+=8,h<S&&(p+=E[i++]<<h,h+=8)),D+=p&(1<<S)-1,D>l){n.msg="invalid distance too far back",M.mode=16209;break e}if(p>>>=S,h-=S,S=r-s,D>S){if(S=D-S,S>f&&M.sane){n.msg="invalid distance too far back",M.mode=16209;break e}if(C=0,O=d,u===0){if(C+=c-S,S<A){A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}}else if(u<S){if(C+=c+u-S,S-=u,S<A){A-=S;do L[r++]=d[C++];while(--S);if(C=0,u<A){S=u,A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}}}else if(C+=u-S,S<A){A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}for(;A>2;)L[r++]=O[C++],L[r++]=O[C++],L[r++]=O[C++],A-=3;A&&(L[r++]=O[C++],A>1&&(L[r++]=O[C++]))}else{C=r-D;do L[r++]=L[C++],L[r++]=L[C++],L[r++]=L[C++],A-=3;while(A>2);A&&(L[r++]=L[C++],A>1&&(L[r++]=L[C++]))}}else if((S&64)===0){x=y[(x&65535)+(p&(1<<S)-1)];continue n}else{n.msg="invalid distance code",M.mode=16209;break e}break}}else if((S&64)===0){x=m[(x&65535)+(p&(1<<S)-1)];continue t}else if(S&32){M.mode=16191;break e}else{n.msg="invalid literal/length code",M.mode=16209;break e}break}}while(i<o&&r<a);A=h>>3,i-=A,h-=A<<3,p&=(1<<h)-1,n.next_in=i,n.next_out=r,n.avail_in=i<o?5+(o-i):5-(i-o),n.avail_out=r<a?257+(a-r):257-(r-a),M.hold=p,M.bits=h}});var qa=ae((Xy,Xa)=>{"use strict";var L0=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]),M0=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]),U0=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]),B0=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]),R0=(e,n,t,i,o,r,s,a)=>{let l=a.bits,c=0,f=0,u=0,d=0,p=0,h=0,m=0,y=0,g=0,k=0,x,S,A,D,C,O=null,E,L=new Uint16Array(16),M=new Uint16Array(16),J=null,pe,R,ie;for(c=0;c<=15;c++)L[c]=0;for(f=0;f<i;f++)L[n[t+f]]++;for(p=l,d=15;d>=1&&L[d]===0;d--);if(p>d&&(p=d),d===0)return o[r++]=1<<24|64<<16|0,o[r++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<d&&L[u]===0;u++);for(p<u&&(p=u),y=1,c=1;c<=15;c++)if(y<<=1,y-=L[c],y<0)return-1;if(y>0&&(e===0||d!==1))return-1;for(M[1]=0,c=1;c<15;c++)M[c+1]=M[c]+L[c];for(f=0;f<i;f++)n[t+f]!==0&&(s[M[n[t+f]]++]=f);if(e===0?(O=J=s,E=20):e===1?(O=L0,J=M0,E=257):(O=U0,J=B0,E=0),k=0,f=0,c=u,C=r,h=p,m=0,A=-1,g=1<<p,D=g-1,e===1&&g>852||e===2&&g>592)return 1;for(;;){pe=c-m,s[f]+1<E?(R=0,ie=s[f]):s[f]>=E?(R=J[s[f]-E],ie=O[s[f]-E]):(R=96,ie=0),x=1<<c-m,S=1<<h,u=S;do S-=x,o[C+(k>>m)+S]=pe<<24|R<<16|ie|0;while(S!==0);for(x=1<<c-1;k&x;)x>>=1;if(x!==0?(k&=x-1,k+=x):k=0,f++,--L[c]===0){if(c===d)break;c=n[t+s[f]]}if(c>p&&(k&D)!==A){for(m===0&&(m=p),C+=u,h=c-m,y=1<<h;h+m<d&&(y-=L[h+m],!(y<=0));)h++,y<<=1;if(g+=1<<h,e===1&&g>852||e===2&&g>592)return 1;A=k&D,o[A]=p<<24|h<<16|C-r|0}}return k!==0&&(o[C+k]=c-m<<24|64<<16|0),a.bits=p,0};Xa.exports=R0});var Dl=ae((qy,it)=>{"use strict";var Sr=Jo(),gt=Qo(),T0=Wa(),ai=qa(),j0=0,vl=1,Sl=2,{Z_FINISH:Za,Z_BLOCK:z0,Z_TREES:zi,Z_OK:tn,Z_STREAM_END:$0,Z_NEED_DICT:V0,Z_STREAM_ERROR:Je,Z_DATA_ERROR:xl,Z_MEM_ERROR:xr,Z_BUF_ERROR:N0,Z_DEFLATED:Ka}=zt(),Gi=16180,Ya=16181,Ja=16182,Qa=16183,el=16184,tl=16185,nl=16186,il=16187,ol=16188,rl=16189,Ni=16190,It=16191,mr=16192,sl=16193,yr=16194,al=16195,ll=16196,cl=16197,fl=16198,$i=16199,Vi=16200,dl=16201,ul=16202,pl=16203,hl=16204,gl=16205,br=16206,ml=16207,yl=16208,ke=16209,kr=16210,kl=16211,G0=852,H0=592,W0=15,X0=W0,bl=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function q0(){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 nn=e=>{if(!e)return 1;let n=e.state;return!n||n.strm!==e||n.mode<Gi||n.mode>kl?1:0},_l=e=>{if(nn(e))return Je;let n=e.state;return e.total_in=e.total_out=n.total=0,e.msg="",n.wrap&&(e.adler=n.wrap&1),n.mode=Gi,n.last=0,n.havedict=0,n.flags=-1,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new Int32Array(G0),n.distcode=n.distdyn=new Int32Array(H0),n.sane=1,n.back=-1,tn},Al=e=>{if(nn(e))return Je;let n=e.state;return n.wsize=0,n.whave=0,n.wnext=0,_l(e)},Il=(e,n)=>{let t;if(nn(e))return Je;let i=e.state;return n<0?(t=0,n=-n):(t=(n>>4)+5,n<48&&(n&=15)),n&&(n<8||n>15)?Je:(i.window!==null&&i.wbits!==n&&(i.window=null),i.wrap=t,i.wbits=n,Al(e))},Cl=(e,n)=>{if(!e)return Je;let t=new q0;e.state=t,t.strm=e,t.window=null,t.mode=Gi;let i=Il(e,n);return i!==tn&&(e.state=null),i},Z0=e=>Cl(e,X0),wl=!0,wr,vr,K0=e=>{if(wl){wr=new Int32Array(512),vr=new Int32Array(32);let n=0;for(;n<144;)e.lens[n++]=8;for(;n<256;)e.lens[n++]=9;for(;n<280;)e.lens[n++]=7;for(;n<288;)e.lens[n++]=8;for(ai(vl,e.lens,0,288,wr,0,e.work,{bits:9}),n=0;n<32;)e.lens[n++]=5;ai(Sl,e.lens,0,32,vr,0,e.work,{bits:5}),wl=!1}e.lencode=wr,e.lenbits=9,e.distcode=vr,e.distbits=5},Pl=(e,n,t,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(n.subarray(t-r.wsize,t),0),r.wnext=0,r.whave=r.wsize):(o=r.wsize-r.wnext,o>i&&(o=i),r.window.set(n.subarray(t-i,t-i+o),r.wnext),i-=o,i?(r.window.set(n.subarray(t-i,t),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},Y0=(e,n)=>{let t,i,o,r,s,a,l,c,f,u,d,p,h,m,y=0,g,k,x,S,A,D,C,O,E=new Uint8Array(4),L,M,J=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(nn(e)||!e.output||!e.input&&e.avail_in!==0)return Je;t=e.state,t.mode===It&&(t.mode=mr),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=t.hold,f=t.bits,u=a,d=l,O=tn;e:for(;;)switch(t.mode){case Gi:if(t.wrap===0){t.mode=mr;break}for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&2&&c===35615){t.wbits===0&&(t.wbits=15),t.check=0,E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0),c=0,f=0,t.mode=Ya;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",t.mode=ke;break}if((c&15)!==Ka){e.msg="unknown compression method",t.mode=ke;break}if(c>>>=4,f-=4,C=(c&15)+8,t.wbits===0&&(t.wbits=C),C>15||C>t.wbits){e.msg="invalid window size",t.mode=ke;break}t.dmax=1<<t.wbits,t.flags=0,e.adler=t.check=1,t.mode=c&512?rl:It,c=0,f=0;break;case Ya:for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.flags=c,(t.flags&255)!==Ka){e.msg="unknown compression method",t.mode=ke;break}if(t.flags&57344){e.msg="unknown header flags set",t.mode=ke;break}t.head&&(t.head.text=c>>8&1),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0,t.mode=Ja;case Ja:for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.head&&(t.head.time=c),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,E[2]=c>>>16&255,E[3]=c>>>24&255,t.check=gt(t.check,E,4,0)),c=0,f=0,t.mode=Qa;case Qa:for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.head&&(t.head.xflags=c&255,t.head.os=c>>8),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0,t.mode=el;case el:if(t.flags&1024){for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.length=c,t.head&&(t.head.extra_len=c),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0}else t.head&&(t.head.extra=null);t.mode=tl;case tl:if(t.flags&1024&&(p=t.length,p>a&&(p=a),p&&(t.head&&(C=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(i.subarray(r,r+p),C)),t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,t.length-=p),t.length))break e;t.length=0,t.mode=nl;case nl:if(t.flags&2048){if(a===0)break e;p=0;do C=i[r+p++],t.head&&C&&t.length<65536&&(t.head.name+=String.fromCharCode(C));while(C&&p<a);if(t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,C)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=il;case il:if(t.flags&4096){if(a===0)break e;p=0;do C=i[r+p++],t.head&&C&&t.length<65536&&(t.head.comment+=String.fromCharCode(C));while(C&&p<a);if(t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,C)break e}else t.head&&(t.head.comment=null);t.mode=ol;case ol:if(t.flags&512){for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&4&&c!==(t.check&65535)){e.msg="header crc mismatch",t.mode=ke;break}c=0,f=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=It;break;case rl:for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}e.adler=t.check=bl(c),c=0,f=0,t.mode=Ni;case Ni:if(t.havedict===0)return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,V0;e.adler=t.check=1,t.mode=It;case It:if(n===z0||n===zi)break e;case mr:if(t.last){c>>>=f&7,f-=f&7,t.mode=br;break}for(;f<3;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}switch(t.last=c&1,c>>>=1,f-=1,c&3){case 0:t.mode=sl;break;case 1:if(K0(t),t.mode=$i,n===zi){c>>>=2,f-=2;break e}break;case 2:t.mode=ll;break;case 3:e.msg="invalid block type",t.mode=ke}c>>>=2,f-=2;break;case sl:for(c>>>=f&7,f-=f&7;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",t.mode=ke;break}if(t.length=c&65535,c=0,f=0,t.mode=yr,n===zi)break e;case yr:t.mode=al;case al:if(p=t.length,p){if(p>a&&(p=a),p>l&&(p=l),p===0)break e;o.set(i.subarray(r,r+p),s),a-=p,r+=p,l-=p,s+=p,t.length-=p;break}t.mode=It;break;case ll:for(;f<14;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.nlen=(c&31)+257,c>>>=5,f-=5,t.ndist=(c&31)+1,c>>>=5,f-=5,t.ncode=(c&15)+4,c>>>=4,f-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=ke;break}t.have=0,t.mode=cl;case cl:for(;t.have<t.ncode;){for(;f<3;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.lens[J[t.have++]]=c&7,c>>>=3,f-=3}for(;t.have<19;)t.lens[J[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,L={bits:t.lenbits},O=ai(j0,t.lens,0,19,t.lencode,0,t.work,L),t.lenbits=L.bits,O){e.msg="invalid code lengths set",t.mode=ke;break}t.have=0,t.mode=fl;case fl:for(;t.have<t.nlen+t.ndist;){for(;y=t.lencode[c&(1<<t.lenbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(x<16)c>>>=g,f-=g,t.lens[t.have++]=x;else{if(x===16){for(M=g+2;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(c>>>=g,f-=g,t.have===0){e.msg="invalid bit length repeat",t.mode=ke;break}C=t.lens[t.have-1],p=3+(c&3),c>>>=2,f-=2}else if(x===17){for(M=g+3;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=g,f-=g,C=0,p=3+(c&7),c>>>=3,f-=3}else{for(M=g+7;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=g,f-=g,C=0,p=11+(c&127),c>>>=7,f-=7}if(t.have+p>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=ke;break}for(;p--;)t.lens[t.have++]=C}}if(t.mode===ke)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=ke;break}if(t.lenbits=9,L={bits:t.lenbits},O=ai(vl,t.lens,0,t.nlen,t.lencode,0,t.work,L),t.lenbits=L.bits,O){e.msg="invalid literal/lengths set",t.mode=ke;break}if(t.distbits=6,t.distcode=t.distdyn,L={bits:t.distbits},O=ai(Sl,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,L),t.distbits=L.bits,O){e.msg="invalid distances set",t.mode=ke;break}if(t.mode=$i,n===zi)break e;case $i:t.mode=Vi;case Vi:if(a>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,T0(e,d),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=t.hold,f=t.bits,t.mode===It&&(t.back=-1);break}for(t.back=0;y=t.lencode[c&(1<<t.lenbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(k&&(k&240)===0){for(S=g,A=k,D=x;y=t.lencode[D+((c&(1<<S+A)-1)>>S)],g=y>>>24,k=y>>>16&255,x=y&65535,!(S+g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=S,f-=S,t.back+=S}if(c>>>=g,f-=g,t.back+=g,t.length=x,k===0){t.mode=gl;break}if(k&32){t.back=-1,t.mode=It;break}if(k&64){e.msg="invalid literal/length code",t.mode=ke;break}t.extra=k&15,t.mode=dl;case dl:if(t.extra){for(M=t.extra;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.length+=c&(1<<t.extra)-1,c>>>=t.extra,f-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=ul;case ul:for(;y=t.distcode[c&(1<<t.distbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if((k&240)===0){for(S=g,A=k,D=x;y=t.distcode[D+((c&(1<<S+A)-1)>>S)],g=y>>>24,k=y>>>16&255,x=y&65535,!(S+g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=S,f-=S,t.back+=S}if(c>>>=g,f-=g,t.back+=g,k&64){e.msg="invalid distance code",t.mode=ke;break}t.offset=x,t.extra=k&15,t.mode=pl;case pl:if(t.extra){for(M=t.extra;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.offset+=c&(1<<t.extra)-1,c>>>=t.extra,f-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=ke;break}t.mode=hl;case hl:if(l===0)break e;if(p=d-l,t.offset>p){if(p=t.offset-p,p>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=ke;break}p>t.wnext?(p-=t.wnext,h=t.wsize-p):h=t.wnext-p,p>t.length&&(p=t.length),m=t.window}else m=o,h=s-t.offset,p=t.length;p>l&&(p=l),l-=p,t.length-=p;do o[s++]=m[h++];while(--p);t.length===0&&(t.mode=Vi);break;case gl:if(l===0)break e;o[s++]=t.length,l--,t.mode=Vi;break;case br:if(t.wrap){for(;f<32;){if(a===0)break e;a--,c|=i[r++]<<f,f+=8}if(d-=l,e.total_out+=d,t.total+=d,t.wrap&4&&d&&(e.adler=t.check=t.flags?gt(t.check,o,d,s-d):Sr(t.check,o,d,s-d)),d=l,t.wrap&4&&(t.flags?c:bl(c))!==t.check){e.msg="incorrect data check",t.mode=ke;break}c=0,f=0}t.mode=ml;case ml:if(t.wrap&&t.flags){for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&4&&c!==(t.total&4294967295)){e.msg="incorrect length check",t.mode=ke;break}c=0,f=0}t.mode=yl;case yl:O=$0;break e;case ke:O=xl;break e;case kr:return xr;case kl:default:return Je}return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,(t.wsize||d!==e.avail_out&&t.mode<ke&&(t.mode<br||n!==Za))&&Pl(e,e.output,e.next_out,d-e.avail_out)?(t.mode=kr,xr):(u-=e.avail_in,d-=e.avail_out,e.total_in+=u,e.total_out+=d,t.total+=d,t.wrap&4&&d&&(e.adler=t.check=t.flags?gt(t.check,o,d,e.next_out-d):Sr(t.check,o,d,e.next_out-d)),e.data_type=t.bits+(t.last?64:0)+(t.mode===It?128:0)+(t.mode===$i||t.mode===yr?256:0),(u===0&&d===0||n===Za)&&O===tn&&(O=N0),O)},J0=e=>{if(nn(e))return Je;let n=e.state;return n.window&&(n.window=null),e.state=null,tn},Q0=(e,n)=>{if(nn(e))return Je;let t=e.state;return(t.wrap&2)===0?Je:(t.head=n,n.done=!1,tn)},ep=(e,n)=>{let t=n.length,i,o,r;return nn(e)||(i=e.state,i.wrap!==0&&i.mode!==Ni)?Je:i.mode===Ni&&(o=1,o=Sr(o,n,t,0),o!==i.check)?xl:(r=Pl(e,n,t,t),r?(i.mode=kr,xr):(i.havedict=1,tn))};it.exports.inflateReset=Al;it.exports.inflateReset2=Il;it.exports.inflateResetKeep=_l;it.exports.inflateInit=Z0;it.exports.inflateInit2=Cl;it.exports.inflate=Y0;it.exports.inflateEnd=J0;it.exports.inflateGetHeader=Q0;it.exports.inflateSetDictionary=ep;it.exports.inflateInfo="pako inflate (from Nodeca project)"});var El=ae((Zy,Ol)=>{"use strict";function tp(){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}Ol.exports=tp});var Ul=ae((Ky,An)=>{"use strict";var Ct=Dl(),Ll=dr(),Ir=ur(),Cr=Ui(),np=pr(),ip=El(),Ml=Object.prototype.toString,{Z_NO_FLUSH:op,Z_FINISH:rp,Z_OK:li,Z_STREAM_END:_r,Z_NEED_DICT:Ar,Z_STREAM_ERROR:sp,Z_DATA_ERROR:Fl,Z_MEM_ERROR:ap}=zt();function ci(e){this.options=Ll.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let n=this.options;n.raw&&n.windowBits>=0&&n.windowBits<16&&(n.windowBits=-n.windowBits,n.windowBits===0&&(n.windowBits=-15)),n.windowBits>=0&&n.windowBits<16&&!(e&&e.windowBits)&&(n.windowBits+=32),n.windowBits>15&&n.windowBits<48&&(n.windowBits&15)===0&&(n.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new np,this.strm.avail_out=0;let t=Ct.inflateInit2(this.strm,n.windowBits);if(t!==li)throw new Error(Cr[t]);if(this.header=new ip,Ct.inflateGetHeader(this.strm,this.header),n.dictionary&&(typeof n.dictionary=="string"?n.dictionary=Ir.string2buf(n.dictionary):Ml.call(n.dictionary)==="[object ArrayBuffer]"&&(n.dictionary=new Uint8Array(n.dictionary)),n.raw&&(t=Ct.inflateSetDictionary(this.strm,n.dictionary),t!==li)))throw new Error(Cr[t])}ci.prototype.push=function(e,n){let t=this.strm,i=this.options.chunkSize,o=this.options.dictionary,r,s,a;if(this.ended)return!1;for(n===~~n?s=n:s=n===!0?rp:op,Ml.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),r=Ct.inflate(t,s),r===Ar&&o&&(r=Ct.inflateSetDictionary(t,o),r===li?r=Ct.inflate(t,s):r===Fl&&(r=Ar));t.avail_in>0&&r===_r&&t.state.wrap>0&&e[t.next_in]!==0;)Ct.inflateReset(t),r=Ct.inflate(t,s);switch(r){case sp:case Fl:case Ar:case ap:return this.onEnd(r),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||r===_r))if(this.options.to==="string"){let l=Ir.utf8border(t.output,t.next_out),c=t.next_out-l,f=Ir.buf2string(t.output,l);t.next_out=c,t.avail_out=i-c,c&&t.output.set(t.output.subarray(l,l+c),0),this.onData(f)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(r===li&&a===0)){if(r===_r)return r=Ct.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};ci.prototype.onData=function(e){this.chunks.push(e)};ci.prototype.onEnd=function(e){e===li&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ll.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Pr(e,n){let t=new ci(n);if(t.push(e),t.err)throw t.msg||Cr[t.err];return t.result}function lp(e,n){return n=n||{},n.raw=!0,Pr(e,n)}An.exports.Inflate=ci;An.exports.inflate=Pr;An.exports.inflateRaw=lp;An.exports.ungzip=Pr;An.exports.constants=zt()});var Hi=ae((Yy,mt)=>{"use strict";var{Deflate:cp,deflate:fp,deflateRaw:dp,gzip:up}=Ga(),{Inflate:pp,inflate:hp,inflateRaw:gp,ungzip:mp}=Ul(),yp=zt();mt.exports.Deflate=cp;mt.exports.deflate=fp;mt.exports.deflateRaw=dp;mt.exports.gzip=up;mt.exports.Inflate=pp;mt.exports.inflate=hp;mt.exports.inflateRaw=gp;mt.exports.ungzip=mp;mt.exports.constants=yp});var Bl=ae(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.decodeJpeg=_p;var fi=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]),Wi=4017,Xi=799,qi=3406,Zi=2276,Ki=1567,Yi=3784,In=5793,Ji=2896,bp=100,Dr=64*1024*1024,Or=0,Er=Dr;function Cn(e){if(!isFinite(e)||e<0)throw new Error(`Invalid memory allocation size (${e})`);let n=Or+e;if(n>Er){let t=Math.ceil((n-Er)/1024/1024);throw new Error(`Max memory limit exceeded by at least ${t}MB`)}Or=n}function wp(e,n){let t=16;for(;t>0&&!e[t-1];)t--;let i=[{children:[],index:0}],o=0,r=i[0];for(let s=0;s<t;s++){for(let a=0;a<e[s];a++){for(r=i.pop(),r.children[r.index]=n[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<t){let a={children:[],index:0};i.push(a),r.children[r.index]=a.children,r=a}}return i[0].children}function vp(e,n,t,i,o,r,s,a,l){let c=t.mcusPerLine,f=t.progressive,u=n,d=0,p=0;function h(){if(p>0)return p--,d>>p&1;if(d=e[n++],d==255){let B=e[n++];if(B)throw new Error(`unexpected marker: ${(d<<8|B).toString(16)}`)}return p=7,d>>>7}function m(B){if(!B)throw new Error("Missing Huffman table");let $=B;for(;;){if($=$[h()],typeof $=="number")return $;if($===void 0)throw new Error("invalid huffman sequence")}}function y(B){let $=0;for(;B>0;)$=$<<1|h(),B--;return $}function g(B){let $=y(B);return $>=1<<B-1?$:$+(-1<<B)+1}function k(B,$){let ne=m(B.huffmanTableDC),ge=ne===0?0:g(ne);$[0]=B.pred+=ge;let Q=1;for(;Q<64;){let ee=m(B.huffmanTableAC),be=ee&15,Se=ee>>4;if(be===0){if(Se<15)break;Q+=16;continue}Q+=Se;let xe=fi[Q];$[xe]=g(be),Q++}}function x(B,$){let ne=m(B.huffmanTableDC),ge=ne===0?0:g(ne)<<l;$[0]=B.pred+=ge}function S(B,$){$[0]|=h()<<l}let A=0;function D(B,$){if(A>0){A--;return}let ne=r,ge=s;for(;ne<=ge;){let Q=m(B.huffmanTableAC),ee=Q&15,be=Q>>4;if(ee===0){if(be<15){A=y(be)+(1<<be)-1;break}ne+=16;continue}ne+=be;let Se=fi[ne];$[Se]=g(ee)*(1<<l),ne++}}let C=0,O=0;function E(B,$){let ne=r,ge=s,Q=0;for(;ne<=ge;){let ee=fi[ne],be=$[ee]<0?-1:1;switch(C){case 0:let Se=m(B.huffmanTableAC),xe=Se&15;if(Q=Se>>4,xe===0)Q<15?(A=y(Q)+(1<<Q),C=4):(Q=16,C=1);else{if(xe!==1)throw new Error("invalid ACn encoding");O=g(xe),C=Q?2:3}continue;case 1:case 2:$[ee]?$[ee]+=(h()<<l)*be:(Q--,Q===0&&(C=C==2?3:0));break;case 3:$[ee]?$[ee]+=(h()<<l)*be:($[ee]=O<<l,C=0);break;case 4:$[ee]&&($[ee]+=(h()<<l)*be);break}ne++}C===4&&(A--,A===0&&(C=0))}function L(B,$,ne,ge,Q){let ee=ne/c|0,be=ne%c,Se=ee*B.v+ge,xe=be*B.h+Q;B.blocks[Se]!==void 0&&$(B,B.blocks[Se][xe])}function M(B,$,ne){let ge=ne/B.blocksPerLine|0,Q=ne%B.blocksPerLine;B.blocks[ge]!==void 0&&$(B,B.blocks[ge][Q])}let J=i.length,pe,R;f?r===0?R=a===0?x:S:R=a===0?D:E:R=k;let ie=0,he;if(J==1?he=i[0].blocksPerLine*i[0].blocksPerColumn:he=c*t.mcusPerColumn,!isFinite(he)||he<0)throw new Error("Invalid number of MCUs");o||(o=he);let ce,Ce,W;for(;ie<he;){for(let B=0;B<J;B++)i[B].pred=0;if(A=0,J==1){pe=i[0];for(let B=0;B<o&&(M(pe,R,ie),ie++,ie!==he);B++);}else for(let B=0;B<o;B++){for(let $=0;$<J;$++){pe=i[$],ce=pe.h,Ce=pe.v;for(let ne=0;ne<Ce;ne++)for(let ge=0;ge<ce;ge++)L(pe,R,ie,ne,ge)}if(ie++,ie===he)break}if(ie===he)do{if(e[n]===255&&e[n+1]!==0)break;n+=1}while(n<e.length-2);if(p=0,W=e[n]<<8|e[n+1],W<65280)throw new Error("marker was not found");if(W>=65488&&W<=65495)n+=2;else break}return n-u}function Sp(e){let n=[],t=e.blocksPerLine,i=e.blocksPerColumn,o=t<<3,r=new Int32Array(64),s=new Uint8Array(64);function a(l,c,f){let u=e.quantizationTable;if(!u)throw new Error("Missing quantization table");let d=f;for(let p=0;p<64;p++)d[p]=l[p]*u[p];for(let p=0;p<8;++p){let h=8*p;if(d[1+h]==0&&d[2+h]==0&&d[3+h]==0&&d[4+h]==0&&d[5+h]==0&&d[6+h]==0&&d[7+h]==0){let O=In*d[0+h]+512>>10;d[0+h]=O,d[1+h]=O,d[2+h]=O,d[3+h]=O,d[4+h]=O,d[5+h]=O,d[6+h]=O,d[7+h]=O;continue}let m=In*d[0+h]+128>>8,y=In*d[4+h]+128>>8,g=d[2+h],k=d[6+h],x=Ji*(d[1+h]-d[7+h])+128>>8,S=Ji*(d[1+h]+d[7+h])+128>>8,A=d[3+h]<<4,D=d[5+h]<<4,C=m-y+1>>1;m=m+y+1>>1,y=C,C=g*Yi+k*Ki+128>>8,g=g*Ki-k*Yi+128>>8,k=C,C=x-D+1>>1,x=x+D+1>>1,D=C,C=S+A+1>>1,A=S-A+1>>1,S=C,C=m-k+1>>1,m=m+k+1>>1,k=C,C=y-g+1>>1,y=y+g+1>>1,g=C,C=x*Zi+S*qi+2048>>12,x=x*qi-S*Zi+2048>>12,S=C,C=A*Xi+D*Wi+2048>>12,A=A*Wi-D*Xi+2048>>12,D=C,d[0+h]=m+S,d[7+h]=m-S,d[1+h]=y+D,d[6+h]=y-D,d[2+h]=g+A,d[5+h]=g-A,d[3+h]=k+x,d[4+h]=k-x}for(let p=0;p<8;++p){let h=p;if(d[8+h]==0&&d[16+h]==0&&d[24+h]==0&&d[32+h]==0&&d[40+h]==0&&d[48+h]==0&&d[56+h]==0){let O=In*f[p+0]+8192>>14;d[0+h]=O,d[8+h]=O,d[16+h]=O,d[24+h]=O,d[32+h]=O,d[40+h]=O,d[48+h]=O,d[56+h]=O;continue}let m=In*d[0+h]+2048>>12,y=In*d[32+h]+2048>>12,g=d[16+h],k=d[48+h],x=Ji*(d[8+h]-d[56+h])+2048>>12,S=Ji*(d[8+h]+d[56+h])+2048>>12,A=d[24+h],D=d[40+h],C=m-y+1>>1;m=m+y+1>>1,y=C,C=g*Yi+k*Ki+2048>>12,g=g*Ki-k*Yi+2048>>12,k=C,C=x-D+1>>1,x=x+D+1>>1,D=C,C=S+A+1>>1,A=S-A+1>>1,S=C,C=m-k+1>>1,m=m+k+1>>1,k=C,C=y-g+1>>1,y=y+g+1>>1,g=C,C=x*Zi+S*qi+2048>>12,x=x*qi-S*Zi+2048>>12,S=C,C=A*Xi+D*Wi+2048>>12,A=A*Wi-D*Xi+2048>>12,D=C,d[0+h]=m+S,d[56+h]=m-S,d[8+h]=y+D,d[48+h]=y-D,d[16+h]=g+A,d[40+h]=g-A,d[24+h]=k+x,d[32+h]=k-x}for(let p=0;p<64;++p){let h=128+(d[p]+8>>4);c[p]=h<0?0:h>255?255:h}}Cn(o*i*8);for(let l=0;l<i;l++){let c=l<<3;for(let f=0;f<8;f++)n.push(new Uint8Array(o));for(let f=0;f<t;f++){a(e.blocks[l][f],s,r);let u=0,d=f<<3;for(let p=0;p<8;p++){let h=n[c+p];for(let m=0;m<8;m++)h[d+m]=s[u++]}}}return n}function Pt(e){return e<0?0:e>255?255:e}function xp(e){let n={width:0,height:0,adobe:void 0,components:[],exifBuffer:void 0,jfif:void 0},t=bp*1e3*1e3,i=0;function o(){let g=e[i]<<8|e[i+1];return i+=2,g}function r(){let g=o(),k=e.subarray(i,i+g-2);return i+=k.length,k}function s(g){let k=0,x=0;for(let D in g.components)if(g.components.hasOwnProperty(D)){let C=g.components[D];k<C.h&&(k=C.h),x<C.v&&(x=C.v)}let S=Math.ceil(g.samplesPerLine/8/k),A=Math.ceil(g.scanLines/8/x);for(let D in g.components)if(g.components.hasOwnProperty(D)){let C=g.components[D],O=Math.ceil(Math.ceil(g.samplesPerLine/8)*C.h/k),E=Math.ceil(Math.ceil(g.scanLines/8)*C.v/x),L=S*C.h,M=A*C.v,J=M*L,pe=[];Cn(J*256);for(let R=0;R<M;R++){let ie=[];for(let he=0;he<L;he++)ie.push(new Int32Array(64));pe.push(ie)}C.blocksPerLine=O,C.blocksPerColumn=E,C.blocks=pe}g.maxH=k,g.maxV=x,g.mcusPerLine=S,g.mcusPerColumn=A}let a=null,l=null,c,f=0,u=[],d=[],p=[],h=[],m=o(),y=-1;if(m!=65496)throw new Error("SOI not found");for(m=o();m!=65497;){switch(m){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();m===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])}),m===65505&&g[0]===69&&g[1]===120&&g[2]===105&&g[3]===102&&g[4]===0&&(n.exifBuffer=g.subarray(5,g.length)),m===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 k=o()+i-2;for(;i<k;){let x=e[i++];Cn(256);let S=new Int32Array(64);if(x>>4===0)for(let A=0;A<64;A++){let D=fi[A];S[D]=e[i++]}else if(x>>4===1)for(let A=0;A<64;A++){let D=fi[A];S[D]=o()}else throw new Error("DQT: invalid table spec");u[x&15]=S}break}case 65472:case 65473:case 65474:{o(),c={extended:m===65473,progressive:m===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>t){let x=Math.ceil((g-t)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${x}MP`)}let k=e[i++];if(!k)throw new Error("SOF: no components in frame");for(let x=0;x<k;x++){let S=e[i],A=e[i+1]>>4,D=e[i+1]&15;if(A<1||A>4||D<1||D>4)throw new Error(`SOF: invalid sampling factors (${A}x${D})`);let C=e[i+2];c.componentsOrder.push(S),c.components[S]={h:A,v:D,quantizationIdx:C,blocksPerColumn:0,blocksPerLine:0,blocks:[],pred:0},i+=3}s(c),d.push(c);break}case 65476:{let g=o();for(let k=2;k<g;){let x=e[i++],S=new Uint8Array(16),A=0;for(let E=0;E<16;E++,i++)A+=S[E]=e[i];Cn(16+A);let D=new Uint8Array(A);for(let E=0;E<A;E++,i++)D[E]=e[i];k+=17+A;let C=x&15,O=x>>4===0?h:p;O[C]=wp(S,D)}break}case 65501:o(),f=o();break;case 65500:o(),o();break;case 65498:{if(!c)throw new Error("SOS: scan before frame header (SOF)");o();let g=e[i++],k=[];for(let C=0;C<g;C++){let O=e[i++],E=c.components[O];if(!E)throw new Error(`SOS: component ${O} not found in frame`);let L=e[i++];E.huffmanTableDC=h[L>>4],E.huffmanTableAC=p[L&15],k.push(E)}let x=e[i++],S=e[i++],A=e[i++],D=vp(e,i,c,k,f,x,S,A>>4,A&15);i+=D;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(m===224||m==225){if(y!==-1)throw new Error(`first unknown JPEG marker at offset ${y.toString(16)}, second unknown JPEG marker ${m.toString(16)} at offset ${(i-1).toString(16)}`);y=i-1;let g=o();if(e[i+g-2]===255){i+=g-2;break}}throw new Error("unknown JPEG marker "+m.toString(16))}}m=o()}if(d.length!=1)throw new Error("only single frame JPEGs supported");for(let g=0;g<d.length;g++){let k=d[g].components;for(let x of Object.keys(k)){let S=k[+x],A=u[S.quantizationIdx];if(!A)throw new Error(`Missing quantization table ${S.quantizationIdx}`);S.quantizationTable=A}}n.width=c.samplesPerLine,n.height=c.scanLines,n.jfif=a,n.adobe=l,n.components=[];for(let g=0;g<c.componentsOrder.length;g++){let k=c.components[c.componentsOrder[g]];n.components.push({lines:Sp(k),scaleX:k.h/c.maxH,scaleY:k.v/c.maxV})}return n}function kp(e){let n=0,t=!1,i=e.width,o=e.height,r=i*o*e.components.length;Cn(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 f=0;f<i;f++){let u=c[0|f*a.scaleX];s[n++]=u}}break}case 2:{let a=e.components[0],l=e.components[1];for(let c=0;c<o;c++){let f=a.lines[0|c*a.scaleY],u=l.lines[0|c*l.scaleY];for(let d=0;d<i;d++){let p=f[0|d*a.scaleX];s[n++]=p;let h=u[0|d*l.scaleX];s[n++]=h}}break}case 3:{t=e.jfif?!0:e.adobe?!!e.adobe.transformCode:!0;let a=e.components[0],l=e.components[1],c=e.components[2];for(let f=0;f<o;f++){let u=a.lines[0|f*a.scaleY],d=l.lines[0|f*l.scaleY],p=c.lines[0|f*c.scaleY];for(let h=0;h<i;h++){let m,y,g,k,x,S;t?(m=u[0|h*a.scaleX],y=d[0|h*l.scaleX],g=p[0|h*c.scaleX],k=Pt(m+1.402*(g-128)),x=Pt(m-.3441363*(y-128)-.71413636*(g-128)),S=Pt(m+1.772*(y-128))):(k=u[0|h*a.scaleX],x=d[0|h*l.scaleX],S=p[0|h*c.scaleX]),s[n++]=k,s[n++]=x,s[n++]=S}}break}case 4:{if(!e.adobe)throw new Error("Unsupported color mode (4 components)");t=!1,e.adobe&&e.adobe.transformCode&&(t=!0);let a=e.components[0],l=e.components[1],c=e.components[2],f=e.components[3];for(let u=0;u<o;u++){let d=a.lines[0|u*a.scaleY],p=l.lines[0|u*l.scaleY],h=c.lines[0|u*c.scaleY],m=f.lines[0|u*f.scaleY];for(let y=0;y<i;y++){let g,k,x,S,A,D,C;t?(g=d[0|y*a.scaleX],k=p[0|y*l.scaleX],x=h[0|y*c.scaleX],S=m[0|y*f.scaleX],A=255-Pt(g+1.402*(x-128)),D=255-Pt(g-.3441363*(k-128)-.71413636*(x-128)),C=255-Pt(g+1.772*(k-128))):(A=d[0|y*a.scaleX],D=p[0|y*l.scaleX],C=h[0|y*c.scaleX],S=m[0|y*f.scaleX]),s[n++]=255-A,s[n++]=255-D,s[n++]=255-C,s[n++]=255-S}}break}default:throw new Error("Unsupported color mode")}return s}function _p(e,n,t){if(Or=0,Er=t===void 0?Dr:Math.min(Dr,Math.max(0,t)),e.length===0)throw new Error("Empty jpeg buffer");let i=xp(e);Cn(i.width*i.height*4);let o=kp(i),r=n(i.width,i.height),s=r.width,a=r.height,l=r.data,c=0,f=0;switch(i.components.length){case 1:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++];l[f++]=p,l[f++]=p,l[f++]=p,l[f++]=255}break;case 2:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++];l[f++]=p,l[f++]=p,l[f++]=p,l[f++]=h}break;case 3:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++],m=o[c++];l[f++]=p,l[f++]=h,l[f++]=m,l[f++]=255}break;case 4:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++],m=o[c++],y=o[c++],g=255-Pt(p*(1-y/255)+y),k=255-Pt(h*(1-y/255)+y),x=255-Pt(m*(1-y/255)+y);l[f++]=g,l[f++]=k,l[f++]=x,l[f++]=255}break;default:throw new Error("Unsupported color mode")}return r}});var Ot=ae(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.createImageData=G.createCanvas=G.MaskParams=G.LayerMaskFlags=G.ColorSpace=G.largeAdditionalInfoKeys=G.largeAdditionalInfoKeysObserved=G.layerColors=G.toBlendMode=G.fromBlendMode=G.MOCK_HANDLERS=void 0;G.revMap=$l;G.createEnum=Ip;G.offsetForChannel=Cp;G.normalizeLabAB=Pp;G.denormalizeLabAB=Dp;G.clamp=Op;G.hasAlpha=Ep;G.cmykToRgbValues=Qi;G.rgbToCmykValues=Up;G.resetImageData=Bp;G.imageDataToCanvas=Rp;G.decodeBitmap=Tp;G.writeDataRaw=jp;G.writeDataRLE=zp;G.planarToBytes=Vl;G.writeDataRLEBytes=$p;G.writeDataZipWithPrediction=Vp;G.writeDataZipWithoutPrediction=Np;G.createCanvasFromData=Gp;G.initializeCanvas=Xp;var zl=Hi(),Ap=Bl();G.MOCK_HANDLERS=!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","seafoam","indigo","magenta","fuchsia"];G.largeAdditionalInfoKeysObserved=["lnk3","lnkE","pths","extd","extn","FELS","artd"];G.largeAdditionalInfoKeys=["LMsk","Lr16","Lr32","Layr","Mt16","Mt32","Mtrn","Alph","FMsk","lnk2","FEid","FXid","PxSD","cinf",...G.largeAdditionalInfoKeysObserved];function $l(e){let n={};return Object.keys(e).forEach(t=>n[e[t]]=t),n}function Ip(e,n,t){let i=$l(t);return{decode:s=>{let a=s.split(".")[1];if(a&&!i[a]){if(Object.prototype.hasOwnProperty.call(t,a))return a;let l=a.replace(/([A-Z])/g," $1").toLowerCase();if(Object.prototype.hasOwnProperty.call(t,l))return l;throw new Error(`Unrecognized value for enum: '${s}'`)}return i[a]||n},encode:s=>{if(s&&!t[s])throw new Error(`Invalid value for enum: '${s}'`);return`${e}.${s?t[s]:t[n]}`}}}var Rl;(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"})(Rl||(G.ColorSpace=Rl={}));var Tl;(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"})(Tl||(G.LayerMaskFlags=Tl={}));var jl;(function(e){e[e.UserMaskDensity=1]="UserMaskDensity",e[e.UserMaskFeather=2]="UserMaskFeather",e[e.VectorMaskDensity=4]="VectorMaskDensity",e[e.VectorMaskFeather=8]="VectorMaskFeather"})(jl||(G.MaskParams=jl={}));function Cp(e,n){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return n?3:e+1;case-1:return n?4:3;default:return e+1}}function Pp(e,n=1){return e<0?e/(128*n):e/(127*n)}function Dp(e,n=1){return e<0?e*(128*n):e*(127*n)}function Op(e,n,t){return e<n?n:e>t?t:e}function Ep(e){let n=e.width*e.height*4,t=e.data instanceof Float32Array?1:e.data instanceof Uint16Array?65535:255;for(let i=3;i<n;i+=4)if(e.data[i]!==t)return!0;return!1}function Qi(e,n,t,i,o){o[0]=255+e*(-4.387332384609988*e+54.48615194189176*n+18.82290502165302*t+212.25662451639585*i-285.2331026137004)+n*(1.7149763477362134*n-5.6096736904047315*t-17.873870861415444*i-5.497006427196366)+t*(-2.5217340131683033*t-21.248923337353073*i+17.5119270841813)+i*(-21.86122147463605*i-189.48180835922747),o[1]=255+e*(8.841041422036149*e+60.118027045597366*n+6.871425592049007*t+31.159100130055922*i-79.2970844816548)+n*(-15.310361306967817*n+17.575251261109482*t+131.35250912493976*i-190.9453302588951)+t*(4.444339102852739*t+9.8632861493405*i-24.86741582555878)+i*(-20.737325471181034*i-187.80453709719578),o[2]=255+e*(.8842522430003296*e+8.078677503112928*n+30.89978309703729*t-.23883238689178934*i-14.183576799673286)+n*(10.49593273432072*n+63.02378494754052*t+50.606957656360734*i-112.23884253719248)+t*(.03296041114873217*t+115.60384449646641*i-193.58209356861505)+i*(-22.33816807309886*i-180.12613974708367)}var Dt=e=>e<0?0:e>1?1:e;function Fp(e,n,t,i,o){let r=[0,0,0],s=[0,0,0],a=[0,0,0],l=[[0,0,0],[0,0,0],[0,0,0]],c=1e-4;for(let f=0;f<20&&(Qi(o[0],o[1],o[2],i,r),a[0]=r[0]-e,a[1]=r[1]-n,a[2]=r[2]-t,!(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]<1e-6));f++){for(let C=0;C<3;C++){let O=o[C];o[C]=O+c,Qi(o[0],o[1],o[2],i,s),o[C]=O;for(let E=0;E<3;E++)l[E][C]=(s[E]-r[E])/c}let[[u,d,p],[h,m,y],[g,k,x]]=l,S=u*(m*x-y*k)-d*(h*x-y*g)+p*(h*k-m*g);if(Math.abs(S)<1e-12)break;let A=[[m*x-y*k,p*k-d*x,d*y-p*m],[y*g-h*x,u*x-p*g,p*h-u*y],[h*k-m*g,d*g-u*k,u*m-d*h]],D=0;for(let C=0;C<3;C++){let O=-(A[C][0]*a[0]+A[C][1]*a[1]+A[C][2]*a[2])/S,E=Dt(o[C]+O);D+=Math.abs(E-o[C]),o[C]=E}if(D<1e-9)break}return Qi(o[0],o[1],o[2],i,r),(r[0]-e)*(r[0]-e)+(r[1]-n)*(r[1]-n)+(r[2]-t)*(r[2]-t)}function Lp(e,n,t,i){let o=Math.max(e,n,t)/255,r=Math.pow(Dt((1-o-.2)/.8),1.3),s=[0,0,0],a=1/0,l=1/0,c=f=>{s[0]=Dt(1-e/255-f),s[1]=Dt(1-n/255-f),s[2]=Dt(1-t/255-f);let u=Fp(e,n,t,f,s),d=Math.max(u,.1)+Math.abs(f-r)*.01;d<a&&(a=d,l=u,i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=f)};if(c(r),l>.1)for(let f=0;f<=10;f++)c(f/10);if(l>.1){let f=i[3];for(let u=-5;u<=5;u++)c(Dt(f+u/100))}}var eo=33,Lr;function Mp(){if(!Lr){let e=eo,n=new Float32Array(e*e*e*4),t=[0,0,0,0];for(let i=0,o=0;i<e;i++)for(let r=0;r<e;r++)for(let s=0;s<e;s++,o+=4)Lp(i*255/(e-1),r*255/(e-1),s*255/(e-1),t),n[o]=t[0],n[o+1]=t[1],n[o+2]=t[2],n[o+3]=t[3];Lr=n}return Lr}function Up(e,n,t,i){let o=Mp(),r=eo-1,s=Dt(e)*r,a=Dt(n)*r,l=Dt(t)*r,c=Math.min(r-1,Math.floor(s)),f=Math.min(r-1,Math.floor(a)),u=Math.min(r-1,Math.floor(l)),d=s-c,p=a-f,h=l-u;i[0]=i[1]=i[2]=i[3]=0;for(let m=0;m<8;m++){let y=m>>2,g=m>>1&1,k=m&1,x=(y?d:1-d)*(g?p:1-p)*(k?h:1-h),S=(((c+y)*eo+f+g)*eo+u+k)*4;i[0]+=x*o[S],i[1]+=x*o[S+1],i[2]+=x*o[S+2],i[3]+=x*o[S+3]}}function Bp({data:e}){let n=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let t=0,i=e.length|0;t<i;t=t+4|0)e[t+0]=0,e[t+1]=0,e[t+2]=0,e[t+3]=n}function Rp(e){let n=(0,G.createCanvas)(e.width,e.height),t;if(e.data instanceof Uint8ClampedArray)t=e;else{t=(0,G.createImageData)(e.width,e.height);let i=e.data,o=t.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 n.getContext("2d").putImageData(t,0,0),n}function Tp(e,n,t,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<t;){let l=e[s++];for(let c=0;c<8&&a<t;c++,a++,r+=4){let f=l&128?0:255;l=l<<1,n[r+0]=f,n[r+1]=f,n[r+2]=f,n[r+3]=255}}}function jp(e,n,t,i){if(!t||!i)return;let o=new Uint8Array(t*i);for(let r=0;r<o.length;r++)o[r]=e.data[r*4+n];return o}function zp(e,{data:n,width:t,height:i},o,r){if(!t||!i)return e.subarray(0,0);let s=4*t|0,a=0,l=o.length*(r?4:2)*i|0;for(let c of o)for(let f=0,u=c|0;f<i;f++){let d=f*s|0,p=d+s|0,h=p+c-4|0,m=h-4|0,y=l;for(u=d+c|0;u<p;u=u+4|0)if(u<m){let k=n[u];u=u+4|0;let x=n[u];u=u+4|0;let S=n[u];if(k===x&&k===S){let A=3;for(;A<128&&u<h&&n[u+4|0]===k;)A=A+1|0,u=u+4|0;e[l++]=1-A,e[l++]=k}else{let A=l,D=!0,C=1;for(e[l++]=0,e[l++]=k;u<h&&C<128;)if(u=u+4|0,k=x,x=S,S=n[u],k===x&&k===S){u=u-12|0,D=!1;break}else C++,e[l++]=k;D&&(C<127?(e[l++]=x,e[l++]=S,C+=2):C<128?(e[l++]=x,C++,u=u-4|0):u=u-8|0),e[A]=C-1}}else u===h?(e[l++]=0,e[l++]=n[u]):(e[l++]=1,e[l++]=n[u],u=u+4|0,e[l++]=n[u]);if(l>e.length)throw new Error(`RLE buffer too small (${e.length})`);let g=l-y;r&&(e[a++]=g>>24&255,e[a++]=g>>16&255),e[a++]=g>>8&255,e[a++]=g&255}return e.subarray(0,l)}function Vl(e){if(e instanceof Uint8Array)return e;let n=new Uint8Array(e.byteLength),t=new DataView(n.buffer);if(e instanceof Uint16Array)for(let i=0;i<e.length;i++)t.setUint16(i*2,e[i],!1);else for(let i=0;i<e.length;i++)t.setFloat32(i*4,e[i],!1);return n}function $p(e,n,t,i){let o=i?4:2,r=new Uint8Array(t*(o+n+Math.ceil(n/128))),s=o*t;for(let a=0;a<t;a++){let l=s,c=a*n,f=c+n,u=c;for(;u<f;){let p=1;for(;u+p<f&&p<128&&e[u+p]===e[u];)p++;if(p>1)r[s++]=257-p,r[s++]=e[u],u+=p;else{let h=s++,m=0;for(;u<f&&m<128&&!(u+2<f&&e[u]===e[u+1]&&e[u]===e[u+2]);)r[s++]=e[u++],m++;r[h]=m-1}}let d=s-l;for(let p=0;p<o;p++)r[a*o+p]=d>>>(o-p-1)*8&255}return r.subarray(0,s)}function Vp(e,n,t){let i;if(e instanceof Uint8Array){i=new Uint8Array(n*t);for(let o=0,r=0;o<t;o++)for(let s=0,a=0;s<n;s++,r++)i[r]=e[r]-a,a=e[r]}else if(e instanceof Uint16Array){i=new Uint8Array(n*t*2);for(let o=0,r=0;o<t;o++)for(let s=0,a=0;s<n;s++,r++){let l=e[r]-a&65535;i[r*2]=l>>8,i[r*2+1]=l&255,a=e[r]}}else{let o=n*4,r=Vl(e);i=new Uint8Array(o*t);for(let s=0;s<t;s++){let a=s*o;for(let l=0;l<n;l++)for(let c=0;c<4;c++)i[a+c*n+l]=r[a+l*4+c];for(let l=o-1;l>0;l--)i[a+l]-=i[a+l-1]}}return(0,zl.deflate)(i)}function Np({data:e,width:n,height:t},i){let o=n*t,r=new Uint8Array(o),s=[],a=0;for(let l of i){for(let f=0,u=l;f<o;f++,u+=4)r[f]=e[u];let c=(0,zl.deflate)(r);s.push(c),a+=c.byteLength}if(s.length>0){let l=new Uint8Array(a),c=0;for(let f of s)l.set(f,c),c+=f.byteLength;return l}else return s[0]}function Gp(e,n){let t=(0,G.createCanvas)(100,100);try{let i=t.getContext("2d"),o=(0,Ap.decodeJpeg)(e,(r,s)=>i.createImageData(r,s),n.totalMemoryLimit);t.width=o.width,t.height=o.height,i.putImageData(o,0,0),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=o.width*o.height*4)}catch(i){n.log("JPEG decompression error",i.message)}return t}var Hp=()=>{throw new Error("Canvas not initialized, use initializeCanvas method to set up createCanvas method")};G.createCanvas=Hp;var Mr,Wp=(e,n)=>(Mr||(Mr=(0,G.createCanvas)(1,1)),Mr.getContext("2d").createImageData(e,n));G.createImageData=Wp;typeof document<"u"&&(G.createCanvas=(e,n)=>{let t=document.createElement("canvas");return t.width=e,t.height=n,t});function Xp(e,n){G.createCanvas=e,G.createImageData=n||G.createImageData}});var no=ae(to=>{"use strict";to.byteLength=Zp;to.toByteArray=Yp;to.fromByteArray=eh;var yt=[],Qe=[],qp=typeof Uint8Array<"u"?Uint8Array:Array,Ur="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(on=0,Nl=Ur.length;on<Nl;++on)yt[on]=Ur[on],Qe[Ur.charCodeAt(on)]=on;var on,Nl;Qe[45]=62;Qe[95]=63;function Gl(e){var n=e.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=n);var i=t===n?0:4-t%4;return[t,i]}function Zp(e){var n=Gl(e),t=n[0],i=n[1];return(t+i)*3/4-i}function Kp(e,n,t){return(n+t)*3/4-t}function Yp(e){var n,t=Gl(e),i=t[0],o=t[1],r=new qp(Kp(e,i,o)),s=0,a=o>0?i-4:i,l;for(l=0;l<a;l+=4)n=Qe[e.charCodeAt(l)]<<18|Qe[e.charCodeAt(l+1)]<<12|Qe[e.charCodeAt(l+2)]<<6|Qe[e.charCodeAt(l+3)],r[s++]=n>>16&255,r[s++]=n>>8&255,r[s++]=n&255;return o===2&&(n=Qe[e.charCodeAt(l)]<<2|Qe[e.charCodeAt(l+1)]>>4,r[s++]=n&255),o===1&&(n=Qe[e.charCodeAt(l)]<<10|Qe[e.charCodeAt(l+1)]<<4|Qe[e.charCodeAt(l+2)]>>2,r[s++]=n>>8&255,r[s++]=n&255),r}function Jp(e){return yt[e>>18&63]+yt[e>>12&63]+yt[e>>6&63]+yt[e&63]}function Qp(e,n,t){for(var i,o=[],r=n;r<t;r+=3)i=(e[r]<<16&16711680)+(e[r+1]<<8&65280)+(e[r+2]&255),o.push(Jp(i));return o.join("")}function eh(e){for(var n,t=e.length,i=t%3,o=[],r=16383,s=0,a=t-i;s<a;s+=r)o.push(Qp(e,s,s+r>a?a:s+r));return i===1?(n=e[t-1],o.push(yt[n>>2]+yt[n<<4&63]+"==")):i===2&&(n=(e[t-2]<<8)+e[t-1],o.push(yt[n>>10]+yt[n>>4&63]+yt[n<<2&63]+"=")),o.join("")}});var Br=ae(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.stringLengthInBytes=Wl;Pn.encodeStringTo=Xl;Pn.encodeString=ih;Pn.decodeString=oh;function th(e){return(e&4294967168)===0?1:(e&4294965248)===0?2:(e&4294901760)===0?3:4}function Hl(e,n){let t=e.charCodeAt(n);if(t<55296||t>57343)return t;if(t<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);if(i>=56320&&i<=57343)return((t&1023)<<10)+(i&1023)+65536}return 65533}function Wl(e){let n=0;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);i<128?n+=1:i<2048?n+=2:Hl(e,t)>65535?(n+=4,t++):n+=3}return n}function nh(e,n,t){let i=th(t);switch(i){case 1:e[n]=t;break;case 2:e[n]=t>>6&31|192,e[n+1]=t&63|128;break;case 3:e[n]=t>>12&15|224,e[n+1]=t>>6&63|128,e[n+2]=t&63|128;break;default:e[n]=t>>18&7|240,e[n+1]=t>>12&63|128,e[n+2]=t>>6&63|128,e[n+3]=t&63|128;break}return i}function Xl(e,n,t){for(let i=0;i<t.length;i++){let o=t.charCodeAt(i);if(o<128)e[n++]=o;else{let r=Hl(t,i);r>65535&&i++,n+=nh(e,n,r)}}return n}function ih(e){if(e.length>1e3&&typeof TextEncoder<"u")return new TextEncoder().encode(e);let n=new Uint8Array(Wl(e));return Xl(n,0,e),n}function oh(e){let n=[];function t(l){l>65535&&(l-=65536,n.push(String.fromCharCode(l>>>10&1023|55296)),l=56320|l&1023),n.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?t(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):t(65533);continue}if(c<s||c>a){i=0,r=0,o=0,s=128,a=191,t(65533),l--;continue}s=128,a=191,i=i<<6|c&63,o++,o===r&&(t(i),i=0,r=0,o=0)}return r!==0&&t(65533),n.join("")}});var ao=ae(_=>{"use strict";var rh=_&&_.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(_,"__esModule",{value:!0});_.FlCl=_.ExtR=_.ExtT=_.DfsM=_.blurType=_.Lns=_.MztT=_.Chnl=_.Dstr=_.ZZTy=_.Wvtp=_.SphM=_.RplS=_.Cnvr=_.UndA=_.DspM=_.SmBQ=_.SmBM=_.BlrQ=_.BlrM=_.strokeStyleLineAlignment=_.strokeStyleLineJoinType=_.strokeStyleLineCapType=_.ESliceBGColorType=_.ESliceOrigin=_.ESliceVertAlign=_.ESliceHorzAlign=_.ESliceType=_.FrFl=_.FStl=_.ClrS=_.Clry=_.gradientInterpolationMethodType=_.stdTrackID=_.animInterpStyleEnum=_.GrdT=_.IGSr=_.BETE=_.BESs=_.bvlT=_.BESl=_.BlnM=_.warpStyle=_.Annt=_.Ornt=_.textGridding=_.outputSettingsRoot=_.layerStateRoot=_.cameraRawFilterKeyTypes=_.cameraRawFilterClassID=void 0;_.patternColorHandling=_.presetKindType=_.prjM=_.FlMd=_.IntC=_.IntE=_.Drct=_.WndM=_.CntE=void 0;_.readAsciiStringOrClassId=bt;_.writeAsciiStringOrClassId=et;_.readDescriptorStructure=jr;_.writeDescriptorStructure=zr;_.pathSelectionStateToReference=hh;_.writeClassStructure=Dn;_.readVersionAndDescriptor=mh;_.writeVersionAndDescriptor=yh;_.horzVrtcToXY=oo;_.xyToHorzVrtc=ro;_.descBoundsToBounds=bh;_.boundsToDescBounds=wh;_.serializeEffects=ac;_.parseEffects=lc;_.parseTrackList=vh;_.serializeTrackList=Sh;_.parseVectorContent=xh;_.serializeVectorContent=kh;_.parseColor=sn;_.serializeColor=an;_.parseAngle=On;_.parsePercent=Pe;_.parsePercentOrAngle=yc;_.parseUnits=wt;_.parseUnitsOrNumber=bc;_.parseUnitsToNumber=Ch;_.unitsAngle=ln;_.unitsPercent=rt;_.unitsPercentF=St;_.unitsValue=vt;_.frac=Ph;var V=Ot(),te=st(),Z=En();function sh(e){let n={};return Object.keys(e).forEach(t=>n[e[t]]=t),n}var di={"#Ang":"Angle","#Rsl":"Density","#Rlt":"Distance","#Nne":"None","#Prc":"Percent","#Pxl":"Pixels","#Mlm":"Millimeters","#Pnt":"Points",RrPi:"Picas",RrIn:"Inches",RrCm:"Centimeters"},io=sh(di);function F(e,n){return{name:e,classID:n}}var X=F("","null"),Rr=!1,ec={strokeStyleContent:F("","solidColorLayer"),printProofSetup:F(Rr?"\u6821\u6837\u8BBE\u7F6E":"Proof Setup","proofSetup"),Grad:F(Rr?"\u6E10\u53D8":"Gradient","Grdn"),Trnf:F(Rr?"\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:X,duration:X,workInTime:X,workOutTime:X,audioClipGroupList:X,bounds:F("","Rctn"),customEnvelopeWarp:F("","customEnvelopeWarp"),warp:F("","warp"),"Sz ":F("","Pnt "),origin:F("","Pnt "),autoExpandOffset:F("","Pnt "),keyOriginShapeBBox:F("","unitRect"),Vrsn:X,psVersion:X,docDefaultNewArtboardBackgroundColor:F("","RGBC"),artboardRect:F("","classFloatRect"),framedGroupRect:F("","classFloatRect"),keyOriginRRectRadii:F("","radii"),keyOriginBoxCorners:X,rectangleCornerA:F("","Pnt "),rectangleCornerB:F("","Pnt "),rectangleCornerC:F("","Pnt "),rectangleCornerD:F("","Pnt "),keyOriginPolyPreviousTightBoxCorners:X,keyOriginPolyTrueRectCorners:X,keyOriginLineStart:F("","Pnt "),keyOriginLineEnd:F("","Pnt "),compInfo:X,quiltWarp:F("","quiltWarp"),generatorSettings:X,crema:X,FrIn:X,blendOptions:X,FXRf:X,Lefx:X,time:X,animKey:X,timeScope:X,inTime:X,outTime:X,sheetStyle:X,translation:X,Skew:X,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:X,FXRefPoint:X,vectorMask:X,layerSpecific:X,LSpc:X,textLayerSettings:F("","warp"),placedLayerSettings:X,IMsk:X,VMsk:X,TxtC:X,ClMg:F("","ClMg"),interpretation:F("","footageInterpretation"),bgColor:F("","NativeQuad")},tc={"Crv ":F("","CrPt"),Clrs:F("","Clrt"),Trns:F("","TrnS"),keyDescriptorList:X,keyRootDescriptorList:X,solidFillMulti:F("","SoFi"),gradientFillMulti:F("","GrFl"),dropShadowMulti:F("","DrSh"),innerShadowMulti:F("","IrSh"),frameFXMulti:F("","FrFX"),FrIn:X,FSts:X,LaSt:X,sheetTimelineOptions:X,trackList:F("","animationTrack"),globalTrackList:F("","animationTrack"),keyList:X,audioClipGroupList:X,audioClipList:X,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:X,list:X,Adjs:F("","CrvA"),vertices:F("","Pnt "),warpedVertices:F("","Pnt "),quads:F("","quadIndices")},ql={TEXT:["Txt ","printerName","Nm ","Idnt","blackAndWhitePresetFileName","LUT3DFileName","exportOption","scaleSettings","BackgroundImagePath","ImageSubfolderName","SavedIteratedName","presetFileName","curvesPresetFileName","mixerPresetFileName","placed","description","reason","artboardPresetName","json","clipID","relPath","fullPath","mediaDescriptor","Msge","altTag","url","cellText","preset","KnNm","FPth","comment","originalPath","Bk ","pathUnicodeName"],tdta:["EngineData","LUT3DFileData","indexArray","originalVertexArray","deformedVertexArray","LqMe","bookKey"],long:["TextIndex","RndS","Mdpn","Smth","Lctn","strokeStyleVersion","LaID","Vrsn","Cnt ","bookID","cropRectBottom","cropRectLeft","cropRectRight","cropRectTop","Version","BackgroundColorBlue","BackgroundColorGreen","BackgroundColorRed","BackgroundColorState","AttributeCase","Encoding","DuplicateFileNameBehavior","ImageMapLocation","ImageMapType","Indent","LineEndings","SpacersEmptyCells","SpacersHorizontal","SpacersVertical","StylesFormat","TDWidthHeight","TagCase","ColorPolicy","MetadataPolicy","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","pixelSourceType","framedGroupType","keyOriginPolySides","keyOriginLineArrConc","noisePreSeed","associatedLayer","placedLayerCompID","VAlign"],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","pathSymmetryMode","interpretAlpha","knockout","TxPT","TxPR"],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","Lnkd","showAlteredVideo","lightingOn","LockPPI","keyOriginLineArrowSt","keyOriginLineArrowEnd","Expn","substitutesUsed","blendClipped","blendInterior","TxMP"],doub:["warpValue","warpPerspective","warpPerspectiveOther","Intr","Wdth","Hght","Gmm ","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","stylization","cleanliness","brushScale","microBrush","specularity","PreferredResolution","FrGL","keyOriginLineWeight","keyOriginLineArrWdth","keyOriginLineArrLngth","keyOriginPolyPixelHSF","keyOriginPolyCornerRadius","gradientAspectRatio"],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","fillOpacity","keyOriginPolyStarRatio"],VlLs:["Crv ","Clrs","Mnm ","Mxm ","Trns","pathList","keyRootDescriptorList","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","vertices","warpedVertices","quads","indices","Mpng","textLayerSettingsWarpRect"],ObAr:["meshPoints","quiltSliceX","quiltSliceY"],"obj ":["null","Chnl"],"Pth ":["DspF"],alis:["alis"]},ah=["Rd ","Grn ","Bl ","Yllw","Ylw ","Cyn ","Mgnt","Blck","Gry ","Lmnc","A ","B "],lh=["Grsc","LbCl","GRYC","LABC"];_.cameraRawFilterClassID="Adobe Camera Raw Filter";_.cameraRawFilterKeyTypes={CrVe:"TEXT",PrVN:"long",PrVe:"long",WBal:"enum",Ex12:"doub",ShpR:"doub","Crv ":"VlLs",CrvR:"VlLs",CrvG:"VlLs",CrvB:"VlLs"};function nc(e){if(typeof e=="boolean")return"bool";if(typeof e=="number"&&!Number.isInteger(e))return"doub";if(Array.isArray(e))return"VlLs";if(e&&typeof e=="object"){if(typeof e._classID=="string")return"Objc";if(typeof e.classID=="string")return"type";if(typeof e.low=="number"&&typeof e.high=="number")return"comp";if(typeof e.units=="string"&&typeof e.value=="number")return"UntF"}}var ic={"Mnm ":"long","Mxm ":"long",HtmlFileNameComponents:"long",SavingFileNameComponents:"long",SliceFileNameComponents:"long",Inpt:"long",Otpt:"long",FrLs:"long",strokeStyleLineDashSet:"UntF",Trnf:"doub",nonAffineTransform:"doub",keyDescriptorList:"Objc",keyRootDescriptorList:"Objc",pathList:"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",textLayerSettingsWarpRect:"doub",Chnl:"enum",indices:"long",Mpng:"long"},so={};for(let e of Object.keys(ql))for(let n of ql[e])so[n]=e;for(let e of Object.keys(ec))so[e]||(so[e]="Objc");for(let e of Object.keys(tc))ic[e]="Objc";var Tr="PixelSource.origin";_.layerStateRoot="layerState";function ch(e,n,t,i){return e==="presetKind"?typeof n=="string"?"enum":"long":e==="null"&&t==="slices"?"TEXT":e==="groupID"?t==="slices"?"long":"TEXT":e==="Sz "?"Wdth"in n?"Objc":"units"in n?"UntF":"doub":e==="Type"?typeof n=="string"?"enum":"long":e==="AntA"?typeof n=="string"?"enum":"bool":(e==="Hrzn"||e==="Vrtc")&&(i.Type==="keyType.Pstn"||i._classID==="Ofst"||t===Tr)?"long":e==="Hrzn"||e==="Vrtc"||e==="Top "||e==="Left"||e==="Btom"||e==="Rght"?t==="slices"?"long":typeof n=="number"?"doub":"UntF":e==="Vrsn"?typeof n=="number"?"long":"Objc":e==="Rd "||e==="Grn "||e==="Bl "?t==="artd"?"long":"doub":e==="Trnf"?Array.isArray(n)?"VlLs":"Objc":e==="alpha"&&t==="slices"?"long":(e==="Inpt"||e==="Otpt")&&i._classID==="HsbP"?"enum":(e==="Inpt"||e==="Otpt")&&i._classID==="LvlA"?"VlLs":e==="Intr"&&typeof n=="boolean"?"bool":e==="PgPs"?"enum":e==="LghD"&&i._classID==="oilPaint"?"long":so[e]}function bt(e){let n=(0,te.readInt32)(e);return(0,te.readAsciiString)(e,n||4)}function et(e,n){if(n.length===4&&n!=="warp"&&n!=="time"&&n!=="hold"&&n!=="list"&&n!=="json")(0,Z.writeInt32)(e,0),(0,Z.writeSignature)(e,n);else{(0,Z.writeInt32)(e,n.length);for(let t=0;t<n.length;t++)(0,Z.writeUint8)(e,n.charCodeAt(t))}}function jr(e,n){let t=rn(e),i=n?{_name:t.name,_classID:t.classID}:{},o=(0,te.readUint32)(e);for(let r=0;r<o;r++){let s=bt(e),a=(0,te.readSignature)(e),l=oc(e,a,n);i[s]=l}return i}_.outputSettingsRoot="outputSettings";function zr(e,n,t,i,o){var r;e.logMissingFeatures&&!t&&e.log("Missing classId for: ",n,t,i),(0,Z.writeUnicodeStringWithPadding)(e,n),o===_.outputSettingsRoot&&t==="null"?((0,Z.writeInt32)(e,4),(0,Z.writeSignature)(e,t)):et(e,t);let a=Object.keys(i).filter(l=>l!=="_name"&&l!=="_classID"&&i[l]!==void 0);(0,Z.writeUint32)(e,a.length);for(let l of a){let c=ch(l,i[l],o,i),f=o,u=ec[l];t===_.cameraRawFilterClassID&&(c=(r=_.cameraRawFilterKeyTypes[l])!==null&&r!==void 0?r:"long",f=_.cameraRawFilterClassID),l==="bounds"&&o==="text"?u=F("","bounds"):l==="origin"?(c=o==="slices"?"enum":"Objc",t==="PixelSource"&&(u=X,f=Tr)):l==="Ofst"&&o===_.layerStateRoot&&typeof i[l].Hrzn=="number"?(u=X,f=Tr):(l==="Cyn "||l==="Mgnt"||l==="Ylw "||l==="Blck")&&i._classID==="CMYC"?c="doub":/^PN[a-z][a-z]$/.test(l)?c="TEXT":/^PT[a-z][a-z]$/.test(l)?c="long":/^PF[a-z][a-z]$/.test(l)||(l==="Rds "||l==="Thsh")&&typeof i[l]=="number"&&i._classID==="SmrB"?c="doub":l==="ClSz"||l==="Rds "||l==="Amnt"?c=typeof i[l]=="number"?"long":"UntF":(l==="sdwM"||l==="hglM")&&typeof i[l]=="string"||l==="blur"&&typeof i[l]=="string"?c="enum":l==="Hght"&&typeof i[l]=="number"&&i._classID==="Embs"||l==="Angl"&&typeof i[l]=="number"&&(i._classID==="Embs"||i._classID==="smartSharpen"||i._classID==="Twrl"||i._classID==="MtnB")?c="long":l==="Angl"&&typeof i[l]=="number"?c="doub":l==="bounds"&&o==="slices"?(c="Objc",u=F("","Rct1")):l==="Scl "?typeof i[l]=="object"&&"Hrzn"in i[l]?(c="Objc",u=X):typeof i[l]=="number"?c="long":c="UntF":l==="audioClipGroupList"&&a.length===1?c="VlLs":(l==="Strt"||l==="Brgh")&&"H "in i?c="doub":l==="Wdth"&&typeof i[l]=="object"?c="UntF":l==="Ofst"&&typeof i[l]=="number"?c="long":l==="Strt"&&typeof i[l]=="object"?(c="Objc",u=X):ah.indexOf(l)!==-1?c=t==="RGBC"&&o!=="artd"||lh.indexOf(t)!==-1?"doub":"long":l==="profile"?c=t==="printOutput"||t==="proofSetup"?"TEXT":"tdta":l==="alis"&&typeof i[l]=="string"?c=/[^\x00-\xff]/.test(i[l])?"TEXT":"alis":l==="strokeStyleContent"?i[l]["Clr "]?u=F("","solidColorLayer"):i[l].Grad?u=F("","gradientLayer"):i[l].Ptrn?u=F("","patternLayer"):e.logMissingFeatures&&e.log("Invalid strokeStyleContent value",i[l]):l==="bounds"&&o==="quiltWarp"&&(u=F("","classFloatRect")),u&&u.classID==="RGBC"&&("H "in i[l]?u={classID:"HSBC",name:""}:"Cyn "in i[l]?u={classID:"CMYC",name:""}:"Lmnc"in i[l]?u={classID:"LbCl",name:""}:"Gry "in i[l]&&(u={classID:"Grsc",name:""})),c||(c=nc(i[l])),et(e,l),(0,Z.writeSignature)(e,c||"long"),rc(e,c||"long",i[l],l,u,f),e.logMissingFeatures&&!c&&e.log(`Missing descriptor field type for: '${l}' in`,i)}}function oc(e,n,t){switch(n){case"obj ":return ph(e);case"Objc":case"GlbO":return jr(e,t);case"VlLs":{let i=(0,te.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=(0,te.readSignature)(e);o.push(oc(e,s,t))}return o}case"doub":return(0,te.readFloat64)(e);case"UntF":{let i=(0,te.readSignature)(e),o=(0,te.readFloat64)(e);if(!di[i])throw new Error(`Invalid units: ${i}`);return{units:di[i],value:o}}case"UnFl":{let i=(0,te.readSignature)(e),o=(0,te.readFloat32)(e);if(!di[i])throw new Error(`Invalid units: ${i}`);return{units:di[i],value:o}}case"TEXT":return(0,te.readUnicodeString)(e);case"enum":{let i=bt(e),o=bt(e);return`${i}.${o}`}case"long":return(0,te.readInt32)(e);case"comp":{let i=(0,te.readUint32)(e);return{low:(0,te.readUint32)(e),high:i}}case"bool":return!!(0,te.readUint8)(e);case"type":case"GlbC":return rn(e);case"alis":{let i=(0,te.readInt32)(e);return(0,te.readAsciiString)(e,i)}case"tdta":{let i=(0,te.readInt32)(e);if(i>e.view.byteLength-e.offset)throw new Error(`Invalid tdta length: ${i}`);return(0,te.readBytes)(e,i)}case"ObAr":{(0,te.readInt32)(e),(0,te.readUnicodeString)(e),bt(e);let i=(0,te.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=bt(e);(0,te.readSignature)(e),(0,te.readSignature)(e);let a=(0,te.readInt32)(e),l=[];for(let c=0;c<a;c++)l.push((0,te.readFloat64)(e));o.push({type:s,values:l})}return o}case"Pth ":{(0,te.readInt32)(e);let i=(0,te.readSignature)(e);(0,te.readInt32LE)(e);let o=(0,te.readInt32LE)(e),r=(0,te.readUnicodeStringWithLengthLE)(e,o);return{sig:i,path:r}}default:throw new Error(`Invalid TySh descriptor OSType: ${n} at ${e.offset.toString(16)}`)}}var fh={meshPoints:"rationalPoint",quiltSliceX:"UntF",quiltSliceY:"UntF"};function rc(e,n,t,i,o,r){var s;switch(n){case"obj ":gh(e,i,t);break;case"Objc":case"GlbO":{if(typeof t!="object")throw new Error(`Invalid struct value: ${JSON.stringify(t)}, key: ${i}`);if(!o&&!t._classID)throw new Error(`Missing ext type for: '${i}' (${JSON.stringify(t)})`);let a=t._name||o?.name||"",l=t._classID||o.classID;zr(e,a,l,t,r);break}case"VlLs":if(!Array.isArray(t))throw new Error(`Invalid list value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,t.length);for(let a=0;a<t.length;a++){let l=r===_.cameraRawFilterClassID?"long":(s=ic[i])!==null&&s!==void 0?s:nc(t[a]);(0,Z.writeSignature)(e,l||"long"),rc(e,l||"long",t[a],`${i}[]`,tc[i],r),e.logMissingFeatures&&!l&&e.log(`Missing descriptor array type for: '${i}' in`,t)}break;case"doub":if(typeof t!="number")throw new Error(`Invalid number value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeFloat64)(e,t);break;case"UntF":if(!io[t.units])throw new Error(`Invalid units: ${t.units} in ${i}`);(0,Z.writeSignature)(e,io[t.units]),(0,Z.writeFloat64)(e,t.value);break;case"UnFl":if(!io[t.units])throw new Error(`Invalid units: ${t.units} in ${i}`);(0,Z.writeSignature)(e,io[t.units]),(0,Z.writeFloat32)(e,t.value);break;case"TEXT":(0,Z.writeUnicodeStringWithPadding)(e,t);break;case"enum":{if(typeof t!="string")throw new Error(`Invalid enum value: ${JSON.stringify(t)}, key: ${i}`);let[a,l]=t.split(".");et(e,a),et(e,l);break}case"long":if(typeof t!="number")throw new Error(`Invalid integer value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,Math.round(t));break;case"comp":if(!t||typeof t!="object")throw new Error(`Invalid large integer value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUint32)(e,t.high>>>0),(0,Z.writeUint32)(e,t.low>>>0);break;case"bool":if(typeof t!="boolean")throw new Error(`Invalid boolean value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUint8)(e,t?1:0);break;case"type":case"GlbC":if(!t||typeof t!="object")throw new Error(`Invalid class value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUnicodeStringWithPadding)(e,t.name||""),et(e,t.classID);break;case"alis":{if(typeof t!="string")throw new Error(`Invalid alias value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,t.length);for(let a=0;a<t.length;a++)(0,Z.writeUint8)(e,t.charCodeAt(a)&255);break}case"tdta":(0,Z.writeInt32)(e,t.byteLength),(0,Z.writeBytes)(e,t);break;case"ObAr":{(0,Z.writeInt32)(e,16),(0,Z.writeUnicodeStringWithPadding)(e,"");let a=fh[i];if(!a)throw new Error(`Not implemented ObArType for: ${i}`);et(e,a),(0,Z.writeInt32)(e,t.length);for(let l=0;l<t.length;l++){et(e,t[l].type),(0,Z.writeSignature)(e,"UnFl"),(0,Z.writeSignature)(e,"#Pxl"),(0,Z.writeInt32)(e,t[l].values.length);for(let c=0;c<t[l].values.length;c++)(0,Z.writeFloat64)(e,t[l].values[c])}break}case"Pth ":{let a=t.path+"\0",l=12+a.length*2;(0,Z.writeInt32)(e,l),(0,Z.writeSignature)(e,t.sig),(0,Z.writeInt32LE)(e,l),(0,Z.writeInt32LE)(e,a.length),(0,Z.writeUnicodeStringWithoutLengthLE)(e,a);break}default:throw new Error(`Not implemented descriptor OSType: ${n}`)}}var dh=["prop","Clss","Enmr","rele","Idnt","indx","name"];function uh(e){return!!e&&typeof e=="object"&&dh.indexOf(e.type)!==-1}function ph(e){let n=(0,te.readInt32)(e),t=[];for(let i=0;i<n;i++){let o=(0,te.readSignature)(e);switch(o){case"prop":rn(e),t.push(bt(e));break;case"Clss":t.push(rn(e));break;case"Enmr":{rn(e);let r=bt(e),s=bt(e);t.push(`${r}.${s}`);break}case"rele":rn(e),t.push((0,te.readUint32)(e));break;case"Idnt":case"indx":t.push((0,te.readInt32)(e));break;case"name":rn(e),t.push((0,te.readUnicodeString)(e));break;default:throw new Error(`Invalid descriptor reference type: ${o}`)}}return t}function sc(e){if(typeof e=="string"){let n=/^([a-z ]{4}|[a-z]{5,})\.([a-z ]+)$/i.exec(e);return n?{type:"Enmr",_name:"",_classID:n[1],typeID:n[1],enumValue:n[2]}:{type:"name",_name:"",_classID:"Lyr ",value:e}}else{if(typeof e=="number")return{type:"Idnt",value:e};if(e&&typeof e=="object"&&typeof e.classID=="string")return{type:"Clss",_name:e.name||"",_classID:e.classID};throw new Error(`Invalid descriptor reference value: ${JSON.stringify(e)}`)}}function hh(e){return e.map(n=>{let t=sc(n);return t.type==="Enmr"&&(t._classID="Path"),t})}function gh(e,n,t){if(!Array.isArray(t))throw new Error(`Invalid reference value: ${JSON.stringify(t)}, key: ${n}`);(0,Z.writeInt32)(e,t.length);for(let i of t){let o=uh(i)?i:sc(i);switch((0,Z.writeSignature)(e,o.type),o.type){case"prop":Dn(e,o._name||"",o._classID),et(e,o.keyID);break;case"Clss":Dn(e,o._name||"",o._classID);break;case"Enmr":Dn(e,o._name||"",o._classID),et(e,o.typeID),et(e,o.enumValue);break;case"rele":Dn(e,o._name||"",o._classID),(0,Z.writeUint32)(e,o.value);break;case"Idnt":case"indx":(0,Z.writeInt32)(e,o.value);break;case"name":Dn(e,o._name||"",o._classID),(0,Z.writeUnicodeStringWithPadding)(e,`${o.value}`);break;default:throw new Error(`Invalid descriptor reference type: ${o.type}`)}}return t}function rn(e){let n=(0,te.readUnicodeString)(e),t=bt(e);return{name:n,classID:t}}function Dn(e,n,t){(0,Z.writeUnicodeStringWithPadding)(e,n),et(e,t)}function mh(e,n=!1){let t=(0,te.readUint32)(e);if(t!==16)throw new Error(`Invalid descriptor version: ${t}`);return jr(e,n)}function yh(e,n,t,i,o=""){(0,Z.writeUint32)(e,16),zr(e,n,t,i,o)}function oo(e){return{x:e.Hrzn,y:e.Vrtc}}function ro(e){return{Hrzn:e.x,Vrtc:e.y}}function bh(e){return{top:wt(e["Top "]),left:wt(e.Left),right:wt(e.Rght),bottom:wt(e.Btom)}}function wh(e){return{Left:vt(e.left,"bounds.left"),"Top ":vt(e.top,"bounds.top"),Rght:vt(e.right,"bounds.right"),Btom:vt(e.bottom,"bounds.bottom")}}function Zl(e){let n={enabled:!!e.enab,position:_.FStl.decode(e.Styl),fillType:_.FrFl.decode(e.PntT),blendMode:_.BlnM.decode(e["Md "]),opacity:Pe(e.Opct),size:bc(e["Sz "])};return e.present!==void 0&&(n.present=e.present),e.showInDialog!==void 0&&(n.showInDialog=e.showInDialog),e.overprint!==void 0&&(n.overprint=e.overprint),e["Clr "]&&(n.color=sn(e["Clr "])),e.Grad&&(n.gradient=dc(e)),e.Ptrn&&(n.pattern=pc(e)),n}function Kl(e){let n={};return n.enab=!!e.enabled,e.present!==void 0&&(n.present=!!e.present),e.showInDialog!==void 0&&(n.showInDialog=!!e.showInDialog),n.Styl=_.FStl.encode(e.position),n.PntT=_.FrFl.encode(e.fillType),n["Md "]=_.BlnM.encode(e.blendMode),n.Opct=rt(e.opacity),n["Sz "]=vt(e.size,"size"),e.color&&(n["Clr "]=an(e.color)),e.gradient&&(n=Object.assign(Object.assign({},n),hc(e.gradient))),e.pattern&&(n=Object.assign(Object.assign({},n),gc(e.pattern))),e.overprint!==void 0&&(n.overprint=!!e.overprint),n}function ac(e,n,t){var i,o,r;let s=t?{"Scl ":St((i=e.scale)!==null&&i!==void 0?i:1),masterFXSwitch:!e.disabled}:{masterFXSwitch:!e.disabled,"Scl ":St((o=e.scale)!==null&&o!==void 0?o:1)},a=["dropShadow","innerShadow","solidFill","gradientOverlay","stroke"];for(let f of a)if(e[f]&&!Array.isArray(e[f]))throw new Error(`${f} should be an array`);let l=f=>!!f&&f.length>1&&t,c=f=>!!f&&f.length>=1&&(!t||f.length===1);if(c(e.dropShadow)&&(s.DrSh=Xe(e.dropShadow[0],"dropShadow",n)),l(e.dropShadow)&&(s.dropShadowMulti=e.dropShadow.map(f=>Xe(f,"dropShadow",n))),c(e.innerShadow)&&(s.IrSh=Xe(e.innerShadow[0],"innerShadow",n)),l(e.innerShadow)&&(s.innerShadowMulti=e.innerShadow.map(f=>Xe(f,"innerShadow",n))),e.outerGlow&&(s.OrGl=Xe(e.outerGlow,"outerGlow",n)),l(e.solidFill)&&(s.solidFillMulti=e.solidFill.map(f=>Xe(f,"solidFill",n))),l(e.gradientOverlay)&&(s.gradientFillMulti=e.gradientOverlay.map(f=>Xe(f,"gradientOverlay",n))),l(e.stroke)&&(s.frameFXMulti=e.stroke.map(f=>Kl(f))),e.innerGlow&&(s.IrGl=Xe(e.innerGlow,"innerGlow",n)),e.bevel&&(s.ebbl=Xe(e.bevel,"bevel",n)),c(e.solidFill)&&(s.SoFi=Xe(e.solidFill[0],"solidFill",n)),e.patternOverlay&&(s.patternFill=Xe(e.patternOverlay,"patternOverlay",n)),c(e.gradientOverlay)&&(s.GrFl=Xe(e.gradientOverlay[0],"gradientOverlay",n)),e.satin&&(s.ChFX=Xe(e.satin,"satin",n)),c(e.stroke)&&(s.FrFX=Kl((r=e.stroke)===null||r===void 0?void 0:r[0])),t){s.numModifyingFX=0;for(let f of Object.keys(e)){let u=e[f];if(!(u==null||typeof u!="object"))if(Array.isArray(u))for(let d of u)d?.enabled&&s.numModifyingFX++;else u.enabled&&s.numModifyingFX++}}return s}function lc(e,n){let t={},i=e,{_name:o,_classID:r,"Scl ":s,masterFXSwitch:a,DrSh:l,dropShadowMulti:c,IrSh:f,innerShadowMulti:u,OrGl:d,IrGl:p,ebbl:h,SoFi:m,solidFillMulti:y,patternFill:g,GrFl:k,gradientFillMulti:x,ChFX:S,FrFX:A,frameFXMulti:D,numModifyingFX:C}=i,O=rh(i,["_name","_classID","Scl ","masterFXSwitch","DrSh","dropShadowMulti","IrSh","innerShadowMulti","OrGl","IrGl","ebbl","SoFi","solidFillMulti","patternFill","GrFl","gradientFillMulti","ChFX","FrFX","frameFXMulti","numModifyingFX"]);return a||(t.disabled=!0),s&&(t.scale=Pe(s)),l&&(t.dropShadow=[We(l,n)]),c&&(t.dropShadow=c.map(E=>We(E,n))),f&&(t.innerShadow=[We(f,n)]),u&&(t.innerShadow=u.map(E=>We(E,n))),d&&(t.outerGlow=We(d,n)),p&&(t.innerGlow=We(p,n)),h&&(t.bevel=We(h,n,"bevel")),m&&(t.solidFill=[We(m,n)]),y&&(t.solidFill=y.map(E=>We(E,n))),g&&(t.patternOverlay=We(g,n)),k&&(t.gradientOverlay=[We(k,n)]),x&&(t.gradientOverlay=x.map(E=>We(E,n))),S&&(t.satin=We(S,n)),A&&(t.stroke=[Zl(A)]),D&&(t.stroke=D.map(E=>Zl(E))),n.logMissingFeatures&&Object.keys(O).length&&n.log("Unhandled effect keys:",O),t}function Yl(e,n){let t=[];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},f=_.animInterpStyleEnum.decode(o.animInterpStyle);switch(l.Type){case"keyType.Opct":t.push({interpolation:f,time:c,selected:a,type:"opacity",value:Pe(l.Opct)});break;case"keyType.Pstn":t.push({interpolation:f,time:c,selected:a,type:"position",x:l.Hrzn,y:l.Vrtc});break;case"keyType.Trnf":t.push({interpolation:f,time:c,selected:a,type:"transform",scale:oo(l["Scl "]),skew:oo(l.Skew),rotation:l.rotation,translation:oo(l.translation)});break;case"keyType.sheetStyle":{let u={interpolation:f,time:c,selected:a,type:"style"};l.sheetStyle.Lefx&&(u.style=lc(l.sheetStyle.Lefx,n)),t.push(u);break}case"keyType.globalLighting":{t.push({interpolation:f,time:c,selected:a,type:"globalLighting",globalAngle:l.gblA,globalAltitude:l.globalAltitude});break}default:throw new Error("Unsupported keyType value")}}return t}function Jl(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i],{time:r,selected:s=!1,interpolation:a}=o,l=_.animInterpStyleEnum.encode(a),c;switch(o.type){case"opacity":c={Type:"keyType.Opct",Opct:rt(o.value)};break;case"position":c={Type:"keyType.Pstn",Hrzn:o.x,Vrtc:o.y};break;case"transform":c={Type:"keyType.Trnf","Scl ":ro(o.scale),Skew:ro(o.skew),rotation:o.rotation,translation:ro(o.translation)};break;case"style":c={Type:"keyType.sheetStyle",sheetStyle:{Vrsn:1,blendOptions:{}}},o.style&&(c.sheetStyle={Vrsn:1,Lefx:ac(o.style,n,!1),blendOptions:{}});break;case"globalLighting":{c={Type:"keyType.globalLighting",gblA:o.globalAngle,globalAltitude:o.globalAltitude};break}default:throw new Error("Unsupported keyType value")}t.push({Vrsn:1,animInterpStyle:l,time:r,animKey:c,selected:s})}return t}function vh(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i],r={type:_.stdTrackID.decode(o.trackID),enabled:o.enab,keys:Yl(o.keyList,n)};o.effectParams&&(r.effectParams={fillCanvas:o.effectParams.fillCanvas,zoomOrigin:o.effectParams.zoomOrigin,keys:Yl(o.effectParams.keyList,n)}),t.push(r)}return t}function Sh(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i];t.push(Object.assign(Object.assign({trackID:_.stdTrackID.encode(o.type),Vrsn:1,enab:!!o.enabled,Effc:!!o.effectParams},o.effectParams?{effectParams:{keyList:Jl(o.effectParams.keys,n),fillCanvas:o.effectParams.fillCanvas,zoomOrigin:o.effectParams.zoomOrigin}}:{}),{keyList:Jl(o.keys,n)}))}return t}function We(e,n,t){let i={};for(let o of Object.keys(e)){let r=e[o];switch(o){case"enab":i.enabled=!!r;break;case"uglg":i.useGlobalLight=!!r;break;case"AntA":i.antialiased=!!r;break;case"Algn":i.align=!!r;break;case"Dthr":i.dither=!!r;break;case"Invr":i.invert=!!r;break;case"Rvrs":i.reverse=!!r;break;case"Clr ":i.color=sn(r);break;case"hglC":i.highlightColor=sn(r);break;case"sdwC":i.shadowColor=sn(r);break;case"Styl":i.position=_.FStl.decode(r);break;case"Md ":i.blendMode=_.BlnM.decode(r);break;case"hglM":i.highlightBlendMode=_.BlnM.decode(r);break;case"sdwM":i.shadowBlendMode=_.BlnM.decode(r);break;case"bvlS":i.style=_.BESl.decode(r);break;case"bvlD":i.direction=_.BESs.decode(r);break;case"bvlT":i.technique=_.bvlT.decode(r);break;case"GlwT":i.technique=_.BETE.decode(r);break;case"glwS":i.source=_.IGSr.decode(r);break;case"Type":i.type=_.GrdT.decode(r);break;case"gs99":case"gradientsInterpolationMethod":i.interpolationMethod=_.gradientInterpolationMethodType.decode(r);break;case"Opct":i.opacity=Pe(r);break;case"hglO":i.highlightOpacity=Pe(r);break;case"sdwO":i.shadowOpacity=Pe(r);break;case"lagl":i.angle=On(r);break;case"Angl":i.angle=On(r);break;case"Lald":i.altitude=On(r);break;case"Sftn":i.soften=wt(r);break;case"srgR":i.strength=Pe(r);break;case"blur":i.size=wt(r);break;case"Nose":i.noise=Pe(r);break;case"Inpr":i.range=Pe(r);break;case"Ckmt":i.choke=wt(r);break;case"ShdN":i.jitter=Pe(r);break;case"Dstn":i.distance=wt(r);break;case"Scl ":i.scale=Pe(r);break;case"Ptrn":i.pattern={name:r["Nm "],id:r.Idnt};break;case"phase":i.phase=uc(r);break;case"Ofst":i.offset={x:Pe(r.Hrzn),y:Pe(r.Vrtc)};break;case"MpgS":case"TrnS":{let s={name:r["Nm "],curve:r["Crv "].map(a=>a.Cnty!==void 0?{x:a.Hrzn,y:a.Vrtc,curved:a.Cnty}:{x:a.Hrzn,y:a.Vrtc})};t==="bevel"&&o==="MpgS"?i.shapeContour=s:i.contour=s;break}case"Grad":i.gradient=cc(r);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":i[o]=r;break;case"_name":case"_classID":break;default:n.logMissingFeatures&&n.log(`Invalid effect key: '${o}', value:`,r)}}return i}function Xe(e,n,t){let i={enab:!1};n==="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 "]=an(s);break;case"highlightColor":i.hglC=an(s);break;case"shadowColor":i.sdwC=an(s);break;case"position":i.Styl=_.FStl.encode(s);break;case"blendMode":i["Md "]=_.BlnM.encode(s);break;case"highlightBlendMode":i.hglM=_.BlnM.encode(s);break;case"shadowBlendMode":i.sdwM=_.BlnM.encode(s);break;case"style":i.bvlS=_.BESl.encode(s);break;case"direction":i.bvlD=_.BESs.encode(s);break;case"technique":n==="bevel"?i.bvlT=_.bvlT.encode(s):i.GlwT=_.BETE.encode(s);break;case"source":i.glwS=_.IGSr.encode(s);break;case"type":i.Type=_.GrdT.encode(s);break;case"interpolationMethod":i[n==="outerGlow"||n==="innerGlow"?"gradientsInterpolationMethod":"gs99"]=_.gradientInterpolationMethodType.encode(s);break;case"opacity":i.Opct=rt(s);break;case"highlightOpacity":i.hglO=rt(s);break;case"shadowOpacity":i.sdwO=rt(s);break;case"angle":n==="gradientOverlay"||n==="patternOverlay"?i.Angl=ln(s):i.lagl=ln(s);break;case"altitude":i.Lald=ln(s);break;case"soften":i.Sftn=vt(s,r);break;case"strength":i.srgR=rt(s);break;case"size":i.blur=vt(s,r);break;case"noise":i.Nose=rt(s);break;case"range":i.Inpr=rt(s);break;case"choke":i.Ckmt=vt(s,r);break;case"jitter":i.ShdN=rt(s);break;case"distance":i.Dstn=vt(s,r);break;case"scale":i["Scl "]=rt(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:St(s.x),Vrtc:St(s.y)};break;case"contour":i[n==="satin"?"MpgS":"TrnS"]=Ql(s);break;case"shapeContour":i.MpgS=Ql(s);break;case"gradient":i.Grad=fc(s);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":i[r]=s;break;default:t.logMissingFeatures&&t.log(`Invalid effect key: '${r}', value:`,s)}}return i}function Ql(e){return{"Nm ":e.name,"Crv ":e.curve.map(n=>n.curved!==void 0?{Hrzn:n.x,Vrtc:n.y,Cnty:!!n.curved}:{Hrzn:n.x,Vrtc:n.y})}}function cc(e){return e.GrdF==="GrdF.CstS"?{type:"solid",name:e["Nm "],smoothness:e.Intr/4096,colorStops:e.Clrs.map(t=>{let i={color:t["Clr "]?sn(t["Clr "]):{r:0,g:0,b:0},location:t.Lctn/4096,midpoint:t.Mdpn/100};if(t.Type)try{let o=_.Clry.decode(t.Type);o!=="user"&&(i.type=o)}catch{}return i}),opacityStops:e.Trns.map(t=>({opacity:Pe(t.Opct),location:t.Lctn/4096,midpoint:t.Mdpn/100}))}:{type:"noise",name:e["Nm "],roughness:e.Smth/4096,colorModel:_.ClrS.decode(e.ClrS),randomSeed:e.RndS,restrictColors:!!e.VctC,addTransparency:!!e.ShTr,min:e["Mnm "].map(n=>n/100),max:e["Mxm "].map(n=>n/100)}}function fc(e){var n,t;return e.type==="solid"?{"Nm ":e.name||"",GrdF:"GrdF.CstS",Intr:Math.round(((n=e.smoothness)!==null&&n!==void 0?n:1)*4096),Clrs:e.colorStops.map(o=>{var r,s;return{"Clr ":an(o.color),Type:_.Clry.encode((r=o.type)!==null&&r!==void 0?r:"user"),Lctn:Math.round(o.location*4096),Mdpn:Math.round(((s=o.midpoint)!==null&&s!==void 0?s:.5)*100)}}),Trns:e.opacityStops.map(o=>{var r;return{Opct:St(o.opacity),Lctn:Math.round(o.location*4096),Mdpn:Math.round(((r=o.midpoint)!==null&&r!==void 0?r:.5)*100)}})}:{GrdF:"GrdF.ClNs","Nm ":e.name||"",ShTr:!!e.addTransparency,VctC:!!e.restrictColors,ClrS:_.ClrS.encode(e.colorModel),RndS:e.randomSeed||0,Smth:Math.round(((t=e.roughness)!==null&&t!==void 0?t:1)*4096),"Mnm ":(e.min||[0,0,0,0]).map(i=>Math.round(i*100)),"Mxm ":(e.max||[1,1,1,1]).map(i=>Math.round(i*100))}}function dc(e){let n=cc(e.Grad);return n.style=_.GrdT.decode(e.Type),e.Dthr!==void 0&&(n.dither=e.Dthr),e.gradientsInterpolationMethod!==void 0&&(n.interpolationMethod=_.gradientInterpolationMethodType.decode(e.gradientsInterpolationMethod)),e.Rvrs!==void 0&&(n.reverse=e.Rvrs),e.Angl!==void 0&&(n.angle=On(e.Angl)),e["Scl "]!==void 0&&(n.scale=Pe(e["Scl "])),e.Algn!==void 0&&(n.align=e.Algn),e.Ofst!==void 0&&(n.offset={x:Pe(e.Ofst.Hrzn),y:Pe(e.Ofst.Vrtc)}),e.gradientAspectRatio!==void 0&&(n.aspectRatio=e.gradientAspectRatio),e.noisePreSeed!==void 0&&(n.noisePreSeed=e.noisePreSeed),n}function uc({Hrzn:e,Vrtc:n}){return{x:typeof e=="number"?e:e.value,y:typeof n=="number"?n:n.value}}function pc(e){let n={name:e.Ptrn["Nm "],id:e.Ptrn.Idnt};return e.Algn!==void 0&&(n.align=e.Algn),e.Lnkd!==void 0&&(n.linked=e.Lnkd),e.phase!==void 0&&(n.phase=uc(e.phase)),e["Scl "]!==void 0&&(n.scale=Pe(e["Scl "])),e.Angl!==void 0&&(n.angle=On(e.Angl)),n}function xh(e){if("Grad"in e)return dc(e);if("Ptrn"in e)return Object.assign({type:"pattern"},pc(e));if("Clr "in e)return{type:"color",color:sn(e["Clr "])};throw new Error("Invalid vector content")}function hc(e){let n={};return e.dither!==void 0&&(n.Dthr=e.dither),e.interpolationMethod!==void 0&&(n.gradientsInterpolationMethod=_.gradientInterpolationMethodType.encode(e.interpolationMethod)),e.reverse!==void 0&&(n.Rvrs=e.reverse),e.aspectRatio!==void 0&&(n.gradientAspectRatio=e.aspectRatio),e.angle!==void 0&&(n.Angl=ln(e.angle)),n.Type=_.GrdT.encode(e.style),e.align!==void 0&&(n.Algn=e.align),e.scale!==void 0&&(n["Scl "]=St(e.scale)),e.offset&&(n.Ofst={Hrzn:St(e.offset.x),Vrtc:St(e.offset.y)}),e.noisePreSeed!==void 0&&(n.noisePreSeed=e.noisePreSeed),n.Grad=fc(e),n}function gc(e){let n={Ptrn:{"Nm ":e.name||"",Idnt:e.id||""}};return e.align!==void 0&&(n.Algn=!!e.align),e.linked!==void 0&&(n.Lnkd=!!e.linked),e.phase!==void 0&&(n.phase={Hrzn:e.phase.x,Vrtc:e.phase.y}),e.scale!==void 0&&(n["Scl "]=St(e.scale)),e.angle!==void 0&&(n.Angl=ln(e.angle)),n}function kh(e){return e.type==="color"?{key:"SoCo",descriptor:{"Clr ":an(e.color)}}:e.type==="pattern"?{key:"PtFl",descriptor:gc(e)}:{key:"GdFl",descriptor:hc(e)}}var _h={"H ":[e=>e/360,e=>e*360],Strt:[e=>e/100,e=>e*100],Brgh:[e=>e/100,e=>e*100],"Cyn ":[e=>e*255/100,e=>e*100/255],Mgnt:[e=>e*255/100,e=>e*100/255],"Ylw ":[e=>e*255/100,e=>e*100/255],Blck:[e=>e*255/100,e=>e*100/255],"Gry ":[e=>e*255/100,e=>e*100/255],Lmnc:[e=>e/100,e=>e*100],"A ":[V.normalizeLabAB,V.denormalizeLabAB],"B ":[V.normalizeLabAB,V.denormalizeLabAB]};function ot(e,n){let t=_h[e];if(!t)return n;let[i,o]=t,r=o(n);if(!isFinite(r))return r;for(let s=1;s<17;s++){let a=+r.toPrecision(s);if(i(a)===n)return a}return r}function mc(e){return e._classID==="BkCl"||"Bk "in e||"bookID"in e}function sn(e){var n,t,i;let o=Ah(e);if(mc(e)){let r=e,s=r.bookKey;o.book={book:(n=r["Bk "])!==null&&n!==void 0?n:"",name:(t=r["Nm "])!==null&&t!==void 0?t:"",bookID:(i=r.bookID)!==null&&i!==void 0?i:0,bookKey:typeof s=="string"?s:s?String.fromCharCode(...Array.from(s)):""}}return o}function Ah(e){if("H "in e)return{h:yc(e["H "]),s:e.Strt/100,b:e.Brgh/100};if("Rd "in e)return{r:e["Rd "],g:e["Grn "],b:e["Bl "]};if("Cyn "in e)return{c:e["Cyn "]*255/100,m:e.Mgnt*255/100,y:e["Ylw "]*255/100,k:e.Blck*255/100};if("Gry "in e)return{k:e["Gry "]*255/100};if("Lmnc"in e)return{l:e.Lmnc/100,a:(0,V.normalizeLabAB)(e["A "]),b:(0,V.normalizeLabAB)(e["B "])};if("redFloat"in e)return{fr:e.redFloat,fg:e.greenFloat,fb:e.blueFloat};if(mc(e))return{r:0,g:0,b:0};throw new Error("Unsupported color descriptor")}function an(e){let n=Ih(e);if(e?.book){let{book:t,name:i,bookID:o,bookKey:r}=e.book,s=new Uint8Array(r.length);for(let a=0;a<s.length;a++)s[a]=r.charCodeAt(a)&255;Object.assign(n,{"Bk ":t,"Nm ":i,bookID:o,bookKey:s})}return n}function Ih(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 ":ln(ot("H ",e.h||0)),Strt:ot("Strt",e.s||0),Brgh:ot("Brgh",e.b||0)};if("c"in e)return{_name:"",_classID:"CMYC","Cyn ":ot("Cyn ",e.c||0),Mgnt:ot("Mgnt",e.m||0),"Ylw ":ot("Ylw ",e.y||0),Blck:ot("Blck",e.k||0)};if("l"in e)return{_name:"",_classID:"LbCl",Lmnc:ot("Lmnc",e.l||0),"A ":ot("A ",e.a||0),"B ":ot("B ",e.b||0)};if("k"in e)return{_name:"",_classID:"Grsc","Gry ":ot("Gry ",e.k||0)};throw new Error("Invalid color value")}else return{_name:"",_classID:"RGBC","Rd ":0,"Grn ":0,"Bl ":0}}function On(e){if(e===void 0)return 0;if(e.units!=="Angle")throw new Error(`Invalid units: ${e.units}`);return e.value}function Pe(e){if(e===void 0)return 1;if(e.units!=="Percent")throw new Error(`Invalid units: ${e.units}`);return e.value/100}function yc(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 wt({units:e,value:n}){if(e!=="Pixels"&&e!=="Millimeters"&&e!=="Points"&&e!=="None"&&e!=="Picas"&&e!=="Inches"&&e!=="Centimeters"&&e!=="Density"&&e!=="Distance")throw new Error(`Invalid units: ${JSON.stringify({units:e,value:n})}`);return{value:n,units:e}}function bc(e,n="Pixels"){return typeof e=="number"?{value:e,units:n}:wt(e)}function Ch({units:e,value:n},t){if(e!==t)throw new Error(`Invalid units: ${JSON.stringify({units:e,value:n})}`);return n}function ln(e){return{units:"Angle",value:e||0}}function rt(e){return{units:"Percent",value:Math.round((e||0)*100)}}function St(e){return{units:"Percent",value:(e||0)*100}}function vt(e,n){if(e==null)return{units:"Pixels",value:0};if(typeof e!="object")throw new Error(`Invalid value: ${JSON.stringify(e)} (key: ${n}) (should have value and units)`);let{units:t,value:i}=e;if(typeof i!="number")throw new Error(`Invalid value in ${JSON.stringify(e)} (key: ${n})`);if(t!=="Pixels"&&t!=="Millimeters"&&t!=="Points"&&t!=="None"&&t!=="Picas"&&t!=="Inches"&&t!=="Centimeters"&&t!=="Density"&&t!=="Distance")throw new Error(`Invalid units in ${JSON.stringify(e)} (key: ${n})`);return{units:t,value:i}}function Ph({numerator:e,denominator:n}){return{numerator:e,denominator:n}}_.textGridding=(0,V.createEnum)("textGridding","none",{none:"None",round:"Rnd "});_.Ornt=(0,V.createEnum)("Ornt","horizontal",{horizontal:"Hrzn",vertical:"Vrtc"});_.Annt=(0,V.createEnum)("Annt","sharp",{none:"Anno",sharp:"antiAliasSharp",crisp:"AnCr",strong:"AnSt",smooth:"AnSm",platform:"antiAliasPlatformGray",platformLCD:"antiAliasPlatformLCD"});_.warpStyle=(0,V.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"});_.BlnM=(0,V.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":"passThrough"});_.BESl=(0,V.createEnum)("BESl","inner bevel",{"inner bevel":"InrB","outer bevel":"OtrB",emboss:"Embs","pillow emboss":"PlEb","stroke emboss":"strokeEmboss"});_.bvlT=(0,V.createEnum)("bvlT","smooth",{smooth:"SfBL","chisel hard":"PrBL","chisel soft":"Slmt"});_.BESs=(0,V.createEnum)("BESs","up",{up:"In ",down:"Out "});_.BETE=(0,V.createEnum)("BETE","softer",{softer:"SfBL",precise:"PrBL"});_.IGSr=(0,V.createEnum)("IGSr","edge",{edge:"SrcE",center:"SrcC"});_.GrdT=(0,V.createEnum)("GrdT","linear",{linear:"Lnr ",radial:"Rdl ",angle:"Angl",reflected:"Rflc",diamond:"Dmnd"});_.animInterpStyleEnum=(0,V.createEnum)("animInterpStyle","linear",{linear:"Lnr ",hold:"hold"});_.stdTrackID=(0,V.createEnum)("stdTrackID","opacity",{opacity:"opacityTrack",style:"styleTrack",sheetTransform:"sheetTransformTrack",sheetPosition:"sheetPositionTrack",globalLighting:"globalLightingTrack"});_.gradientInterpolationMethodType=(0,V.createEnum)("gradientInterpolationMethodType","perceptual",{perceptual:"Perc",linear:"Lnr ",classic:"Gcls",smooth:"Smoo"});_.Clry=(0,V.createEnum)("Clry","user",{user:"UsrS",foreground:"FrgC",background:"BckC"});_.ClrS=(0,V.createEnum)("ClrS","rgb",{rgb:"RGBC",hsb:"HSBl",lab:"LbCl",hsl:"HSLC"});_.FStl=(0,V.createEnum)("FStl","outside",{outside:"OutF",center:"CtrF",inside:"InsF"});_.FrFl=(0,V.createEnum)("FrFl","color",{color:"SClr",gradient:"GrFl",pattern:"Ptrn"});_.ESliceType=(0,V.createEnum)("ESliceType","image",{image:"Img ",noImage:"noImage"});_.ESliceHorzAlign=(0,V.createEnum)("ESliceHorzAlign","default",{default:"default"});_.ESliceVertAlign=(0,V.createEnum)("ESliceVertAlign","default",{default:"default"});_.ESliceOrigin=(0,V.createEnum)("ESliceOrigin","userGenerated",{userGenerated:"userGenerated",autoGenerated:"autoGenerated",layer:"layer"});_.ESliceBGColorType=(0,V.createEnum)("ESliceBGColorType","none",{none:"None",matte:"matte",color:"Clr "});_.strokeStyleLineCapType=(0,V.createEnum)("strokeStyleLineCapType","butt",{butt:"strokeStyleButtCap",round:"strokeStyleRoundCap",square:"strokeStyleSquareCap"});_.strokeStyleLineJoinType=(0,V.createEnum)("strokeStyleLineJoinType","miter",{miter:"strokeStyleMiterJoin",round:"strokeStyleRoundJoin",bevel:"strokeStyleBevelJoin"});_.strokeStyleLineAlignment=(0,V.createEnum)("strokeStyleLineAlignment","inside",{inside:"strokeStyleAlignInside",center:"strokeStyleAlignCenter",outside:"strokeStyleAlignOutside"});_.BlrM=(0,V.createEnum)("BlrM","spin",{spin:"Spn ",zoom:"Zm "});_.BlrQ=(0,V.createEnum)("BlrQ","good",{draft:"Drft",good:"Gd ",best:"Bst "});_.SmBM=(0,V.createEnum)("SmBM","normal",{normal:"SBMN","edge only":"SBME","overlay edge":"SBMO"});_.SmBQ=(0,V.createEnum)("SmBQ","medium",{low:"SBQL",medium:"SBQM",high:"SBQH"});_.DspM=(0,V.createEnum)("DspM","stretch to fit",{"stretch to fit":"StrF",tile:"Tile"});_.UndA=(0,V.createEnum)("UndA","repeat edge pixels",{"wrap around":"WrpA","repeat edge pixels":"RptE"});_.Cnvr=(0,V.createEnum)("Cnvr","rectangular to polar",{"rectangular to polar":"RctP","polar to rectangular":"PlrR"});_.RplS=(0,V.createEnum)("RplS","medium",{small:"Sml ",medium:"Mdm ",large:"Lrg "});_.SphM=(0,V.createEnum)("SphM","normal",{normal:"Nrml","horizontal only":"HrzO","vertical only":"VrtO"});_.Wvtp=(0,V.createEnum)("Wvtp","sine",{sine:"WvSn",triangle:"WvTr",square:"WvSq"});_.ZZTy=(0,V.createEnum)("ZZTy","pond ripples",{"around center":"ArnC","out from center":"OtFr","pond ripples":"PndR"});_.Dstr=(0,V.createEnum)("Dstr","uniform",{uniform:"Unfr",gaussian:"Gsn "});_.Chnl=(0,V.createEnum)("Chnl","composite",{red:"Rd ",green:"Grn ",blue:"Bl ",composite:"Cmps"});_.MztT=(0,V.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"});_.Lns=(0,V.createEnum)("Lns ","50-300mm zoom",{"50-300mm zoom":"Zm ","32mm prime":"Nkn ","105mm prime":"Nkn1","movie prime":"PnVs"});_.blurType=(0,V.createEnum)("blurType","gaussian blur",{"gaussian blur":"GsnB","lens blur":"lensBlur","motion blur":"MtnB"});_.DfsM=(0,V.createEnum)("DfsM","normal",{normal:"Nrml","darken only":"DrkO","lighten only":"LghO",anisotropic:"anisotropic"});_.ExtT=(0,V.createEnum)("ExtT","blocks",{blocks:"Blks",pyramids:"Pyrm"});_.ExtR=(0,V.createEnum)("ExtR","random",{random:"Rndm","level-based":"LvlB"});_.FlCl=(0,V.createEnum)("FlCl","background color",{"background color":"FlBc","foreground color":"FlFr","inverse image":"FlIn","unaltered image":"FlSm"});_.CntE=(0,V.createEnum)("CntE","upper",{lower:"Lwr ",upper:"Upr "});_.WndM=(0,V.createEnum)("WndM","wind",{wind:"Wnd ",blast:"Blst",stagger:"Stgr"});_.Drct=(0,V.createEnum)("Drct","right",{left:"Left",right:"Rght"});_.IntE=(0,V.createEnum)("IntE","odd lines",{"odd lines":"ElmO","even lines":"ElmE"});_.IntC=(0,V.createEnum)("IntC","interpolation",{duplication:"CrtD",interpolation:"CrtI"});_.FlMd=(0,V.createEnum)("FlMd","wrap around",{"set to transparent":"Bckg","repeat edge pixels":"Rpt ","wrap around":"Wrp "});_.prjM=(0,V.createEnum)("prjM","fisheye",{fisheye:"fisP",perspective:"perP",auto:"auto","full spherical":"fusP"});_.presetKindType=(0,V.createEnum)("presetKindType","custom",{custom:"presetKindCustom",default:"presetKindDefault"});_.patternColorHandling=(0,V.createEnum)("","convert",{convert:"conv","avoid conversion":"avod","luminance only":"lumi"})});var qr=ae(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.resourceHandlersMap=Et.resourceHandlers=void 0;Et.shouldReadResource=Fh;var Dh=no(),Fn=ui(),I=st(),P=En(),cn=Ot(),Oc=Br(),z=ao();Et.resourceHandlers=[];Et.resourceHandlersMap={};function Oh(e){let n=[],t=new Proxy({},{get(i,o){typeof o=="string"&&!n.includes(o)&&n.push(o)}});try{e(t)}catch{}return n}var Eh=new Set(["layersGroup","layerGroupsEnabledId","alphaChannelNames","transparencyIndex"]);function j(e,n,t,i,o={}){var r,s;let a=(r=o.fields)!==null&&r!==void 0?r:Oh(n),l=a.some(f=>Eh.has(f)),c={key:e,keyCount:(s=o.keyCount)!==null&&s!==void 0?s:1,has:n,read:t,write:i,name:o.name,fields:a,required:l};Et.resourceHandlers.push(c);for(let f=0;f<c.keyCount;f++)Et.resourceHandlersMap[c.key+f]=c}function Fh(e,n){return!n||e.required||n.size>0&&e.fields.some(t=>n.has(t))}var Lh=!1,lo=[void 0,"PPI","PPCM"],co=[void 0,"Inches","Centimeters","Points","Picas","Columns"],wc="0123456789abcdef";function vc(e){return e<=57?e-48:e>=97?e-87:e-55}function Mh(e,n){return vc(e.charCodeAt(n))<<4|vc(e.charCodeAt(n+1))}function Vr(e,n){let t=(0,I.readBytes)(e,n);return(0,I.decodeUtf8)(e,t)}function Nr(e,n){let t=(0,Oc.encodeString)(n);(0,P.writeBytes)(e,t)}function Ec(e){let n=(0,I.readUint8)(e),t=(0,I.readBytes)(e,n);return Fc(e,t)}function Fc(e,n){let t=!1;for(let i=0;i<n.byteLength;i++)if(n[i]&128){t=!0;break}if(t){for(let i of[(0,I.getGbkStrictDecoder)(e),(0,I.getUtf8StrictDecoder)(e)])if(i)try{return i.decode(n)}catch{}}return(0,I.decodeUtf8)(e,n)}function Lc(e){let n="";for(let t=0;t<e.length;){let i=e.codePointAt(t);n+=i>127?"?":String.fromCharCode(i),t+=i>65535?2:1}return n.length>255?n.substring(0,255):n}function Mc(e,n){let t=(0,Oc.encodeString)(Lc(n));(0,P.writeUint8)(e,t.byteLength),(0,P.writeBytes)(e,t)}j(1028,e=>e.iptcData!==void 0,(e,n,t)=>{n.iptcData=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.iptcData)});j(1061,e=>e.captionDigest!==void 0,(e,n)=>{let t="";for(let i=0;i<16;i++){let o=(0,I.readUint8)(e);t+=wc[o>>4],t+=wc[o&15]}n.captionDigest=t},(e,n)=>{for(let t=0;t<16;t++)(0,P.writeUint8)(e,Mh(n.captionDigest,t*2))});j(1060,e=>e.xmpMetadata!==void 0,(e,n,t)=>{n.xmpMetadata=Vr(e,t())},(e,n)=>{Nr(e,n.xmpMetadata)});var fo=(0,cn.createEnum)("Inte","perceptual",{perceptual:"Img ",saturation:"Grp ","relative colorimetric":"Clrm","absolute colorimetric":"AClr"});j(1085,e=>e.windowsDevMode!==void 0,(e,n,t)=>{n.windowsDevMode=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.windowsDevMode)});j(1082,e=>e.printInformation!==void 0,(e,n)=>{var t,i;let o=(0,z.readVersionAndDescriptor)(e);n.printInformation={printerName:o.printerName||"",renderingIntent:fo.decode((t=o.Inte)!==null&&t!==void 0?t:"Inte.Img ")};let r=n.printInformation;o.PstS!==void 0&&(r.printerManagesColors=o.PstS),o.ClrS==="ClrS.Grys"&&(r.printerProfileColorSpace="grayscale"),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:fo.decode((i=o.printProofSetup.Inte)!==null&&i!==void 0?i:"Inte.Img "),blackPointCompensation:!!o.printProofSetup.MpBl,paperWhite:!!o.printProofSetup.paperWhite})},(e,n)=>{let t=n.printInformation,i={};t.printerManagesColors?i.PstS=!0:(t.hardProof!==void 0&&(i.hardProof=!!t.hardProof),i.ClrS=t.printerProfileColorSpace==="grayscale"?"ClrS.Grys":"ClrS.RGBC",t.printerProfile!==void 0&&(i["Nm "]=t.printerProfile)),i.Inte=fo.encode(t.renderingIntent),!t.printerManagesColors&&t.blackPointCompensation!==void 0&&(i.MpBl=!!t.blackPointCompensation),i.printSixteenBit=!!t.printSixteenBit,i.printerName=t.printerName||"",t.proofSetup&&"profile"in t.proofSetup?i.printProofSetup={profile:t.proofSetup.profile||"",Inte:fo.encode(t.proofSetup.renderingIntent),MpBl:!!t.proofSetup.blackPointCompensation,paperWhite:!!t.proofSetup.paperWhite}:t.proofSetup&&(i.printProofSetup={Bltn:`builtinProof.${t.proofSetup.builtin||"proofCMYK"}`}),(0,z.writeVersionAndDescriptor)(e,"","printOutput",i)});j(1083,e=>e.printStyle!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.printStyle={caption:t.Cptn,calibrationBars:t.Clbr,registrationMarks:t.RgsM,cornerCropMarks:t.CrnC,centerCropMarks:t.CntC,labels:t.Lbls,negative:t.Ngtv,emulsionDown:t.EmlD,interpolate:t.Intr,backgroundColor:(0,z.parseColor)(t.Bckg),border:(0,z.parseUnits)(t.BrdT),bleed:(0,z.parseUnits)(t["Bld "]),resolution:(0,z.parseUnits)(t.Rslt),vectorData:t.vectorData,pagePosition:t.PgPs==="PgPs.PgPC"?"centered":t.PgPs,left:(0,z.parseUnits)(t.Left),top:(0,z.parseUnits)(t["Top "]),scale:(0,z.parsePercent)(t["Scl "])},t.cropWhenPrinting!==void 0&&(n.printStyle.cropWhenPrinting=t.cropWhenPrinting,n.printStyle.cropRect={top:t.cropRectTop||0,left:t.cropRectLeft||0,bottom:t.cropRectBottom||0,right:t.cropRectRight||0})},(e,n)=>{var t,i,o,r,s,a,l,c,f,u;let d=n.printStyle,p={Cptn:!!d.caption,Clbr:!!d.calibrationBars,RgsM:!!d.registrationMarks,CrnC:!!d.cornerCropMarks,CntC:!!d.centerCropMarks,Lbls:!!d.labels,Ngtv:!!d.negative,EmlD:!!d.emulsionDown,Intr:!!d.interpolate,Bckg:(0,z.serializeColor)(d.backgroundColor||{r:255,g:255,b:255}),BrdT:(0,z.unitsValue)(d.border||{units:"Distance",value:0},"border"),"Bld ":(0,z.unitsValue)(d.bleed||{units:"Distance",value:0},"bleed"),Rslt:(0,z.unitsValue)(d.resolution||{units:"Pixels",value:72},"resolution"),vectorData:(t=d.vectorData)!==null&&t!==void 0?t:!0,PgPs:!d.pagePosition||d.pagePosition==="centered"?"PgPs.PgPC":d.pagePosition,Left:(0,z.unitsValue)(d.left||{units:"Distance",value:0},"left"),"Top ":(0,z.unitsValue)(d.top||{units:"Distance",value:0},"top"),"Scl ":(0,z.unitsPercentF)((i=d.scale)!==null&&i!==void 0?i:1)};(d.cropWhenPrinting!==void 0||d.cropRect)&&(p.cropWhenPrinting=!!d.cropWhenPrinting,p.cropRectBottom=(r=(o=d.cropRect)===null||o===void 0?void 0:o.bottom)!==null&&r!==void 0?r:0,p.cropRectLeft=(a=(s=d.cropRect)===null||s===void 0?void 0:s.left)!==null&&a!==void 0?a:0,p.cropRectRight=(c=(l=d.cropRect)===null||l===void 0?void 0:l.right)!==null&&c!==void 0?c:0,p.cropRectTop=(u=(f=d.cropRect)===null||f===void 0?void 0:f.top)!==null&&u!==void 0?u:0),(0,z.writeVersionAndDescriptor)(e,"","printOutputOptions",p)});j(1005,e=>e.resolutionInfo!==void 0,(e,n)=>{let t=(0,I.readFixedPoint32)(e),i=(0,I.readUint16)(e),o=(0,I.readUint16)(e),r=(0,I.readFixedPoint32)(e),s=(0,I.readUint16)(e),a=(0,I.readUint16)(e);n.resolutionInfo={horizontalResolution:t,horizontalResolutionUnit:lo[i]||"PPI",widthUnit:co[o]||"Inches",verticalResolution:r,verticalResolutionUnit:lo[s]||"PPI",heightUnit:co[a]||"Inches"}},(e,n)=>{let t=n.resolutionInfo;(0,P.writeFixedPoint32)(e,t.horizontalResolution||0),(0,P.writeUint16)(e,Math.max(1,lo.indexOf(t.horizontalResolutionUnit))),(0,P.writeUint16)(e,Math.max(1,co.indexOf(t.widthUnit))),(0,P.writeFixedPoint32)(e,t.verticalResolution||0),(0,P.writeUint16)(e,Math.max(1,lo.indexOf(t.verticalResolutionUnit))),(0,P.writeUint16)(e,Math.max(1,co.indexOf(t.heightUnit)))});var Sc=["centered","size to fit","user defined"];j(1062,e=>e.printScale!==void 0,(e,n)=>{n.printScale={style:Sc[(0,I.readInt16)(e)],x:(0,I.readFloat32)(e),y:(0,I.readFloat32)(e),scale:(0,I.readFloat32)(e)}},(e,n)=>{let{style:t,x:i,y:o,scale:r}=n.printScale;(0,P.writeInt16)(e,Math.max(0,Sc.indexOf(t))),(0,P.writeFloat32)(e,i||0),(0,P.writeFloat32)(e,o||0),(0,P.writeFloat32)(e,r||0)});j(1006,e=>e.alphaChannelNames!==void 0,(e,n,t)=>{if(n.alphaChannelNames)(0,I.skipBytes)(e,t());else for(n.alphaChannelNames=[];t()>0;){let i=Ec(e);n.alphaChannelNames.push(i)}},(e,n)=>{for(let t of n.alphaChannelNames)Mc(e,t)});j(1045,e=>e.alphaChannelNames!==void 0,(e,n,t)=>{for(n.alphaChannelNames=[];t()>0;)n.alphaChannelNames.push((0,I.readUnicodeString)(e))},(e,n)=>{for(let t of n.alphaChannelNames)(0,P.writeUnicodeStringWithPadding)(e,t)});var Uc=["selected","protected","spot"],Uh=[0,1,2,7,8];function Bc(e){let n={opacity:0,kind:"selected"},t=e.view.getUint16(e.offset);Uh.indexOf(t)!==-1?n.color=(0,I.readColor)(e):((0,I.skipBytes)(e,2),n.rawColor={colorSpace:t,values:[(0,I.readUint16)(e),(0,I.readUint16)(e),(0,I.readUint16)(e),(0,I.readUint16)(e)]}),n.opacity=(0,I.readUint16)(e)/100;let i=Uc[(0,I.readUint8)(e)];if(!i)throw new Error("Invalid display info kind");return n.kind=i,n}j(1007,()=>!1,(e,n,t)=>{let i=[];for(;t()>=14;)i.push(Bc(e)),(0,I.skipBytes)(e,1);n.alphaChannelDisplayInfo||(n.alphaChannelDisplayInfo=i)},()=>{},{fields:["alphaChannelDisplayInfo"]});j(1077,e=>e.alphaChannelDisplayInfo!==void 0,(e,n,t)=>{let i=(0,I.readUint32)(e);if(i!==1)throw new Error(`Invalid display info version: ${i}`);for(n.alphaChannelDisplayInfo=[];t()>=13;)n.alphaChannelDisplayInfo.push(Bc(e))},(e,n)=>{(0,P.writeUint32)(e,1);for(let t of n.alphaChannelDisplayInfo){if(!t.color&&t.rawColor){(0,P.writeUint16)(e,t.rawColor.colorSpace);for(let i=0;i<4;i++)(0,P.writeUint16)(e,t.rawColor.values[i]|0)}else(0,P.writeColor)(e,t.color||{r:255,g:0,b:0});(0,P.writeUint16)(e,Math.round((0,cn.clamp)(t.opacity,0,1)*100)),(0,P.writeUint8)(e,Math.max(0,Uc.indexOf(t.kind)))}});j(1053,e=>e.alphaIdentifiers!==void 0,(e,n,t)=>{for(n.alphaIdentifiers=[];t()>=4;)n.alphaIdentifiers.push((0,I.readUint32)(e))},(e,n)=>{for(let t of n.alphaIdentifiers)(0,P.writeUint32)(e,t)});j(1010,e=>e.backgroundColor!==void 0,(e,n)=>n.backgroundColor=(0,I.readColor)(e),(e,n)=>(0,P.writeColor)(e,n.backgroundColor));j(1037,e=>e.globalAngle!==void 0,(e,n)=>n.globalAngle=(0,I.readInt32)(e),(e,n)=>(0,P.writeInt32)(e,n.globalAngle));j(1049,e=>e.globalAltitude!==void 0,(e,n)=>n.globalAltitude=(0,I.readUint32)(e),(e,n)=>(0,P.writeUint32)(e,n.globalAltitude));j(1011,e=>e.printFlags!==void 0,(e,n,t)=>{n.printFlags={labels:!!(0,I.readUint8)(e),cropMarks:!!(0,I.readUint8)(e),colorBars:!!(0,I.readUint8)(e),registrationMarks:!!(0,I.readUint8)(e),negative:!!(0,I.readUint8)(e),flip:!!(0,I.readUint8)(e),interpolate:!!(0,I.readUint8)(e),caption:!!(0,I.readUint8)(e),printFlags:t()?!!(0,I.readUint8)(e):!1}},(e,n)=>{let t=n.printFlags;(0,P.writeUint8)(e,t.labels?1:0),(0,P.writeUint8)(e,t.cropMarks?1:0),(0,P.writeUint8)(e,t.colorBars?1:0),(0,P.writeUint8)(e,t.registrationMarks?1:0),(0,P.writeUint8)(e,t.negative?1:0),(0,P.writeUint8)(e,t.flip?1:0),(0,P.writeUint8)(e,t.interpolate?1:0),(0,P.writeUint8)(e,t.caption?1:0),(0,P.writeUint8)(e,t.printFlags?1:0)});j(1034,e=>e.copyrighted!==void 0,(e,n)=>{n.copyrighted=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.copyrighted?1:0)});j(1035,e=>e.url!==void 0,(e,n,t)=>{n.url=(0,I.readAsciiString)(e,t())},(e,n)=>{(0,P.writeAsciiString)(e,n.url)});j(1e4,e=>e.printFlagsInfo!==void 0,(e,n)=>{let t=(0,I.readUint16)(e);if(t!==1)throw new Error(`Invalid print flags information version: ${t}`);let i=!!(0,I.readUint8)(e);(0,I.skipBytes)(e,1);let o=(0,I.readUint32)(e),r=(0,I.readUint16)(e);n.printFlagsInfo={centerCropMarks:i,bleedWidth:o,bleedWidthScale:r}},(e,n)=>{let t=n.printFlagsInfo;(0,P.writeUint16)(e,1),(0,P.writeUint8)(e,t.centerCropMarks?1:0),(0,P.writeUint8)(e,0),(0,P.writeUint32)(e,t.bleedWidth|0),(0,P.writeUint16)(e,t.bleedWidthScale|0)});j(1046,e=>e.indexedColorCount!==void 0,(e,n)=>{n.indexedColorCount=(0,I.readUint16)(e)},(e,n)=>{(0,P.writeUint16)(e,n.indexedColorCount)});j(1047,e=>e.transparencyIndex!==void 0,(e,n)=>{n.transparencyIndex=(0,I.readUint16)(e)},(e,n)=>{(0,P.writeUint16)(e,n.transparencyIndex)});var Rc=["lines/inch","lines/cm"],Tc=["round","ellipse","line","square","cross",void 0,"diamond"];function Gr(e,n){let t=[];for(;n()>=18;){let i=(0,I.readFixedPoint32)(e),o=Rc[(0,I.readUint16)(e)-1];if(!o)throw new Error("Invalid halftone screen frequency units");let r=(0,I.readFixedPoint32)(e),s=Tc[(0,I.readInt16)(e)];if(!s)throw new Error("Invalid halftone screen shape");(0,I.skipBytes)(e,4);let a=!!(0,I.readUint8)(e),l=!!(0,I.readUint8)(e);t.push({frequency:i,frequencyUnits:o,angle:r,shape:s,accurateScreens:a,printerDefaultScreens:l})}return t}function Hr(e,n){for(let t of n)(0,P.writeFixedPoint32)(e,t.frequency),(0,P.writeUint16)(e,Math.max(0,Rc.indexOf(t.frequencyUnits))+1),(0,P.writeFixedPoint32)(e,t.angle),(0,P.writeInt16)(e,Math.max(0,Tc.indexOf(t.shape))),(0,P.writeZeros)(e,4),(0,P.writeUint8)(e,t.accurateScreens?1:0),(0,P.writeUint8)(e,t.printerDefaultScreens?1:0)}j(1012,e=>e.grayscaleHalftoneScreens!==void 0,(e,n,t)=>n.grayscaleHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.grayscaleHalftoneScreens));j(1013,e=>e.colorHalftoneScreens!==void 0,(e,n,t)=>n.colorHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.colorHalftoneScreens));function Wr(e,n){let t=[];for(;n()>=28;){let i=[];for(let r=0;r<13;r++)i.push((0,I.readInt16)(e));let o=!!(0,I.readUint16)(e);t.push({curve:i,override:o})}return t}function Xr(e,n){var t;for(let i of n){for(let o=0;o<13;o++)(0,P.writeInt16)(e,(t=i.curve[o])!==null&&t!==void 0?t:-1);(0,P.writeUint16)(e,i.override?1:0)}}j(1014,e=>e.duotoneHalftoneScreens!==void 0,(e,n,t)=>n.duotoneHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.duotoneHalftoneScreens));j(1017,e=>e.duotoneTransferFunctions!==void 0,(e,n,t)=>n.duotoneTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.duotoneTransferFunctions));j(1018,e=>e.duotoneImageInformation!==void 0,(e,n,t)=>n.duotoneImageInformation=(0,I.readBytes)(e,t()),(e,n)=>(0,P.writeBytes)(e,n.duotoneImageInformation));j(1066,e=>e.alternateDuotoneColors!==void 0,(e,n,t)=>{if((0,I.readUint16)(e)!==1)throw new Error("Invalid alternate duotone colors version");let i=[],o=(0,I.readUint16)(e);for(let a=0;a<o&&t()>=10;a++)i.push((0,I.readColor)(e));let r=(0,I.readUint16)(e);if(r*3>t())throw new Error("Invalid alternate duotone colors Lab table size");let s=(0,I.readBytes)(e,r*3);n.alternateDuotoneColors={colors:i,labColors:s}},(e,n)=>{let{colors:t,labColors:i}=n.alternateDuotoneColors;(0,P.writeUint16)(e,1),(0,P.writeUint16)(e,t.length);for(let o of t)(0,P.writeColor)(e,o);(0,P.writeUint16)(e,Math.floor(i.byteLength/3)),(0,P.writeBytes)(e,i.subarray(0,Math.floor(i.byteLength/3)*3))});j(1015,e=>e.grayscaleTransferFunctions!==void 0,(e,n,t)=>n.grayscaleTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.grayscaleTransferFunctions));j(1016,e=>e.colorTransferFunctions!==void 0,(e,n,t)=>n.colorTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.colorTransferFunctions));j(1080,e=>e.countInformation!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.countInformation=t.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,n)=>{let t={Vrsn:1,countGroupList:n.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,z.writeVersionAndDescriptor)(e,"","Cnt ",t)});j(1024,e=>e.layerState!==void 0,(e,n)=>n.layerState=(0,I.readUint16)(e),(e,n)=>(0,P.writeUint16)(e,n.layerState));j(1026,e=>e.layersGroup!==void 0,(e,n,t)=>{for(n.layersGroup=[];t()>0;)n.layersGroup.push((0,I.readUint16)(e))},(e,n)=>{for(let t of n.layersGroup)(0,P.writeUint16)(e,t)});j(1072,e=>e.layerGroupsEnabledId!==void 0,(e,n,t)=>{for(n.layerGroupsEnabledId=[];t()>0;)n.layerGroupsEnabledId.push((0,I.readUint8)(e))},(e,n)=>{for(let t of n.layerGroupsEnabledId)(0,P.writeUint8)(e,t)});j(1069,e=>e.layerSelectionIds!==void 0,(e,n)=>{let t=(0,I.readUint16)(e);for(n.layerSelectionIds=[];t--;)n.layerSelectionIds.push((0,I.readUint32)(e))},(e,n)=>{(0,P.writeUint16)(e,n.layerSelectionIds.length);for(let t of n.layerSelectionIds)(0,P.writeUint32)(e,t)});j(1032,e=>e.gridAndGuidesInformation!==void 0,(e,n)=>{var t;let i=(0,I.readUint32)(e),o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e);if(i!==1)throw new Error(`Invalid 1032 resource version: ${i}`);let a=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides,l=[];for(let c=0;c<s;c++){let f={location:(0,I.readInt32)(e)/32,direction:(0,I.readUint8)(e)?"horizontal":"vertical"};a?.length===s&&a[c].color&&(f.color=a[c].color),a?.length===s&&a[c].id&&(f.id=a[c].id),l.push(f)}n.gridAndGuidesInformation={grid:{horizontal:o,vertical:r},guides:l}},(e,n)=>{let t=n.gridAndGuidesInformation,i=t.grid||{horizontal:576,vertical:576},o=t.guides||[];(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,Math.round(i.horizontal)),(0,P.writeUint32)(e,Math.round(i.vertical)),(0,P.writeUint32)(e,o.length);for(let r of o)(0,P.writeInt32)(e,Math.round(r.location*32)),(0,P.writeUint8)(e,r.direction==="horizontal"?1:0)});var Bh={r:74,g:255,b:255};j(1092,e=>e.gridAndGuidesInformation!==void 0,(e,n)=>{var t;let i=(0,I.readUint32)(e);if(i!==2)throw new Error(`Invalid 1092 resource version: ${i}`);let o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e),a=[];for(let c=0;c<s;c++){let f=(0,I.readInt32)(e)/32,u=(0,I.readUint8)(e)?"horizontal":"vertical";(0,I.skipBytes)(e,1);let d={r:(0,I.readUint8)(e),g:(0,I.readUint8)(e),b:(0,I.readUint8)(e)};a.push({location:f,direction:u,color:d})}let l=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides;l&&l.length===s?l.forEach((c,f)=>c.color=a[f].color):n.gridAndGuidesInformation={grid:{horizontal:o,vertical:r},guides:a}},(e,n)=>{let t=n.gridAndGuidesInformation,i=t.grid||{horizontal:576,vertical:576},o=t.guides||[];(0,P.writeUint32)(e,2),(0,P.writeUint32)(e,Math.round(i.horizontal)),(0,P.writeUint32)(e,Math.round(i.vertical)),(0,P.writeUint32)(e,o.length);for(let r of o){let s=r.color||Bh;(0,P.writeInt32)(e,Math.round(r.location*32)),(0,P.writeUint8)(e,r.direction==="horizontal"?1:0),(0,P.writeUint8)(e,0),(0,P.writeUint8)(e,Math.round(s.r)),(0,P.writeUint8)(e,Math.round(s.g)),(0,P.writeUint8)(e,Math.round(s.b))}});var xc="00000000-0000-0000-0000-000000000000";j(1097,e=>!!e.gridAndGuidesInformation&&(e.gridAndGuidesInformation.guides||[]).every(n=>n.id),(e,n)=>{var t;let i=(0,I.readUint32)(e),o=[];for(let s=0;s<i;s++)o.push((0,I.readAsciiString)(e,(0,I.readUint32)(e))),(0,I.readUint32)(e),(0,I.readAsciiString)(e,(0,I.readUint32)(e));let r=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides;r&&r.length===i&&r.forEach((s,a)=>s.id=o[a])},(e,n)=>{let t=n.gridAndGuidesInformation.guides||[];(0,P.writeUint32)(e,t.length);for(let i of t)(0,P.writeUint32)(e,i.id.length),(0,P.writeAsciiString)(e,i.id),(0,P.writeUint32)(e,0),(0,P.writeUint32)(e,xc.length),(0,P.writeAsciiString)(e,xc)});j(1065,e=>e.layerComps!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e,!0);n.layerComps={list:[]};for(let i of t.list)n.layerComps.list.push({id:i.compID,name:i["Nm "],capturedInfo:i.capturedInfo}),i.comment!==void 0&&(n.layerComps.list[n.layerComps.list.length-1].comment=i.comment),i.Expn!==void 0&&(n.layerComps.list[n.layerComps.list.length-1].expanded=i.Expn);t.lastAppliedComp!==void 0&&(n.layerComps.lastApplied=t.lastAppliedComp)},(e,n)=>{let t=n.layerComps,i={list:[]};for(let o of t.list){let r={};r._classID="Comp",r["Nm "]=o.name,o.comment!==void 0&&(r.comment=o.comment),r.compID=o.id,r.capturedInfo=o.capturedInfo,o.expanded!==void 0&&(r.Expn=!!o.expanded),i.list.push(r)}t.lastApplied!==void 0&&(i.lastAppliedComp=t.lastApplied),(0,z.writeVersionAndDescriptor)(e,"","CompList",i)});cn.MOCK_HANDLERS&&j(1092,e=>e._ir1092!==void 0,(e,n,t)=>{Lh&&console.log("image resource 1092",t()),n._ir1092=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n._ir1092)});var kc=["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"];j(1078,e=>e.onionSkins!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.onionSkins={enabled:t.enab,framesBefore:t.numBefore,framesAfter:t.numAfter,frameSpacing:t.Spcn,minOpacity:t.minOpacity/100,maxOpacity:t.maxOpacity/100,blendMode:kc[t.BlnM]||"normal"}},(e,n)=>{let t=n.onionSkins,i={Vrsn:1,enab:t.enabled,numBefore:t.framesBefore,numAfter:t.framesAfter,Spcn:t.frameSpacing,minOpacity:Math.round(t.minOpacity*100),maxOpacity:Math.round(t.maxOpacity*100),BlnM:Math.max(0,kc.indexOf(t.blendMode))};(0,z.writeVersionAndDescriptor)(e,"","null",i)});j(1075,e=>e.timelineInformation!==void 0,(e,n)=>{var t,i;let o=(0,z.readVersionAndDescriptor)(e);n.timelineInformation={enabled:o.enab,frameStep:(0,z.frac)(o.frameStep),frameRate:o.frameRate,time:(0,z.frac)(o.time),duration:(0,z.frac)(o.duration),workInTime:(0,z.frac)(o.workInTime),workOutTime:(0,z.frac)(o.workOutTime),repeats:o.LCnt,hasMotion:o.hasMotion,globalTracks:(0,z.parseTrackList)(o.globalTrackList,e)},!((i=(t=o.audioClipGroupList)===null||t===void 0?void 0:t.audioClipGroupList)===null||i===void 0)&&i.length&&(n.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:f})=>({id:s,start:(0,z.frac)(a.Strt),duration:(0,z.frac)(a.duration),inTime:(0,z.frac)(a.inTime),outTime:(0,z.frac)(a.outTime),muted:l,audioLevel:c,frameReader:{type:f.frameReaderType,mediaDescriptor:f.mediaDescriptor,link:{name:f["Lnk "]["Nm "],fullPath:f["Lnk "].fullPath,relativePath:f["Lnk "].relPath}}}))})))},(e,n)=>{var t;let i=n.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,z.serializeTrackList)(i.globalTracks,e),audioClipGroupList:{audioClipGroupList:((t=i.audioClipGroups)!==null&&t!==void 0?t:[]).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,z.writeVersionAndDescriptor)(e,"","null",o,"anim")});j(1076,e=>e.sheetDisclosure!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.sheetDisclosure={},t.sheetTimelineOptions&&(n.sheetDisclosure.sheetTimelineOptions=t.sheetTimelineOptions.map(i=>({sheetID:i.sheetID,sheetDisclosed:i.sheetDisclosed,lightsDisclosed:i.lightsDisclosed,meshesDisclosed:i.meshesDisclosed,materialsDisclosed:i.materialsDisclosed})))},(e,n)=>{let t=n.sheetDisclosure,i={Vrsn:1};t.sheetTimelineOptions&&(i.sheetTimelineOptions=t.sheetTimelineOptions.map(o=>({Vrsn:2,sheetID:o.sheetID,sheetDisclosed:o.sheetDisclosed,lightsDisclosed:o.lightsDisclosed,meshesDisclosed:o.meshesDisclosed,materialsDisclosed:o.materialsDisclosed}))),(0,z.writeVersionAndDescriptor)(e,"","null",i)});j(1054,e=>e.urlsList!==void 0,(e,n)=>{let t=(0,I.readUint32)(e);n.urlsList=[];for(let i=0;i<t;i++){if((0,I.readSignature)(e)!=="slic"&&e.throwForMissingFeatures)throw new Error("Unknown long");let r=(0,I.readUint32)(e),s=(0,I.readUnicodeString)(e);n.urlsList.push({id:r,url:s,ref:"slice"})}},(e,n)=>{let t=n.urlsList;(0,P.writeUint32)(e,t.length);for(let i=0;i<t.length;i++)(0,P.writeSignature)(e,"slic"),(0,P.writeUint32)(e,t[i].id),(0,P.writeUnicodeString)(e,t[i].url)});function _c(e){return{"Top ":e.top,Left:e.left,Btom:e.bottom,Rght:e.right}}function Ac(e){return{top:e["Top "],left:e.Left,bottom:e.Btom,right:e.Rght}}function uo(e,n){return e[Math.max(0,Math.min(e.length-1,n))]}var Ic=["autoGenerated","layer","userGenerated"],Cc=["noImage","image"],po=["default"];j(1050,e=>e.slices?e.slices.length:0,(e,n,t)=>{var i;let o=(0,I.readUint32)(e);if(o===6){n.slices||(n.slices=[]);let r=(0,I.readInt32)(e),s=(0,I.readInt32)(e),a=(0,I.readInt32)(e),l=(0,I.readInt32)(e),c=(0,I.readUnicodeString)(e),f=(0,I.readUint32)(e);n.slices.push({bounds:{top:r,left:s,bottom:a,right:l},groupName:c,slices:[]});let u=n.slices[n.slices.length-1].slices;for(let d=0;d<f;d++){let p=(0,I.readUint32)(e),h=(0,I.readUint32)(e),m=uo(Ic,(0,I.readUint32)(e)),y=m=="layer"?(0,I.readUint32)(e):0,g=(0,I.readUnicodeString)(e),k=uo(Cc,(0,I.readUint32)(e)),x=(0,I.readInt32)(e),S=(0,I.readInt32)(e),A=(0,I.readInt32)(e),D=(0,I.readInt32)(e),C=(0,I.readUnicodeString)(e),O=(0,I.readUnicodeString)(e),E=(0,I.readUnicodeString)(e),L=(0,I.readUnicodeString)(e),M=!!(0,I.readUint8)(e),J=(0,I.readUnicodeString)(e),pe=uo(po,(0,I.readUint32)(e)),R=uo(po,(0,I.readUint32)(e)),ie=(0,I.readUint8)(e),he=(0,I.readUint8)(e),ce=(0,I.readUint8)(e),Ce=(0,I.readUint8)(e),W=ie+he+ce+Ce===0?"none":ie===0?"matte":"color";u.push({id:p,groupId:h,origin:m,associatedLayerId:y,name:g,target:O,message:E,altTag:L,cellTextIsHTML:M,cellText:J,horizontalAlignment:pe,verticalAlignment:R,type:k,url:C,bounds:{top:S,left:x,bottom:D,right:A},backgroundColorType:W,backgroundColor:{r:he,g:ce,b:Ce,a:ie}})}if(t()){let d=(0,z.readVersionAndDescriptor)(e),p=new Map;for(let h of u)p.has(h.id)||p.set(h.id,h);d.slices.forEach(h=>{let m=p.get(h.sliceID);m&&(m.topOutset=h.topOutset,m.leftOutset=h.leftOutset,m.bottomOutset=h.bottomOutset,m.rightOutset=h.rightOutset)})}}else if(o===7||o===8){let r=(0,z.readVersionAndDescriptor)(e);n.slices||(n.slices=[]),n.slices.push({groupName:(i=r.baseName)!==null&&i!==void 0?i:"",bounds:Ac(r.bounds),slices:r.slices.map(s=>{var a;return Object.assign(Object.assign({},s["Nm "]?{name:s["Nm "]}:{}),{id:s.sliceID,groupId:s.groupID,associatedLayerId:(a=s.associatedLayer)!==null&&a!==void 0?a:0,origin:z.ESliceOrigin.decode(s.origin),type:z.ESliceType.decode(s.Type),bounds:Ac(s.bounds),url:s.url,target:s.null,message:s.Msge,altTag:s.altTag,cellTextIsHTML:s.cellTextIsHTML,cellText:s.cellText,horizontalAlignment:z.ESliceHorzAlign.decode(s.horzAlign),verticalAlignment:z.ESliceVertAlign.decode(s.vertAlign),backgroundColorType:z.ESliceBGColorType.decode(s.bgColorType),backgroundColor:s.bgColor?{r:s.bgColor["Rd "],g:s.bgColor["Grn "],b:s.bgColor["Bl "],a:s.bgColor.alpha}:{r:0,g:0,b:0,a:0},topOutset:s.topOutset||0,leftOutset:s.leftOutset||0,bottomOutset:s.bottomOutset||0,rightOutset:s.rightOutset||0})})})}else throw new Error(`Invalid slices version (${o})`)},(e,n,t)=>{let{bounds:i,groupName:o,slices:r}=n.slices[t];(0,P.writeUint32)(e,6),(0,P.writeInt32)(e,i.top),(0,P.writeInt32)(e,i.left),(0,P.writeInt32)(e,i.bottom),(0,P.writeInt32)(e,i.right),(0,P.writeUnicodeString)(e,o),(0,P.writeUint32)(e,r.length);for(let a=0;a<r.length;a++){let l=r[a],{a:c,r:f,g:u,b:d}=l.backgroundColor;l.backgroundColorType==="none"?c=f=u=d=0:l.backgroundColorType==="matte"&&(c=0,f=u=d=255),(0,P.writeUint32)(e,l.id),(0,P.writeUint32)(e,l.groupId),(0,P.writeUint32)(e,Ic.indexOf(l.origin)),l.origin==="layer"&&(0,P.writeUint32)(e,l.associatedLayerId),(0,P.writeUnicodeString)(e,l.name||""),(0,P.writeUint32)(e,Cc.indexOf(l.type)),(0,P.writeInt32)(e,l.bounds.left),(0,P.writeInt32)(e,l.bounds.top),(0,P.writeInt32)(e,l.bounds.right),(0,P.writeInt32)(e,l.bounds.bottom),(0,P.writeUnicodeString)(e,l.url),(0,P.writeUnicodeString)(e,l.target),(0,P.writeUnicodeString)(e,l.message),(0,P.writeUnicodeString)(e,l.altTag),(0,P.writeUint8)(e,l.cellTextIsHTML?1:0),(0,P.writeUnicodeString)(e,l.cellText),(0,P.writeUint32)(e,po.indexOf(l.horizontalAlignment)),(0,P.writeUint32)(e,po.indexOf(l.verticalAlignment)),(0,P.writeUint8)(e,c),(0,P.writeUint8)(e,f),(0,P.writeUint8)(e,u),(0,P.writeUint8)(e,d)}let s={bounds:_c(i),slices:[]};r.forEach(a=>{let l=Object.assign(Object.assign({sliceID:a.id,groupID:a.groupId,origin:z.ESliceOrigin.encode(a.origin),Type:z.ESliceType.encode(a.type),bounds:_c(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:z.ESliceHorzAlign.encode(a.horizontalAlignment),vertAlign:z.ESliceVertAlign.encode(a.verticalAlignment),bgColorType:z.ESliceBGColorType.encode(a.backgroundColorType)});if(a.backgroundColorType==="color"){let{r:c,g:f,b:u,a:d}=a.backgroundColor;l.bgColor={"Rd ":c,"Grn ":f,"Bl ":u,alpha:d}}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,z.writeVersionAndDescriptor)(e,"","null",s,"slices")});j(1064,e=>e.pixelAspectRatio!==void 0,(e,n)=>{if((0,I.readUint32)(e)>2)throw new Error("Invalid pixelAspectRatio version");n.pixelAspectRatio={aspect:(0,I.readFloat64)(e)}},(e,n)=>{(0,P.writeUint32)(e,2),(0,P.writeFloat64)(e,n.pixelAspectRatio.aspect)});j(1041,e=>e.iccUntaggedProfile!==void 0,(e,n)=>{n.iccUntaggedProfile=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.iccUntaggedProfile?1:0)});j(1039,e=>e.iccProfile!==void 0,(e,n,t)=>{n.iccProfile=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.iccProfile)});j(1044,e=>e.idsSeedNumber!==void 0,(e,n)=>n.idsSeedNumber=(0,I.readUint32)(e),(e,n)=>(0,P.writeUint32)(e,n.idsSeedNumber));j(1038,e=>e.colorSamplers!==void 0&&!e.colorSamplers.some(n=>n.depth!==void 0),(e,n,t)=>{var i;let o=(0,I.readUint32)(e);if(o!==1)throw new Error(`Invalid color samplers version: ${o}`);if(!((i=n.colorSamplers)===null||i===void 0)&&i.some(s=>s.depth!==void 0))return(0,I.skipBytes)(e,t());let r=(0,I.readUint32)(e);n.colorSamplers=[];for(let s=0;s<r&&t()>=10;s++){let a=(0,I.readInt32)(e)/16,l=(0,I.readInt32)(e)/16,c=(0,I.readInt16)(e);n.colorSamplers.push({x:l,y:a,colorSpace:c})}},(e,n)=>{(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,n.colorSamplers.length);for(let t of n.colorSamplers)(0,P.writeInt32)(e,Math.round(t.y*16)),(0,P.writeInt32)(e,Math.round(t.x*16)),(0,P.writeInt16)(e,t.colorSpace)});j(1073,e=>e.colorSamplers!==void 0&&e.colorSamplers.some(n=>n.depth!==void 0),(e,n,t)=>{let i=(0,I.readUint32)(e);if(i<1||i>3)throw new Error(`Invalid color samplers version: ${i}`);let o=(0,I.readUint32)(e);n.colorSamplers=[];for(let r=0;r<o&&t()>=10;r++){let s=i===3?(0,I.readUint32)(e):i,a=s===1?(0,I.readInt32)(e)/16:(0,I.readFloat32)(e),l=s===1?(0,I.readInt32)(e)/16:(0,I.readFloat32)(e),c=(0,I.readInt16)(e),f=i>=2?(0,I.readInt16)(e):1;n.colorSamplers.push({x:l,y:a,colorSpace:c,depth:f})}},(e,n)=>{var t;(0,P.writeUint32)(e,3),(0,P.writeUint32)(e,n.colorSamplers.length);for(let i of n.colorSamplers)(0,P.writeUint32)(e,1),(0,P.writeInt32)(e,Math.round(i.y*16)),(0,P.writeInt32)(e,Math.round(i.x*16)),(0,P.writeInt16)(e,i.colorSpace),(0,P.writeInt16)(e,(t=i.depth)!==null&&t!==void 0?t:1)});j(1022,e=>e.quickMaskInfo!==void 0,(e,n)=>{let t=(0,I.readUint16)(e),i=!!(0,I.readUint8)(e);n.quickMaskInfo={channelId:t,initiallyEmpty:i}},(e,n)=>{(0,P.writeUint16)(e,n.quickMaskInfo.channelId),(0,P.writeUint8)(e,n.quickMaskInfo.initiallyEmpty?1:0)});j(1074,e=>e.measurementScale!==void 0,(e,n,t)=>{n.measurementScale=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.measurementScale)});j(1042,e=>e.effectsVisible!==void 0,(e,n)=>{n.effectsVisible=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.effectsVisible?1:0)});j(1036,e=>e.thumbnail!==void 0||e.thumbnailRaw!==void 0,(e,n,t)=>{let i=(0,I.readUint32)(e),o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e);(0,I.readUint32)(e),(0,I.readUint32)(e);let a=(0,I.readUint16)(e);if((0,I.readUint16)(e),i===0&&a===24&&s>=o*3&&s*r<=t()){if(e.useRawThumbnail){e.logMissingFeatures&&e.log("Raw thumbnail data is not supported with useRawThumbnail option"),(0,I.skipBytes)(e,t());return}let f=(0,I.readBytes)(e,s*r),u=(0,cn.createImageData)(o,r);for(let d=0,p=0;d<r;d++)for(let h=0,m=d*s;h<o;h++,m+=3,p+=4)u.data[p+0]=f[m+0],u.data[p+1]=f[m+1],u.data[p+2]=f[m+2],u.data[p+3]=255;n.thumbnail=(0,cn.imageDataToCanvas)(u),(0,I.skipBytes)(e,t());return}if(i!==1||a!==24){e.logMissingFeatures&&e.log(`Invalid thumbnail data (format: ${i}, bitsPerPixel: ${a})`),(0,I.skipBytes)(e,t());return}let l=t(),c=(0,I.readBytes)(e,l);e.useRawThumbnail?n.thumbnailRaw={width:o,height:r,data:c}:c.byteLength&&(n.thumbnail=(0,cn.createCanvasFromData)(c,e))},(e,n)=>{var t;let i=0,o=0,r=new Uint8Array(0);if(n.thumbnailRaw)i=n.thumbnailRaw.width,o=n.thumbnailRaw.height,r=n.thumbnailRaw.data;else try{let u=(t=n.thumbnail.toDataURL("image/jpeg",1))===null||t===void 0?void 0:t.substring(23);u&&(r=(0,Dh.toByteArray)(u),i=n.thumbnail.width,o=n.thumbnail.height)}catch{}let s=24,a=Math.floor((i*s+31)/32)*4,l=1,c=a*o*l,f=r.length;(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,i),(0,P.writeUint32)(e,o),(0,P.writeUint32)(e,a),(0,P.writeUint32)(e,c),(0,P.writeUint32)(e,f),(0,P.writeUint16)(e,s),(0,P.writeUint16)(e,l),(0,P.writeBytes)(e,r)});j(1057,e=>e.versionInfo!==void 0,(e,n,t)=>{if((0,I.readUint32)(e)!==1)throw new Error("Invalid versionInfo version");n.versionInfo={hasRealMergedData:!!(0,I.readUint8)(e),writerName:(0,I.readUnicodeString)(e),readerName:(0,I.readUnicodeString)(e),fileVersion:(0,I.readUint32)(e)},(0,I.skipBytes)(e,t())},(e,n)=>{let t=n.versionInfo;(0,P.writeUint32)(e,1),(0,P.writeUint8)(e,t.hasRealMergedData?1:0),(0,P.writeUnicodeString)(e,t.writerName),(0,P.writeUnicodeString)(e,t.readerName),(0,P.writeUint32)(e,t.fileVersion)});j(1058,e=>e.exifData!==void 0,(e,n,t)=>{n.exifData=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.exifData)});j(7e3,e=>e.imageReadyVariables!==void 0,(e,n,t)=>{n.imageReadyVariables=Vr(e,t())},(e,n)=>{Nr(e,n.imageReadyVariables)});j(7001,e=>e.imageReadyDataSets!==void 0,(e,n,t)=>{n.imageReadyDataSets=Vr(e,t())},(e,n)=>{Nr(e,n.imageReadyDataSets)});j(1088,e=>e.pathSelectionState!==void 0,(e,n,t)=>{let i=(0,z.readVersionAndDescriptor)(e);n.pathSelectionState=i.null},(e,n)=>{let t={null:(0,z.pathSelectionStateToReference)(n.pathSelectionState)};(0,z.writeVersionAndDescriptor)(e,"","null",t)});j(1025,e=>e.workPath!==void 0,(e,n,t,{width:i,height:o})=>{n.workPath={paths:[]},(0,Fn.readVectorMask)(e,n.workPath,i,o,t()),(0,I.skipBytes)(e,t())},(e,n,t,{width:i,height:o})=>{(0,Fn.writeVectorMask)(e,n.workPath,i,o)});var $r=999;j(2e3,e=>e.savedPaths?Math.min(e.savedPaths.length,$r):0,(e,n,t,{signature:i,id:o,name:r,width:s,height:a})=>{var l,c;if(i!=="8BIM"){e.logMissingFeatures&&e.log(`Unhandled image resource: ${i} ${o}`),(0,I.skipBytes)(e,t());return}let f=(l=n.savedPaths)!==null&&l!==void 0?l:n.savedPaths=[],u={name:Fc(e,r),paths:[]};(0,Fn.readVectorMask)(e,u,s,a,t()),(0,I.skipBytes)(e,t());let d=(c=n.savedPathsOrigination)===null||c===void 0?void 0:c[f.length];d&&(u.vectorOrigination={keyDescriptorList:d}),f.push(u)},(e,n,t,{width:i,height:o})=>{(0,Fn.writeVectorMask)(e,n.savedPaths[t],i,o)},{keyCount:$r,name:(e,n)=>Lc(e.savedPaths[n].name)});j(3e3,e=>{var n;return!!(!((n=e.savedPaths)===null||n===void 0)&&n.some(t=>t.vectorOrigination))},(e,n,t)=>{(0,z.readVersionAndDescriptor)(e).keyRootDescriptorList.forEach((o,r)=>{var s,a;let l=(0,Fn.parseKeyDescriptorList)(o);if(!l.length)return;let c=(s=n.savedPaths)===null||s===void 0?void 0:s[r];c?c.vectorOrigination={keyDescriptorList:l}:((a=n.savedPathsOrigination)!==null&&a!==void 0?a:n.savedPathsOrigination=[])[r]=l}),(0,I.skipBytes)(e,t())},(e,n)=>{let t={keyRootDescriptorList:n.savedPaths.slice(0,$r).map(i=>{var o,r;return(0,Fn.serializeKeyDescriptorList)((r=(o=i.vectorOrigination)===null||o===void 0?void 0:o.keyDescriptorList)!==null&&r!==void 0?r:[])})};(0,z.writeVersionAndDescriptor)(e,"","null",t)},{name:()=>"OriginDataIRB"});j(2999,e=>e.clippingPath!==void 0,(e,n,t)=>{let i=Ec(e),o=(0,I.readFixedPoint32)(e);(0,I.skipBytes)(e,t()),n.clippingPath={name:i,flatness:o}},(e,n)=>{Mc(e,n.clippingPath.name),(0,P.writeFixedPoint32)(e,n.clippingPath.flatness),(0,P.writeUint16)(e,1)});var Pc=(0,cn.createEnum)("FrmD","auto",{auto:"Auto",none:"None",dispose:"Disp"});function Dc(e){let n=[];return e.outputSettings!==void 0&&n.push("mset"),e.animations!==void 0&&n.push("mani","mfri"),n}j(4e3,e=>Dc(e).length,(e,n,t)=>{let i=(0,I.readSignature)(e);if(i==="mset")n.outputSettings=(0,z.readVersionAndDescriptor)(e,!0),(0,I.skipBytes)(e,t());else if(i==="mfri")(0,I.skipBytes)(e,t());else if(i==="mani")(0,I.checkSignature)(e,"IRFR"),(0,I.readSection)(e,1,o=>{for(;o()>0;){(0,I.checkSignature)(e,"8BIM");let r=(0,I.readSignature)(e);(0,I.readSection)(e,1,s=>{if(r==="AnDs"){let a=(0,z.readVersionAndDescriptor)(e);n.animations={frames:a.FrIn.map(l=>{let c={id:l.FrID,delay:(l.FrDl||0)/100,dispose:l.FrDs?Pc.decode(l.FrDs):"auto"};return l.FrGA!==void 0&&(c.globalAngle=l.FrGA),l.FrGL!==void 0&&(c.globalAltitude=l.FrGL),c}),animations:a.FSts.map(l=>({id:l.FsID,frames:l.FsFr,repeats:l.LCnt,activeFrame:l.AFrm||0}))},a.AFSt!==void 0&&(n.animations.activeAnimation=a.AFSt),(0,I.skipBytes)(e,s())}else if(r==="Roll"){let a=(0,I.readBytes)(e,s());e.logDevFeatures&&e.log("#4000 Roll",a)}else e.logMissingFeatures&&e.log("Unhandled subsection in #4000",r),(0,I.skipBytes)(e,s())})}}),(0,I.skipBytes)(e,t());else if(i==="mopt"){let o=(0,I.readBytes)(e,t());e.logDevFeatures&&e.log("#4000 mopt",o)}else e.logMissingFeatures&&e.log(`Unhandled plug-in resource key: ${i}`),(0,I.skipBytes)(e,t())},(e,n,t)=>{var i,o;let r=Dc(n)[t];if(r==="mset")(0,P.writeSignature)(e,"mset"),(0,z.writeVersionAndDescriptor)(e,"","null",n.outputSettings,z.outputSettingsRoot);else if(r==="mfri"){let s=n.animations;(0,P.writeSignature)(e,"mfri"),(0,P.writeUint32)(e,2),(0,P.writeUint32)(e,16),(0,P.writeUint32)(e,s.frames.length),(0,P.writeUint32)(e,(o=(i=s.animations[0])===null||i===void 0?void 0:i.activeFrame)!==null&&o!==void 0?o:0),(0,P.writeUint32)(e,s.animations.length),(0,P.writeUint32)(e,0)}else r==="mani"&&((0,P.writeSignature)(e,"mani"),(0,P.writeSignature)(e,"IRFR"),(0,P.writeSection)(e,1,()=>{(0,P.writeSignature)(e,"8BIM"),(0,P.writeSignature)(e,"AnDs"),(0,P.writeSection)(e,1,()=>{let s=Object.assign(Object.assign({},n.animations.activeAnimation!==void 0?{AFSt:n.animations.activeAnimation}:{}),{FrIn:[],FSts:[]});for(let a=0;a<n.animations.frames.length;a++){let l=n.animations.frames[a],c={FrID:l.id};l.delay&&(c.FrDl=Math.round(l.delay*100)),c.FrDs=Pc.encode(l.dispose),l.globalAngle!==void 0&&(c.FrGA=l.globalAngle),l.globalAltitude!==void 0&&(c.FrGL=l.globalAltitude),s.FrIn.push(c)}for(let a=0;a<n.animations.animations.length;a++){let l=n.animations.animations[a],c={FsID:l.id,AFrm:l.activeFrame|0,FsFr:l.frames,LCnt:l.repeats|0};s.FSts.push(c)}(0,z.writeVersionAndDescriptor)(e,"","null",s)}),(0,P.writeSignature)(e,"8BIM"),(0,P.writeSignature)(e,"Roll"),(0,P.writeSection)(e,1,()=>{(0,P.writeZeros)(e,8)})}))},{keyCount:1e3})});var st=ae(N=>{"use strict";var Rh=N&&N.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(N,"__esModule",{value:!0});N.supportedColorModes=void 0;N.getUtf8Decoder=Gc;N.getUtf8StrictDecoder=Vh;N.getGbkStrictDecoder=Nh;N.decodeUtf8=Gh;N.createReader=mi;N.warnOrThrow=qt;N.readUint8=ve;N.peekUint8=Hc;N.readInt16=Xt;N.readUint16=de;N.readUint16LE=Hh;N.readInt32=Re;N.readInt32LE=Wh;N.readUint32=we;N.readFloat32=Xh;N.readFloat64=es;N.readFixedPoint32=qh;N.readFixedPointPath32=Zh;N.readBytes=xt;N.readSignature=yi;N.validSignatureAt=Wc;N.readPascalString=ss;N.readUnicodeString=Xc;N.readUnicodeStringWithLength=Yc;N.readUnicodeStringWithLengthLE=Kh;N.readAsciiString=Yh;N.skipBytes=_e;N.checkSignature=ls;N.readPsd=Qh;N.readLayerInfo=Qc;N.getCompositeImageData=tf;N.getCompositeCanvas=rg;N.getLayerImageData=nf;N.getLayerMaskImageData=of;N.getLayerRealMaskImageData=rf;N.getLayerCanvas=sg;N.getLayerMaskCanvas=ag;N.getLayerRealMaskCanvas=lg;N.getFilterEffectsMaskImageData=sf;N.getFilterEffectsMaskExtraImageData=af;N.getFilterEffectsMaskCanvas=cg;N.getFilterEffectsMaskExtraCanvas=fg;N.decodeLayerPixels=dg;N.readGlobalLayerMaskInfo=cf;N.readAdditionalLayerInfo=cs;N.readDataZip=os;N.readDataRLE=bi;N.readSection=at;N.readColor=Sg;N.readPatternSafe=xg;N.readPattern=hf;N.consumeMemory=Mn;var Th=Hi(),Te=Ot(),jh=ui(),zh=Br(),jc=qr();N.supportedColorModes=[0,1,3,2,4];var $h=["bitmap","grayscale","indexed","RGB","CMYK","","","multichannel","duotone","lab"];function hi(e){let n=e.width*e.height*4;for(let t=0;t<n;t+=4){let i=e.data[t];e.data[t+1]=i,e.data[t+2]=i}}function rs(e,n){try{return typeof TextDecoder<"u"?new TextDecoder(e,n):null}catch{return null}}function Gc(e){return e.utf8Decoder===void 0&&(e.utf8Decoder=rs("utf-8",{ignoreBOM:!0})),e.utf8Decoder}function Vh(e){return e.utf8StrictDecoder===void 0&&(e.utf8StrictDecoder=rs("utf-8",{ignoreBOM:!0,fatal:!0})),e.utf8StrictDecoder}function Nh(e){return e.gbkDecoder===void 0&&(e.gbkDecoder=rs("gbk",{fatal:!0})),e.gbkDecoder}function Gh(e,n){let t=n.byteLength>1e3?Gc(e):null;return t?t.decode(n):(0,zh.decodeString)(n)}function mi(e,n,t){return{view:new DataView(e,n,t),offset:0,strict:!1,debug:!1,large:!1,globalAlpha:!1,log:console.log}}function qt(e,n){if(e.strict)throw new Error(n);e.debug&&e.log(n)}function ve(e){return e.offset+=1,e.view.getUint8(e.offset-1)}function Hc(e){return e.view.getUint8(e.offset)}function Xt(e){return e.offset+=2,e.view.getInt16(e.offset-2,!1)}function de(e){return e.offset+=2,e.view.getUint16(e.offset-2,!1)}function Hh(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 Wh(e){return e.offset+=4,e.view.getInt32(e.offset-4,!0)}function we(e){return e.offset+=4,e.view.getUint32(e.offset-4,!1)}function Xh(e){return e.offset+=4,e.view.getFloat32(e.offset-4,!1)}function es(e){return e.offset+=8,e.view.getFloat64(e.offset-8,!1)}function qh(e){return Re(e)/65536}function Zh(e){return Re(e)/(1<<24)}function xt(e,n){if(!(n>=0))throw new Error(`Invalid length: ${n}`);let t=e.offset,i=e.view.byteLength;if(e.offset+=n,t+n>i){if(qt(e,"Reading bytes exceeding buffer length"),n>100*1024*1024)throw new Error("Reading past end of file");Mn(e,n);let o=new Uint8Array(n),r=Math.min(n,i-t);return r>0&&o.set(new Uint8Array(e.view.buffer,e.view.byteOffset+t,r)),o}else return new Uint8Array(e.view.buffer,e.view.byteOffset+t,n)}function yi(e){return Jc(e,4)}function Wc(e,n){let t=String.fromCharCode(e.view.getUint8(n))+String.fromCharCode(e.view.getUint8(n+1))+String.fromCharCode(e.view.getUint8(n+2))+String.fromCharCode(e.view.getUint8(n+3));return t=="8BIM"||t=="8B64"}function ss(e,n){let t=ve(e),i=t?Jc(e,t):"";for(;++t%n;)e.offset++;return i}function Xc(e){let n=we(e);return Yc(e,n)}var pi=8192,as=64;function qc(e,n){if(e.offset<0||e.offset+n>e.view.byteLength)throw new RangeError("Offset is outside the bounds of the DataView")}function Zc(e,n,t){if(!(n>0))return"";qc(e,n*2);let i=e.view,o=e.offset,r="";if(n<=as){for(let a=0;a<n;a++,o+=2)r+=String.fromCharCode(i.getUint16(o,t));return e.offset=o,r.charCodeAt(r.length-1)===0&&(r=r.substring(0,r.length-1)),r}let s=new Uint16Array(Math.min(n,pi));for(let a=0;a<n;a+=pi){let l=Math.min(pi,n-a);for(let c=0;c<l;c++,o+=2)s[c]=i.getUint16(o,t);r+=String.fromCharCode.apply(null,l===s.length?s:s.subarray(0,l))}return e.offset=o,r.charCodeAt(r.length-1)===0&&(r=r.substring(0,r.length-1)),r}function Kc(e){let n="";for(let t=0;t<e.length;t+=pi)n+=String.fromCharCode.apply(null,e.subarray(t,t+pi));return n}function Yc(e,n){return Zc(e,n,!1)}function Kh(e,n){return Zc(e,n,!0)}function Yh(e,n){if(!(n>0))return"";if(qc(e,n),n<=as){let i=e.view,o="";for(let r=0,s=e.offset;r<n;r++,s++)o+=String.fromCharCode(i.getUint8(s));return e.offset+=n,o}let t=Kc(new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,n));return e.offset+=n,t}function _e(e,n){e.offset+=n}function ls(e,n,t){let i=e.offset,o=yi(e);if(o!==n&&o!==t)throw new Error(`Invalid signature: '${o}' at 0x${i.toString(16)}`)}function Jc(e,n){let t=xt(e,n);if(n>as)return Kc(t);let i="";for(let o=0;o<t.length;o++)i+=String.fromCharCode(t[o]);return i}function Jh(e){return e==="8BIM"||e==="MeSa"||e==="AgHg"||e==="PHUT"||e==="DCSR"}function Qh(e,n={}){var t;ls(e,"8BPS");let i=de(e);if(i!==1&&i!==2)throw new Error(`Invalid PSD file version: ${i}`);_e(e,6);let o=de(e),r=we(e),s=we(e),a=de(e),l=de(e),c=i===1?3e4:3e5;if(s>c||r>c)throw new Error(`Invalid size: ${s}x${r}`);if(o<1||o>57)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: ${(t=$h[l])!==null&&t!==void 0?t:l}`);let f={width:s,height:r,channels:o,bitsPerChannel:a,colorMode:l};Object.assign(e,n),e.large=i===2,e.globalAlpha=!1,e.layersInGlobalInfo=!1;let u=e.imageResourcesWhitelist;e.imageResourcesWhitelistSet=u?u instanceof Set?u:new Set(u):void 0,"totalMemoryLimit"in e||(e.totalMemoryLimit=2*1024*1024*1024),at(e,1,S=>{if(S()){if(l===2){if(S()!=768)throw new Error("Invalid color palette size");f.palette=[];for(let A=0;A<256;A++)f.palette.push({r:ve(e),g:0,b:0});for(let A=0;A<256;A++)f.palette[A].g=ve(e);for(let A=0;A<256;A++)f.palette[A].b=ve(e)}_e(e,S())}});let d={},p=0;at(e,1,S=>{for(;S()>=12;){let A=ff(e,Jh),D=de(e),C=ve(e),O=xt(e,C);_e(e,(C+1)%2),at(e,2,E=>{let L=jc.resourceHandlersMap[D];if(L)if(D===1036&&!!e.skipThumbnail||!(0,jc.shouldReadResource)(L,e.imageResourcesWhitelistSet))_e(e,E());else try{L.read(e,d,E,{signature:A,id:D,name:O,width:s,height:r})}catch(J){if(e.throwForMissingFeatures)throw J;_e(e,E())}else e.logMissingFeatures&&e.log(`Unhandled image resource: ${D} (${E()})`),_e(e,E())})}p=S(),_e(e,S())}),p&&!zc(e,e.offset)&&zc(e,e.offset-p)&&(e.offset-=p);let{layersGroup:h,layerGroupsEnabledId:m,savedPathsOrigination:y}=d,g=Rh(d,["layersGroup","layerGroupsEnabledId","savedPathsOrigination"]);Object.keys(g).length&&(f.imageResources=g),at(e,1,S=>{if(at(e,2,A=>{Qc(e,f,d),_e(e,A())},void 0,e.large),S()>0){let A=cf(e);A&&(f.globalLayerMaskInfo=A)}else _e(e,S());for(;S()>0;){for(;S()&&Hc(e)===0;)_e(e,1);S()>=12?cs(e,f,f,d):_e(e,S())}},void 0,e.large);let k=f.children&&f.children.length;if(!(e.skipCompositeImageData&&(e.skipLayerImageData||k)))if(e.useRawData){let S=Math.min(e.offset,e.view.byteLength),A=new Uint8Array(e.view.buffer,e.view.byteOffset+S,e.view.byteLength-S);f.rawCompositeData=A,f.rawCompositeDataInfo={large:e.large,globalAlpha:e.globalAlpha},e.layersInGlobalInfo&&(f.rawCompositeDataInfo.layersInGlobalInfo=!0)}else{let S=df(e,f);e.useImageData?f.imageData=S:f.canvas=(0,Te.imageDataToCanvas)(S)}return f}function Qc(e,n,t){var i,o;let{layersGroup:r=[],layerGroupsEnabledId:s=[]}=t,a=Xt(e);a<0&&(e.globalAlpha=!0,a=-a);let l=[],c=[];for(let u=0;u<a;u++){let{layer:d,channels:p}=eg(e,n,t);r[u]!==void 0&&(d.linkGroup=r[u]),s[u]!==void 0&&(d.linkGroupEnabled=!!s[u]),l.push(d),c.push(p)}for(let u=0;u<a;u++)og(e,n,l[u],c[u]);n.children||(n.children=[]);let f=[n];for(let u=l.length-1;u>=0;u--){let d=l[u],p=d.sectionDivider?d.sectionDivider.type:0;p===1||p===2?(d.opened=p===1,d.children=[],delete d.canvas,delete d.imageData,!((i=d.sectionDivider)===null||i===void 0)&&i.key&&(d.blendMode=(o=Te.toBlendMode[d.sectionDivider.key])!==null&&o!==void 0?o:d.blendMode),f[f.length-1].children.unshift(d),f.push(d)):p===3?f.length>1&&f.pop():f[f.length-1].children.unshift(d)}}function eg(e,n,t){let i={};if(i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!ts(i,e))throw new Error("Invalid layer size");let o=de(e),r=[];for(let l=0;l<o;l++){let c=Xt(e),f=we(e);if(e.large){if(f!==0)throw new Error("Sizes larger than 4GB are not supported");f=we(e)}r.push({id:c,length:f})}ls(e,"8BIM");let s=yi(e);if(!Te.toBlendMode[s]){if(e.throwForMissingFeatures)throw new Error(`Invalid blend mode: '${s}'`);e.logMissingFeatures&&e.log(`Unknown blend mode: '${s}', using normal blend mode`)}i.blendMode=Te.toBlendMode[s]||"normal",i.opacity=ve(e)/255,i.clipping=ve(e)===1;let a=ve(e);return i.transparencyProtected=(a&1)!==0,i.hidden=(a&2)!==0,a&32&&(i.effectsOpen=!0),_e(e,1),at(e,1,l=>{tg(e,i);let c=ig(e);for(c&&(i.blendingRanges=c),i.name=ss(e,1);l()>4&&!Wc(e,e.offset);)e.offset++;for(;l()>=12;)cs(e,i,n,t);_e(e,l())}),{layer:i,channels:r}}function zc(e,n){let t=e.large?8:4;if(n<0||n+t>e.view.byteLength)return!1;let i=e.large?e.view.getUint32(n)*4294967296+e.view.getUint32(n+4):e.view.getUint32(n);return n+t+i<=e.view.byteLength}function ts(e,n){let t=(e.right||0)-(e.left||0),i=(e.bottom||0)-(e.top||0),o=n.large?3e5:3e4;return t<=o&&i<=o}function tg(e,n){return at(e,1,t=>{if(!t())return;let i={};if(n.mask=i,i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!ts(i,e))throw new Error("Invalid mask size");i.defaultColor=ve(e);let o=ve(e);if(i.positionRelativeToLayer=(o&1)!==0,i.disabled=(o&2)!==0,i.fromVectorData=(o&8)!==0,ng(e,o,t())){let r={};n.realMask=r;let s=ve(e);if(r.positionRelativeToLayer=(s&1)!==0,r.disabled=(s&2)!==0,r.fromVectorData=(s&8)!==0,r.defaultColor=ve(e),r.top=Re(e),r.left=Re(e),r.bottom=Re(e),r.right=Re(e),!ts(r,e))throw new Error("Invalid realMask size")}if(o&16){let r=ve(e);r&1&&(i.userMaskDensity=ve(e)/255),r&2&&(i.userMaskFeather=es(e)),r&4&&(i.vectorMaskDensity=ve(e)/255),r&8&&(i.vectorMaskFeather=es(e))}_e(e,t())})}function ef(e){return 1+(e&1?1:0)+(e&2?8:0)+(e&4?1:0)+(e&8?8:0)}function $c(e,n,t){if(t<1)return!1;let i=e.getUint8(n);if(i===0||i&-16)return!1;let o=ef(i);if(t<o||t-o>3)return!1;for(let r=o;r<t;r++)if(e.getUint8(n+r)!==0)return!1;return!0}function ng(e,n,t){if(t<18)return!1;if(!(n&16))return!0;let{view:i,offset:o}=e;return $c(i,o,t)?!1:$c(i,o+18,t-18)?!0:t===18||t-18>=ef(i.getUint8(o+18))}function ho(e){return[ve(e),ve(e),ve(e),ve(e)]}function ig(e){return at(e,1,n=>{let t=ho(e),i=ho(e),o=[];for(;n()>0;){let r=ho(e),s=ho(e);o.push({sourceRange:r,destRange:s})}return{compositeGrayBlendSource:t,compositeGraphBlendDestinationRange:i,ranges:o}})}function og(e,n,t,i){if(e.skipLayerImageData)return;let{colorMode:o=3,bitsPerChannel:r=8}=n;t.rawData={colorMode:o,bitsPerChannel:r,channels:[],large:e.large};for(let s of i){let a=e.offset,l=0,c;if(s.length>=2){if(l=de(e),l>3&&(e.offset-=1,l=de(e)),l>3&&(e.offset-=4,l=de(e)),l>3)throw new Error(`Invalid compression: ${l}`);s.length>2&&(c=xt(e,s.length-2))}e.offset=a+s.length,t.rawData.channels.push({id:s.id,compression:l,data:c})}if(!e.useRawData)try{lf(t,e)}catch(s){if(e.throwForMissingFeatures||s.message==="Exceeded memory limit")throw s;e.logMissingFeatures&&e.log(`Failed to decode layer image data: ${s.message}`),delete t.rawData}}function gi({data:e},n){let t=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255,i=(n?4:3)|0,o=e.length|0,r=(n?5:4)|0;for(let s=i;s<o;s=s+r|0)e[s]=t}function tf(e){let n=e.rawCompositeData;if(!n)return;let t=mi(n.buffer,n.byteOffset,n.byteLength),i=e.rawCompositeDataInfo;return i&&(t.large=i.large,t.globalAlpha=i.globalAlpha,t.layersInGlobalInfo=!!i.layersInGlobalInfo),df(t,e)}function rg(e){return Un(tf(e))}function nf(e){return Ln(e,qe.Layer,!1,void 0)}function of(e){return Ln(e,qe.Mask,!1,void 0)}function rf(e){return Ln(e,qe.RealMask,!1,void 0)}function sg(e){return Un(nf(e))}function ag(e){return Un(of(e))}function lg(e){return Un(rf(e))}function sf(e){let{depth:n,channels:t,colorMode:i=3}=e,o=Math.max(0,e.right-e.left),r=Math.max(0,e.bottom-e.top);if(!o||!r)return;let s=i===4;if(s&&n!==8&&n!==16)throw new Error("bitsPerChannel not supported");let a=s?5:4,l=t.length-1,c=Math.min(s?4:i===1?1:3,t.length-2),f=Ft(o,r,n,a,void 0);for(let u=0;u<t.length;u++){let d=t[u];d&&(u<c?ns(d,f,o,r,n,u,a):u===l&&ns(d,f,o,r,n,a-1,a))}if(i===1&&hi(f),t[l]||gi(f,s),s){let u=f;f=Ft(u.width,u.height,n,4,void 0),mo(u,f,!1)}return f}function af(e){let{extra:n,depth:t}=e;if(!n)return;let i=Math.max(0,n.right-n.left),o=Math.max(0,n.bottom-n.top);if(!i||!o)return;let r=Ft(i,o,t,4,void 0);return ns(n,r,i,o,t,0,4),hi(r),gi(r,!1),r}function cg(e){return Un(sf(e))}function fg(e){return Un(af(e))}function ns({compressionMode:e,data:n},t,i,o,r,s,a){let l=mi(n.buffer,n.byteOffset,n.byteLength);is(l,n.byteLength,t,e,i,o,r,s,!0,a)}function Un(e){return e&&(0,Te.imageDataToCanvas)(e)}function Zr(e,n,t){n&&(t?e.imageData=n:e.canvas=(0,Te.imageDataToCanvas)(n))}function dg(e,n){lf(e,{useImageData:n})}function lf(e,n){var t,i,o;let{throwForMissingFeatures:r,useImageData:s}=n,a=Ln(e,qe.Layer,r,n.totalMemoryLimit,n);if(Zr(e,a,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(t=a?.data.byteLength)!==null&&t!==void 0?t:0),e.mask){let l=Ln(e,qe.Mask,r,n.totalMemoryLimit,n);Zr(e.mask,l,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(i=l?.data.byteLength)!==null&&i!==void 0?i:0)}if(e.realMask){let l=Ln(e,qe.RealMask,r,n.totalMemoryLimit,n);Zr(e.realMask,l,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(o=l?.data.byteLength)!==null&&o!==void 0?o:0)}delete e.rawData}var qe;(function(e){e[e.Layer=0]="Layer",e[e.Mask=1]="Mask",e[e.RealMask=2]="RealMask"})(qe||(qe={}));function Ln(e,n,t,i,o){var r;if(!e.rawData)return;let{colorMode:s,bitsPerChannel:a,channels:l,large:c}=e.rawData,f=Math.max(0,(e.right||0)-(e.left||0)),u=Math.max(0,(e.bottom||0)-(e.top||0)),d=s===4,p,h,m=!1;if(f&&u&&n===qe.Layer)if(d){if(a!==8&&a!==16)throw new Error("bitsPerChannel not supported");p=Ft(f,u,a,5,i)}else p=Ft(f,u,a,4,i);for(let{id:y,compression:g,data:k}of l){if(!k)continue;let x=mi(k.buffer,k.byteOffset,k.byteLength);if(x.debug=!!o?.debug,o?.log&&(x.log=o.log),i!==void 0&&(x.totalMemoryLimit=Math.max(0,i-((r=p?.data.byteLength)!==null&&r!==void 0?r:0))),y===-2||y===-3){if(y===-2&&n!==qe.Mask||y===-3&&n!==qe.RealMask)continue;let S=y===-2?e.mask:e.realMask;if(!S)throw new Error(`Missing layer ${y===-2?"mask":"real mask"} data`);let A=Math.max(0,(S.right||0)-(S.left||0)),D=Math.max(0,(S.bottom||0)-(S.top||0));A&&D&&(h=Ft(A,D,a,4,i),i!==void 0&&(x.totalMemoryLimit=Math.max(0,x.totalMemoryLimit-h.data.byteLength)),is(x,k.byteLength,h,g,A,D,a,0,c,4),hi(h),gi(h,!1))}else{if(n!==qe.Layer)continue;let S=(0,Te.offsetForChannel)(y,d),A=p;if(S<0&&(A=void 0,t))throw new Error(`Channel not supported: ${y}`);is(x,k.byteLength,A,g,f,u,a,S,c,d?5:4)}y===-1&&(m=!0)}if(p&&(s===1&&hi(p),m||gi(p,d),d)){let y=p,g=i===void 0?void 0:Math.max(0,i-y.data.byteLength);p=Ft(y.width,y.height,a,4,g),mo(y,p,!1)}return n===qe.Layer?p:h}function is(e,n,t,i,o,r,s,a,l,c){if(n)if(i===0){n!==o*r*Math.floor(s/8)&&qt(e,`Invalid length (${n}, ${o*r*Math.floor(s/8)})`);let f=xt(e,n);uf(f,t,s,c,a)}else if(i===1)bi(e,t,o,r,s,c,[a],l);else if(i===2){let f=xt(e,n);os(f,t,o,r,s,c,a,!1,e)}else if(i===3){let f=xt(e,n);os(f,t,o,r,s,c,a,!0,e)}else throw new Error(`Invalid Compression type: ${i}`)}function cf(e){return at(e,1,n=>{if(!n())return;let t=de(e),i=de(e),o=de(e),r=de(e),s=de(e),a=Math.min(de(e),100)/100,l=ve(e);return _e(e,n()),{overlayColorSpace:t,colorSpace1:i,colorSpace2:o,colorSpace3:r,colorSpace4:s,opacity:a,kind:l}})}var ug=[0,1,-1,2,-2,3,-3,4,-4];function ff(e,n){let t=e.offset,i="";for(let o of ug){try{e.offset=t+o,i=yi(e)}catch{}if(n(i))break}if(!n(i))throw new Error(`Invalid signature: '${i}' at 0x${t.toString(16)}`);return i}function pg(e){return e==="8BIM"||e==="8B64"}function cs(e,n,t,i){let o=ff(e,pg),r=yi(e),s=o==="8B64"||e.large&&Te.largeAdditionalInfoKeys.indexOf(r)!==-1;if(e.large&&o==="8BIM"&&Te.largeAdditionalInfoKeysObserved.indexOf(r)!==-1){let a=e.offset+8<=e.view.byteLength?e.view.getUint32(e.offset+4):0,l=a===943868237||a===943863348;s=e.view.getUint32(e.offset)===0&&!l}at(e,2,a=>{let l=jh.infoHandlersMap[r];l?l.read(e,n,a,t,i):(e.logMissingFeatures&&r!=="GenI"&&r!=="OCIO"&&r!=="CAI "&&e.log(`Unhandled additional info: ${r}`),_e(e,a())),a()&&(e.logMissingFeatures&&e.log(`Unread ${a()} bytes left for additional info: ${r}`),_e(e,a()))},!1,s)}function Ft(e,n,t,i,o){let r=e*n*i*Math.max(1,t/8);if(o!==void 0&&r>o)throw new Error("Exceeded memory limit");if(t===1||t===8)return i===4?(0,Te.createImageData)(e,n):{width:e,height:n,data:new Uint8ClampedArray(e*n*i)};if(t===16)return{width:e,height:n,data:new Uint16Array(e*n*i)};if(t===32)return{width:e,height:n,data:new Float32Array(e*n*i)};throw new Error(`Invalid bitDepth (${t})`)}function df(e,n){var t,i,o;let r=de(e),s=(t=n.bitsPerChannel)!==null&&t!==void 0?t:8,{width:a,height:l}=n;if(N.supportedColorModes.indexOf(n.colorMode)===-1)throw new Error(`Color mode not supported: ${n.colorMode}`);if(r!==0&&r!==1)throw new Error(`Compression type not supported: ${r}`);let c=Ft(a,l,s,4,e.totalMemoryLimit);switch(e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit-=c.data.byteLength),(0,Te.resetImageData)(c),n.colorMode){case 0:{if(s!==1)throw new Error("Invalid bitsPerChannel for bitmap color mode");let f=Math.ceil(a/8),u;r===0?u=xt(e,f*l):(u=new Uint8Array(f*l),bi(e,{data:u,width:f,height:l},f,l,8,1,[0],e.large)),(0,Te.decodeBitmap)(u,c.data,a,l);break}case 3:case 1:{let f=n.colorMode===1?1:3,u=Kr(e,n,f,3);Yr(e,r,c,s,4,u),n.colorMode===1&&hi(c);break}case 2:{if(s!==8)throw new Error("bitsPerChannel not supported");if(!n.palette)throw new Error("Missing color palette");let f=Kr(e,n,1,-1),u={width:a,height:l,data:new Uint8Array(a*l)};Yr(e,r,u,8,1,f),gg(u,c,n.palette,(o=(i=n.imageResources)===null||i===void 0?void 0:i.transparencyIndex)!==null&&o!==void 0?o:-1);break}case 4:{if(s!==8&&s!==16)throw new Error("bitsPerChannel not supported");let f=Kr(e,n,4,4),u=Ft(a,l,s,5,e.totalMemoryLimit);gi(u,!0),Yr(e,r,u,s,5,f),mo(u,c,!!e.globalAlpha);break}default:throw new Error(`Color mode not supported: ${n.colorMode}`)}return e.globalAlpha&&n.colorMode!==4&&hg(c),c}function Kr(e,n,t,i){var o,r,s;let a=(o=n.channels)!==null&&o!==void 0?o:t+(e.globalAlpha?1:0);if(a<t)throw new Error(`Invalid channel count: ${a}`);let l=(s=(r=n.imageResources)===null||r===void 0?void 0:r.alphaChannelNames)!==null&&s!==void 0?s:[],c=l.length,f=!!e.layersInGlobalInfo&&l[0]==="Transparency"&&c===a-t,u=e.globalAlpha||f||a-t>c,d=[];for(let p=0;p<a;p++)p<t?d.push(p):p===t&&u&&i>=0?d.push(i):d.push(-1);return d}function Yr(e,n,t,i,o,r){if(n===0){let s=t.width*t.height*yo(i);for(let a of r)a<0?_e(e,s):uf(xt(e,s),t,i,o,a)}else if(n===1)bi(e,t,t.width,t.height,i,o,r,e.large);else throw new Error(`Compression not supported: ${n}`)}function hg({data:e,width:n,height:t}){let i=n*t*4;if(e instanceof Float32Array)for(let o=0;o<i;o+=4){let r=e[o+3];if(r>0&&r<1){let s=1/r,a=1-s;for(let l=0;l<3;l++){let c=e[o+l]*s+a;e[o+l]=c<0?0:c}}}else if(e instanceof Uint16Array)for(let o=0;o<i;o+=4){let r=e[o+3];if(r!==0&&r!==65535){let s=65535/r,a=65535*(1-s);for(let l=0;l<3;l++){let c=Math.round(e[o+l]*s+a);e[o+l]=c<0?0:c>65535?65535:c}}}else for(let o=0;o<i;o+=4){let r=e[o+3];if(r!=0&&r!=255){let a=1/(r/255),l=255*(1-a);e[o+0]=e[o+0]*a+l,e[o+1]=e[o+1]*a+l,e[o+2]=e[o+2]*a+l}}}function Jr(e,n){return e=Math.round(e*(n/255)),e<=0?0:e>=n?n:e}function mo(e,n,t){let i=n.width*n.height*4,o=e.data,r=n.data,s=o instanceof Uint16Array?65535:255,a=r instanceof Uint16Array?65535:255,l=[0,0,0];for(let c=0,f=0;f<i;c+=5,f+=4){let u=o[c+4],d=1-o[c]/s,p=1-o[c+1]/s,h=1-o[c+2]/s,m=1-o[c+3]/s;if(t&&u>0&&u<s){let y=s/u;d=Math.min(1,d*y),p=Math.min(1,p*y),h=Math.min(1,h*y),m=Math.min(1,m*y)}(0,Te.cmykToRgbValues)(d,p,h,m,l),r[f]=Jr(l[0],a),r[f+1]=Jr(l[1],a),r[f+2]=Jr(l[2],a),r[f+3]=s===a?u:Math.round(u*a/s)}}function gg(e,n,t,i){let o=e.width*e.height,r=e.data,s=n.data;for(let a=0,l=0;a<o;a++,l+=4){let c=r[a],f=t[c];s[l+0]=f.r,s[l+1]=f.g,s[l+2]=f.b,s[l+3]=c===i?0:255}}function yo(e){switch(e){case 1:case 8:return 1;case 16:return 2;case 32:return 4;default:throw new Error(`Invalid bitDepth (${e})`)}}function fs(e,n){if(e.BYTES_PER_ELEMENT!==n)throw new Error("Invalid array types")}function uf(e,n,t,i,o){let r=yo(t);if(!n||o<0||o>=i)return;let s=n.data;fs(s,r);let a=Math.min(n.width*n.height,Math.floor(e.byteLength/r))|0;if(r===1)for(let l=0,c=o|0;l<a;l++,c=c+i|0)s[c]=e[l];else if(r===2)for(let l=0,c=0,f=o|0;l<a;l++,c+=2,f=f+i|0)s[f]=e[c]<<8|e[c+1];else{let l=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let c=0,f=0,u=o|0;c<a;c++,f+=4,u=u+i|0)s[u]=l.getFloat32(f,!1)}}function mg(e,n,t){for(let i=0;i<t;i++){let o=i*n;for(let r=1,s=o+1;r<n;r++,s++)e[s]=e[s-1]+e[s]}}var Qr=new Error("Decompressed data exceeds expected size");function pf(e,n,t,i=!1){let o=new Uint8Array(n),r=0,s=!1,a=new Th.Inflate({chunkSize:Math.max(1024,Math.min(n,65536)),raw:i});a.onData=l=>{let c=l,f=Math.min(c.length,n-r);if(f>0&&o.set(f===c.length?c:c.subarray(0,f),r),r+=f,f<c.length)throw s=!0,Qr},a.onEnd=l=>{var c;a.err=l,a.msg=((c=a.strm)===null||c===void 0?void 0:c.msg)||""};try{a.push(e,!0)}catch(l){if(l!==Qr)throw l}if(s)t&&qt(t,Qr.message);else{if(a.err&&a.msg==="incorrect data check"&&!i)return t&&qt(t,`Invalid zip data: ${a.msg}`),pf(e.subarray(2),n,t,!0);if(a.err)throw new Error(`Invalid zip data: ${a.msg}`)}return o}function os(e,n,t,i,o,r,s,a,l){let c=yo(o);if(!n||s<0||s>=r)return;let f=n.data;fs(f,c);let u=t*i*c;l&&Mn(l,u);try{let d=pf(e,u,l);if(c===1)for(let p=0,h=0;p<i;p++){let m=0;for(let y=0,g=s+p*t*r;y<t;y++,h++,g+=r){let k=d[h];a&&(k=m=m+k&255),f[g]=k}}else if(c===2)for(let p=0,h=0;p<i;p++){let m=0;for(let y=0,g=s+p*t*r;y<t;y++,h+=2,g+=r){let k=d[h]<<8|d[h+1];a&&(k=m=m+k&65535),f[g]=k}}else{let p=new Uint32Array(f.buffer,f.byteOffset,f.length);if(a){mg(d,t*4,i);for(let h=0,m=s;h<i;h++){let y=t*4*h;for(let g=0;g<t;g++,y++,m+=r){let k=y+t,x=k+t,S=x+t;p[m]=(d[y]<<24|d[k]<<16|d[x]<<8|d[S])>>>0}}}else{let h=new DataView(d.buffer,d.byteOffset,d.byteLength);for(let m=0,y=0,g=s,k=t*i;m<k;m++,y+=4,g+=r)p[g]=h.getUint32(y,!1)}}}finally{l&&go(l,u)}}function yg(e,n,t,i,o){let r=0;for(;n<t&&r<o;){let s=e[n++];if(s>128){if(n>=t)break;let a=e[n++],l=257-s;l>o-r&&(l=o-r),i.fill(a,r,r+l),r+=l}else if(s<128){let a=s+1;for(a>o-r&&(a=o-r),a>t-n&&(a=t-n);a>0;a--)i[r++]=e[n++]}}return r}function bg(e,n,t,i,o,r,s,a,l){let c=e.length|0;for(let f=0;f<r;f++,t++){let u=(i<c?i:c)|0;i+=n[t];let d=(i<c?i:c)|0,p=a+f*o*l|0,h=0;for(;u<d&&h<o;){let m=e[u++]|0;if(m>128){if(u>=d)break;let y=e[u++]|0,g=257-m|0;g>o-h&&(g=o-h|0),h=h+g|0;for(let k=p+g*l|0;p<k;p=p+l|0)s[p]=y}else if(m<128){let y=m+1|0;y>o-h&&(y=o-h|0),y>d-u&&(y=d-u|0),h=h+y|0;for(let g=u+y|0;u<g;u=u+1|0,p=p+l|0)s[p]=e[u]}}}}function wg(e,n,t,i,o,r){if(t===2)for(let s=0,a=0;s<n;s++,a+=2,o+=r)i[o]=e[a]<<8|e[a+1];else{let s=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=0,l=0;a<n;a++,l+=4,o+=r)i[o]=s.getFloat32(l,!1)}}function vg(e,n,t,i,o,r,s,a,l,c,f){let u=e.length,d=o*c;for(let p=0;p<r;p++,t++){let h=i<u?i:u;i+=n[t];let m=i<u?i:u;if(h>=m)continue;let y=yg(e,h,m,f,d);wg(f,Math.floor(y/c),c,s,a+p*o*l,l)}}function bi(e,n,t,i,o,r,s,a){let l=n&&n.data,c=s.length*i,u=c*(a?4:2),d=e.view.byteLength,p=yo(o),h;Mn(e,u);try{if(e.offset+u>d)throw new Error("RLE row lengths exceed buffer length");h=a?new Uint32Array(c):new Uint16Array(c);let k=0;if(a)for(let x=0;x<c;x++)k+=h[x]=we(e);else for(let x=0;x<c;x++)k+=h[x]=de(e);k>d-e.offset&&qt(e,"RLE data exceeds buffer length"),l&&fs(l,p)}catch(k){throw go(e,u),k}let m=new Uint8Array(e.view.buffer,e.view.byteOffset,d),y=l&&p>1?new Uint8Array(t*p):void 0,g=e.offset;for(let k=0,x=0;k<s.length;k++,x+=i){let S=s[k]|0,A=g;for(let D=0;D<i;D++)g+=h[x+D];l&&S>=0&&S<r&&(p===1?bg(m,h,x,A,t,i,l,S,r):vg(m,h,x,A,t,i,l,S,r,p,y))}e.offset=g,go(e,u)}function at(e,n,t,i=!0,o=!1){let r=we(e);if(o){if(r!==0)throw new Error("Sizes larger than 4GB are not supported");r=we(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=t(()=>s-e.offset);for(e.offset!==s&&(e.offset>s?qt(e,"Exceeded section limits"):qt(e,"Unread section data"));r%n;)r++,s++;return e.offset=s,a}function Sg(e){switch(de(e)){case 0:{let t=de(e)/257,i=de(e)/257,o=de(e)/257;return _e(e,2),{r:t,g:i,b:o}}case 1:{let t=de(e)/65535,i=de(e)/65535,o=de(e)/65535;return _e(e,2),{h:t,s:i,b:o}}case 2:{let t=(65535-de(e))/257,i=(65535-de(e))/257,o=(65535-de(e))/257,r=(65535-de(e))/257;return{c:t,m:i,y:o,k:r}}case 7:{let t=Xt(e)/1e4,i=Xt(e),o=Xt(e),r=(0,Te.normalizeLabAB)(i,100),s=(0,Te.normalizeLabAB)(o,100);return _e(e,2),{l:t,a:r,b:s}}case 8:{let t=de(e)*255/1e4;return _e(e,6),{k:t}}default:throw new Error("Invalid color space")}}var Vc=3e4;function xg(e){let n=e.view.getUint32(e.offset);for(;n%4;)n++;let t=e.offset+4+n;try{return hf(e)}catch(i){if(e.throwForMissingFeatures)throw i;e.logMissingFeatures&&e.log(`Skipped pattern: ${i.message}`),e.offset=t;return}}function hf(e){let n=we(e);for(;n%4;)n++;let t=e.offset+n,i=we(e);if(i!==1)throw new Error(`Invalid pattern version: ${i}`);let o=we(e),r=Xt(e),s=Xt(e);if(o!==3&&o!==1&&o!==2&&o!==4)throw new Error(`Unsupported pattern color mode: ${o}`);let a=Xc(e),l=ss(e,1),c=[];if(o===2){for(let M=0;M<256;M++)c.push({r:ve(e),g:ve(e),b:ve(e)});e.view.getUint32(e.offset)!==3&&_e(e,4)}let f=we(e);if(f!==3)throw new Error(`Invalid pattern VMAL version: ${f}`);we(e);let u=we(e),d=we(e),p=we(e),h=we(e),m=we(e),y=h-d,g=p-u;if(y<0||g<0)throw new Error("Invalid pattern bounds");if(y>Vc||g>Vc)throw new Error(`Pattern too large (${y}x${g})`);if(m>64)throw new Error(`Invalid pattern channel count: ${m}`);if(y*g>(Math.min(t,e.view.byteLength)-e.offset)*64)throw new Error("Pattern data out of bounds");let k=o===3?3:o===4?4:1,x=o===4,S=x?4:3,A=[],D=0;for(let M=0,J=0;M<m+2&&e.offset+4<=t;M++){if(!we(e))continue;let R=we(e);if(!R)continue;if(R<23)throw new Error("Invalid pattern channel length");let ie=we(e),he=we(e),ce=we(e),Ce=we(e),W=we(e),B=de(e),$=ve(e),ne=xt(e,R-23),ge=B===8||B===16||B===32?B:ie;if(ge!==8&&ge!==16&&ge!==32)throw new Error(`Unsupported pattern pixel depth: ${ge}`);if(he<u||ce<d||Ce>p||W>h||Ce<he||W<ce)throw new Error("Pattern channel bounds outside of pattern bounds");let Q=J<k?J:J===k?S:-1;if(J++,Q===-1)continue;let ee=W-ce,be=Ce-he,Se=ee*(ge/8),xe=Se*be;if($===0){if(ne.byteLength<xe)throw new Error("Pattern channel data out of bounds")}else if($===1){if(xe>ne.byteLength*64)throw new Error("Pattern channel data out of bounds");D=Math.max(D,xe)}else throw new Error("Invalid pattern compression mode");A.push({target:Q,depth:ge,compressionMode:$,cdata:ne,ctop:he,cleft:ce,w:ee,h:be,rowBytes:Se,channelSize:xe})}let C=y*g*4,O=x?y*g*5:0;Mn(e,C+O+D),go(e,C+O+D);let E=new Uint8Array(C);for(let M=3;M<E.byteLength;M+=4)E[M]=255;let L=x?new Uint8Array(O).fill(255):void 0;for(let{target:M,depth:J,compressionMode:pe,cdata:R,ctop:ie,cleft:he,w:ce,h:Ce,rowBytes:W,channelSize:B}of A){let $=R;if(pe===1){$=new Uint8Array(B);let Q=mi(R.buffer,R.byteOffset,R.byteLength);bi(Q,{data:$,width:W,height:Ce},W,Ce,8,1,[0],!1)}J!==8&&($=kg($,ce*Ce,J));let ne=he-d,ge=ie-u;if(L)Nc($,L,ce,Ce,(ne+ge*y)*5+M,y*5,5);else if(M===3||o===3)Nc($,E,ce,Ce,(ne+ge*y)*4+M,y*4,4);else if(o===2){let Q=new Uint8Array(768);for(let ee=0;ee<256;ee++)Q[ee*3+0]=c[ee].r,Q[ee*3+1]=c[ee].g,Q[ee*3+2]=c[ee].b;for(let ee=0;ee<Ce;ee++)for(let be=0,Se=ee*ce,xe=(ne+(ee+ge)*y)*4;be<ce;be++,Se++,xe+=4){let jt=$[Se]*3;E[xe+0]=Q[jt+0],E[xe+1]=Q[jt+1],E[xe+2]=Q[jt+2]}}else for(let Q=0;Q<Ce;Q++)for(let ee=0,be=Q*ce,Se=(ne+(Q+ge)*y)*4;ee<ce;ee++,be++,Se+=4){let xe=$[be];E[Se+0]=xe,E[Se+1]=xe,E[Se+2]=xe}}return L&&mo({width:y,height:g,data:L},{width:y,height:g,data:E},!1),Mn(e,C),e.offset=t,{id:l,name:a,x:r,y:s,bounds:{x:d,y:u,w:y,h:g},data:E}}function kg(e,n,t){let i=new Uint8Array(n);if(t===16)for(let o=0;o<n;o++)i[o]=Math.round((e[o*2]<<8|e[o*2+1])/257);else{let o=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let r=0;r<n;r++){let s=o.getFloat32(r*4,!1);i[r]=s>0?s<1?Math.round(s*255):255:0}}return i}function Nc(e,n,t,i,o,r,s){for(let a=0,l=0;a<i;a++)for(let c=0,f=o+a*r;c<t;c++,l++,f+=s)n[f]=e[l]}function Mn(e,n){if(!(n>=0))throw new Error("Invalid size");if(e.totalMemoryLimit!==void 0){if(e.totalMemoryLimit<n)throw new Error("Exceeded memory limit");e.totalMemoryLimit-=n}}function go(e,n){e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit+=n)}});var yf=ae(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.readEffects=_g;bo.writeEffects=Ag;var mf=Ot(),H=st(),T=En(),ds=[void 0,"outer bevel","inner bevel","emboss","pillow emboss","stroke emboss"];function Bn(e){return(0,H.checkSignature)(e,"8BIM"),mf.toBlendMode[(0,H.readSignature)(e)]||"normal"}function Tn(e,n){(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,mf.fromBlendMode[n]||"norm")}function Rn(e){return(0,H.readUint8)(e)/255}function jn(e,n){(0,T.writeUint8)(e,Math.round(n*255)|0)}function _g(e){let n=(0,H.readUint16)(e);if(n!==0)throw new Error(`Invalid effects layer version: ${n}`);let t=(0,H.readUint16)(e),i={};for(let o=0;o<t;o++){(0,H.checkSignature)(e,"8BIM");let r=(0,H.readSignature)(e);switch(r){case"cmnS":{let s=(0,H.readUint32)(e),a=(0,H.readUint32)(e);if((0,H.readUint8)(e),(0,H.skipBytes)(e,2),s!==7||a!==0)throw new Error("Invalid effects common state");break}case"dsdw":case"isdw":{let s=(0,H.readUint32)(e),a=(0,H.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,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readFixedPoint32)(e),f=(0,H.readFixedPoint32)(e),u=(0,H.readColor)(e),d=Bn(e),p=!!(0,H.readUint8)(e),h=!!(0,H.readUint8)(e),m=Rn(e);s>=51&&(0,H.readColor)(e);let y={size:{units:"Pixels",value:l},distance:{units:"Pixels",value:f},angle:c,color:u,blendMode:d,enabled:p,useGlobalLight:h,opacity:m};r==="dsdw"?i.dropShadow=[y]:i.innerShadow=[y];break}case"oglw":{let s=(0,H.readUint32)(e),a=(0,H.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,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readColor)(e),f=Bn(e),u=!!(0,H.readUint8)(e),d=Rn(e);s>=42&&(0,H.readColor)(e),i.outerGlow={size:{units:"Pixels",value:l},color:c,blendMode:f,enabled:u,opacity:d};break}case"iglw":{let s=(0,H.readUint32)(e),a=(0,H.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,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readColor)(e),f=Bn(e),u=!!(0,H.readUint8)(e),d=Rn(e);s>=43&&((0,H.readUint8)(e),(0,H.readColor)(e)),i.innerGlow={size:{units:"Pixels",value:l},color:c,blendMode:f,enabled:u,opacity:d};break}case"bevl":{let s=(0,H.readUint32)(e),a=(0,H.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,H.readFixedPoint32)(e),c=(0,H.readFixedPoint32)(e),f=(0,H.readFixedPoint32)(e),u=Bn(e),d=Bn(e),p=(0,H.readColor)(e),h=(0,H.readColor)(e),m=ds[(0,H.readUint8)(e)]||"inner bevel",y=Rn(e),g=Rn(e),k=!!(0,H.readUint8)(e),x=!!(0,H.readUint8)(e),S=(0,H.readUint8)(e)?"down":"up";s>=78&&((0,H.readColor)(e),(0,H.readColor)(e)),i.bevel={size:{units:"Pixels",value:f},angle:l,strength:c,highlightBlendMode:u,shadowBlendMode:d,highlightColor:p,shadowColor:h,style:m,highlightOpacity:y,shadowOpacity:g,enabled:k,useGlobalLight:x,direction:S};break}case"sofi":{let s=(0,H.readUint32)(e),a=(0,H.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=Bn(e),c=(0,H.readColor)(e),f=Rn(e),u=!!(0,H.readUint8)(e);(0,H.readColor)(e),i.solidFill=[{blendMode:l,color:c,opacity:f,enabled:u}];break}default:throw new Error(`Invalid effect type: '${r}'`)}}return i}function gf(e,n){var t;(0,T.writeUint32)(e,51),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,n.size&&n.size.value||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeFixedPoint32)(e,n.angle||0),(0,T.writeFixedPoint32)(e,n.distance&&n.distance.value||0),(0,T.writeColor)(e,n.color),Tn(e,n.blendMode),(0,T.writeUint8)(e,n.enabled?1:0),(0,T.writeUint8)(e,n.useGlobalLight?1:0),jn(e,(t=n.opacity)!==null&&t!==void 0?t:1),(0,T.writeColor)(e,n.color)}function Ag(e,n){var t,i,o,r,s,a,l,c,f,u,d;let p=(t=n.dropShadow)===null||t===void 0?void 0:t[0],h=(i=n.innerShadow)===null||i===void 0?void 0:i[0],m=n.outerGlow,y=n.innerGlow,g=n.bevel,k=(o=n.solidFill)===null||o===void 0?void 0:o[0],x=1;if(p&&x++,h&&x++,m&&x++,y&&x++,g&&x++,k&&x++,(0,T.writeUint16)(e,0),(0,T.writeUint16)(e,x),(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"cmnS"),(0,T.writeUint32)(e,7),(0,T.writeUint32)(e,0),(0,T.writeUint8)(e,1),(0,T.writeZeros)(e,2),p&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"dsdw"),gf(e,p)),h&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"isdw"),gf(e,h)),m&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"oglw"),(0,T.writeUint32)(e,42),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,((r=m.size)===null||r===void 0?void 0:r.value)||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeColor)(e,m.color),Tn(e,m.blendMode),(0,T.writeUint8)(e,m.enabled?1:0),jn(e,(s=m.opacity)!==null&&s!==void 0?s:1),(0,T.writeColor)(e,m.color)),y&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"iglw"),(0,T.writeUint32)(e,43),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,((a=y.size)===null||a===void 0?void 0:a.value)||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeColor)(e,y.color),Tn(e,y.blendMode),(0,T.writeUint8)(e,y.enabled?1:0),jn(e,(l=y.opacity)!==null&&l!==void 0?l:1),(0,T.writeUint8)(e,0),(0,T.writeColor)(e,y.color)),g){(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"bevl"),(0,T.writeUint32)(e,78),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,g.angle||0),(0,T.writeFixedPoint32)(e,g.strength||0),(0,T.writeFixedPoint32)(e,((c=g.size)===null||c===void 0?void 0:c.value)||0),Tn(e,g.highlightBlendMode),Tn(e,g.shadowBlendMode),(0,T.writeColor)(e,g.highlightColor),(0,T.writeColor)(e,g.shadowColor);let S=ds.indexOf(g.style);(0,T.writeUint8)(e,S<=0?ds.indexOf("inner bevel"):S),jn(e,(f=g.highlightOpacity)!==null&&f!==void 0?f:1),jn(e,(u=g.shadowOpacity)!==null&&u!==void 0?u:1),(0,T.writeUint8)(e,g.enabled?1:0),(0,T.writeUint8)(e,g.useGlobalLight?1:0),(0,T.writeUint8)(e,g.direction==="down"?1:0),(0,T.writeColor)(e,g.highlightColor),(0,T.writeColor)(e,g.shadowColor)}k&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"sofi"),(0,T.writeUint32)(e,34),(0,T.writeUint32)(e,2),Tn(e,k.blendMode),(0,T.writeColor)(e,k.color),jn(e,(d=k.opacity)!==null&&d!==void 0?d:1),(0,T.writeUint8)(e,k.enabled?1:0),(0,T.writeColor)(e,k.color))}});var us=ae(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.setProperty=Sf;wi.parseEngineData=Ig;wi.serializeEngineData=Dg;var wo=st();function bf(e){return e===32||e===10||e===13||e===9}function wf(e){return e>=48&&e<=57||e===46||e===45}function Sf(e,n,t){n==="__proto__"?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}var vf=64;function Ig(e,n){let t=0;function i(){for(;t<e.length&&bf(e[t]);)t++}function o(){let m=e[t];return t++,m===92&&(m=e[t],t++),m}function r(){let m="";if(e[t]===41)return t++,m;if(e[t]!==254||e[t+1]!==255){for(;t<e.length&&e[t]!==41;)m+=String.fromCharCode(o());return(0,wo.consumeMemory)(n,m.length*2),t++,m}for(t+=2;t<e.length&&e[t]!==41;){let y=o(),g=o(),k=y<<8|g;m+=String.fromCharCode(k)}return(0,wo.consumeMemory)(n,m.length*2),t++,m}let s=null,a=[];function l(m){a.length?(c(m),a.push(m)):(a.push(m),s=m)}function c(m){if(!a.length)throw new Error("Invalid data");(0,wo.consumeMemory)(n,vf);let y=a[a.length-1];if(typeof y=="string"){let g=a[a.length-2];Sf(g,y,m),u()}else if(Array.isArray(y))y.push(m);else throw new Error("Invalid data")}function f(m){a.length||l({});let y=a[a.length-1];if(typeof y=="string"||Array.isArray(y))c(m==="nil"?null:`/${m}`);else if(y&&typeof y=="object")(0,wo.consumeMemory)(n,vf+m.length*2),a.push(m);else throw new Error("Invalid data")}function u(){if(!a.length)throw new Error("Invalid data");a.pop()}i();let d=e.length,p=0,h="";for(;d>0&&e[d-1]===0;)d--;for(;t<d;){let m=t,y=e[m];if(y===60&&e[m+1]===60)t+=2,l({});else if(y===62&&e[m+1]===62)t+=2,u();else if(y===47){t+=1;let g=t;for(;t<e.length&&!bf(e[t]);)t++;let k="";for(let x=g;x<t;x++)k+=String.fromCharCode(e[x]);f(k)}else if(y===40)t+=1,c(r());else if(y===91)t+=1,l([]);else if(y===93)t+=1,u();else if(y===110&&e[m+1]===117&&e[m+2]===108&&e[m+3]===108)t+=4,c(null);else if(y===116&&e[m+1]===114&&e[m+2]===117&&e[m+3]===101)t+=4,c(!0);else if(y===102&&e[m+1]===97&&e[m+2]===108&&e[m+3]===115&&e[m+4]===101)t+=5,c(!1);else if(wf(y)){let g="";for(;t<e.length&&wf(e[t]);)g+=String.fromCharCode(e[t]),t++;c(parseFloat(g))}else t+=1,p||(h=`'${String.fromCharCode(y)}' (${y}) at ${t}`),p++;i()}return p&&n.log(`Invalid tokens in engine data (${p} in total, first: ${h})`),s}var Cg=["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"],Pg=["RunLengthArray"];function Dg(e,n=!1){let t=new Uint8Array(1024),i=0,o=0;function r(y){if(i>=t.length){let g=new Uint8Array(t.length*2);g.set(t),t=g}t[i]=y,i++}function s(y){for(let g=0;g<y.length;g++)r(y.charCodeAt(g))}function a(){if(n)s(" ");else for(let y=0;y<o;y++)s(" ")}function l(y,g){a(),s(`/${y}`),m(g,y,!0),n||s(`
2
- `)}function c(y){return Number.isFinite(y)?y:0}function f(y){return c(y).toString()}function u(y){return c(y).toFixed(5).replace(/(\d)0+$/g,"$1").replace(/^0+\.([1-9])/g,".$1").replace(/^-0+\.0(\d)/g,"-.0$1")}function d(y,g){return y=c(y),g&&Cg.indexOf(g)!==-1||(y|0)!==y?u(y):f(y)}function p(y){let g=Object.keys(y);return g.indexOf("98")!==-1&&g.unshift(...g.splice(g.indexOf("98"),1)),g.indexOf("99")!==-1&&g.unshift(...g.splice(g.indexOf("99"),1)),g}function h(y){(y===40||y===41||y===92)&&r(92),r(y)}function m(y,g,k=!1){function x(){k?s(" "):a()}if(y==null)x(),s(n?"/nil":"null");else if(typeof y=="number")x(),s(d(y,g));else if(typeof y=="boolean")x(),s(y?"true":"false");else if(typeof y=="string")if(x(),(g==="99"||g==="98")&&y.charAt(0)==="/")s(y);else{s("("),r(254),r(255);for(let S=0;S<y.length;S++){let A=y.charCodeAt(S);h(A>>8&255),h(A&255)}s(")")}else if(Array.isArray(y))if(x(),y.every(S=>typeof S=="number")){s("[");let S=Pg.indexOf(g)!==-1;for(let A of y)s(" "),s(S?d(A):u(A));s(" ]")}else{s("["),n||s(`
1
+ var cu=Object.create;var ia=Object.defineProperty;var fu=Object.getOwnPropertyDescriptor;var du=Object.getOwnPropertyNames;var uu=Object.getPrototypeOf,pu=Object.prototype.hasOwnProperty;var ae=(e,n)=>()=>{try{return n||e((n={exports:{}}).exports,n),n.exports}catch(t){throw n=0,t}};var hu=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of du(n))!pu.call(e,o)&&o!==t&&ia(e,o,{get:()=>n[o],enumerable:!(i=fu(n,o))||i.enumerable});return e};var gu=(e,n,t)=>(t=e!=null?cu(uu(e)):{},hu(n||!e||!e.__esModule?ia(t,"default",{value:e,enumerable:!0}):t,e));var _a=ae((My,bn)=>{"use strict";function yn(e){let n=e.length;for(;--n>=0;)e[n]=0}var mu=0,ca=1,yu=2,bu=3,wu=258,Wo=29,Qn=256,Zn=Qn+1+Wo,mn=30,Xo=19,fa=2*Zn+1,Yt=15,zo=16,vu=7,qo=256,da=16,ua=17,pa=18,Go=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]),Fi=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]),Su=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ha=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xu=512,At=new Array((Zn+2)*2);yn(At);var qn=new Array(mn*2);yn(qn);var Kn=new Array(xu);yn(Kn);var Yn=new Array(wu-bu+1);yn(Yn);var Zo=new Array(Wo);yn(Zo);var Li=new Array(mn);yn(Li);function $o(e,n,t,i,o){this.static_tree=e,this.extra_bits=n,this.extra_base=t,this.elems=i,this.max_length=o,this.has_stree=e&&e.length}var ga,ma,ya;function Vo(e,n){this.dyn_tree=e,this.max_code=0,this.stat_desc=n}var ba=e=>e<256?Kn[e]:Kn[256+(e>>>7)],Jn=(e,n)=>{e.pending_buf[e.pending++]=n&255,e.pending_buf[e.pending++]=n>>>8&255},Ve=(e,n,t)=>{e.bi_valid>zo-t?(e.bi_buf|=n<<e.bi_valid&65535,Jn(e,e.bi_buf),e.bi_buf=n>>zo-e.bi_valid,e.bi_valid+=t-zo):(e.bi_buf|=n<<e.bi_valid&65535,e.bi_valid+=t)},ft=(e,n,t)=>{Ve(e,t[n*2],t[n*2+1])},wa=(e,n)=>{let t=0;do t|=e&1,e>>>=1,t<<=1;while(--n>0);return t>>>1},ku=e=>{e.bi_valid===16?(Jn(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)},_u=(e,n)=>{let t=n.dyn_tree,i=n.max_code,o=n.stat_desc.static_tree,r=n.stat_desc.has_stree,s=n.stat_desc.extra_bits,a=n.stat_desc.extra_base,l=n.stat_desc.max_length,c,f,u,d,p,h,m=0;for(d=0;d<=Yt;d++)e.bl_count[d]=0;for(t[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<fa;c++)f=e.heap[c],d=t[t[f*2+1]*2+1]+1,d>l&&(d=l,m++),t[f*2+1]=d,!(f>i)&&(e.bl_count[d]++,p=0,f>=a&&(p=s[f-a]),h=t[f*2],e.opt_len+=h*(d+p),r&&(e.static_len+=h*(o[f*2+1]+p)));if(m!==0){do{for(d=l-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[l]--,m-=2}while(m>0);for(d=l;d!==0;d--)for(f=e.bl_count[d];f!==0;)u=e.heap[--c],!(u>i)&&(t[u*2+1]!==d&&(e.opt_len+=(d-t[u*2+1])*t[u*2],t[u*2+1]=d),f--)}},va=(e,n,t)=>{let i=new Array(Yt+1),o=0,r,s;for(r=1;r<=Yt;r++)o=o+t[r-1]<<1,i[r]=o;for(s=0;s<=n;s++){let a=e[s*2+1];a!==0&&(e[s*2]=wa(i[a]++,a))}},Au=()=>{let e,n,t,i,o,r=new Array(Yt+1);for(t=0,i=0;i<Wo-1;i++)for(Zo[i]=t,e=0;e<1<<Go[i];e++)Yn[t++]=i;for(Yn[t-1]=i,o=0,i=0;i<16;i++)for(Li[i]=o,e=0;e<1<<Fi[i];e++)Kn[o++]=i;for(o>>=7;i<mn;i++)for(Li[i]=o<<7,e=0;e<1<<Fi[i]-7;e++)Kn[256+o++]=i;for(n=0;n<=Yt;n++)r[n]=0;for(e=0;e<=143;)At[e*2+1]=8,e++,r[8]++;for(;e<=255;)At[e*2+1]=9,e++,r[9]++;for(;e<=279;)At[e*2+1]=7,e++,r[7]++;for(;e<=287;)At[e*2+1]=8,e++,r[8]++;for(va(At,Zn+1,r),e=0;e<mn;e++)qn[e*2+1]=5,qn[e*2]=wa(e,5);ga=new $o(At,Go,Qn+1,Zn,Yt),ma=new $o(qn,Fi,0,mn,Yt),ya=new $o(new Array(0),Su,0,Xo,vu)},Sa=e=>{let n;for(n=0;n<Zn;n++)e.dyn_ltree[n*2]=0;for(n=0;n<mn;n++)e.dyn_dtree[n*2]=0;for(n=0;n<Xo;n++)e.bl_tree[n*2]=0;e.dyn_ltree[qo*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},xa=e=>{e.bi_valid>8?Jn(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},oa=(e,n,t,i)=>{let o=n*2,r=t*2;return e[o]<e[r]||e[o]===e[r]&&i[n]<=i[t]},No=(e,n,t)=>{let i=e.heap[t],o=t<<1;for(;o<=e.heap_len&&(o<e.heap_len&&oa(n,e.heap[o+1],e.heap[o],e.depth)&&o++,!oa(n,i,e.heap[o],e.depth));)e.heap[t]=e.heap[o],t=o,o<<=1;e.heap[t]=i},ra=(e,n,t)=>{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?ft(e,o,n):(s=Yn[o],ft(e,s+Qn+1,n),a=Go[s],a!==0&&(o-=Zo[s],Ve(e,o,a)),i--,s=ba(i),ft(e,s,t),a=Fi[s],a!==0&&(i-=Li[s],Ve(e,i,a)));while(r<e.sym_next);ft(e,qo,n)},Ho=(e,n)=>{let t=n.dyn_tree,i=n.stat_desc.static_tree,o=n.stat_desc.has_stree,r=n.stat_desc.elems,s,a,l=-1,c;for(e.heap_len=0,e.heap_max=fa,s=0;s<r;s++)t[s*2]!==0?(e.heap[++e.heap_len]=l=s,e.depth[s]=0):t[s*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,t[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=i[c*2+1]);for(n.max_code=l,s=e.heap_len>>1;s>=1;s--)No(e,t,s);c=r;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],No(e,t,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,t[c*2]=t[s*2]+t[a*2],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,t[s*2+1]=t[a*2+1]=c,e.heap[1]=c++,No(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],_u(e,n),va(t,l,e.bl_count)},sa=(e,n,t)=>{let i,o=-1,r,s=n[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),n[(t+1)*2+1]=65535,i=0;i<=t;i++)r=s,s=n[(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[da*2]++):a<=10?e.bl_tree[ua*2]++:e.bl_tree[pa*2]++,a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4))},aa=(e,n,t)=>{let i,o=-1,r,s=n[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),i=0;i<=t;i++)if(r=s,s=n[(i+1)*2+1],!(++a<l&&r===s)){if(a<c)do ft(e,r,e.bl_tree);while(--a!==0);else r!==0?(r!==o&&(ft(e,r,e.bl_tree),a--),ft(e,da,e.bl_tree),Ve(e,a-3,2)):a<=10?(ft(e,ua,e.bl_tree),Ve(e,a-3,3)):(ft(e,pa,e.bl_tree),Ve(e,a-11,7));a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4)}},Iu=e=>{let n;for(sa(e,e.dyn_ltree,e.l_desc.max_code),sa(e,e.dyn_dtree,e.d_desc.max_code),Ho(e,e.bl_desc),n=Xo-1;n>=3&&e.bl_tree[ha[n]*2+1]===0;n--);return e.opt_len+=3*(n+1)+5+5+4,n},Cu=(e,n,t,i)=>{let o;for(Ve(e,n-257,5),Ve(e,t-1,5),Ve(e,i-4,4),o=0;o<i;o++)Ve(e,e.bl_tree[ha[o]*2+1],3);aa(e,e.dyn_ltree,n-1),aa(e,e.dyn_dtree,t-1)},Pu=e=>{let n=4093624447,t;for(t=0;t<=31;t++,n>>>=1)if(n&1&&e.dyn_ltree[t*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(t=32;t<Qn;t++)if(e.dyn_ltree[t*2]!==0)return 1;return 0},la=!1,Du=e=>{la||(Au(),la=!0),e.l_desc=new Vo(e.dyn_ltree,ga),e.d_desc=new Vo(e.dyn_dtree,ma),e.bl_desc=new Vo(e.bl_tree,ya),e.bi_buf=0,e.bi_valid=0,Sa(e)},ka=(e,n,t,i)=>{Ve(e,(mu<<1)+(i?1:0),3),xa(e),Jn(e,t),Jn(e,~t),t&&e.pending_buf.set(e.window.subarray(n,n+t),e.pending),e.pending+=t},Ou=e=>{Ve(e,ca<<1,3),ft(e,qo,At),ku(e)},Eu=(e,n,t,i)=>{let o,r,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=Pu(e)),Ho(e,e.l_desc),Ho(e,e.d_desc),s=Iu(e),o=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=o&&(o=r)):o=r=t+5,t+4<=o&&n!==-1?ka(e,n,t,i):e.strategy===4||r===o?(Ve(e,(ca<<1)+(i?1:0),3),ra(e,At,qn)):(Ve(e,(yu<<1)+(i?1:0),3),Cu(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),ra(e,e.dyn_ltree,e.dyn_dtree)),Sa(e),i&&xa(e)},Fu=(e,n,t)=>(e.pending_buf[e.sym_buf+e.sym_next++]=n,e.pending_buf[e.sym_buf+e.sym_next++]=n>>8,e.pending_buf[e.sym_buf+e.sym_next++]=t,n===0?e.dyn_ltree[t*2]++:(e.matches++,n--,e.dyn_ltree[(Yn[t]+Qn+1)*2]++,e.dyn_dtree[ba(n)*2]++),e.sym_next===e.sym_end);bn.exports._tr_init=Du;bn.exports._tr_stored_block=ka;bn.exports._tr_flush_block=Eu;bn.exports._tr_tally=Fu;bn.exports._tr_align=Ou});var Ko=ae((Uy,Aa)=>{"use strict";var Lu=(e,n,t,i)=>{let o=e&65535|0,r=e>>>16&65535|0,s=0;for(;t!==0;){s=t>2e3?2e3:t,t-=s;do o=o+n[i++]|0,r=r+o|0;while(--s);o%=65521,r%=65521}return o|r<<16|0};Aa.exports=Lu});var Yo=ae((By,Ia)=>{"use strict";var Mu=()=>{let e,n=[];for(var t=0;t<256;t++){e=t;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;n[t]=e}return n},Uu=new Uint32Array(Mu()),Bu=(e,n,t,i)=>{let o=Uu,r=i+t;e^=-1;for(let s=i;s<r;s++)e=e>>>8^o[(e^n[s])&255];return e^-1};Ia.exports=Bu});var Mi=ae((Ry,Ca)=>{"use strict";Ca.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 zt=ae((Ty,Pa)=>{"use strict";Pa.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 Ta=ae((jy,ht)=>{"use strict";var{_tr_init:Ru,_tr_stored_block:er,_tr_flush_block:Tu,_tr_tally:Gt,_tr_align:ju}=_a(),Fa=Ko(),$t=Yo(),zu=Mi(),{Z_NO_FLUSH:Ht,Z_PARTIAL_FLUSH:$u,Z_FULL_FLUSH:Vu,Z_FINISH:Ye,Z_BLOCK:Da,Z_OK:Oe,Z_STREAM_END:Oa,Z_STREAM_ERROR:ut,Z_DATA_ERROR:Nu,Z_BUF_ERROR:Jo,Z_DEFAULT_COMPRESSION:Gu,Z_FILTERED:Hu,Z_HUFFMAN_ONLY:Ui,Z_RLE:Wu,Z_FIXED:Xu,Z_DEFAULT_STRATEGY:qu,Z_UNKNOWN:Zu,Z_DEFLATED:Bi}=zt(),Ku=9,Yu=15,Ju=8,Qu=29,e0=256,tr=e0+1+Qu,t0=30,n0=19,i0=2*tr+1,o0=15,oe=3,Nt=258,pt=Nt+oe+1,r0=32,vn=42,ar=57,nr=69,ir=73,or=91,rr=103,Jt=113,ti=666,Be=1,xn=2,en=3,kn=4,s0=3,Qt=(e,n)=>(e.msg=zu[n],n),Ea=e=>e*2-(e>4?9:0),Vt=e=>{let n=e.length;for(;--n>=0;)e[n]=0},a0=e=>{let n,t,i,o=e.w_size;n=e.hash_size,i=n;do t=e.head[--i],e.head[i]=t>=o?t-o:0;while(--n);n=o,i=n;do t=e.prev[--i],e.prev[i]=t>=o?t-o:0;while(--n)},l0=(e,n,t)=>(n<<e.hash_shift^t)&e.hash_mask,Wt=l0,Ge=e=>{let n=e.state,t=n.pending;t>e.avail_out&&(t=e.avail_out),t!==0&&(e.output.set(n.pending_buf.subarray(n.pending_out,n.pending_out+t),e.next_out),e.next_out+=t,n.pending_out+=t,e.total_out+=t,e.avail_out-=t,n.pending-=t,n.pending===0&&(n.pending_out=0))},He=(e,n)=>{Tu(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,n),e.block_start=e.strstart,Ge(e.strm)},fe=(e,n)=>{e.pending_buf[e.pending++]=n},ei=(e,n)=>{e.pending_buf[e.pending++]=n>>>8&255,e.pending_buf[e.pending++]=n&255},sr=(e,n,t,i)=>{let o=e.avail_in;return o>i&&(o=i),o===0?0:(e.avail_in-=o,n.set(e.input.subarray(e.next_in,e.next_in+o),t),e.state.wrap===1?e.adler=Fa(e.adler,n,o,t):e.state.wrap===2&&(e.adler=$t(e.adler,n,o,t)),e.next_in+=o,e.total_in+=o,o)},La=(e,n)=>{let t=e.max_chain_length,i=e.strstart,o,r,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-pt?e.strstart-(e.w_size-pt):0,c=e.window,f=e.w_mask,u=e.prev,d=e.strstart+Nt,p=c[i+s-1],h=c[i+s];e.prev_length>=e.good_match&&(t>>=2),a>e.lookahead&&(a=e.lookahead);do if(o=n,!(c[o+s]!==h||c[o+s-1]!==p||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<d);if(r=Nt-(d-i),i=d-Nt,r>s){if(e.match_start=n,s=r,r>=a)break;p=c[i+s-1],h=c[i+s]}}while((n=u[n&f])>l&&--t!==0);return s<=e.lookahead?s:e.lookahead},Sn=e=>{let n=e.w_size,t,i,o;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=n+(n-pt)&&(e.window.set(e.window.subarray(n,n+n-i),0),e.match_start-=n,e.strstart-=n,e.block_start-=n,e.insert>e.strstart&&(e.insert=e.strstart),a0(e),i+=n),e.strm.avail_in===0)break;if(t=sr(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=t,e.lookahead+e.insert>=oe)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=Wt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=Wt(e,e.ins_h,e.window[o+oe-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<oe)););}while(e.lookahead<pt&&e.strm.avail_in!==0)},Ma=(e,n)=>{let t=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<t&&(i===0&&n!==Ye||n===Ht||i!==o+e.strm.avail_in)))break;s=n===Ye&&i===o+e.strm.avail_in?1:0,er(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,Ge(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&&(sr(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?kn:n!==Ht&&n!==Ye&&e.strm.avail_in===0&&e.strstart===e.block_start?xn:(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&&(sr(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,t=r>e.w_size?e.w_size:r,o=e.strstart-e.block_start,(o>=t||(o||n===Ye)&&n!==Ht&&e.strm.avail_in===0&&o<=r)&&(i=o>r?r:o,s=n===Ye&&e.strm.avail_in===0&&i===o?1:0,er(e,e.block_start,i,s),e.block_start+=i,Ge(e.strm)),s?en:Be)},Qo=(e,n)=>{let t,i;for(;;){if(e.lookahead<pt){if(Sn(e),e.lookahead<pt&&n===Ht)return Be;if(e.lookahead===0)break}if(t=0,e.lookahead>=oe&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),t!==0&&e.strstart-t<=e.w_size-pt&&(e.match_length=La(e,t)),e.match_length>=oe)if(i=Gt(e,e.strstart-e.match_start,e.match_length-oe),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=oe){e.match_length--;do e.strstart++,e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=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=Wt(e,e.ins_h,e.window[e.strstart+1]);else i=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=e.strstart<oe-1?e.strstart:oe-1,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},wn=(e,n)=>{let t,i,o;for(;;){if(e.lookahead<pt){if(Sn(e),e.lookahead<pt&&n===Ht)return Be;if(e.lookahead===0)break}if(t=0,e.lookahead>=oe&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=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=oe-1,t!==0&&e.prev_length<e.max_lazy_match&&e.strstart-t<=e.w_size-pt&&(e.match_length=La(e,t),e.match_length<=5&&(e.strategy===Hu||e.match_length===oe&&e.strstart-e.match_start>4096)&&(e.match_length=oe-1)),e.prev_length>=oe&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-oe,i=Gt(e,e.strstart-1-e.prev_match,e.prev_length-oe),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=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=oe-1,e.strstart++,i&&(He(e,!1),e.strm.avail_out===0))return Be}else if(e.match_available){if(i=Gt(e,0,e.window[e.strstart-1]),i&&He(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Be}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Gt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<oe-1?e.strstart:oe-1,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},c0=(e,n)=>{let t,i,o,r,s=e.window;for(;;){if(e.lookahead<=Nt){if(Sn(e),e.lookahead<=Nt&&n===Ht)return Be;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=oe&&e.strstart>0&&(o=e.strstart-1,i=s[o],i===s[++o]&&i===s[++o]&&i===s[++o])){r=e.strstart+Nt;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=Nt-(r-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=oe?(t=Gt(e,1,e.match_length-oe),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=0,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},f0=(e,n)=>{let t;for(;;){if(e.lookahead===0&&(Sn(e),e.lookahead===0)){if(n===Ht)return Be;break}if(e.match_length=0,t=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=0,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn};function dt(e,n,t,i,o){this.good_length=e,this.max_lazy=n,this.nice_length=t,this.max_chain=i,this.func=o}var ni=[new dt(0,0,0,0,Ma),new dt(4,4,8,4,Qo),new dt(4,5,16,8,Qo),new dt(4,6,32,32,Qo),new dt(4,4,16,16,wn),new dt(8,16,32,32,wn),new dt(8,16,128,128,wn),new dt(8,32,128,256,wn),new dt(32,128,258,1024,wn),new dt(32,258,258,4096,wn)],d0=e=>{e.window_size=2*e.w_size,Vt(e.head),e.max_lazy_match=ni[e.level].max_lazy,e.good_match=ni[e.level].good_length,e.nice_match=ni[e.level].nice_length,e.max_chain_length=ni[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=oe-1,e.match_available=0,e.ins_h=0};function u0(){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=Bi,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(i0*2),this.dyn_dtree=new Uint16Array((2*t0+1)*2),this.bl_tree=new Uint16Array((2*n0+1)*2),Vt(this.dyn_ltree),Vt(this.dyn_dtree),Vt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(o0+1),this.heap=new Uint16Array(2*tr+1),Vt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*tr+1),Vt(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 ii=e=>{if(!e)return 1;let n=e.state;return!n||n.strm!==e||n.status!==vn&&n.status!==ar&&n.status!==nr&&n.status!==ir&&n.status!==or&&n.status!==rr&&n.status!==Jt&&n.status!==ti?1:0},Ua=e=>{if(ii(e))return Qt(e,ut);e.total_in=e.total_out=0,e.data_type=Zu;let n=e.state;return n.pending=0,n.pending_out=0,n.wrap<0&&(n.wrap=-n.wrap),n.status=n.wrap===2?ar:n.wrap?vn:Jt,e.adler=n.wrap===2?0:1,n.last_flush=-2,Ru(n),Oe},Ba=e=>{let n=Ua(e);return n===Oe&&d0(e.state),n},p0=(e,n)=>ii(e)||e.state.wrap!==2?ut:(e.state.gzhead=n,Oe),Ra=(e,n,t,i,o,r)=>{if(!e)return ut;let s=1;if(n===Gu&&(n=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),o<1||o>Ku||t!==Bi||i<8||i>15||n<0||n>9||r<0||r>Xu||i===8&&s!==1)return Qt(e,ut);i===8&&(i=9);let a=new u0;return e.state=a,a.strm=e,a.status=vn,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+oe-1)/oe),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=n,a.strategy=r,a.method=t,Ba(e)},h0=(e,n)=>Ra(e,n,Bi,Yu,Ju,qu),g0=(e,n)=>{if(ii(e)||n>Da||n<0)return e?Qt(e,ut):ut;let t=e.state;if(!e.output||e.avail_in!==0&&!e.input||t.status===ti&&n!==Ye)return Qt(e,e.avail_out===0?Jo:ut);let i=t.last_flush;if(t.last_flush=n,t.pending!==0){if(Ge(e),e.avail_out===0)return t.last_flush=-1,Oe}else if(e.avail_in===0&&Ea(n)<=Ea(i)&&n!==Ye)return Qt(e,Jo);if(t.status===ti&&e.avail_in!==0)return Qt(e,Jo);if(t.status===vn&&t.wrap===0&&(t.status=Jt),t.status===vn){let o=Bi+(t.w_bits-8<<4)<<8,r=-1;if(t.strategy>=Ui||t.level<2?r=0:t.level<6?r=1:t.level===6?r=2:r=3,o|=r<<6,t.strstart!==0&&(o|=r0),o+=31-o%31,ei(t,o),t.strstart!==0&&(ei(t,e.adler>>>16),ei(t,e.adler&65535)),e.adler=1,t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(t.status===ar){if(e.adler=0,fe(t,31),fe(t,139),fe(t,8),t.gzhead)fe(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),fe(t,t.gzhead.time&255),fe(t,t.gzhead.time>>8&255),fe(t,t.gzhead.time>>16&255),fe(t,t.gzhead.time>>24&255),fe(t,t.level===9?2:t.strategy>=Ui||t.level<2?4:0),fe(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(fe(t,t.gzhead.extra.length&255),fe(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(e.adler=$t(e.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=nr;else if(fe(t,0),fe(t,0),fe(t,0),fe(t,0),fe(t,0),fe(t,t.level===9?2:t.strategy>=Ui||t.level<2?4:0),fe(t,s0),t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(t.status===nr){if(t.gzhead.extra){let o=t.pending,r=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+r>t.pending_buf_size;){let a=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex+=a,Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0,r-=a}let s=new Uint8Array(t.gzhead.extra);t.pending_buf.set(s.subarray(t.gzindex,t.gzindex+r),t.pending),t.pending+=r,t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex=0}t.status=ir}if(t.status===ir){if(t.gzhead.name){let o=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0}t.gzindex<t.gzhead.name.length?r=t.gzhead.name.charCodeAt(t.gzindex++)&255:r=0,fe(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex=0}t.status=or}if(t.status===or){if(t.gzhead.comment){let o=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0}t.gzindex<t.gzhead.comment.length?r=t.gzhead.comment.charCodeAt(t.gzindex++)&255:r=0,fe(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o))}t.status=rr}if(t.status===rr){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(Ge(e),t.pending!==0))return t.last_flush=-1,Oe;fe(t,e.adler&255),fe(t,e.adler>>8&255),e.adler=0}if(t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(e.avail_in!==0||t.lookahead!==0||n!==Ht&&t.status!==ti){let o=t.level===0?Ma(t,n):t.strategy===Ui?f0(t,n):t.strategy===Wu?c0(t,n):ni[t.level].func(t,n);if((o===en||o===kn)&&(t.status=ti),o===Be||o===en)return e.avail_out===0&&(t.last_flush=-1),Oe;if(o===xn&&(n===$u?ju(t):n!==Da&&(er(t,0,0,!1),n===Vu&&(Vt(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),Ge(e),e.avail_out===0))return t.last_flush=-1,Oe}return n!==Ye?Oe:t.wrap<=0?Oa:(t.wrap===2?(fe(t,e.adler&255),fe(t,e.adler>>8&255),fe(t,e.adler>>16&255),fe(t,e.adler>>24&255),fe(t,e.total_in&255),fe(t,e.total_in>>8&255),fe(t,e.total_in>>16&255),fe(t,e.total_in>>24&255)):(ei(t,e.adler>>>16),ei(t,e.adler&65535)),Ge(e),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Oe:Oa)},m0=e=>{if(ii(e))return ut;let n=e.state.status;return e.state=null,n===Jt?Qt(e,Nu):Oe},y0=(e,n)=>{let t=n.length;if(ii(e))return ut;let i=e.state,o=i.wrap;if(o===2||o===1&&i.status!==vn||i.lookahead)return ut;if(o===1&&(e.adler=Fa(e.adler,n,t,0)),i.wrap=0,t>=i.w_size){o===0&&(Vt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let l=new Uint8Array(i.w_size);l.set(n.subarray(t-i.w_size,t),0),n=l,t=i.w_size}let r=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=t,e.next_in=0,e.input=n,Sn(i);i.lookahead>=oe;){let l=i.strstart,c=i.lookahead-(oe-1);do i.ins_h=Wt(i,i.ins_h,i.window[l+oe-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=oe-1,Sn(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=oe-1,i.match_available=0,e.next_in=s,e.input=a,e.avail_in=r,i.wrap=o,Oe};ht.exports.deflateInit=h0;ht.exports.deflateInit2=Ra;ht.exports.deflateReset=Ba;ht.exports.deflateResetKeep=Ua;ht.exports.deflateSetHeader=p0;ht.exports.deflate=g0;ht.exports.deflateEnd=m0;ht.exports.deflateSetDictionary=y0;ht.exports.deflateInfo="pako deflate (from Nodeca project)"});var cr=ae((zy,lr)=>{"use strict";var b0=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);lr.exports.assign=function(e){let n=Array.prototype.slice.call(arguments,1);for(;n.length;){let t=n.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(let i in t)b0(t,i)&&(e[i]=t[i])}}return e};lr.exports.flattenChunks=e=>{let n=0;for(let i=0,o=e.length;i<o;i++)n+=e[i].length;let t=new Uint8Array(n);for(let i=0,o=0,r=e.length;i<r;i++){let s=e[i];t.set(s,o),o+=s.length}return t}});var fr=ae(($y,Ri)=>{"use strict";var ja=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{ja=!1}var oi=new Uint8Array(256);for(let e=0;e<256;e++)oi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;oi[254]=oi[254]=1;Ri.exports.string2buf=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let n,t,i,o,r,s=e.length,a=0;for(o=0;o<s;o++)t=e.charCodeAt(o),(t&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),o++)),a+=t<128?1:t<2048?2:t<65536?3:4;for(n=new Uint8Array(a),r=0,o=0;r<a;o++)t=e.charCodeAt(o),(t&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),o++)),t<128?n[r++]=t:t<2048?(n[r++]=192|t>>>6,n[r++]=128|t&63):t<65536?(n[r++]=224|t>>>12,n[r++]=128|t>>>6&63,n[r++]=128|t&63):(n[r++]=240|t>>>18,n[r++]=128|t>>>12&63,n[r++]=128|t>>>6&63,n[r++]=128|t&63);return n};var w0=(e,n)=>{if(n<65534&&e.subarray&&ja)return String.fromCharCode.apply(null,e.length===n?e:e.subarray(0,n));let t="";for(let i=0;i<n;i++)t+=String.fromCharCode(e[i]);return t};Ri.exports.buf2string=(e,n)=>{let t=n||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,n));let i,o,r=new Array(t*2);for(o=0,i=0;i<t;){let s=e[i++];if(s<128){r[o++]=s;continue}let a=oi[s];if(a>4){r[o++]=65533,i+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&i<t;)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 w0(r,o)};Ri.exports.utf8border=(e,n)=>{n=n||e.length,n>e.length&&(n=e.length);let t=n-1;for(;t>=0&&(e[t]&192)===128;)t--;return t<0||t===0?n:t+oi[e[t]]>n?t:n}});var dr=ae((Vy,za)=>{"use strict";function v0(){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}za.exports=v0});var Ga=ae((Ny,_n)=>{"use strict";var ri=Ta(),$a=cr(),Va=fr(),ur=Mi(),S0=dr(),Na=Object.prototype.toString,{Z_NO_FLUSH:x0,Z_SYNC_FLUSH:k0,Z_FULL_FLUSH:_0,Z_FINISH:A0,Z_OK:Ti,Z_STREAM_END:I0,Z_DEFAULT_COMPRESSION:C0,Z_DEFAULT_STRATEGY:P0,Z_DEFLATED:D0}=zt();function si(e){this.options=$a.assign({level:C0,method:D0,chunkSize:16384,windowBits:15,memLevel:8,strategy:P0},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new S0,this.strm.avail_out=0;let t=ri.deflateInit2(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(t!==Ti)throw new Error(ur[t]);if(n.header&&ri.deflateSetHeader(this.strm,n.header),n.dictionary){let i;if(typeof n.dictionary=="string"?i=Va.string2buf(n.dictionary):Na.call(n.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(n.dictionary):i=n.dictionary,t=ri.deflateSetDictionary(this.strm,i),t!==Ti)throw new Error(ur[t]);this._dict_set=!0}}si.prototype.push=function(e,n){let t=this.strm,i=this.options.chunkSize,o,r;if(this.ended)return!1;for(n===~~n?r=n:r=n===!0?A0:x0,typeof e=="string"?t.input=Va.string2buf(e):Na.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),(r===k0||r===_0)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(o=ri.deflate(t,r),o===I0)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),o=ri.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===Ti;if(t.avail_out===0){this.onData(t.output);continue}if(r>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};si.prototype.onData=function(e){this.chunks.push(e)};si.prototype.onEnd=function(e){e===Ti&&(this.result=$a.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function pr(e,n){let t=new si(n);if(t.push(e,!0),t.err)throw t.msg||ur[t.err];return t.result}function O0(e,n){return n=n||{},n.raw=!0,pr(e,n)}function E0(e,n){return n=n||{},n.gzip=!0,pr(e,n)}_n.exports.Deflate=si;_n.exports.deflate=pr;_n.exports.deflateRaw=O0;_n.exports.gzip=E0;_n.exports.constants=zt()});var Wa=ae((Gy,Ha)=>{"use strict";Ha.exports=function(n,t){let i,o,r,s,a,l,c,f,u,d,p,h,m,y,g,k,x,S,A,D,C,O,E,L,M=n.state;i=n.next_in,E=n.input,o=i+(n.avail_in-5),r=n.next_out,L=n.output,s=r-(t-n.avail_out),a=r+(n.avail_out-257),l=M.dmax,c=M.wsize,f=M.whave,u=M.wnext,d=M.window,p=M.hold,h=M.bits,m=M.lencode,y=M.distcode,g=(1<<M.lenbits)-1,k=(1<<M.distbits)-1;e:do{h<15&&(p+=E[i++]<<h,h+=8,p+=E[i++]<<h,h+=8),x=m[p&g];t:for(;;){if(S=x>>>24,p>>>=S,h-=S,S=x>>>16&255,S===0)L[r++]=x&65535;else if(S&16){A=x&65535,S&=15,S&&(h<S&&(p+=E[i++]<<h,h+=8),A+=p&(1<<S)-1,p>>>=S,h-=S),h<15&&(p+=E[i++]<<h,h+=8,p+=E[i++]<<h,h+=8),x=y[p&k];n:for(;;){if(S=x>>>24,p>>>=S,h-=S,S=x>>>16&255,S&16){if(D=x&65535,S&=15,h<S&&(p+=E[i++]<<h,h+=8,h<S&&(p+=E[i++]<<h,h+=8)),D+=p&(1<<S)-1,D>l){n.msg="invalid distance too far back",M.mode=16209;break e}if(p>>>=S,h-=S,S=r-s,D>S){if(S=D-S,S>f&&M.sane){n.msg="invalid distance too far back",M.mode=16209;break e}if(C=0,O=d,u===0){if(C+=c-S,S<A){A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}}else if(u<S){if(C+=c+u-S,S-=u,S<A){A-=S;do L[r++]=d[C++];while(--S);if(C=0,u<A){S=u,A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}}}else if(C+=u-S,S<A){A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}for(;A>2;)L[r++]=O[C++],L[r++]=O[C++],L[r++]=O[C++],A-=3;A&&(L[r++]=O[C++],A>1&&(L[r++]=O[C++]))}else{C=r-D;do L[r++]=L[C++],L[r++]=L[C++],L[r++]=L[C++],A-=3;while(A>2);A&&(L[r++]=L[C++],A>1&&(L[r++]=L[C++]))}}else if((S&64)===0){x=y[(x&65535)+(p&(1<<S)-1)];continue n}else{n.msg="invalid distance code",M.mode=16209;break e}break}}else if((S&64)===0){x=m[(x&65535)+(p&(1<<S)-1)];continue t}else if(S&32){M.mode=16191;break e}else{n.msg="invalid literal/length code",M.mode=16209;break e}break}}while(i<o&&r<a);A=h>>3,i-=A,h-=A<<3,p&=(1<<h)-1,n.next_in=i,n.next_out=r,n.avail_in=i<o?5+(o-i):5-(i-o),n.avail_out=r<a?257+(a-r):257-(r-a),M.hold=p,M.bits=h}});var qa=ae((Hy,Xa)=>{"use strict";var F0=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]),L0=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]),M0=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]),U0=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]),B0=(e,n,t,i,o,r,s,a)=>{let l=a.bits,c=0,f=0,u=0,d=0,p=0,h=0,m=0,y=0,g=0,k=0,x,S,A,D,C,O=null,E,L=new Uint16Array(16),M=new Uint16Array(16),J=null,pe,R,ie;for(c=0;c<=15;c++)L[c]=0;for(f=0;f<i;f++)L[n[t+f]]++;for(p=l,d=15;d>=1&&L[d]===0;d--);if(p>d&&(p=d),d===0)return o[r++]=1<<24|64<<16|0,o[r++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<d&&L[u]===0;u++);for(p<u&&(p=u),y=1,c=1;c<=15;c++)if(y<<=1,y-=L[c],y<0)return-1;if(y>0&&(e===0||d!==1))return-1;for(M[1]=0,c=1;c<15;c++)M[c+1]=M[c]+L[c];for(f=0;f<i;f++)n[t+f]!==0&&(s[M[n[t+f]]++]=f);if(e===0?(O=J=s,E=20):e===1?(O=F0,J=L0,E=257):(O=M0,J=U0,E=0),k=0,f=0,c=u,C=r,h=p,m=0,A=-1,g=1<<p,D=g-1,e===1&&g>852||e===2&&g>592)return 1;for(;;){pe=c-m,s[f]+1<E?(R=0,ie=s[f]):s[f]>=E?(R=J[s[f]-E],ie=O[s[f]-E]):(R=96,ie=0),x=1<<c-m,S=1<<h,u=S;do S-=x,o[C+(k>>m)+S]=pe<<24|R<<16|ie|0;while(S!==0);for(x=1<<c-1;k&x;)x>>=1;if(x!==0?(k&=x-1,k+=x):k=0,f++,--L[c]===0){if(c===d)break;c=n[t+s[f]]}if(c>p&&(k&D)!==A){for(m===0&&(m=p),C+=u,h=c-m,y=1<<h;h+m<d&&(y-=L[h+m],!(y<=0));)h++,y<<=1;if(g+=1<<h,e===1&&g>852||e===2&&g>592)return 1;A=k&D,o[A]=p<<24|h<<16|C-r|0}}return k!==0&&(o[C+k]=c-m<<24|64<<16|0),a.bits=p,0};Xa.exports=B0});var Dl=ae((Wy,it)=>{"use strict";var wr=Ko(),gt=Yo(),R0=Wa(),ai=qa(),T0=0,vl=1,Sl=2,{Z_FINISH:Za,Z_BLOCK:j0,Z_TREES:ji,Z_OK:tn,Z_STREAM_END:z0,Z_NEED_DICT:$0,Z_STREAM_ERROR:Je,Z_DATA_ERROR:xl,Z_MEM_ERROR:vr,Z_BUF_ERROR:V0,Z_DEFLATED:Ka}=zt(),Ni=16180,Ya=16181,Ja=16182,Qa=16183,el=16184,tl=16185,nl=16186,il=16187,ol=16188,rl=16189,Vi=16190,It=16191,hr=16192,sl=16193,gr=16194,al=16195,ll=16196,cl=16197,fl=16198,zi=16199,$i=16200,dl=16201,ul=16202,pl=16203,hl=16204,gl=16205,mr=16206,ml=16207,yl=16208,ke=16209,Sr=16210,kl=16211,N0=852,G0=592,H0=15,W0=H0,bl=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function X0(){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 nn=e=>{if(!e)return 1;let n=e.state;return!n||n.strm!==e||n.mode<Ni||n.mode>kl?1:0},_l=e=>{if(nn(e))return Je;let n=e.state;return e.total_in=e.total_out=n.total=0,e.msg="",n.wrap&&(e.adler=n.wrap&1),n.mode=Ni,n.last=0,n.havedict=0,n.flags=-1,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new Int32Array(N0),n.distcode=n.distdyn=new Int32Array(G0),n.sane=1,n.back=-1,tn},Al=e=>{if(nn(e))return Je;let n=e.state;return n.wsize=0,n.whave=0,n.wnext=0,_l(e)},Il=(e,n)=>{let t;if(nn(e))return Je;let i=e.state;return n<0?(t=0,n=-n):(t=(n>>4)+5,n<48&&(n&=15)),n&&(n<8||n>15)?Je:(i.window!==null&&i.wbits!==n&&(i.window=null),i.wrap=t,i.wbits=n,Al(e))},Cl=(e,n)=>{if(!e)return Je;let t=new X0;e.state=t,t.strm=e,t.window=null,t.mode=Ni;let i=Il(e,n);return i!==tn&&(e.state=null),i},q0=e=>Cl(e,W0),wl=!0,yr,br,Z0=e=>{if(wl){yr=new Int32Array(512),br=new Int32Array(32);let n=0;for(;n<144;)e.lens[n++]=8;for(;n<256;)e.lens[n++]=9;for(;n<280;)e.lens[n++]=7;for(;n<288;)e.lens[n++]=8;for(ai(vl,e.lens,0,288,yr,0,e.work,{bits:9}),n=0;n<32;)e.lens[n++]=5;ai(Sl,e.lens,0,32,br,0,e.work,{bits:5}),wl=!1}e.lencode=yr,e.lenbits=9,e.distcode=br,e.distbits=5},Pl=(e,n,t,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(n.subarray(t-r.wsize,t),0),r.wnext=0,r.whave=r.wsize):(o=r.wsize-r.wnext,o>i&&(o=i),r.window.set(n.subarray(t-i,t-i+o),r.wnext),i-=o,i?(r.window.set(n.subarray(t-i,t),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},K0=(e,n)=>{let t,i,o,r,s,a,l,c,f,u,d,p,h,m,y=0,g,k,x,S,A,D,C,O,E=new Uint8Array(4),L,M,J=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(nn(e)||!e.output||!e.input&&e.avail_in!==0)return Je;t=e.state,t.mode===It&&(t.mode=hr),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=t.hold,f=t.bits,u=a,d=l,O=tn;e:for(;;)switch(t.mode){case Ni:if(t.wrap===0){t.mode=hr;break}for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&2&&c===35615){t.wbits===0&&(t.wbits=15),t.check=0,E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0),c=0,f=0,t.mode=Ya;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",t.mode=ke;break}if((c&15)!==Ka){e.msg="unknown compression method",t.mode=ke;break}if(c>>>=4,f-=4,C=(c&15)+8,t.wbits===0&&(t.wbits=C),C>15||C>t.wbits){e.msg="invalid window size",t.mode=ke;break}t.dmax=1<<t.wbits,t.flags=0,e.adler=t.check=1,t.mode=c&512?rl:It,c=0,f=0;break;case Ya:for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.flags=c,(t.flags&255)!==Ka){e.msg="unknown compression method",t.mode=ke;break}if(t.flags&57344){e.msg="unknown header flags set",t.mode=ke;break}t.head&&(t.head.text=c>>8&1),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0,t.mode=Ja;case Ja:for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.head&&(t.head.time=c),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,E[2]=c>>>16&255,E[3]=c>>>24&255,t.check=gt(t.check,E,4,0)),c=0,f=0,t.mode=Qa;case Qa:for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.head&&(t.head.xflags=c&255,t.head.os=c>>8),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0,t.mode=el;case el:if(t.flags&1024){for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.length=c,t.head&&(t.head.extra_len=c),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0}else t.head&&(t.head.extra=null);t.mode=tl;case tl:if(t.flags&1024&&(p=t.length,p>a&&(p=a),p&&(t.head&&(C=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(i.subarray(r,r+p),C)),t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,t.length-=p),t.length))break e;t.length=0,t.mode=nl;case nl:if(t.flags&2048){if(a===0)break e;p=0;do C=i[r+p++],t.head&&C&&t.length<65536&&(t.head.name+=String.fromCharCode(C));while(C&&p<a);if(t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,C)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=il;case il:if(t.flags&4096){if(a===0)break e;p=0;do C=i[r+p++],t.head&&C&&t.length<65536&&(t.head.comment+=String.fromCharCode(C));while(C&&p<a);if(t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,C)break e}else t.head&&(t.head.comment=null);t.mode=ol;case ol:if(t.flags&512){for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&4&&c!==(t.check&65535)){e.msg="header crc mismatch",t.mode=ke;break}c=0,f=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=It;break;case rl:for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}e.adler=t.check=bl(c),c=0,f=0,t.mode=Vi;case Vi:if(t.havedict===0)return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,$0;e.adler=t.check=1,t.mode=It;case It:if(n===j0||n===ji)break e;case hr:if(t.last){c>>>=f&7,f-=f&7,t.mode=mr;break}for(;f<3;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}switch(t.last=c&1,c>>>=1,f-=1,c&3){case 0:t.mode=sl;break;case 1:if(Z0(t),t.mode=zi,n===ji){c>>>=2,f-=2;break e}break;case 2:t.mode=ll;break;case 3:e.msg="invalid block type",t.mode=ke}c>>>=2,f-=2;break;case sl:for(c>>>=f&7,f-=f&7;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",t.mode=ke;break}if(t.length=c&65535,c=0,f=0,t.mode=gr,n===ji)break e;case gr:t.mode=al;case al:if(p=t.length,p){if(p>a&&(p=a),p>l&&(p=l),p===0)break e;o.set(i.subarray(r,r+p),s),a-=p,r+=p,l-=p,s+=p,t.length-=p;break}t.mode=It;break;case ll:for(;f<14;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.nlen=(c&31)+257,c>>>=5,f-=5,t.ndist=(c&31)+1,c>>>=5,f-=5,t.ncode=(c&15)+4,c>>>=4,f-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=ke;break}t.have=0,t.mode=cl;case cl:for(;t.have<t.ncode;){for(;f<3;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.lens[J[t.have++]]=c&7,c>>>=3,f-=3}for(;t.have<19;)t.lens[J[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,L={bits:t.lenbits},O=ai(T0,t.lens,0,19,t.lencode,0,t.work,L),t.lenbits=L.bits,O){e.msg="invalid code lengths set",t.mode=ke;break}t.have=0,t.mode=fl;case fl:for(;t.have<t.nlen+t.ndist;){for(;y=t.lencode[c&(1<<t.lenbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(x<16)c>>>=g,f-=g,t.lens[t.have++]=x;else{if(x===16){for(M=g+2;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(c>>>=g,f-=g,t.have===0){e.msg="invalid bit length repeat",t.mode=ke;break}C=t.lens[t.have-1],p=3+(c&3),c>>>=2,f-=2}else if(x===17){for(M=g+3;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=g,f-=g,C=0,p=3+(c&7),c>>>=3,f-=3}else{for(M=g+7;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=g,f-=g,C=0,p=11+(c&127),c>>>=7,f-=7}if(t.have+p>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=ke;break}for(;p--;)t.lens[t.have++]=C}}if(t.mode===ke)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=ke;break}if(t.lenbits=9,L={bits:t.lenbits},O=ai(vl,t.lens,0,t.nlen,t.lencode,0,t.work,L),t.lenbits=L.bits,O){e.msg="invalid literal/lengths set",t.mode=ke;break}if(t.distbits=6,t.distcode=t.distdyn,L={bits:t.distbits},O=ai(Sl,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,L),t.distbits=L.bits,O){e.msg="invalid distances set",t.mode=ke;break}if(t.mode=zi,n===ji)break e;case zi:t.mode=$i;case $i:if(a>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,R0(e,d),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=t.hold,f=t.bits,t.mode===It&&(t.back=-1);break}for(t.back=0;y=t.lencode[c&(1<<t.lenbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(k&&(k&240)===0){for(S=g,A=k,D=x;y=t.lencode[D+((c&(1<<S+A)-1)>>S)],g=y>>>24,k=y>>>16&255,x=y&65535,!(S+g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=S,f-=S,t.back+=S}if(c>>>=g,f-=g,t.back+=g,t.length=x,k===0){t.mode=gl;break}if(k&32){t.back=-1,t.mode=It;break}if(k&64){e.msg="invalid literal/length code",t.mode=ke;break}t.extra=k&15,t.mode=dl;case dl:if(t.extra){for(M=t.extra;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.length+=c&(1<<t.extra)-1,c>>>=t.extra,f-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=ul;case ul:for(;y=t.distcode[c&(1<<t.distbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if((k&240)===0){for(S=g,A=k,D=x;y=t.distcode[D+((c&(1<<S+A)-1)>>S)],g=y>>>24,k=y>>>16&255,x=y&65535,!(S+g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=S,f-=S,t.back+=S}if(c>>>=g,f-=g,t.back+=g,k&64){e.msg="invalid distance code",t.mode=ke;break}t.offset=x,t.extra=k&15,t.mode=pl;case pl:if(t.extra){for(M=t.extra;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.offset+=c&(1<<t.extra)-1,c>>>=t.extra,f-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=ke;break}t.mode=hl;case hl:if(l===0)break e;if(p=d-l,t.offset>p){if(p=t.offset-p,p>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=ke;break}p>t.wnext?(p-=t.wnext,h=t.wsize-p):h=t.wnext-p,p>t.length&&(p=t.length),m=t.window}else m=o,h=s-t.offset,p=t.length;p>l&&(p=l),l-=p,t.length-=p;do o[s++]=m[h++];while(--p);t.length===0&&(t.mode=$i);break;case gl:if(l===0)break e;o[s++]=t.length,l--,t.mode=$i;break;case mr:if(t.wrap){for(;f<32;){if(a===0)break e;a--,c|=i[r++]<<f,f+=8}if(d-=l,e.total_out+=d,t.total+=d,t.wrap&4&&d&&(e.adler=t.check=t.flags?gt(t.check,o,d,s-d):wr(t.check,o,d,s-d)),d=l,t.wrap&4&&(t.flags?c:bl(c))!==t.check){e.msg="incorrect data check",t.mode=ke;break}c=0,f=0}t.mode=ml;case ml:if(t.wrap&&t.flags){for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&4&&c!==(t.total&4294967295)){e.msg="incorrect length check",t.mode=ke;break}c=0,f=0}t.mode=yl;case yl:O=z0;break e;case ke:O=xl;break e;case Sr:return vr;case kl:default:return Je}return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,(t.wsize||d!==e.avail_out&&t.mode<ke&&(t.mode<mr||n!==Za))&&Pl(e,e.output,e.next_out,d-e.avail_out)?(t.mode=Sr,vr):(u-=e.avail_in,d-=e.avail_out,e.total_in+=u,e.total_out+=d,t.total+=d,t.wrap&4&&d&&(e.adler=t.check=t.flags?gt(t.check,o,d,e.next_out-d):wr(t.check,o,d,e.next_out-d)),e.data_type=t.bits+(t.last?64:0)+(t.mode===It?128:0)+(t.mode===zi||t.mode===gr?256:0),(u===0&&d===0||n===Za)&&O===tn&&(O=V0),O)},Y0=e=>{if(nn(e))return Je;let n=e.state;return n.window&&(n.window=null),e.state=null,tn},J0=(e,n)=>{if(nn(e))return Je;let t=e.state;return(t.wrap&2)===0?Je:(t.head=n,n.done=!1,tn)},Q0=(e,n)=>{let t=n.length,i,o,r;return nn(e)||(i=e.state,i.wrap!==0&&i.mode!==Vi)?Je:i.mode===Vi&&(o=1,o=wr(o,n,t,0),o!==i.check)?xl:(r=Pl(e,n,t,t),r?(i.mode=Sr,vr):(i.havedict=1,tn))};it.exports.inflateReset=Al;it.exports.inflateReset2=Il;it.exports.inflateResetKeep=_l;it.exports.inflateInit=q0;it.exports.inflateInit2=Cl;it.exports.inflate=K0;it.exports.inflateEnd=Y0;it.exports.inflateGetHeader=J0;it.exports.inflateSetDictionary=Q0;it.exports.inflateInfo="pako inflate (from Nodeca project)"});var El=ae((Xy,Ol)=>{"use strict";function ep(){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}Ol.exports=ep});var Ul=ae((qy,An)=>{"use strict";var Ct=Dl(),Ll=cr(),_r=fr(),Ar=Mi(),tp=dr(),np=El(),Ml=Object.prototype.toString,{Z_NO_FLUSH:ip,Z_FINISH:op,Z_OK:li,Z_STREAM_END:xr,Z_NEED_DICT:kr,Z_STREAM_ERROR:rp,Z_DATA_ERROR:Fl,Z_MEM_ERROR:sp}=zt();function ci(e){this.options=Ll.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let n=this.options;n.raw&&n.windowBits>=0&&n.windowBits<16&&(n.windowBits=-n.windowBits,n.windowBits===0&&(n.windowBits=-15)),n.windowBits>=0&&n.windowBits<16&&!(e&&e.windowBits)&&(n.windowBits+=32),n.windowBits>15&&n.windowBits<48&&(n.windowBits&15)===0&&(n.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new tp,this.strm.avail_out=0;let t=Ct.inflateInit2(this.strm,n.windowBits);if(t!==li)throw new Error(Ar[t]);if(this.header=new np,Ct.inflateGetHeader(this.strm,this.header),n.dictionary&&(typeof n.dictionary=="string"?n.dictionary=_r.string2buf(n.dictionary):Ml.call(n.dictionary)==="[object ArrayBuffer]"&&(n.dictionary=new Uint8Array(n.dictionary)),n.raw&&(t=Ct.inflateSetDictionary(this.strm,n.dictionary),t!==li)))throw new Error(Ar[t])}ci.prototype.push=function(e,n){let t=this.strm,i=this.options.chunkSize,o=this.options.dictionary,r,s,a;if(this.ended)return!1;for(n===~~n?s=n:s=n===!0?op:ip,Ml.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),r=Ct.inflate(t,s),r===kr&&o&&(r=Ct.inflateSetDictionary(t,o),r===li?r=Ct.inflate(t,s):r===Fl&&(r=kr));t.avail_in>0&&r===xr&&t.state.wrap>0&&e[t.next_in]!==0;)Ct.inflateReset(t),r=Ct.inflate(t,s);switch(r){case rp:case Fl:case kr:case sp:return this.onEnd(r),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||r===xr))if(this.options.to==="string"){let l=_r.utf8border(t.output,t.next_out),c=t.next_out-l,f=_r.buf2string(t.output,l);t.next_out=c,t.avail_out=i-c,c&&t.output.set(t.output.subarray(l,l+c),0),this.onData(f)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(r===li&&a===0)){if(r===xr)return r=Ct.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};ci.prototype.onData=function(e){this.chunks.push(e)};ci.prototype.onEnd=function(e){e===li&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ll.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Ir(e,n){let t=new ci(n);if(t.push(e),t.err)throw t.msg||Ar[t.err];return t.result}function ap(e,n){return n=n||{},n.raw=!0,Ir(e,n)}An.exports.Inflate=ci;An.exports.inflate=Ir;An.exports.inflateRaw=ap;An.exports.ungzip=Ir;An.exports.constants=zt()});var Gi=ae((Zy,mt)=>{"use strict";var{Deflate:lp,deflate:cp,deflateRaw:fp,gzip:dp}=Ga(),{Inflate:up,inflate:pp,inflateRaw:hp,ungzip:gp}=Ul(),mp=zt();mt.exports.Deflate=lp;mt.exports.deflate=cp;mt.exports.deflateRaw=fp;mt.exports.gzip=dp;mt.exports.Inflate=up;mt.exports.inflate=pp;mt.exports.inflateRaw=hp;mt.exports.ungzip=gp;mt.exports.constants=mp});var Bl=ae(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.decodeJpeg=kp;var fi=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]),Hi=4017,Wi=799,Xi=3406,qi=2276,Zi=1567,Ki=3784,In=5793,Yi=2896,yp=100,Cr=64*1024*1024,Pr=0,Dr=Cr;function Cn(e){if(!isFinite(e)||e<0)throw new Error(`Invalid memory allocation size (${e})`);let n=Pr+e;if(n>Dr){let t=Math.ceil((n-Dr)/1024/1024);throw new Error(`Max memory limit exceeded by at least ${t}MB`)}Pr=n}function bp(e,n){let t=16;for(;t>0&&!e[t-1];)t--;let i=[{children:[],index:0}],o=0,r=i[0];for(let s=0;s<t;s++){for(let a=0;a<e[s];a++){for(r=i.pop(),r.children[r.index]=n[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<t){let a={children:[],index:0};i.push(a),r.children[r.index]=a.children,r=a}}return i[0].children}function wp(e,n,t,i,o,r,s,a,l){let c=t.mcusPerLine,f=t.progressive,u=n,d=0,p=0;function h(){if(p>0)return p--,d>>p&1;if(d=e[n++],d==255){let B=e[n++];if(B)throw new Error(`unexpected marker: ${(d<<8|B).toString(16)}`)}return p=7,d>>>7}function m(B){if(!B)throw new Error("Missing Huffman table");let $=B;for(;;){if($=$[h()],typeof $=="number")return $;if($===void 0)throw new Error("invalid huffman sequence")}}function y(B){let $=0;for(;B>0;)$=$<<1|h(),B--;return $}function g(B){let $=y(B);return $>=1<<B-1?$:$+(-1<<B)+1}function k(B,$){let ne=m(B.huffmanTableDC),ge=ne===0?0:g(ne);$[0]=B.pred+=ge;let Q=1;for(;Q<64;){let ee=m(B.huffmanTableAC),be=ee&15,Se=ee>>4;if(be===0){if(Se<15)break;Q+=16;continue}Q+=Se;let xe=fi[Q];$[xe]=g(be),Q++}}function x(B,$){let ne=m(B.huffmanTableDC),ge=ne===0?0:g(ne)<<l;$[0]=B.pred+=ge}function S(B,$){$[0]|=h()<<l}let A=0;function D(B,$){if(A>0){A--;return}let ne=r,ge=s;for(;ne<=ge;){let Q=m(B.huffmanTableAC),ee=Q&15,be=Q>>4;if(ee===0){if(be<15){A=y(be)+(1<<be)-1;break}ne+=16;continue}ne+=be;let Se=fi[ne];$[Se]=g(ee)*(1<<l),ne++}}let C=0,O=0;function E(B,$){let ne=r,ge=s,Q=0;for(;ne<=ge;){let ee=fi[ne],be=$[ee]<0?-1:1;switch(C){case 0:let Se=m(B.huffmanTableAC),xe=Se&15;if(Q=Se>>4,xe===0)Q<15?(A=y(Q)+(1<<Q),C=4):(Q=16,C=1);else{if(xe!==1)throw new Error("invalid ACn encoding");O=g(xe),C=Q?2:3}continue;case 1:case 2:$[ee]?$[ee]+=(h()<<l)*be:(Q--,Q===0&&(C=C==2?3:0));break;case 3:$[ee]?$[ee]+=(h()<<l)*be:($[ee]=O<<l,C=0);break;case 4:$[ee]&&($[ee]+=(h()<<l)*be);break}ne++}C===4&&(A--,A===0&&(C=0))}function L(B,$,ne,ge,Q){let ee=ne/c|0,be=ne%c,Se=ee*B.v+ge,xe=be*B.h+Q;B.blocks[Se]!==void 0&&$(B,B.blocks[Se][xe])}function M(B,$,ne){let ge=ne/B.blocksPerLine|0,Q=ne%B.blocksPerLine;B.blocks[ge]!==void 0&&$(B,B.blocks[ge][Q])}let J=i.length,pe,R;f?r===0?R=a===0?x:S:R=a===0?D:E:R=k;let ie=0,he;if(J==1?he=i[0].blocksPerLine*i[0].blocksPerColumn:he=c*t.mcusPerColumn,!isFinite(he)||he<0)throw new Error("Invalid number of MCUs");o||(o=he);let ce,Ce,W;for(;ie<he;){for(let B=0;B<J;B++)i[B].pred=0;if(A=0,J==1){pe=i[0];for(let B=0;B<o&&(M(pe,R,ie),ie++,ie!==he);B++);}else for(let B=0;B<o;B++){for(let $=0;$<J;$++){pe=i[$],ce=pe.h,Ce=pe.v;for(let ne=0;ne<Ce;ne++)for(let ge=0;ge<ce;ge++)L(pe,R,ie,ne,ge)}if(ie++,ie===he)break}if(ie===he)do{if(e[n]===255&&e[n+1]!==0)break;n+=1}while(n<e.length-2);if(p=0,W=e[n]<<8|e[n+1],W<65280)throw new Error("marker was not found");if(W>=65488&&W<=65495)n+=2;else break}return n-u}function vp(e){let n=[],t=e.blocksPerLine,i=e.blocksPerColumn,o=t<<3,r=new Int32Array(64),s=new Uint8Array(64);function a(l,c,f){let u=e.quantizationTable;if(!u)throw new Error("Missing quantization table");let d=f;for(let p=0;p<64;p++)d[p]=l[p]*u[p];for(let p=0;p<8;++p){let h=8*p;if(d[1+h]==0&&d[2+h]==0&&d[3+h]==0&&d[4+h]==0&&d[5+h]==0&&d[6+h]==0&&d[7+h]==0){let O=In*d[0+h]+512>>10;d[0+h]=O,d[1+h]=O,d[2+h]=O,d[3+h]=O,d[4+h]=O,d[5+h]=O,d[6+h]=O,d[7+h]=O;continue}let m=In*d[0+h]+128>>8,y=In*d[4+h]+128>>8,g=d[2+h],k=d[6+h],x=Yi*(d[1+h]-d[7+h])+128>>8,S=Yi*(d[1+h]+d[7+h])+128>>8,A=d[3+h]<<4,D=d[5+h]<<4,C=m-y+1>>1;m=m+y+1>>1,y=C,C=g*Ki+k*Zi+128>>8,g=g*Zi-k*Ki+128>>8,k=C,C=x-D+1>>1,x=x+D+1>>1,D=C,C=S+A+1>>1,A=S-A+1>>1,S=C,C=m-k+1>>1,m=m+k+1>>1,k=C,C=y-g+1>>1,y=y+g+1>>1,g=C,C=x*qi+S*Xi+2048>>12,x=x*Xi-S*qi+2048>>12,S=C,C=A*Wi+D*Hi+2048>>12,A=A*Hi-D*Wi+2048>>12,D=C,d[0+h]=m+S,d[7+h]=m-S,d[1+h]=y+D,d[6+h]=y-D,d[2+h]=g+A,d[5+h]=g-A,d[3+h]=k+x,d[4+h]=k-x}for(let p=0;p<8;++p){let h=p;if(d[8+h]==0&&d[16+h]==0&&d[24+h]==0&&d[32+h]==0&&d[40+h]==0&&d[48+h]==0&&d[56+h]==0){let O=In*f[p+0]+8192>>14;d[0+h]=O,d[8+h]=O,d[16+h]=O,d[24+h]=O,d[32+h]=O,d[40+h]=O,d[48+h]=O,d[56+h]=O;continue}let m=In*d[0+h]+2048>>12,y=In*d[32+h]+2048>>12,g=d[16+h],k=d[48+h],x=Yi*(d[8+h]-d[56+h])+2048>>12,S=Yi*(d[8+h]+d[56+h])+2048>>12,A=d[24+h],D=d[40+h],C=m-y+1>>1;m=m+y+1>>1,y=C,C=g*Ki+k*Zi+2048>>12,g=g*Zi-k*Ki+2048>>12,k=C,C=x-D+1>>1,x=x+D+1>>1,D=C,C=S+A+1>>1,A=S-A+1>>1,S=C,C=m-k+1>>1,m=m+k+1>>1,k=C,C=y-g+1>>1,y=y+g+1>>1,g=C,C=x*qi+S*Xi+2048>>12,x=x*Xi-S*qi+2048>>12,S=C,C=A*Wi+D*Hi+2048>>12,A=A*Hi-D*Wi+2048>>12,D=C,d[0+h]=m+S,d[56+h]=m-S,d[8+h]=y+D,d[48+h]=y-D,d[16+h]=g+A,d[40+h]=g-A,d[24+h]=k+x,d[32+h]=k-x}for(let p=0;p<64;++p){let h=128+(d[p]+8>>4);c[p]=h<0?0:h>255?255:h}}Cn(o*i*8);for(let l=0;l<i;l++){let c=l<<3;for(let f=0;f<8;f++)n.push(new Uint8Array(o));for(let f=0;f<t;f++){a(e.blocks[l][f],s,r);let u=0,d=f<<3;for(let p=0;p<8;p++){let h=n[c+p];for(let m=0;m<8;m++)h[d+m]=s[u++]}}}return n}function Pt(e){return e<0?0:e>255?255:e}function Sp(e){let n={width:0,height:0,adobe:void 0,components:[],exifBuffer:void 0,jfif:void 0},t=yp*1e3*1e3,i=0;function o(){let g=e[i]<<8|e[i+1];return i+=2,g}function r(){let g=o(),k=e.subarray(i,i+g-2);return i+=k.length,k}function s(g){let k=0,x=0;for(let D in g.components)if(g.components.hasOwnProperty(D)){let C=g.components[D];k<C.h&&(k=C.h),x<C.v&&(x=C.v)}let S=Math.ceil(g.samplesPerLine/8/k),A=Math.ceil(g.scanLines/8/x);for(let D in g.components)if(g.components.hasOwnProperty(D)){let C=g.components[D],O=Math.ceil(Math.ceil(g.samplesPerLine/8)*C.h/k),E=Math.ceil(Math.ceil(g.scanLines/8)*C.v/x),L=S*C.h,M=A*C.v,J=M*L,pe=[];Cn(J*256);for(let R=0;R<M;R++){let ie=[];for(let he=0;he<L;he++)ie.push(new Int32Array(64));pe.push(ie)}C.blocksPerLine=O,C.blocksPerColumn=E,C.blocks=pe}g.maxH=k,g.maxV=x,g.mcusPerLine=S,g.mcusPerColumn=A}let a=null,l=null,c,f=0,u=[],d=[],p=[],h=[],m=o(),y=-1;if(m!=65496)throw new Error("SOI not found");for(m=o();m!=65497;){switch(m){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();m===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])}),m===65505&&g[0]===69&&g[1]===120&&g[2]===105&&g[3]===102&&g[4]===0&&(n.exifBuffer=g.subarray(5,g.length)),m===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 k=o()+i-2;for(;i<k;){let x=e[i++];Cn(256);let S=new Int32Array(64);if(x>>4===0)for(let A=0;A<64;A++){let D=fi[A];S[D]=e[i++]}else if(x>>4===1)for(let A=0;A<64;A++){let D=fi[A];S[D]=o()}else throw new Error("DQT: invalid table spec");u[x&15]=S}break}case 65472:case 65473:case 65474:{o(),c={extended:m===65473,progressive:m===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>t){let x=Math.ceil((g-t)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${x}MP`)}let k=e[i++];if(!k)throw new Error("SOF: no components in frame");for(let x=0;x<k;x++){let S=e[i],A=e[i+1]>>4,D=e[i+1]&15;if(A<1||A>4||D<1||D>4)throw new Error(`SOF: invalid sampling factors (${A}x${D})`);let C=e[i+2];c.componentsOrder.push(S),c.components[S]={h:A,v:D,quantizationIdx:C,blocksPerColumn:0,blocksPerLine:0,blocks:[],pred:0},i+=3}s(c),d.push(c);break}case 65476:{let g=o();for(let k=2;k<g;){let x=e[i++],S=new Uint8Array(16),A=0;for(let E=0;E<16;E++,i++)A+=S[E]=e[i];Cn(16+A);let D=new Uint8Array(A);for(let E=0;E<A;E++,i++)D[E]=e[i];k+=17+A;let C=x&15,O=x>>4===0?h:p;O[C]=bp(S,D)}break}case 65501:o(),f=o();break;case 65500:o(),o();break;case 65498:{if(!c)throw new Error("SOS: scan before frame header (SOF)");o();let g=e[i++],k=[];for(let C=0;C<g;C++){let O=e[i++],E=c.components[O];if(!E)throw new Error(`SOS: component ${O} not found in frame`);let L=e[i++];E.huffmanTableDC=h[L>>4],E.huffmanTableAC=p[L&15],k.push(E)}let x=e[i++],S=e[i++],A=e[i++],D=wp(e,i,c,k,f,x,S,A>>4,A&15);i+=D;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(m===224||m==225){if(y!==-1)throw new Error(`first unknown JPEG marker at offset ${y.toString(16)}, second unknown JPEG marker ${m.toString(16)} at offset ${(i-1).toString(16)}`);y=i-1;let g=o();if(e[i+g-2]===255){i+=g-2;break}}throw new Error("unknown JPEG marker "+m.toString(16))}}m=o()}if(d.length!=1)throw new Error("only single frame JPEGs supported");for(let g=0;g<d.length;g++){let k=d[g].components;for(let x of Object.keys(k)){let S=k[+x],A=u[S.quantizationIdx];if(!A)throw new Error(`Missing quantization table ${S.quantizationIdx}`);S.quantizationTable=A}}n.width=c.samplesPerLine,n.height=c.scanLines,n.jfif=a,n.adobe=l,n.components=[];for(let g=0;g<c.componentsOrder.length;g++){let k=c.components[c.componentsOrder[g]];n.components.push({lines:vp(k),scaleX:k.h/c.maxH,scaleY:k.v/c.maxV})}return n}function xp(e){let n=0,t=!1,i=e.width,o=e.height,r=i*o*e.components.length;Cn(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 f=0;f<i;f++){let u=c[0|f*a.scaleX];s[n++]=u}}break}case 2:{let a=e.components[0],l=e.components[1];for(let c=0;c<o;c++){let f=a.lines[0|c*a.scaleY],u=l.lines[0|c*l.scaleY];for(let d=0;d<i;d++){let p=f[0|d*a.scaleX];s[n++]=p;let h=u[0|d*l.scaleX];s[n++]=h}}break}case 3:{t=e.jfif?!0:e.adobe?!!e.adobe.transformCode:!0;let a=e.components[0],l=e.components[1],c=e.components[2];for(let f=0;f<o;f++){let u=a.lines[0|f*a.scaleY],d=l.lines[0|f*l.scaleY],p=c.lines[0|f*c.scaleY];for(let h=0;h<i;h++){let m,y,g,k,x,S;t?(m=u[0|h*a.scaleX],y=d[0|h*l.scaleX],g=p[0|h*c.scaleX],k=Pt(m+1.402*(g-128)),x=Pt(m-.3441363*(y-128)-.71413636*(g-128)),S=Pt(m+1.772*(y-128))):(k=u[0|h*a.scaleX],x=d[0|h*l.scaleX],S=p[0|h*c.scaleX]),s[n++]=k,s[n++]=x,s[n++]=S}}break}case 4:{if(!e.adobe)throw new Error("Unsupported color mode (4 components)");t=!1,e.adobe&&e.adobe.transformCode&&(t=!0);let a=e.components[0],l=e.components[1],c=e.components[2],f=e.components[3];for(let u=0;u<o;u++){let d=a.lines[0|u*a.scaleY],p=l.lines[0|u*l.scaleY],h=c.lines[0|u*c.scaleY],m=f.lines[0|u*f.scaleY];for(let y=0;y<i;y++){let g,k,x,S,A,D,C;t?(g=d[0|y*a.scaleX],k=p[0|y*l.scaleX],x=h[0|y*c.scaleX],S=m[0|y*f.scaleX],A=255-Pt(g+1.402*(x-128)),D=255-Pt(g-.3441363*(k-128)-.71413636*(x-128)),C=255-Pt(g+1.772*(k-128))):(A=d[0|y*a.scaleX],D=p[0|y*l.scaleX],C=h[0|y*c.scaleX],S=m[0|y*f.scaleX]),s[n++]=255-A,s[n++]=255-D,s[n++]=255-C,s[n++]=255-S}}break}default:throw new Error("Unsupported color mode")}return s}function kp(e,n,t){if(Pr=0,Dr=t===void 0?Cr:Math.min(Cr,Math.max(0,t)),e.length===0)throw new Error("Empty jpeg buffer");let i=Sp(e);Cn(i.width*i.height*4);let o=xp(i),r=n(i.width,i.height),s=r.width,a=r.height,l=r.data,c=0,f=0;switch(i.components.length){case 1:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++];l[f++]=p,l[f++]=p,l[f++]=p,l[f++]=255}break;case 2:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++];l[f++]=p,l[f++]=p,l[f++]=p,l[f++]=h}break;case 3:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++],m=o[c++];l[f++]=p,l[f++]=h,l[f++]=m,l[f++]=255}break;case 4:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++],m=o[c++],y=o[c++],g=255-Pt(p*(1-y/255)+y),k=255-Pt(h*(1-y/255)+y),x=255-Pt(m*(1-y/255)+y);l[f++]=g,l[f++]=k,l[f++]=x,l[f++]=255}break;default:throw new Error("Unsupported color mode")}return r}});var Ot=ae(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.createImageData=G.createCanvas=G.MaskParams=G.LayerMaskFlags=G.ColorSpace=G.largeAdditionalInfoKeys=G.largeAdditionalInfoKeysObserved=G.layerColors=G.toBlendMode=G.fromBlendMode=G.MOCK_HANDLERS=void 0;G.createEnum=Ap;G.offsetForChannel=Ip;G.normalizeLabAB=Cp;G.denormalizeLabAB=Pp;G.clamp=Dp;G.hasAlpha=Op;G.cmykToRgbValues=Ji;G.rgbToCmykValues=Mp;G.resetImageData=Up;G.imageDataToCanvas=Bp;G.decodeBitmap=Rp;G.writeDataRaw=Tp;G.writeDataRLE=jp;G.planarToBytes=$l;G.writeDataRLEBytes=zp;G.writeDataZipWithPrediction=$p;G.writeDataZipWithoutPrediction=Vp;G.createCanvasFromData=Np;G.initializeCanvas=Wp;var zl=Gi(),_p=Bl();G.MOCK_HANDLERS=!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","seafoam","indigo","magenta","fuchsia"];G.largeAdditionalInfoKeysObserved=["lnk3","lnkE","pths","extd","extn","FELS","artd"];G.largeAdditionalInfoKeys=["LMsk","Lr16","Lr32","Layr","Mt16","Mt32","Mtrn","Alph","FMsk","lnk2","FEid","FXid","PxSD","cinf",...G.largeAdditionalInfoKeysObserved];function Ap(e,n,t){let i=new Map;for(let s of Object.keys(t))i.set(t[s],s);return{decode:s=>{let a=s.split(".")[1],l=a?i.get(a):void 0;if(a&&!l){if(Object.prototype.hasOwnProperty.call(t,a))return a;let c=a.replace(/([A-Z])/g," $1").toLowerCase();if(Object.prototype.hasOwnProperty.call(t,c))return c;throw new Error(`Unrecognized value for enum: '${s}'`)}return l||n},encode:s=>{if(s&&!t[s])throw new Error(`Invalid value for enum: '${s}'`);return`${e}.${s?t[s]:t[n]}`}}}var Rl;(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"})(Rl||(G.ColorSpace=Rl={}));var Tl;(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"})(Tl||(G.LayerMaskFlags=Tl={}));var jl;(function(e){e[e.UserMaskDensity=1]="UserMaskDensity",e[e.UserMaskFeather=2]="UserMaskFeather",e[e.VectorMaskDensity=4]="VectorMaskDensity",e[e.VectorMaskFeather=8]="VectorMaskFeather"})(jl||(G.MaskParams=jl={}));function Ip(e,n){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return n?3:e+1;case-1:return n?4:3;default:return e+1}}function Cp(e,n=1){return e<0?e/(128*n):e/(127*n)}function Pp(e,n=1){return e<0?e*(128*n):e*(127*n)}function Dp(e,n,t){return e<n?n:e>t?t:e}function Op(e){let n=e.width*e.height*4,t=e.data instanceof Float32Array?1:e.data instanceof Uint16Array?65535:255;for(let i=3;i<n;i+=4)if(e.data[i]!==t)return!0;return!1}function Ji(e,n,t,i,o){o[0]=255+e*(-4.387332384609988*e+54.48615194189176*n+18.82290502165302*t+212.25662451639585*i-285.2331026137004)+n*(1.7149763477362134*n-5.6096736904047315*t-17.873870861415444*i-5.497006427196366)+t*(-2.5217340131683033*t-21.248923337353073*i+17.5119270841813)+i*(-21.86122147463605*i-189.48180835922747),o[1]=255+e*(8.841041422036149*e+60.118027045597366*n+6.871425592049007*t+31.159100130055922*i-79.2970844816548)+n*(-15.310361306967817*n+17.575251261109482*t+131.35250912493976*i-190.9453302588951)+t*(4.444339102852739*t+9.8632861493405*i-24.86741582555878)+i*(-20.737325471181034*i-187.80453709719578),o[2]=255+e*(.8842522430003296*e+8.078677503112928*n+30.89978309703729*t-.23883238689178934*i-14.183576799673286)+n*(10.49593273432072*n+63.02378494754052*t+50.606957656360734*i-112.23884253719248)+t*(.03296041114873217*t+115.60384449646641*i-193.58209356861505)+i*(-22.33816807309886*i-180.12613974708367)}var Dt=e=>e<0?0:e>1?1:e;function Ep(e,n,t,i,o){let r=[0,0,0],s=[0,0,0],a=[0,0,0],l=[[0,0,0],[0,0,0],[0,0,0]],c=1e-4;for(let f=0;f<20&&(Ji(o[0],o[1],o[2],i,r),a[0]=r[0]-e,a[1]=r[1]-n,a[2]=r[2]-t,!(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]<1e-6));f++){for(let C=0;C<3;C++){let O=o[C];o[C]=O+c,Ji(o[0],o[1],o[2],i,s),o[C]=O;for(let E=0;E<3;E++)l[E][C]=(s[E]-r[E])/c}let[[u,d,p],[h,m,y],[g,k,x]]=l,S=u*(m*x-y*k)-d*(h*x-y*g)+p*(h*k-m*g);if(Math.abs(S)<1e-12)break;let A=[[m*x-y*k,p*k-d*x,d*y-p*m],[y*g-h*x,u*x-p*g,p*h-u*y],[h*k-m*g,d*g-u*k,u*m-d*h]],D=0;for(let C=0;C<3;C++){let O=-(A[C][0]*a[0]+A[C][1]*a[1]+A[C][2]*a[2])/S,E=Dt(o[C]+O);D+=Math.abs(E-o[C]),o[C]=E}if(D<1e-9)break}return Ji(o[0],o[1],o[2],i,r),(r[0]-e)*(r[0]-e)+(r[1]-n)*(r[1]-n)+(r[2]-t)*(r[2]-t)}function Fp(e,n,t,i){let o=Math.max(e,n,t)/255,r=Math.pow(Dt((1-o-.2)/.8),1.3),s=[0,0,0],a=1/0,l=1/0,c=f=>{s[0]=Dt(1-e/255-f),s[1]=Dt(1-n/255-f),s[2]=Dt(1-t/255-f);let u=Ep(e,n,t,f,s),d=Math.max(u,.1)+Math.abs(f-r)*.01;d<a&&(a=d,l=u,i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=f)};if(c(r),l>.1)for(let f=0;f<=10;f++)c(f/10);if(l>.1){let f=i[3];for(let u=-5;u<=5;u++)c(Dt(f+u/100))}}var Qi=33,Er;function Lp(){if(!Er){let e=Qi,n=new Float32Array(e*e*e*4),t=[0,0,0,0];for(let i=0,o=0;i<e;i++)for(let r=0;r<e;r++)for(let s=0;s<e;s++,o+=4)Fp(i*255/(e-1),r*255/(e-1),s*255/(e-1),t),n[o]=t[0],n[o+1]=t[1],n[o+2]=t[2],n[o+3]=t[3];Er=n}return Er}function Mp(e,n,t,i){let o=Lp(),r=Qi-1,s=Dt(e)*r,a=Dt(n)*r,l=Dt(t)*r,c=Math.min(r-1,Math.floor(s)),f=Math.min(r-1,Math.floor(a)),u=Math.min(r-1,Math.floor(l)),d=s-c,p=a-f,h=l-u;i[0]=i[1]=i[2]=i[3]=0;for(let m=0;m<8;m++){let y=m>>2,g=m>>1&1,k=m&1,x=(y?d:1-d)*(g?p:1-p)*(k?h:1-h),S=(((c+y)*Qi+f+g)*Qi+u+k)*4;i[0]+=x*o[S],i[1]+=x*o[S+1],i[2]+=x*o[S+2],i[3]+=x*o[S+3]}}function Up({data:e}){let n=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let t=0,i=e.length|0;t<i;t=t+4|0)e[t+0]=0,e[t+1]=0,e[t+2]=0,e[t+3]=n}function Bp(e){let n=(0,G.createCanvas)(e.width,e.height),t;if(e.data instanceof Uint8ClampedArray)t=e;else{t=(0,G.createImageData)(e.width,e.height);let i=e.data,o=t.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 n.getContext("2d").putImageData(t,0,0),n}function Rp(e,n,t,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<t;){let l=e[s++];for(let c=0;c<8&&a<t;c++,a++,r+=4){let f=l&128?0:255;l=l<<1,n[r+0]=f,n[r+1]=f,n[r+2]=f,n[r+3]=255}}}function Tp(e,n,t,i){if(!t||!i)return;let o=new Uint8Array(t*i);for(let r=0;r<o.length;r++)o[r]=e.data[r*4+n];return o}function jp(e,{data:n,width:t,height:i},o,r){if(!t||!i)return e.subarray(0,0);let s=4*t|0,a=0,l=o.length*(r?4:2)*i|0;for(let c of o)for(let f=0,u=c|0;f<i;f++){let d=f*s|0,p=d+s|0,h=p+c-4|0,m=h-4|0,y=l;for(u=d+c|0;u<p;u=u+4|0)if(u<m){let k=n[u];u=u+4|0;let x=n[u];u=u+4|0;let S=n[u];if(k===x&&k===S){let A=3;for(;A<128&&u<h&&n[u+4|0]===k;)A=A+1|0,u=u+4|0;e[l++]=1-A,e[l++]=k}else{let A=l,D=!0,C=1;for(e[l++]=0,e[l++]=k;u<h&&C<128;)if(u=u+4|0,k=x,x=S,S=n[u],k===x&&k===S){u=u-12|0,D=!1;break}else C++,e[l++]=k;D&&(C<127?(e[l++]=x,e[l++]=S,C+=2):C<128?(e[l++]=x,C++,u=u-4|0):u=u-8|0),e[A]=C-1}}else u===h?(e[l++]=0,e[l++]=n[u]):(e[l++]=1,e[l++]=n[u],u=u+4|0,e[l++]=n[u]);if(l>e.length)throw new Error(`RLE buffer too small (${e.length})`);let g=l-y;r&&(e[a++]=g>>24&255,e[a++]=g>>16&255),e[a++]=g>>8&255,e[a++]=g&255}return e.subarray(0,l)}function $l(e){if(e instanceof Uint8Array)return e;let n=new Uint8Array(e.byteLength),t=new DataView(n.buffer);if(e instanceof Uint16Array)for(let i=0;i<e.length;i++)t.setUint16(i*2,e[i],!1);else for(let i=0;i<e.length;i++)t.setFloat32(i*4,e[i],!1);return n}function zp(e,n,t,i){let o=i?4:2,r=new Uint8Array(t*(o+n+Math.ceil(n/128))),s=o*t;for(let a=0;a<t;a++){let l=s,c=a*n,f=c+n,u=c;for(;u<f;){let p=1;for(;u+p<f&&p<128&&e[u+p]===e[u];)p++;if(p>1)r[s++]=257-p,r[s++]=e[u],u+=p;else{let h=s++,m=0;for(;u<f&&m<128&&!(u+2<f&&e[u]===e[u+1]&&e[u]===e[u+2]);)r[s++]=e[u++],m++;r[h]=m-1}}let d=s-l;for(let p=0;p<o;p++)r[a*o+p]=d>>>(o-p-1)*8&255}return r.subarray(0,s)}function $p(e,n,t){let i;if(e instanceof Uint8Array){i=new Uint8Array(n*t);for(let o=0,r=0;o<t;o++)for(let s=0,a=0;s<n;s++,r++)i[r]=e[r]-a,a=e[r]}else if(e instanceof Uint16Array){i=new Uint8Array(n*t*2);for(let o=0,r=0;o<t;o++)for(let s=0,a=0;s<n;s++,r++){let l=e[r]-a&65535;i[r*2]=l>>8,i[r*2+1]=l&255,a=e[r]}}else{let o=n*4,r=$l(e);i=new Uint8Array(o*t);for(let s=0;s<t;s++){let a=s*o;for(let l=0;l<n;l++)for(let c=0;c<4;c++)i[a+c*n+l]=r[a+l*4+c];for(let l=o-1;l>0;l--)i[a+l]-=i[a+l-1]}}return(0,zl.deflate)(i)}function Vp({data:e,width:n,height:t},i){let o=n*t,r=new Uint8Array(o),s=[],a=0;for(let l of i){for(let f=0,u=l;f<o;f++,u+=4)r[f]=e[u];let c=(0,zl.deflate)(r);s.push(c),a+=c.byteLength}if(s.length>0){let l=new Uint8Array(a),c=0;for(let f of s)l.set(f,c),c+=f.byteLength;return l}else return s[0]}function Np(e,n){let t=(0,G.createCanvas)(100,100);try{let i=t.getContext("2d"),o=(0,_p.decodeJpeg)(e,(r,s)=>i.createImageData(r,s),n.totalMemoryLimit);t.width=o.width,t.height=o.height,i.putImageData(o,0,0),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=o.width*o.height*4)}catch(i){n.log("JPEG decompression error",i.message)}return t}var Gp=()=>{throw new Error("Canvas not initialized, use initializeCanvas method to set up createCanvas method")};G.createCanvas=Gp;var Fr,Hp=(e,n)=>(Fr||(Fr=(0,G.createCanvas)(1,1)),Fr.getContext("2d").createImageData(e,n));G.createImageData=Hp;typeof document<"u"&&(G.createCanvas=(e,n)=>{let t=document.createElement("canvas");return t.width=e,t.height=n,t});function Wp(e,n){G.createCanvas=e,G.createImageData=n||G.createImageData}});var to=ae(eo=>{"use strict";eo.byteLength=qp;eo.toByteArray=Kp;eo.fromByteArray=Qp;var yt=[],Qe=[],Xp=typeof Uint8Array<"u"?Uint8Array:Array,Lr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(on=0,Vl=Lr.length;on<Vl;++on)yt[on]=Lr[on],Qe[Lr.charCodeAt(on)]=on;var on,Vl;Qe[45]=62;Qe[95]=63;function Nl(e){var n=e.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=n);var i=t===n?0:4-t%4;return[t,i]}function qp(e){var n=Nl(e),t=n[0],i=n[1];return(t+i)*3/4-i}function Zp(e,n,t){return(n+t)*3/4-t}function Kp(e){var n,t=Nl(e),i=t[0],o=t[1],r=new Xp(Zp(e,i,o)),s=0,a=o>0?i-4:i,l;for(l=0;l<a;l+=4)n=Qe[e.charCodeAt(l)]<<18|Qe[e.charCodeAt(l+1)]<<12|Qe[e.charCodeAt(l+2)]<<6|Qe[e.charCodeAt(l+3)],r[s++]=n>>16&255,r[s++]=n>>8&255,r[s++]=n&255;return o===2&&(n=Qe[e.charCodeAt(l)]<<2|Qe[e.charCodeAt(l+1)]>>4,r[s++]=n&255),o===1&&(n=Qe[e.charCodeAt(l)]<<10|Qe[e.charCodeAt(l+1)]<<4|Qe[e.charCodeAt(l+2)]>>2,r[s++]=n>>8&255,r[s++]=n&255),r}function Yp(e){return yt[e>>18&63]+yt[e>>12&63]+yt[e>>6&63]+yt[e&63]}function Jp(e,n,t){for(var i,o=[],r=n;r<t;r+=3)i=(e[r]<<16&16711680)+(e[r+1]<<8&65280)+(e[r+2]&255),o.push(Yp(i));return o.join("")}function Qp(e){for(var n,t=e.length,i=t%3,o=[],r=16383,s=0,a=t-i;s<a;s+=r)o.push(Jp(e,s,s+r>a?a:s+r));return i===1?(n=e[t-1],o.push(yt[n>>2]+yt[n<<4&63]+"==")):i===2&&(n=(e[t-2]<<8)+e[t-1],o.push(yt[n>>10]+yt[n>>4&63]+yt[n<<2&63]+"=")),o.join("")}});var Mr=ae(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.stringLengthInBytes=Hl;Pn.encodeStringTo=Wl;Pn.encodeString=nh;Pn.decodeString=ih;function eh(e){return(e&4294967168)===0?1:(e&4294965248)===0?2:(e&4294901760)===0?3:4}function Gl(e,n){let t=e.charCodeAt(n);if(t<55296||t>57343)return t;if(t<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);if(i>=56320&&i<=57343)return((t&1023)<<10)+(i&1023)+65536}return 65533}function Hl(e){let n=0;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);i<128?n+=1:i<2048?n+=2:Gl(e,t)>65535?(n+=4,t++):n+=3}return n}function th(e,n,t){let i=eh(t);switch(i){case 1:e[n]=t;break;case 2:e[n]=t>>6&31|192,e[n+1]=t&63|128;break;case 3:e[n]=t>>12&15|224,e[n+1]=t>>6&63|128,e[n+2]=t&63|128;break;default:e[n]=t>>18&7|240,e[n+1]=t>>12&63|128,e[n+2]=t>>6&63|128,e[n+3]=t&63|128;break}return i}function Wl(e,n,t){for(let i=0;i<t.length;i++){let o=t.charCodeAt(i);if(o<128)e[n++]=o;else{let r=Gl(t,i);r>65535&&i++,n+=th(e,n,r)}}return n}function nh(e){if(e.length>1e3&&typeof TextEncoder<"u")return new TextEncoder().encode(e);let n=new Uint8Array(Hl(e));return Wl(n,0,e),n}function ih(e){let n=[];function t(l){l>65535&&(l-=65536,n.push(String.fromCharCode(l>>>10&1023|55296)),l=56320|l&1023),n.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?t(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):t(65533);continue}if(c<s||c>a){i=0,r=0,o=0,s=128,a=191,t(65533),l--;continue}s=128,a=191,i=i<<6|c&63,o++,o===r&&(t(i),i=0,r=0,o=0)}return r!==0&&t(65533),n.join("")}});var ro=ae(_=>{"use strict";var oh=_&&_.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(_,"__esModule",{value:!0});_.FlCl=_.ExtR=_.ExtT=_.DfsM=_.blurType=_.Lns=_.MztT=_.Chnl=_.Dstr=_.ZZTy=_.Wvtp=_.SphM=_.RplS=_.Cnvr=_.UndA=_.DspM=_.SmBQ=_.SmBM=_.BlrQ=_.BlrM=_.strokeStyleLineAlignment=_.strokeStyleLineJoinType=_.strokeStyleLineCapType=_.ESliceBGColorType=_.ESliceOrigin=_.ESliceVertAlign=_.ESliceHorzAlign=_.ESliceType=_.FrFl=_.FStl=_.ClrS=_.Clry=_.gradientInterpolationMethodType=_.stdTrackID=_.animInterpStyleEnum=_.GrdT=_.IGSr=_.BETE=_.BESs=_.bvlT=_.BESl=_.BlnM=_.warpStyle=_.Annt=_.Ornt=_.textGridding=_.outputSettingsRoot=_.layerStateRoot=_.cameraRawFilterKeyTypes=_.cameraRawFilterClassID=void 0;_.patternColorHandling=_.presetKindType=_.prjM=_.FlMd=_.IntC=_.IntE=_.Drct=_.WndM=_.CntE=void 0;_.readAsciiStringOrClassId=bt;_.writeAsciiStringOrClassId=et;_.readDescriptorStructure=jr;_.writeDescriptorStructure=zr;_.pathSelectionStateToReference=uh;_.writeClassStructure=Dn;_.readVersionAndDescriptor=hh;_.writeVersionAndDescriptor=gh;_.horzVrtcToXY=no;_.xyToHorzVrtc=io;_.descBoundsToBounds=mh;_.boundsToDescBounds=yh;_.serializeEffects=sc;_.parseEffects=ac;_.parseTrackList=bh;_.serializeTrackList=wh;_.parseVectorContent=vh;_.serializeVectorContent=Sh;_.parseColor=sn;_.serializeColor=an;_.parseAngle=On;_.parsePercent=Pe;_.parsePercentOrAngle=mc;_.parseUnits=wt;_.parseUnitsOrNumber=yc;_.parseUnitsToNumber=Ah;_.unitsAngle=ln;_.unitsPercent=rt;_.unitsPercentF=St;_.unitsValue=vt;_.frac=Ih;var V=Ot(),te=st(),Z=En(),Br=new Map([["#Ang","Angle"],["#Rsl","Density"],["#Rlt","Distance"],["#Nne","None"],["#Prc","Percent"],["#Pxl","Pixels"],["#Mlm","Millimeters"],["#Pnt","Points"],["RrPi","Picas"],["RrIn","Inches"],["RrCm","Centimeters"]]),Rr=new Map;Br.forEach((e,n)=>Rr.set(e,n));function F(e,n){return{name:e,classID:n}}var X=F("","null"),Ur=!1,Ql={strokeStyleContent:F("","solidColorLayer"),printProofSetup:F(Ur?"\u6821\u6837\u8BBE\u7F6E":"Proof Setup","proofSetup"),Grad:F(Ur?"\u6E10\u53D8":"Gradient","Grdn"),Trnf:F(Ur?"\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:X,duration:X,workInTime:X,workOutTime:X,audioClipGroupList:X,bounds:F("","Rctn"),customEnvelopeWarp:F("","customEnvelopeWarp"),warp:F("","warp"),"Sz ":F("","Pnt "),origin:F("","Pnt "),autoExpandOffset:F("","Pnt "),keyOriginShapeBBox:F("","unitRect"),Vrsn:X,psVersion:X,docDefaultNewArtboardBackgroundColor:F("","RGBC"),artboardRect:F("","classFloatRect"),framedGroupRect:F("","classFloatRect"),keyOriginRRectRadii:F("","radii"),keyOriginBoxCorners:X,rectangleCornerA:F("","Pnt "),rectangleCornerB:F("","Pnt "),rectangleCornerC:F("","Pnt "),rectangleCornerD:F("","Pnt "),keyOriginPolyPreviousTightBoxCorners:X,keyOriginPolyTrueRectCorners:X,keyOriginLineStart:F("","Pnt "),keyOriginLineEnd:F("","Pnt "),compInfo:X,quiltWarp:F("","quiltWarp"),generatorSettings:X,crema:X,FrIn:X,blendOptions:X,FXRf:X,Lefx:X,time:X,animKey:X,timeScope:X,inTime:X,outTime:X,sheetStyle:X,translation:X,Skew:X,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:X,FXRefPoint:X,vectorMask:X,layerSpecific:X,LSpc:X,textLayerSettings:F("","warp"),placedLayerSettings:X,IMsk:X,VMsk:X,TxtC:X,ClMg:F("","ClMg"),interpretation:F("","footageInterpretation"),bgColor:F("","NativeQuad")},ec={"Crv ":F("","CrPt"),Clrs:F("","Clrt"),Trns:F("","TrnS"),keyDescriptorList:X,keyRootDescriptorList:X,solidFillMulti:F("","SoFi"),gradientFillMulti:F("","GrFl"),dropShadowMulti:F("","DrSh"),innerShadowMulti:F("","IrSh"),frameFXMulti:F("","FrFX"),FrIn:X,FSts:X,LaSt:X,sheetTimelineOptions:X,trackList:F("","animationTrack"),globalTrackList:F("","animationTrack"),keyList:X,audioClipGroupList:X,audioClipList:X,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:X,list:X,Adjs:F("","CrvA"),vertices:F("","Pnt "),warpedVertices:F("","Pnt "),quads:F("","quadIndices")},Xl={TEXT:["Txt ","printerName","Nm ","Idnt","blackAndWhitePresetFileName","LUT3DFileName","exportOption","scaleSettings","BackgroundImagePath","ImageSubfolderName","SavedIteratedName","presetFileName","curvesPresetFileName","mixerPresetFileName","placed","description","reason","artboardPresetName","json","clipID","relPath","fullPath","mediaDescriptor","Msge","altTag","url","cellText","preset","KnNm","FPth","comment","originalPath","Bk ","pathUnicodeName"],tdta:["EngineData","LUT3DFileData","indexArray","originalVertexArray","deformedVertexArray","LqMe","bookKey"],long:["TextIndex","RndS","Mdpn","Smth","Lctn","strokeStyleVersion","LaID","Vrsn","Cnt ","bookID","cropRectBottom","cropRectLeft","cropRectRight","cropRectTop","Version","BackgroundColorBlue","BackgroundColorGreen","BackgroundColorRed","BackgroundColorState","AttributeCase","Encoding","DuplicateFileNameBehavior","ImageMapLocation","ImageMapType","Indent","LineEndings","SpacersEmptyCells","SpacersHorizontal","SpacersVertical","StylesFormat","TDWidthHeight","TagCase","ColorPolicy","MetadataPolicy","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","pixelSourceType","framedGroupType","keyOriginPolySides","keyOriginLineArrConc","noisePreSeed","associatedLayer","placedLayerCompID","VAlign"],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","pathSymmetryMode","interpretAlpha","knockout","TxPT","TxPR"],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","Lnkd","showAlteredVideo","lightingOn","LockPPI","keyOriginLineArrowSt","keyOriginLineArrowEnd","Expn","substitutesUsed","blendClipped","blendInterior","TxMP"],doub:["warpValue","warpPerspective","warpPerspectiveOther","Intr","Wdth","Hght","Gmm ","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","stylization","cleanliness","brushScale","microBrush","specularity","PreferredResolution","FrGL","keyOriginLineWeight","keyOriginLineArrWdth","keyOriginLineArrLngth","keyOriginPolyPixelHSF","keyOriginPolyCornerRadius","gradientAspectRatio"],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","fillOpacity","keyOriginPolyStarRatio"],VlLs:["Crv ","Clrs","Mnm ","Mxm ","Trns","pathList","keyRootDescriptorList","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","vertices","warpedVertices","quads","indices","Mpng","textLayerSettingsWarpRect"],ObAr:["meshPoints","quiltSliceX","quiltSliceY"],"obj ":["null","Chnl"],"Pth ":["DspF"],alis:["alis"]},rh=["Rd ","Grn ","Bl ","Yllw","Ylw ","Cyn ","Mgnt","Blck","Gry ","Lmnc","A ","B "],sh=["Grsc","LbCl","GRYC","LABC"];_.cameraRawFilterClassID="Adobe Camera Raw Filter";_.cameraRawFilterKeyTypes={CrVe:"TEXT",PrVN:"long",PrVe:"long",WBal:"enum",Ex12:"doub",ShpR:"doub","Crv ":"VlLs",CrvR:"VlLs",CrvG:"VlLs",CrvB:"VlLs"};function tc(e){if(typeof e=="boolean")return"bool";if(typeof e=="number"&&!Number.isInteger(e))return"doub";if(Array.isArray(e))return"VlLs";if(e&&typeof e=="object"){if(typeof e._classID=="string")return"Objc";if(typeof e.classID=="string")return"type";if(typeof e.low=="number"&&typeof e.high=="number")return"comp";if(typeof e.units=="string"&&typeof e.value=="number")return"UntF"}}var nc={"Mnm ":"long","Mxm ":"long",HtmlFileNameComponents:"long",SavingFileNameComponents:"long",SliceFileNameComponents:"long",Inpt:"long",Otpt:"long",FrLs:"long",strokeStyleLineDashSet:"UntF",Trnf:"doub",nonAffineTransform:"doub",keyDescriptorList:"Objc",keyRootDescriptorList:"Objc",pathList:"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",textLayerSettingsWarpRect:"doub",Chnl:"enum",indices:"long",Mpng:"long"},oo={};for(let e of Object.keys(Xl))for(let n of Xl[e])oo[n]=e;for(let e of Object.keys(Ql))oo[e]||(oo[e]="Objc");for(let e of Object.keys(ec))nc[e]="Objc";var Tr="PixelSource.origin";_.layerStateRoot="layerState";function ah(e,n,t,i){return e==="presetKind"?typeof n=="string"?"enum":"long":e==="null"&&t==="slices"?"TEXT":e==="groupID"?t==="slices"?"long":"TEXT":e==="Sz "?"Wdth"in n?"Objc":"units"in n?"UntF":"doub":e==="Type"?typeof n=="string"?"enum":"long":e==="AntA"?typeof n=="string"?"enum":"bool":(e==="Hrzn"||e==="Vrtc")&&(i.Type==="keyType.Pstn"||i._classID==="Ofst"||t===Tr)?"long":e==="Hrzn"||e==="Vrtc"||e==="Top "||e==="Left"||e==="Btom"||e==="Rght"?t==="slices"?"long":typeof n=="number"?"doub":"UntF":e==="Vrsn"?typeof n=="number"?"long":"Objc":e==="Rd "||e==="Grn "||e==="Bl "?t==="artd"?"long":"doub":e==="Trnf"?Array.isArray(n)?"VlLs":"Objc":e==="alpha"&&t==="slices"?"long":(e==="Inpt"||e==="Otpt")&&i._classID==="HsbP"?"enum":(e==="Inpt"||e==="Otpt")&&i._classID==="LvlA"?"VlLs":e==="Intr"&&typeof n=="boolean"?"bool":e==="PgPs"?"enum":e==="LghD"&&i._classID==="oilPaint"?"long":oo[e]}function bt(e){let n=(0,te.readInt32)(e);return(0,te.readAsciiString)(e,n||4)}function et(e,n){if(n.length===4&&n!=="warp"&&n!=="time"&&n!=="hold"&&n!=="list"&&n!=="json")(0,Z.writeInt32)(e,0),(0,Z.writeSignature)(e,n);else{(0,Z.writeInt32)(e,n.length);for(let t=0;t<n.length;t++)(0,Z.writeUint8)(e,n.charCodeAt(t))}}function jr(e,n){let t=rn(e),i=n?{_name:t.name,_classID:t.classID}:{},o=(0,te.readUint32)(e);for(let r=0;r<o;r++){let s=bt(e),a=(0,te.readSignature)(e),l=ic(e,a,n);i[s]=l}return i}_.outputSettingsRoot="outputSettings";function zr(e,n,t,i,o){var r;e.logMissingFeatures&&!t&&e.log("Missing classId for: ",n,t,i),(0,Z.writeUnicodeStringWithPadding)(e,n),o===_.outputSettingsRoot&&t==="null"?((0,Z.writeInt32)(e,4),(0,Z.writeSignature)(e,t)):et(e,t);let a=Object.keys(i).filter(l=>l!=="_name"&&l!=="_classID"&&i[l]!==void 0);(0,Z.writeUint32)(e,a.length);for(let l of a){let c=ah(l,i[l],o,i),f=o,u=Ql[l];t===_.cameraRawFilterClassID&&(c=(r=_.cameraRawFilterKeyTypes[l])!==null&&r!==void 0?r:"long",f=_.cameraRawFilterClassID),l==="bounds"&&o==="text"?u=F("","bounds"):l==="origin"?(c=o==="slices"?"enum":"Objc",t==="PixelSource"&&(u=X,f=Tr)):l==="Ofst"&&o===_.layerStateRoot&&typeof i[l].Hrzn=="number"?(u=X,f=Tr):(l==="Cyn "||l==="Mgnt"||l==="Ylw "||l==="Blck")&&i._classID==="CMYC"?c="doub":/^PN[a-z][a-z]$/.test(l)?c="TEXT":/^PT[a-z][a-z]$/.test(l)?c="long":/^PF[a-z][a-z]$/.test(l)||(l==="Rds "||l==="Thsh")&&typeof i[l]=="number"&&i._classID==="SmrB"?c="doub":l==="ClSz"||l==="Rds "||l==="Amnt"?c=typeof i[l]=="number"?"long":"UntF":(l==="sdwM"||l==="hglM")&&typeof i[l]=="string"||l==="blur"&&typeof i[l]=="string"?c="enum":l==="Hght"&&typeof i[l]=="number"&&i._classID==="Embs"||l==="Angl"&&typeof i[l]=="number"&&(i._classID==="Embs"||i._classID==="smartSharpen"||i._classID==="Twrl"||i._classID==="MtnB")?c="long":l==="Angl"&&typeof i[l]=="number"?c="doub":l==="bounds"&&o==="slices"?(c="Objc",u=F("","Rct1")):l==="Scl "?typeof i[l]=="object"&&"Hrzn"in i[l]?(c="Objc",u=X):typeof i[l]=="number"?c="long":c="UntF":l==="audioClipGroupList"&&a.length===1?c="VlLs":(l==="Strt"||l==="Brgh")&&"H "in i?c="doub":l==="Wdth"&&typeof i[l]=="object"?c="UntF":l==="Ofst"&&typeof i[l]=="number"?c="long":l==="Strt"&&typeof i[l]=="object"?(c="Objc",u=X):rh.indexOf(l)!==-1?c=t==="RGBC"&&o!=="artd"||sh.indexOf(t)!==-1?"doub":"long":l==="profile"?c=t==="printOutput"||t==="proofSetup"?"TEXT":"tdta":l==="alis"&&typeof i[l]=="string"?c=/[^\x00-\xff]/.test(i[l])?"TEXT":"alis":l==="strokeStyleContent"?i[l]["Clr "]?u=F("","solidColorLayer"):i[l].Grad?u=F("","gradientLayer"):i[l].Ptrn?u=F("","patternLayer"):e.logMissingFeatures&&e.log("Invalid strokeStyleContent value",i[l]):l==="bounds"&&o==="quiltWarp"&&(u=F("","classFloatRect")),u&&u.classID==="RGBC"&&("H "in i[l]?u={classID:"HSBC",name:""}:"Cyn "in i[l]?u={classID:"CMYC",name:""}:"Lmnc"in i[l]?u={classID:"LbCl",name:""}:"Gry "in i[l]&&(u={classID:"Grsc",name:""})),c||(c=tc(i[l])),et(e,l),(0,Z.writeSignature)(e,c||"long"),oc(e,c||"long",i[l],l,u,f),e.logMissingFeatures&&!c&&e.log(`Missing descriptor field type for: '${l}' in`,i)}}function ic(e,n,t){switch(n){case"obj ":return dh(e);case"Objc":case"GlbO":return jr(e,t);case"VlLs":{let i=(0,te.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=(0,te.readSignature)(e);o.push(ic(e,s,t))}return o}case"doub":return(0,te.readFloat64)(e);case"UntF":{let i=(0,te.readSignature)(e),o=(0,te.readFloat64)(e),r=Br.get(i);if(!r)throw new Error(`Invalid units: ${i}`);return{units:r,value:o}}case"UnFl":{let i=(0,te.readSignature)(e),o=(0,te.readFloat32)(e),r=Br.get(i);if(!r)throw new Error(`Invalid units: ${i}`);return{units:r,value:o}}case"TEXT":return(0,te.readUnicodeString)(e);case"enum":{let i=bt(e),o=bt(e);return`${i}.${o}`}case"long":return(0,te.readInt32)(e);case"comp":{let i=(0,te.readUint32)(e);return{low:(0,te.readUint32)(e),high:i}}case"bool":return!!(0,te.readUint8)(e);case"type":case"GlbC":return rn(e);case"alis":{let i=(0,te.readInt32)(e);return(0,te.readAsciiString)(e,i)}case"tdta":{let i=(0,te.readInt32)(e);if(i>e.view.byteLength-e.offset)throw new Error(`Invalid tdta length: ${i}`);return(0,te.readBytes)(e,i)}case"ObAr":{(0,te.readInt32)(e),(0,te.readUnicodeString)(e),bt(e);let i=(0,te.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=bt(e);(0,te.readSignature)(e),(0,te.readSignature)(e);let a=(0,te.readInt32)(e),l=[];for(let c=0;c<a;c++)l.push((0,te.readFloat64)(e));o.push({type:s,values:l})}return o}case"Pth ":{(0,te.readInt32)(e);let i=(0,te.readSignature)(e);(0,te.readInt32LE)(e);let o=(0,te.readInt32LE)(e),r=(0,te.readUnicodeStringWithLengthLE)(e,o);return{sig:i,path:r}}default:throw new Error(`Invalid TySh descriptor OSType: ${n} at ${e.offset.toString(16)}`)}}var lh={meshPoints:"rationalPoint",quiltSliceX:"UntF",quiltSliceY:"UntF"};function oc(e,n,t,i,o,r){var s;switch(n){case"obj ":ph(e,i,t);break;case"Objc":case"GlbO":{if(typeof t!="object")throw new Error(`Invalid struct value: ${JSON.stringify(t)}, key: ${i}`);if(!o&&!t._classID)throw new Error(`Missing ext type for: '${i}' (${JSON.stringify(t)})`);let a=t._name||o?.name||"",l=t._classID||o.classID;zr(e,a,l,t,r);break}case"VlLs":if(!Array.isArray(t))throw new Error(`Invalid list value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,t.length);for(let a=0;a<t.length;a++){let l=r===_.cameraRawFilterClassID?"long":(s=nc[i])!==null&&s!==void 0?s:tc(t[a]);(0,Z.writeSignature)(e,l||"long"),oc(e,l||"long",t[a],`${i}[]`,ec[i],r),e.logMissingFeatures&&!l&&e.log(`Missing descriptor array type for: '${i}' in`,t)}break;case"doub":if(typeof t!="number")throw new Error(`Invalid number value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeFloat64)(e,t);break;case"UntF":{let a=Rr.get(t.units);if(!a)throw new Error(`Invalid units: ${t.units} in ${i}`);(0,Z.writeSignature)(e,a),(0,Z.writeFloat64)(e,t.value);break}case"UnFl":{let a=Rr.get(t.units);if(!a)throw new Error(`Invalid units: ${t.units} in ${i}`);(0,Z.writeSignature)(e,a),(0,Z.writeFloat32)(e,t.value);break}case"TEXT":(0,Z.writeUnicodeStringWithPadding)(e,t);break;case"enum":{if(typeof t!="string")throw new Error(`Invalid enum value: ${JSON.stringify(t)}, key: ${i}`);let[a,l]=t.split(".");et(e,a),et(e,l);break}case"long":if(typeof t!="number")throw new Error(`Invalid integer value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,Math.round(t));break;case"comp":if(!t||typeof t!="object")throw new Error(`Invalid large integer value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUint32)(e,t.high>>>0),(0,Z.writeUint32)(e,t.low>>>0);break;case"bool":if(typeof t!="boolean")throw new Error(`Invalid boolean value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUint8)(e,t?1:0);break;case"type":case"GlbC":if(!t||typeof t!="object")throw new Error(`Invalid class value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUnicodeStringWithPadding)(e,t.name||""),et(e,t.classID);break;case"alis":{if(typeof t!="string")throw new Error(`Invalid alias value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,t.length);for(let a=0;a<t.length;a++)(0,Z.writeUint8)(e,t.charCodeAt(a)&255);break}case"tdta":(0,Z.writeInt32)(e,t.byteLength),(0,Z.writeBytes)(e,t);break;case"ObAr":{(0,Z.writeInt32)(e,16),(0,Z.writeUnicodeStringWithPadding)(e,"");let a=lh[i];if(!a)throw new Error(`Not implemented ObArType for: ${i}`);et(e,a),(0,Z.writeInt32)(e,t.length);for(let l=0;l<t.length;l++){et(e,t[l].type),(0,Z.writeSignature)(e,"UnFl"),(0,Z.writeSignature)(e,"#Pxl"),(0,Z.writeInt32)(e,t[l].values.length);for(let c=0;c<t[l].values.length;c++)(0,Z.writeFloat64)(e,t[l].values[c])}break}case"Pth ":{let a=t.path+"\0",l=12+a.length*2;(0,Z.writeInt32)(e,l),(0,Z.writeSignature)(e,t.sig),(0,Z.writeInt32LE)(e,l),(0,Z.writeInt32LE)(e,a.length),(0,Z.writeUnicodeStringWithoutLengthLE)(e,a);break}default:throw new Error(`Not implemented descriptor OSType: ${n}`)}}var ch=["prop","Clss","Enmr","rele","Idnt","indx","name"];function fh(e){return!!e&&typeof e=="object"&&ch.indexOf(e.type)!==-1}function dh(e){let n=(0,te.readInt32)(e),t=[];for(let i=0;i<n;i++){let o=(0,te.readSignature)(e);switch(o){case"prop":rn(e),t.push(bt(e));break;case"Clss":t.push(rn(e));break;case"Enmr":{rn(e);let r=bt(e),s=bt(e);t.push(`${r}.${s}`);break}case"rele":rn(e),t.push((0,te.readUint32)(e));break;case"Idnt":case"indx":t.push((0,te.readInt32)(e));break;case"name":rn(e),t.push((0,te.readUnicodeString)(e));break;default:throw new Error(`Invalid descriptor reference type: ${o}`)}}return t}function rc(e){if(typeof e=="string"){let n=/^([a-z ]{4}|[a-z]{5,})\.([a-z ]+)$/i.exec(e);return n?{type:"Enmr",_name:"",_classID:n[1],typeID:n[1],enumValue:n[2]}:{type:"name",_name:"",_classID:"Lyr ",value:e}}else{if(typeof e=="number")return{type:"Idnt",value:e};if(e&&typeof e=="object"&&typeof e.classID=="string")return{type:"Clss",_name:e.name||"",_classID:e.classID};throw new Error(`Invalid descriptor reference value: ${JSON.stringify(e)}`)}}function uh(e){return e.map(n=>{let t=rc(n);return t.type==="Enmr"&&(t._classID="Path"),t})}function ph(e,n,t){if(!Array.isArray(t))throw new Error(`Invalid reference value: ${JSON.stringify(t)}, key: ${n}`);(0,Z.writeInt32)(e,t.length);for(let i of t){let o=fh(i)?i:rc(i);switch((0,Z.writeSignature)(e,o.type),o.type){case"prop":Dn(e,o._name||"",o._classID),et(e,o.keyID);break;case"Clss":Dn(e,o._name||"",o._classID);break;case"Enmr":Dn(e,o._name||"",o._classID),et(e,o.typeID),et(e,o.enumValue);break;case"rele":Dn(e,o._name||"",o._classID),(0,Z.writeUint32)(e,o.value);break;case"Idnt":case"indx":(0,Z.writeInt32)(e,o.value);break;case"name":Dn(e,o._name||"",o._classID),(0,Z.writeUnicodeStringWithPadding)(e,`${o.value}`);break;default:throw new Error(`Invalid descriptor reference type: ${o.type}`)}}return t}function rn(e){let n=(0,te.readUnicodeString)(e),t=bt(e);return{name:n,classID:t}}function Dn(e,n,t){(0,Z.writeUnicodeStringWithPadding)(e,n),et(e,t)}function hh(e,n=!1){let t=(0,te.readUint32)(e);if(t!==16)throw new Error(`Invalid descriptor version: ${t}`);return jr(e,n)}function gh(e,n,t,i,o=""){(0,Z.writeUint32)(e,16),zr(e,n,t,i,o)}function no(e){return{x:e.Hrzn,y:e.Vrtc}}function io(e){return{Hrzn:e.x,Vrtc:e.y}}function mh(e){return{top:wt(e["Top "]),left:wt(e.Left),right:wt(e.Rght),bottom:wt(e.Btom)}}function yh(e){return{Left:vt(e.left,"bounds.left"),"Top ":vt(e.top,"bounds.top"),Rght:vt(e.right,"bounds.right"),Btom:vt(e.bottom,"bounds.bottom")}}function ql(e){let n={enabled:!!e.enab,position:_.FStl.decode(e.Styl),fillType:_.FrFl.decode(e.PntT),blendMode:_.BlnM.decode(e["Md "]),opacity:Pe(e.Opct),size:yc(e["Sz "])};return e.present!==void 0&&(n.present=e.present),e.showInDialog!==void 0&&(n.showInDialog=e.showInDialog),e.overprint!==void 0&&(n.overprint=e.overprint),e["Clr "]&&(n.color=sn(e["Clr "])),e.Grad&&(n.gradient=fc(e)),e.Ptrn&&(n.pattern=uc(e)),n}function Zl(e){let n={};return n.enab=!!e.enabled,e.present!==void 0&&(n.present=!!e.present),e.showInDialog!==void 0&&(n.showInDialog=!!e.showInDialog),n.Styl=_.FStl.encode(e.position),n.PntT=_.FrFl.encode(e.fillType),n["Md "]=_.BlnM.encode(e.blendMode),n.Opct=rt(e.opacity),n["Sz "]=vt(e.size,"size"),e.color&&(n["Clr "]=an(e.color)),e.gradient&&(n=Object.assign(Object.assign({},n),pc(e.gradient))),e.pattern&&(n=Object.assign(Object.assign({},n),hc(e.pattern))),e.overprint!==void 0&&(n.overprint=!!e.overprint),n}function sc(e,n,t){var i,o,r;let s=t?{"Scl ":St((i=e.scale)!==null&&i!==void 0?i:1),masterFXSwitch:!e.disabled}:{masterFXSwitch:!e.disabled,"Scl ":St((o=e.scale)!==null&&o!==void 0?o:1)},a=["dropShadow","innerShadow","solidFill","gradientOverlay","stroke"];for(let f of a)if(e[f]&&!Array.isArray(e[f]))throw new Error(`${f} should be an array`);let l=f=>!!f&&f.length>1&&t,c=f=>!!f&&f.length>=1&&(!t||f.length===1);if(c(e.dropShadow)&&(s.DrSh=Xe(e.dropShadow[0],"dropShadow",n)),l(e.dropShadow)&&(s.dropShadowMulti=e.dropShadow.map(f=>Xe(f,"dropShadow",n))),c(e.innerShadow)&&(s.IrSh=Xe(e.innerShadow[0],"innerShadow",n)),l(e.innerShadow)&&(s.innerShadowMulti=e.innerShadow.map(f=>Xe(f,"innerShadow",n))),e.outerGlow&&(s.OrGl=Xe(e.outerGlow,"outerGlow",n)),l(e.solidFill)&&(s.solidFillMulti=e.solidFill.map(f=>Xe(f,"solidFill",n))),l(e.gradientOverlay)&&(s.gradientFillMulti=e.gradientOverlay.map(f=>Xe(f,"gradientOverlay",n))),l(e.stroke)&&(s.frameFXMulti=e.stroke.map(f=>Zl(f))),e.innerGlow&&(s.IrGl=Xe(e.innerGlow,"innerGlow",n)),e.bevel&&(s.ebbl=Xe(e.bevel,"bevel",n)),c(e.solidFill)&&(s.SoFi=Xe(e.solidFill[0],"solidFill",n)),e.patternOverlay&&(s.patternFill=Xe(e.patternOverlay,"patternOverlay",n)),c(e.gradientOverlay)&&(s.GrFl=Xe(e.gradientOverlay[0],"gradientOverlay",n)),e.satin&&(s.ChFX=Xe(e.satin,"satin",n)),c(e.stroke)&&(s.FrFX=Zl((r=e.stroke)===null||r===void 0?void 0:r[0])),t){s.numModifyingFX=0;for(let f of Object.keys(e)){let u=e[f];if(!(u==null||typeof u!="object"))if(Array.isArray(u))for(let d of u)d?.enabled&&s.numModifyingFX++;else u.enabled&&s.numModifyingFX++}}return s}function ac(e,n){let t={},i=e,{_name:o,_classID:r,"Scl ":s,masterFXSwitch:a,DrSh:l,dropShadowMulti:c,IrSh:f,innerShadowMulti:u,OrGl:d,IrGl:p,ebbl:h,SoFi:m,solidFillMulti:y,patternFill:g,GrFl:k,gradientFillMulti:x,ChFX:S,FrFX:A,frameFXMulti:D,numModifyingFX:C}=i,O=oh(i,["_name","_classID","Scl ","masterFXSwitch","DrSh","dropShadowMulti","IrSh","innerShadowMulti","OrGl","IrGl","ebbl","SoFi","solidFillMulti","patternFill","GrFl","gradientFillMulti","ChFX","FrFX","frameFXMulti","numModifyingFX"]);return a||(t.disabled=!0),s&&(t.scale=Pe(s)),l&&(t.dropShadow=[We(l,n)]),c&&(t.dropShadow=c.map(E=>We(E,n))),f&&(t.innerShadow=[We(f,n)]),u&&(t.innerShadow=u.map(E=>We(E,n))),d&&(t.outerGlow=We(d,n)),p&&(t.innerGlow=We(p,n)),h&&(t.bevel=We(h,n,"bevel")),m&&(t.solidFill=[We(m,n)]),y&&(t.solidFill=y.map(E=>We(E,n))),g&&(t.patternOverlay=We(g,n)),k&&(t.gradientOverlay=[We(k,n)]),x&&(t.gradientOverlay=x.map(E=>We(E,n))),S&&(t.satin=We(S,n)),A&&(t.stroke=[ql(A)]),D&&(t.stroke=D.map(E=>ql(E))),n.logMissingFeatures&&Object.keys(O).length&&n.log("Unhandled effect keys:",O),t}function Kl(e,n){let t=[];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},f=_.animInterpStyleEnum.decode(o.animInterpStyle);switch(l.Type){case"keyType.Opct":t.push({interpolation:f,time:c,selected:a,type:"opacity",value:Pe(l.Opct)});break;case"keyType.Pstn":t.push({interpolation:f,time:c,selected:a,type:"position",x:l.Hrzn,y:l.Vrtc});break;case"keyType.Trnf":t.push({interpolation:f,time:c,selected:a,type:"transform",scale:no(l["Scl "]),skew:no(l.Skew),rotation:l.rotation,translation:no(l.translation)});break;case"keyType.sheetStyle":{let u={interpolation:f,time:c,selected:a,type:"style"};l.sheetStyle.Lefx&&(u.style=ac(l.sheetStyle.Lefx,n)),t.push(u);break}case"keyType.globalLighting":{t.push({interpolation:f,time:c,selected:a,type:"globalLighting",globalAngle:l.gblA,globalAltitude:l.globalAltitude});break}default:throw new Error("Unsupported keyType value")}}return t}function Yl(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i],{time:r,selected:s=!1,interpolation:a}=o,l=_.animInterpStyleEnum.encode(a),c;switch(o.type){case"opacity":c={Type:"keyType.Opct",Opct:rt(o.value)};break;case"position":c={Type:"keyType.Pstn",Hrzn:o.x,Vrtc:o.y};break;case"transform":c={Type:"keyType.Trnf","Scl ":io(o.scale),Skew:io(o.skew),rotation:o.rotation,translation:io(o.translation)};break;case"style":c={Type:"keyType.sheetStyle",sheetStyle:{Vrsn:1,blendOptions:{}}},o.style&&(c.sheetStyle={Vrsn:1,Lefx:sc(o.style,n,!1),blendOptions:{}});break;case"globalLighting":{c={Type:"keyType.globalLighting",gblA:o.globalAngle,globalAltitude:o.globalAltitude};break}default:throw new Error("Unsupported keyType value")}t.push({Vrsn:1,animInterpStyle:l,time:r,animKey:c,selected:s})}return t}function bh(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i],r={type:_.stdTrackID.decode(o.trackID),enabled:o.enab,keys:Kl(o.keyList,n)};o.effectParams&&(r.effectParams={fillCanvas:o.effectParams.fillCanvas,zoomOrigin:o.effectParams.zoomOrigin,keys:Kl(o.effectParams.keyList,n)}),t.push(r)}return t}function wh(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i];t.push(Object.assign(Object.assign({trackID:_.stdTrackID.encode(o.type),Vrsn:1,enab:!!o.enabled,Effc:!!o.effectParams},o.effectParams?{effectParams:{keyList:Yl(o.effectParams.keys,n),fillCanvas:o.effectParams.fillCanvas,zoomOrigin:o.effectParams.zoomOrigin}}:{}),{keyList:Yl(o.keys,n)}))}return t}function We(e,n,t){let i={};for(let o of Object.keys(e)){let r=e[o];switch(o){case"enab":i.enabled=!!r;break;case"uglg":i.useGlobalLight=!!r;break;case"AntA":i.antialiased=!!r;break;case"Algn":i.align=!!r;break;case"Dthr":i.dither=!!r;break;case"Invr":i.invert=!!r;break;case"Rvrs":i.reverse=!!r;break;case"Clr ":i.color=sn(r);break;case"hglC":i.highlightColor=sn(r);break;case"sdwC":i.shadowColor=sn(r);break;case"Styl":i.position=_.FStl.decode(r);break;case"Md ":i.blendMode=_.BlnM.decode(r);break;case"hglM":i.highlightBlendMode=_.BlnM.decode(r);break;case"sdwM":i.shadowBlendMode=_.BlnM.decode(r);break;case"bvlS":i.style=_.BESl.decode(r);break;case"bvlD":i.direction=_.BESs.decode(r);break;case"bvlT":i.technique=_.bvlT.decode(r);break;case"GlwT":i.technique=_.BETE.decode(r);break;case"glwS":i.source=_.IGSr.decode(r);break;case"Type":i.type=_.GrdT.decode(r);break;case"gs99":case"gradientsInterpolationMethod":i.interpolationMethod=_.gradientInterpolationMethodType.decode(r);break;case"Opct":i.opacity=Pe(r);break;case"hglO":i.highlightOpacity=Pe(r);break;case"sdwO":i.shadowOpacity=Pe(r);break;case"lagl":i.angle=On(r);break;case"Angl":i.angle=On(r);break;case"Lald":i.altitude=On(r);break;case"Sftn":i.soften=wt(r);break;case"srgR":i.strength=Pe(r);break;case"blur":i.size=wt(r);break;case"Nose":i.noise=Pe(r);break;case"Inpr":i.range=Pe(r);break;case"Ckmt":i.choke=wt(r);break;case"ShdN":i.jitter=Pe(r);break;case"Dstn":i.distance=wt(r);break;case"Scl ":i.scale=Pe(r);break;case"Ptrn":i.pattern={name:r["Nm "],id:r.Idnt};break;case"phase":i.phase=dc(r);break;case"Ofst":i.offset={x:Pe(r.Hrzn),y:Pe(r.Vrtc)};break;case"MpgS":case"TrnS":{let s={name:r["Nm "],curve:r["Crv "].map(a=>a.Cnty!==void 0?{x:a.Hrzn,y:a.Vrtc,curved:a.Cnty}:{x:a.Hrzn,y:a.Vrtc})};t==="bevel"&&o==="MpgS"?i.shapeContour=s:i.contour=s;break}case"Grad":i.gradient=lc(r);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":i[o]=r;break;case"_name":case"_classID":break;default:n.logMissingFeatures&&n.log(`Invalid effect key: '${o}', value:`,r)}}return i}function Xe(e,n,t){let i={enab:!1};n==="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 "]=an(s);break;case"highlightColor":i.hglC=an(s);break;case"shadowColor":i.sdwC=an(s);break;case"position":i.Styl=_.FStl.encode(s);break;case"blendMode":i["Md "]=_.BlnM.encode(s);break;case"highlightBlendMode":i.hglM=_.BlnM.encode(s);break;case"shadowBlendMode":i.sdwM=_.BlnM.encode(s);break;case"style":i.bvlS=_.BESl.encode(s);break;case"direction":i.bvlD=_.BESs.encode(s);break;case"technique":n==="bevel"?i.bvlT=_.bvlT.encode(s):i.GlwT=_.BETE.encode(s);break;case"source":i.glwS=_.IGSr.encode(s);break;case"type":i.Type=_.GrdT.encode(s);break;case"interpolationMethod":i[n==="outerGlow"||n==="innerGlow"?"gradientsInterpolationMethod":"gs99"]=_.gradientInterpolationMethodType.encode(s);break;case"opacity":i.Opct=rt(s);break;case"highlightOpacity":i.hglO=rt(s);break;case"shadowOpacity":i.sdwO=rt(s);break;case"angle":n==="gradientOverlay"||n==="patternOverlay"?i.Angl=ln(s):i.lagl=ln(s);break;case"altitude":i.Lald=ln(s);break;case"soften":i.Sftn=vt(s,r);break;case"strength":i.srgR=rt(s);break;case"size":i.blur=vt(s,r);break;case"noise":i.Nose=rt(s);break;case"range":i.Inpr=rt(s);break;case"choke":i.Ckmt=vt(s,r);break;case"jitter":i.ShdN=rt(s);break;case"distance":i.Dstn=vt(s,r);break;case"scale":i["Scl "]=rt(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:St(s.x),Vrtc:St(s.y)};break;case"contour":i[n==="satin"?"MpgS":"TrnS"]=Jl(s);break;case"shapeContour":i.MpgS=Jl(s);break;case"gradient":i.Grad=cc(s);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":i[r]=s;break;default:t.logMissingFeatures&&t.log(`Invalid effect key: '${r}', value:`,s)}}return i}function Jl(e){return{"Nm ":e.name,"Crv ":e.curve.map(n=>n.curved!==void 0?{Hrzn:n.x,Vrtc:n.y,Cnty:!!n.curved}:{Hrzn:n.x,Vrtc:n.y})}}function lc(e){return e.GrdF==="GrdF.CstS"?{type:"solid",name:e["Nm "],smoothness:e.Intr/4096,colorStops:e.Clrs.map(t=>{let i={color:t["Clr "]?sn(t["Clr "]):{r:0,g:0,b:0},location:t.Lctn/4096,midpoint:t.Mdpn/100};if(t.Type)try{let o=_.Clry.decode(t.Type);o!=="user"&&(i.type=o)}catch{}return i}),opacityStops:e.Trns.map(t=>({opacity:Pe(t.Opct),location:t.Lctn/4096,midpoint:t.Mdpn/100}))}:{type:"noise",name:e["Nm "],roughness:e.Smth/4096,colorModel:_.ClrS.decode(e.ClrS),randomSeed:e.RndS,restrictColors:!!e.VctC,addTransparency:!!e.ShTr,min:e["Mnm "].map(n=>n/100),max:e["Mxm "].map(n=>n/100)}}function cc(e){var n,t;return e.type==="solid"?{"Nm ":e.name||"",GrdF:"GrdF.CstS",Intr:Math.round(((n=e.smoothness)!==null&&n!==void 0?n:1)*4096),Clrs:e.colorStops.map(o=>{var r,s;return{"Clr ":an(o.color),Type:_.Clry.encode((r=o.type)!==null&&r!==void 0?r:"user"),Lctn:Math.round(o.location*4096),Mdpn:Math.round(((s=o.midpoint)!==null&&s!==void 0?s:.5)*100)}}),Trns:e.opacityStops.map(o=>{var r;return{Opct:St(o.opacity),Lctn:Math.round(o.location*4096),Mdpn:Math.round(((r=o.midpoint)!==null&&r!==void 0?r:.5)*100)}})}:{GrdF:"GrdF.ClNs","Nm ":e.name||"",ShTr:!!e.addTransparency,VctC:!!e.restrictColors,ClrS:_.ClrS.encode(e.colorModel),RndS:e.randomSeed||0,Smth:Math.round(((t=e.roughness)!==null&&t!==void 0?t:1)*4096),"Mnm ":(e.min||[0,0,0,0]).map(i=>Math.round(i*100)),"Mxm ":(e.max||[1,1,1,1]).map(i=>Math.round(i*100))}}function fc(e){let n=lc(e.Grad);return n.style=_.GrdT.decode(e.Type),e.Dthr!==void 0&&(n.dither=e.Dthr),e.gradientsInterpolationMethod!==void 0&&(n.interpolationMethod=_.gradientInterpolationMethodType.decode(e.gradientsInterpolationMethod)),e.Rvrs!==void 0&&(n.reverse=e.Rvrs),e.Angl!==void 0&&(n.angle=On(e.Angl)),e["Scl "]!==void 0&&(n.scale=Pe(e["Scl "])),e.Algn!==void 0&&(n.align=e.Algn),e.Ofst!==void 0&&(n.offset={x:Pe(e.Ofst.Hrzn),y:Pe(e.Ofst.Vrtc)}),e.gradientAspectRatio!==void 0&&(n.aspectRatio=e.gradientAspectRatio),e.noisePreSeed!==void 0&&(n.noisePreSeed=e.noisePreSeed),n}function dc({Hrzn:e,Vrtc:n}){return{x:typeof e=="number"?e:e.value,y:typeof n=="number"?n:n.value}}function uc(e){let n={name:e.Ptrn["Nm "],id:e.Ptrn.Idnt};return e.Algn!==void 0&&(n.align=e.Algn),e.Lnkd!==void 0&&(n.linked=e.Lnkd),e.phase!==void 0&&(n.phase=dc(e.phase)),e["Scl "]!==void 0&&(n.scale=Pe(e["Scl "])),e.Angl!==void 0&&(n.angle=On(e.Angl)),n}function vh(e){if("Grad"in e)return fc(e);if("Ptrn"in e)return Object.assign({type:"pattern"},uc(e));if("Clr "in e)return{type:"color",color:sn(e["Clr "])};throw new Error("Invalid vector content")}function pc(e){let n={};return e.dither!==void 0&&(n.Dthr=e.dither),e.interpolationMethod!==void 0&&(n.gradientsInterpolationMethod=_.gradientInterpolationMethodType.encode(e.interpolationMethod)),e.reverse!==void 0&&(n.Rvrs=e.reverse),e.aspectRatio!==void 0&&(n.gradientAspectRatio=e.aspectRatio),e.angle!==void 0&&(n.Angl=ln(e.angle)),n.Type=_.GrdT.encode(e.style),e.align!==void 0&&(n.Algn=e.align),e.scale!==void 0&&(n["Scl "]=St(e.scale)),e.offset&&(n.Ofst={Hrzn:St(e.offset.x),Vrtc:St(e.offset.y)}),e.noisePreSeed!==void 0&&(n.noisePreSeed=e.noisePreSeed),n.Grad=cc(e),n}function hc(e){let n={Ptrn:{"Nm ":e.name||"",Idnt:e.id||""}};return e.align!==void 0&&(n.Algn=!!e.align),e.linked!==void 0&&(n.Lnkd=!!e.linked),e.phase!==void 0&&(n.phase={Hrzn:e.phase.x,Vrtc:e.phase.y}),e.scale!==void 0&&(n["Scl "]=St(e.scale)),e.angle!==void 0&&(n.Angl=ln(e.angle)),n}function Sh(e){return e.type==="color"?{key:"SoCo",descriptor:{"Clr ":an(e.color)}}:e.type==="pattern"?{key:"PtFl",descriptor:hc(e)}:{key:"GdFl",descriptor:pc(e)}}var xh={"H ":[e=>e/360,e=>e*360],Strt:[e=>e/100,e=>e*100],Brgh:[e=>e/100,e=>e*100],"Cyn ":[e=>e*255/100,e=>e*100/255],Mgnt:[e=>e*255/100,e=>e*100/255],"Ylw ":[e=>e*255/100,e=>e*100/255],Blck:[e=>e*255/100,e=>e*100/255],"Gry ":[e=>e*255/100,e=>e*100/255],Lmnc:[e=>e/100,e=>e*100],"A ":[V.normalizeLabAB,V.denormalizeLabAB],"B ":[V.normalizeLabAB,V.denormalizeLabAB]};function ot(e,n){let t=xh[e];if(!t)return n;let[i,o]=t,r=o(n);if(!isFinite(r))return r;for(let s=1;s<17;s++){let a=+r.toPrecision(s);if(i(a)===n)return a}return r}function gc(e){return e._classID==="BkCl"||"Bk "in e||"bookID"in e}function sn(e){var n,t,i;let o=kh(e);if(gc(e)){let r=e,s=r.bookKey;o.book={book:(n=r["Bk "])!==null&&n!==void 0?n:"",name:(t=r["Nm "])!==null&&t!==void 0?t:"",bookID:(i=r.bookID)!==null&&i!==void 0?i:0,bookKey:typeof s=="string"?s:s?String.fromCharCode(...Array.from(s)):""}}return o}function kh(e){if("H "in e)return{h:mc(e["H "]),s:e.Strt/100,b:e.Brgh/100};if("Rd "in e)return{r:e["Rd "],g:e["Grn "],b:e["Bl "]};if("Cyn "in e)return{c:e["Cyn "]*255/100,m:e.Mgnt*255/100,y:e["Ylw "]*255/100,k:e.Blck*255/100};if("Gry "in e)return{k:e["Gry "]*255/100};if("Lmnc"in e)return{l:e.Lmnc/100,a:(0,V.normalizeLabAB)(e["A "]),b:(0,V.normalizeLabAB)(e["B "])};if("redFloat"in e)return{fr:e.redFloat,fg:e.greenFloat,fb:e.blueFloat};if(gc(e))return{r:0,g:0,b:0};throw new Error("Unsupported color descriptor")}function an(e){let n=_h(e);if(e?.book){let{book:t,name:i,bookID:o,bookKey:r}=e.book,s=new Uint8Array(r.length);for(let a=0;a<s.length;a++)s[a]=r.charCodeAt(a)&255;Object.assign(n,{"Bk ":t,"Nm ":i,bookID:o,bookKey:s})}return n}function _h(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 ":ln(ot("H ",e.h||0)),Strt:ot("Strt",e.s||0),Brgh:ot("Brgh",e.b||0)};if("c"in e)return{_name:"",_classID:"CMYC","Cyn ":ot("Cyn ",e.c||0),Mgnt:ot("Mgnt",e.m||0),"Ylw ":ot("Ylw ",e.y||0),Blck:ot("Blck",e.k||0)};if("l"in e)return{_name:"",_classID:"LbCl",Lmnc:ot("Lmnc",e.l||0),"A ":ot("A ",e.a||0),"B ":ot("B ",e.b||0)};if("k"in e)return{_name:"",_classID:"Grsc","Gry ":ot("Gry ",e.k||0)};throw new Error("Invalid color value")}else return{_name:"",_classID:"RGBC","Rd ":0,"Grn ":0,"Bl ":0}}function On(e){if(e===void 0)return 0;if(e.units!=="Angle")throw new Error(`Invalid units: ${e.units}`);return e.value}function Pe(e){if(e===void 0)return 1;if(e.units!=="Percent")throw new Error(`Invalid units: ${e.units}`);return e.value/100}function mc(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 wt({units:e,value:n}){if(e!=="Pixels"&&e!=="Millimeters"&&e!=="Points"&&e!=="None"&&e!=="Picas"&&e!=="Inches"&&e!=="Centimeters"&&e!=="Density"&&e!=="Distance")throw new Error(`Invalid units: ${JSON.stringify({units:e,value:n})}`);return{value:n,units:e}}function yc(e,n="Pixels"){return typeof e=="number"?{value:e,units:n}:wt(e)}function Ah({units:e,value:n},t){if(e!==t)throw new Error(`Invalid units: ${JSON.stringify({units:e,value:n})}`);return n}function ln(e){return{units:"Angle",value:e||0}}function rt(e){return{units:"Percent",value:Math.round((e||0)*100)}}function St(e){return{units:"Percent",value:(e||0)*100}}function vt(e,n){if(e==null)return{units:"Pixels",value:0};if(typeof e!="object")throw new Error(`Invalid value: ${JSON.stringify(e)} (key: ${n}) (should have value and units)`);let{units:t,value:i}=e;if(typeof i!="number")throw new Error(`Invalid value in ${JSON.stringify(e)} (key: ${n})`);if(t!=="Pixels"&&t!=="Millimeters"&&t!=="Points"&&t!=="None"&&t!=="Picas"&&t!=="Inches"&&t!=="Centimeters"&&t!=="Density"&&t!=="Distance")throw new Error(`Invalid units in ${JSON.stringify(e)} (key: ${n})`);return{units:t,value:i}}function Ih({numerator:e,denominator:n}){return{numerator:e,denominator:n}}_.textGridding=(0,V.createEnum)("textGridding","none",{none:"None",round:"Rnd "});_.Ornt=(0,V.createEnum)("Ornt","horizontal",{horizontal:"Hrzn",vertical:"Vrtc"});_.Annt=(0,V.createEnum)("Annt","sharp",{none:"Anno",sharp:"antiAliasSharp",crisp:"AnCr",strong:"AnSt",smooth:"AnSm",platform:"antiAliasPlatformGray",platformLCD:"antiAliasPlatformLCD"});_.warpStyle=(0,V.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"});_.BlnM=(0,V.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":"passThrough"});_.BESl=(0,V.createEnum)("BESl","inner bevel",{"inner bevel":"InrB","outer bevel":"OtrB",emboss:"Embs","pillow emboss":"PlEb","stroke emboss":"strokeEmboss"});_.bvlT=(0,V.createEnum)("bvlT","smooth",{smooth:"SfBL","chisel hard":"PrBL","chisel soft":"Slmt"});_.BESs=(0,V.createEnum)("BESs","up",{up:"In ",down:"Out "});_.BETE=(0,V.createEnum)("BETE","softer",{softer:"SfBL",precise:"PrBL"});_.IGSr=(0,V.createEnum)("IGSr","edge",{edge:"SrcE",center:"SrcC"});_.GrdT=(0,V.createEnum)("GrdT","linear",{linear:"Lnr ",radial:"Rdl ",angle:"Angl",reflected:"Rflc",diamond:"Dmnd"});_.animInterpStyleEnum=(0,V.createEnum)("animInterpStyle","linear",{linear:"Lnr ",hold:"hold"});_.stdTrackID=(0,V.createEnum)("stdTrackID","opacity",{opacity:"opacityTrack",style:"styleTrack",sheetTransform:"sheetTransformTrack",sheetPosition:"sheetPositionTrack",globalLighting:"globalLightingTrack"});_.gradientInterpolationMethodType=(0,V.createEnum)("gradientInterpolationMethodType","perceptual",{perceptual:"Perc",linear:"Lnr ",classic:"Gcls",smooth:"Smoo"});_.Clry=(0,V.createEnum)("Clry","user",{user:"UsrS",foreground:"FrgC",background:"BckC"});_.ClrS=(0,V.createEnum)("ClrS","rgb",{rgb:"RGBC",hsb:"HSBl",lab:"LbCl",hsl:"HSLC"});_.FStl=(0,V.createEnum)("FStl","outside",{outside:"OutF",center:"CtrF",inside:"InsF"});_.FrFl=(0,V.createEnum)("FrFl","color",{color:"SClr",gradient:"GrFl",pattern:"Ptrn"});_.ESliceType=(0,V.createEnum)("ESliceType","image",{image:"Img ",noImage:"noImage"});_.ESliceHorzAlign=(0,V.createEnum)("ESliceHorzAlign","default",{default:"default"});_.ESliceVertAlign=(0,V.createEnum)("ESliceVertAlign","default",{default:"default"});_.ESliceOrigin=(0,V.createEnum)("ESliceOrigin","userGenerated",{userGenerated:"userGenerated",autoGenerated:"autoGenerated",layer:"layer"});_.ESliceBGColorType=(0,V.createEnum)("ESliceBGColorType","none",{none:"None",matte:"matte",color:"Clr "});_.strokeStyleLineCapType=(0,V.createEnum)("strokeStyleLineCapType","butt",{butt:"strokeStyleButtCap",round:"strokeStyleRoundCap",square:"strokeStyleSquareCap"});_.strokeStyleLineJoinType=(0,V.createEnum)("strokeStyleLineJoinType","miter",{miter:"strokeStyleMiterJoin",round:"strokeStyleRoundJoin",bevel:"strokeStyleBevelJoin"});_.strokeStyleLineAlignment=(0,V.createEnum)("strokeStyleLineAlignment","inside",{inside:"strokeStyleAlignInside",center:"strokeStyleAlignCenter",outside:"strokeStyleAlignOutside"});_.BlrM=(0,V.createEnum)("BlrM","spin",{spin:"Spn ",zoom:"Zm "});_.BlrQ=(0,V.createEnum)("BlrQ","good",{draft:"Drft",good:"Gd ",best:"Bst "});_.SmBM=(0,V.createEnum)("SmBM","normal",{normal:"SBMN","edge only":"SBME","overlay edge":"SBMO"});_.SmBQ=(0,V.createEnum)("SmBQ","medium",{low:"SBQL",medium:"SBQM",high:"SBQH"});_.DspM=(0,V.createEnum)("DspM","stretch to fit",{"stretch to fit":"StrF",tile:"Tile"});_.UndA=(0,V.createEnum)("UndA","repeat edge pixels",{"wrap around":"WrpA","repeat edge pixels":"RptE"});_.Cnvr=(0,V.createEnum)("Cnvr","rectangular to polar",{"rectangular to polar":"RctP","polar to rectangular":"PlrR"});_.RplS=(0,V.createEnum)("RplS","medium",{small:"Sml ",medium:"Mdm ",large:"Lrg "});_.SphM=(0,V.createEnum)("SphM","normal",{normal:"Nrml","horizontal only":"HrzO","vertical only":"VrtO"});_.Wvtp=(0,V.createEnum)("Wvtp","sine",{sine:"WvSn",triangle:"WvTr",square:"WvSq"});_.ZZTy=(0,V.createEnum)("ZZTy","pond ripples",{"around center":"ArnC","out from center":"OtFr","pond ripples":"PndR"});_.Dstr=(0,V.createEnum)("Dstr","uniform",{uniform:"Unfr",gaussian:"Gsn "});_.Chnl=(0,V.createEnum)("Chnl","composite",{red:"Rd ",green:"Grn ",blue:"Bl ",composite:"Cmps"});_.MztT=(0,V.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"});_.Lns=(0,V.createEnum)("Lns ","50-300mm zoom",{"50-300mm zoom":"Zm ","32mm prime":"Nkn ","105mm prime":"Nkn1","movie prime":"PnVs"});_.blurType=(0,V.createEnum)("blurType","gaussian blur",{"gaussian blur":"GsnB","lens blur":"lensBlur","motion blur":"MtnB"});_.DfsM=(0,V.createEnum)("DfsM","normal",{normal:"Nrml","darken only":"DrkO","lighten only":"LghO",anisotropic:"anisotropic"});_.ExtT=(0,V.createEnum)("ExtT","blocks",{blocks:"Blks",pyramids:"Pyrm"});_.ExtR=(0,V.createEnum)("ExtR","random",{random:"Rndm","level-based":"LvlB"});_.FlCl=(0,V.createEnum)("FlCl","background color",{"background color":"FlBc","foreground color":"FlFr","inverse image":"FlIn","unaltered image":"FlSm"});_.CntE=(0,V.createEnum)("CntE","upper",{lower:"Lwr ",upper:"Upr "});_.WndM=(0,V.createEnum)("WndM","wind",{wind:"Wnd ",blast:"Blst",stagger:"Stgr"});_.Drct=(0,V.createEnum)("Drct","right",{left:"Left",right:"Rght"});_.IntE=(0,V.createEnum)("IntE","odd lines",{"odd lines":"ElmO","even lines":"ElmE"});_.IntC=(0,V.createEnum)("IntC","interpolation",{duplication:"CrtD",interpolation:"CrtI"});_.FlMd=(0,V.createEnum)("FlMd","wrap around",{"set to transparent":"Bckg","repeat edge pixels":"Rpt ","wrap around":"Wrp "});_.prjM=(0,V.createEnum)("prjM","fisheye",{fisheye:"fisP",perspective:"perP",auto:"auto","full spherical":"fusP"});_.presetKindType=(0,V.createEnum)("presetKindType","custom",{custom:"presetKindCustom",default:"presetKindDefault"});_.patternColorHandling=(0,V.createEnum)("","convert",{convert:"conv","avoid conversion":"avod","luminance only":"lumi"})});var qr=ae(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.resourceHandlersMap=Et.resourceHandlers=void 0;Et.shouldReadResource=Oh;var Ch=to(),Fn=di(),I=st(),P=En(),cn=Ot(),Dc=Mr(),z=ro();Et.resourceHandlers=[];Et.resourceHandlersMap={};function Ph(e){let n=[],t=new Proxy({},{get(i,o){typeof o=="string"&&!n.includes(o)&&n.push(o)}});try{e(t)}catch{}return n}var Dh=new Set(["layersGroup","layerGroupsEnabledId","alphaChannelNames","transparencyIndex"]);function j(e,n,t,i,o={}){var r,s;let a=(r=o.fields)!==null&&r!==void 0?r:Ph(n),l=a.some(f=>Dh.has(f)),c={key:e,keyCount:(s=o.keyCount)!==null&&s!==void 0?s:1,has:n,read:t,write:i,name:o.name,fields:a,required:l};Et.resourceHandlers.push(c);for(let f=0;f<c.keyCount;f++)Et.resourceHandlersMap[c.key+f]=c}function Oh(e,n){return!n||e.required||n.size>0&&e.fields.some(t=>n.has(t))}var Eh=!1,so=[void 0,"PPI","PPCM"],ao=[void 0,"Inches","Centimeters","Points","Picas","Columns"],bc="0123456789abcdef";function wc(e){return e<=57?e-48:e>=97?e-87:e-55}function Fh(e,n){return wc(e.charCodeAt(n))<<4|wc(e.charCodeAt(n+1))}function Vr(e,n){let t=(0,I.readBytes)(e,n);return(0,I.decodeUtf8)(e,t)}function Nr(e,n){let t=(0,Dc.encodeString)(n);(0,P.writeBytes)(e,t)}function Oc(e){let n=(0,I.readUint8)(e),t=(0,I.readBytes)(e,n);return Ec(e,t)}function Ec(e,n){let t=!1;for(let i=0;i<n.byteLength;i++)if(n[i]&128){t=!0;break}if(t){for(let i of[(0,I.getGbkStrictDecoder)(e),(0,I.getUtf8StrictDecoder)(e)])if(i)try{return i.decode(n)}catch{}}return(0,I.decodeUtf8)(e,n)}function Fc(e){let n="";for(let t=0;t<e.length;){let i=e.codePointAt(t);n+=i>127?"?":String.fromCharCode(i),t+=i>65535?2:1}return n.length>255?n.substring(0,255):n}function Lc(e,n){let t=(0,Dc.encodeString)(Fc(n));(0,P.writeUint8)(e,t.byteLength),(0,P.writeBytes)(e,t)}j(1028,e=>e.iptcData!==void 0,(e,n,t)=>{n.iptcData=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.iptcData)});j(1061,e=>e.captionDigest!==void 0,(e,n)=>{let t="";for(let i=0;i<16;i++){let o=(0,I.readUint8)(e);t+=bc[o>>4],t+=bc[o&15]}n.captionDigest=t},(e,n)=>{for(let t=0;t<16;t++)(0,P.writeUint8)(e,Fh(n.captionDigest,t*2))});j(1060,e=>e.xmpMetadata!==void 0,(e,n,t)=>{n.xmpMetadata=Vr(e,t())},(e,n)=>{Nr(e,n.xmpMetadata)});var lo=(0,cn.createEnum)("Inte","perceptual",{perceptual:"Img ",saturation:"Grp ","relative colorimetric":"Clrm","absolute colorimetric":"AClr"});j(1085,e=>e.windowsDevMode!==void 0,(e,n,t)=>{n.windowsDevMode=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.windowsDevMode)});j(1082,e=>e.printInformation!==void 0,(e,n)=>{var t,i;let o=(0,z.readVersionAndDescriptor)(e);n.printInformation={printerName:o.printerName||"",renderingIntent:lo.decode((t=o.Inte)!==null&&t!==void 0?t:"Inte.Img ")};let r=n.printInformation;o.PstS!==void 0&&(r.printerManagesColors=o.PstS),o.ClrS==="ClrS.Grys"&&(r.printerProfileColorSpace="grayscale"),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:lo.decode((i=o.printProofSetup.Inte)!==null&&i!==void 0?i:"Inte.Img "),blackPointCompensation:!!o.printProofSetup.MpBl,paperWhite:!!o.printProofSetup.paperWhite})},(e,n)=>{let t=n.printInformation,i={};t.printerManagesColors?i.PstS=!0:(t.hardProof!==void 0&&(i.hardProof=!!t.hardProof),i.ClrS=t.printerProfileColorSpace==="grayscale"?"ClrS.Grys":"ClrS.RGBC",t.printerProfile!==void 0&&(i["Nm "]=t.printerProfile)),i.Inte=lo.encode(t.renderingIntent),!t.printerManagesColors&&t.blackPointCompensation!==void 0&&(i.MpBl=!!t.blackPointCompensation),i.printSixteenBit=!!t.printSixteenBit,i.printerName=t.printerName||"",t.proofSetup&&"profile"in t.proofSetup?i.printProofSetup={profile:t.proofSetup.profile||"",Inte:lo.encode(t.proofSetup.renderingIntent),MpBl:!!t.proofSetup.blackPointCompensation,paperWhite:!!t.proofSetup.paperWhite}:t.proofSetup&&(i.printProofSetup={Bltn:`builtinProof.${t.proofSetup.builtin||"proofCMYK"}`}),(0,z.writeVersionAndDescriptor)(e,"","printOutput",i)});j(1083,e=>e.printStyle!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.printStyle={caption:t.Cptn,calibrationBars:t.Clbr,registrationMarks:t.RgsM,cornerCropMarks:t.CrnC,centerCropMarks:t.CntC,labels:t.Lbls,negative:t.Ngtv,emulsionDown:t.EmlD,interpolate:t.Intr,backgroundColor:(0,z.parseColor)(t.Bckg),border:(0,z.parseUnits)(t.BrdT),bleed:(0,z.parseUnits)(t["Bld "]),resolution:(0,z.parseUnits)(t.Rslt),vectorData:t.vectorData,pagePosition:t.PgPs==="PgPs.PgPC"?"centered":t.PgPs,left:(0,z.parseUnits)(t.Left),top:(0,z.parseUnits)(t["Top "]),scale:(0,z.parsePercent)(t["Scl "])},t.cropWhenPrinting!==void 0&&(n.printStyle.cropWhenPrinting=t.cropWhenPrinting,n.printStyle.cropRect={top:t.cropRectTop||0,left:t.cropRectLeft||0,bottom:t.cropRectBottom||0,right:t.cropRectRight||0})},(e,n)=>{var t,i,o,r,s,a,l,c,f,u;let d=n.printStyle,p={Cptn:!!d.caption,Clbr:!!d.calibrationBars,RgsM:!!d.registrationMarks,CrnC:!!d.cornerCropMarks,CntC:!!d.centerCropMarks,Lbls:!!d.labels,Ngtv:!!d.negative,EmlD:!!d.emulsionDown,Intr:!!d.interpolate,Bckg:(0,z.serializeColor)(d.backgroundColor||{r:255,g:255,b:255}),BrdT:(0,z.unitsValue)(d.border||{units:"Distance",value:0},"border"),"Bld ":(0,z.unitsValue)(d.bleed||{units:"Distance",value:0},"bleed"),Rslt:(0,z.unitsValue)(d.resolution||{units:"Pixels",value:72},"resolution"),vectorData:(t=d.vectorData)!==null&&t!==void 0?t:!0,PgPs:!d.pagePosition||d.pagePosition==="centered"?"PgPs.PgPC":d.pagePosition,Left:(0,z.unitsValue)(d.left||{units:"Distance",value:0},"left"),"Top ":(0,z.unitsValue)(d.top||{units:"Distance",value:0},"top"),"Scl ":(0,z.unitsPercentF)((i=d.scale)!==null&&i!==void 0?i:1)};(d.cropWhenPrinting!==void 0||d.cropRect)&&(p.cropWhenPrinting=!!d.cropWhenPrinting,p.cropRectBottom=(r=(o=d.cropRect)===null||o===void 0?void 0:o.bottom)!==null&&r!==void 0?r:0,p.cropRectLeft=(a=(s=d.cropRect)===null||s===void 0?void 0:s.left)!==null&&a!==void 0?a:0,p.cropRectRight=(c=(l=d.cropRect)===null||l===void 0?void 0:l.right)!==null&&c!==void 0?c:0,p.cropRectTop=(u=(f=d.cropRect)===null||f===void 0?void 0:f.top)!==null&&u!==void 0?u:0),(0,z.writeVersionAndDescriptor)(e,"","printOutputOptions",p)});j(1005,e=>e.resolutionInfo!==void 0,(e,n)=>{let t=(0,I.readFixedPoint32)(e),i=(0,I.readUint16)(e),o=(0,I.readUint16)(e),r=(0,I.readFixedPoint32)(e),s=(0,I.readUint16)(e),a=(0,I.readUint16)(e);n.resolutionInfo={horizontalResolution:t,horizontalResolutionUnit:so[i]||"PPI",widthUnit:ao[o]||"Inches",verticalResolution:r,verticalResolutionUnit:so[s]||"PPI",heightUnit:ao[a]||"Inches"}},(e,n)=>{let t=n.resolutionInfo;(0,P.writeFixedPoint32)(e,t.horizontalResolution||0),(0,P.writeUint16)(e,Math.max(1,so.indexOf(t.horizontalResolutionUnit))),(0,P.writeUint16)(e,Math.max(1,ao.indexOf(t.widthUnit))),(0,P.writeFixedPoint32)(e,t.verticalResolution||0),(0,P.writeUint16)(e,Math.max(1,so.indexOf(t.verticalResolutionUnit))),(0,P.writeUint16)(e,Math.max(1,ao.indexOf(t.heightUnit)))});var vc=["centered","size to fit","user defined"];j(1062,e=>e.printScale!==void 0,(e,n)=>{n.printScale={style:vc[(0,I.readInt16)(e)],x:(0,I.readFloat32)(e),y:(0,I.readFloat32)(e),scale:(0,I.readFloat32)(e)}},(e,n)=>{let{style:t,x:i,y:o,scale:r}=n.printScale;(0,P.writeInt16)(e,Math.max(0,vc.indexOf(t))),(0,P.writeFloat32)(e,i||0),(0,P.writeFloat32)(e,o||0),(0,P.writeFloat32)(e,r||0)});j(1006,e=>e.alphaChannelNames!==void 0,(e,n,t)=>{if(n.alphaChannelNames)(0,I.skipBytes)(e,t());else for(n.alphaChannelNames=[];t()>0;){let i=Oc(e);n.alphaChannelNames.push(i)}},(e,n)=>{for(let t of n.alphaChannelNames)Lc(e,t)});j(1045,e=>e.alphaChannelNames!==void 0,(e,n,t)=>{for(n.alphaChannelNames=[];t()>0;)n.alphaChannelNames.push((0,I.readUnicodeString)(e))},(e,n)=>{for(let t of n.alphaChannelNames)(0,P.writeUnicodeStringWithPadding)(e,t)});var Mc=["selected","protected","spot"],Lh=[0,1,2,7,8];function Uc(e){let n={opacity:0,kind:"selected"},t=e.view.getUint16(e.offset);Lh.indexOf(t)!==-1?n.color=(0,I.readColor)(e):((0,I.skipBytes)(e,2),n.rawColor={colorSpace:t,values:[(0,I.readUint16)(e),(0,I.readUint16)(e),(0,I.readUint16)(e),(0,I.readUint16)(e)]}),n.opacity=(0,I.readUint16)(e)/100;let i=Mc[(0,I.readUint8)(e)];if(!i)throw new Error("Invalid display info kind");return n.kind=i,n}j(1007,()=>!1,(e,n,t)=>{let i=[];for(;t()>=14;)i.push(Uc(e)),(0,I.skipBytes)(e,1);n.alphaChannelDisplayInfo||(n.alphaChannelDisplayInfo=i)},()=>{},{fields:["alphaChannelDisplayInfo"]});j(1077,e=>e.alphaChannelDisplayInfo!==void 0,(e,n,t)=>{let i=(0,I.readUint32)(e);if(i!==1)throw new Error(`Invalid display info version: ${i}`);for(n.alphaChannelDisplayInfo=[];t()>=13;)n.alphaChannelDisplayInfo.push(Uc(e))},(e,n)=>{(0,P.writeUint32)(e,1);for(let t of n.alphaChannelDisplayInfo){if(!t.color&&t.rawColor){(0,P.writeUint16)(e,t.rawColor.colorSpace);for(let i=0;i<4;i++)(0,P.writeUint16)(e,t.rawColor.values[i]|0)}else(0,P.writeColor)(e,t.color||{r:255,g:0,b:0});(0,P.writeUint16)(e,Math.round((0,cn.clamp)(t.opacity,0,1)*100)),(0,P.writeUint8)(e,Math.max(0,Mc.indexOf(t.kind)))}});j(1053,e=>e.alphaIdentifiers!==void 0,(e,n,t)=>{for(n.alphaIdentifiers=[];t()>=4;)n.alphaIdentifiers.push((0,I.readUint32)(e))},(e,n)=>{for(let t of n.alphaIdentifiers)(0,P.writeUint32)(e,t)});j(1010,e=>e.backgroundColor!==void 0,(e,n)=>n.backgroundColor=(0,I.readColor)(e),(e,n)=>(0,P.writeColor)(e,n.backgroundColor));j(1037,e=>e.globalAngle!==void 0,(e,n)=>n.globalAngle=(0,I.readInt32)(e),(e,n)=>(0,P.writeInt32)(e,n.globalAngle));j(1049,e=>e.globalAltitude!==void 0,(e,n)=>n.globalAltitude=(0,I.readUint32)(e),(e,n)=>(0,P.writeUint32)(e,n.globalAltitude));j(1011,e=>e.printFlags!==void 0,(e,n,t)=>{n.printFlags={labels:!!(0,I.readUint8)(e),cropMarks:!!(0,I.readUint8)(e),colorBars:!!(0,I.readUint8)(e),registrationMarks:!!(0,I.readUint8)(e),negative:!!(0,I.readUint8)(e),flip:!!(0,I.readUint8)(e),interpolate:!!(0,I.readUint8)(e),caption:!!(0,I.readUint8)(e),printFlags:t()?!!(0,I.readUint8)(e):!1}},(e,n)=>{let t=n.printFlags;(0,P.writeUint8)(e,t.labels?1:0),(0,P.writeUint8)(e,t.cropMarks?1:0),(0,P.writeUint8)(e,t.colorBars?1:0),(0,P.writeUint8)(e,t.registrationMarks?1:0),(0,P.writeUint8)(e,t.negative?1:0),(0,P.writeUint8)(e,t.flip?1:0),(0,P.writeUint8)(e,t.interpolate?1:0),(0,P.writeUint8)(e,t.caption?1:0),(0,P.writeUint8)(e,t.printFlags?1:0)});j(1034,e=>e.copyrighted!==void 0,(e,n)=>{n.copyrighted=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.copyrighted?1:0)});j(1035,e=>e.url!==void 0,(e,n,t)=>{n.url=(0,I.readAsciiString)(e,t())},(e,n)=>{(0,P.writeAsciiString)(e,n.url)});j(1e4,e=>e.printFlagsInfo!==void 0,(e,n)=>{let t=(0,I.readUint16)(e);if(t!==1)throw new Error(`Invalid print flags information version: ${t}`);let i=!!(0,I.readUint8)(e);(0,I.skipBytes)(e,1);let o=(0,I.readUint32)(e),r=(0,I.readUint16)(e);n.printFlagsInfo={centerCropMarks:i,bleedWidth:o,bleedWidthScale:r}},(e,n)=>{let t=n.printFlagsInfo;(0,P.writeUint16)(e,1),(0,P.writeUint8)(e,t.centerCropMarks?1:0),(0,P.writeUint8)(e,0),(0,P.writeUint32)(e,t.bleedWidth|0),(0,P.writeUint16)(e,t.bleedWidthScale|0)});j(1046,e=>e.indexedColorCount!==void 0,(e,n)=>{n.indexedColorCount=(0,I.readUint16)(e)},(e,n)=>{(0,P.writeUint16)(e,n.indexedColorCount)});j(1047,e=>e.transparencyIndex!==void 0,(e,n)=>{n.transparencyIndex=(0,I.readUint16)(e)},(e,n)=>{(0,P.writeUint16)(e,n.transparencyIndex)});var Bc=["lines/inch","lines/cm"],Rc=["round","ellipse","line","square","cross",void 0,"diamond"];function Gr(e,n){let t=[];for(;n()>=18;){let i=(0,I.readFixedPoint32)(e),o=Bc[(0,I.readUint16)(e)-1];if(!o)throw new Error("Invalid halftone screen frequency units");let r=(0,I.readFixedPoint32)(e),s=Rc[(0,I.readInt16)(e)];if(!s)throw new Error("Invalid halftone screen shape");(0,I.skipBytes)(e,4);let a=!!(0,I.readUint8)(e),l=!!(0,I.readUint8)(e);t.push({frequency:i,frequencyUnits:o,angle:r,shape:s,accurateScreens:a,printerDefaultScreens:l})}return t}function Hr(e,n){for(let t of n)(0,P.writeFixedPoint32)(e,t.frequency),(0,P.writeUint16)(e,Math.max(0,Bc.indexOf(t.frequencyUnits))+1),(0,P.writeFixedPoint32)(e,t.angle),(0,P.writeInt16)(e,Math.max(0,Rc.indexOf(t.shape))),(0,P.writeZeros)(e,4),(0,P.writeUint8)(e,t.accurateScreens?1:0),(0,P.writeUint8)(e,t.printerDefaultScreens?1:0)}j(1012,e=>e.grayscaleHalftoneScreens!==void 0,(e,n,t)=>n.grayscaleHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.grayscaleHalftoneScreens));j(1013,e=>e.colorHalftoneScreens!==void 0,(e,n,t)=>n.colorHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.colorHalftoneScreens));function Wr(e,n){let t=[];for(;n()>=28;){let i=[];for(let r=0;r<13;r++)i.push((0,I.readInt16)(e));let o=!!(0,I.readUint16)(e);t.push({curve:i,override:o})}return t}function Xr(e,n){var t;for(let i of n){for(let o=0;o<13;o++)(0,P.writeInt16)(e,(t=i.curve[o])!==null&&t!==void 0?t:-1);(0,P.writeUint16)(e,i.override?1:0)}}j(1014,e=>e.duotoneHalftoneScreens!==void 0,(e,n,t)=>n.duotoneHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.duotoneHalftoneScreens));j(1017,e=>e.duotoneTransferFunctions!==void 0,(e,n,t)=>n.duotoneTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.duotoneTransferFunctions));j(1018,e=>e.duotoneImageInformation!==void 0,(e,n,t)=>n.duotoneImageInformation=(0,I.readBytes)(e,t()),(e,n)=>(0,P.writeBytes)(e,n.duotoneImageInformation));j(1066,e=>e.alternateDuotoneColors!==void 0,(e,n,t)=>{if((0,I.readUint16)(e)!==1)throw new Error("Invalid alternate duotone colors version");let i=[],o=(0,I.readUint16)(e);for(let a=0;a<o&&t()>=10;a++)i.push((0,I.readColor)(e));let r=(0,I.readUint16)(e);if(r*3>t())throw new Error("Invalid alternate duotone colors Lab table size");let s=(0,I.readBytes)(e,r*3);n.alternateDuotoneColors={colors:i,labColors:s}},(e,n)=>{let{colors:t,labColors:i}=n.alternateDuotoneColors;(0,P.writeUint16)(e,1),(0,P.writeUint16)(e,t.length);for(let o of t)(0,P.writeColor)(e,o);(0,P.writeUint16)(e,Math.floor(i.byteLength/3)),(0,P.writeBytes)(e,i.subarray(0,Math.floor(i.byteLength/3)*3))});j(1015,e=>e.grayscaleTransferFunctions!==void 0,(e,n,t)=>n.grayscaleTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.grayscaleTransferFunctions));j(1016,e=>e.colorTransferFunctions!==void 0,(e,n,t)=>n.colorTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.colorTransferFunctions));j(1080,e=>e.countInformation!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.countInformation=t.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,n)=>{let t={Vrsn:1,countGroupList:n.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,z.writeVersionAndDescriptor)(e,"","Cnt ",t)});j(1024,e=>e.layerState!==void 0,(e,n)=>n.layerState=(0,I.readUint16)(e),(e,n)=>(0,P.writeUint16)(e,n.layerState));j(1026,e=>e.layersGroup!==void 0,(e,n,t)=>{for(n.layersGroup=[];t()>0;)n.layersGroup.push((0,I.readUint16)(e))},(e,n)=>{for(let t of n.layersGroup)(0,P.writeUint16)(e,t)});j(1072,e=>e.layerGroupsEnabledId!==void 0,(e,n,t)=>{for(n.layerGroupsEnabledId=[];t()>0;)n.layerGroupsEnabledId.push((0,I.readUint8)(e))},(e,n)=>{for(let t of n.layerGroupsEnabledId)(0,P.writeUint8)(e,t)});j(1069,e=>e.layerSelectionIds!==void 0,(e,n)=>{let t=(0,I.readUint16)(e);for(n.layerSelectionIds=[];t--;)n.layerSelectionIds.push((0,I.readUint32)(e))},(e,n)=>{(0,P.writeUint16)(e,n.layerSelectionIds.length);for(let t of n.layerSelectionIds)(0,P.writeUint32)(e,t)});j(1032,e=>e.gridAndGuidesInformation!==void 0,(e,n)=>{var t;let i=(0,I.readUint32)(e),o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e);if(i!==1)throw new Error(`Invalid 1032 resource version: ${i}`);let a=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides,l=[];for(let c=0;c<s;c++){let f={location:(0,I.readInt32)(e)/32,direction:(0,I.readUint8)(e)?"horizontal":"vertical"};a?.length===s&&a[c].color&&(f.color=a[c].color),a?.length===s&&a[c].id&&(f.id=a[c].id),l.push(f)}n.gridAndGuidesInformation={grid:{horizontal:o,vertical:r},guides:l}},(e,n)=>{let t=n.gridAndGuidesInformation,i=t.grid||{horizontal:576,vertical:576},o=t.guides||[];(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,Math.round(i.horizontal)),(0,P.writeUint32)(e,Math.round(i.vertical)),(0,P.writeUint32)(e,o.length);for(let r of o)(0,P.writeInt32)(e,Math.round(r.location*32)),(0,P.writeUint8)(e,r.direction==="horizontal"?1:0)});var Mh={r:74,g:255,b:255};j(1092,e=>e.gridAndGuidesInformation!==void 0,(e,n)=>{var t;let i=(0,I.readUint32)(e);if(i!==2)throw new Error(`Invalid 1092 resource version: ${i}`);let o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e),a=[];for(let c=0;c<s;c++){let f=(0,I.readInt32)(e)/32,u=(0,I.readUint8)(e)?"horizontal":"vertical";(0,I.skipBytes)(e,1);let d={r:(0,I.readUint8)(e),g:(0,I.readUint8)(e),b:(0,I.readUint8)(e)};a.push({location:f,direction:u,color:d})}let l=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides;l&&l.length===s?l.forEach((c,f)=>c.color=a[f].color):n.gridAndGuidesInformation={grid:{horizontal:o,vertical:r},guides:a}},(e,n)=>{let t=n.gridAndGuidesInformation,i=t.grid||{horizontal:576,vertical:576},o=t.guides||[];(0,P.writeUint32)(e,2),(0,P.writeUint32)(e,Math.round(i.horizontal)),(0,P.writeUint32)(e,Math.round(i.vertical)),(0,P.writeUint32)(e,o.length);for(let r of o){let s=r.color||Mh;(0,P.writeInt32)(e,Math.round(r.location*32)),(0,P.writeUint8)(e,r.direction==="horizontal"?1:0),(0,P.writeUint8)(e,0),(0,P.writeUint8)(e,Math.round(s.r)),(0,P.writeUint8)(e,Math.round(s.g)),(0,P.writeUint8)(e,Math.round(s.b))}});var Sc="00000000-0000-0000-0000-000000000000";j(1097,e=>!!e.gridAndGuidesInformation&&(e.gridAndGuidesInformation.guides||[]).every(n=>n.id),(e,n)=>{var t;let i=(0,I.readUint32)(e),o=[];for(let s=0;s<i;s++)o.push((0,I.readAsciiString)(e,(0,I.readUint32)(e))),(0,I.readUint32)(e),(0,I.readAsciiString)(e,(0,I.readUint32)(e));let r=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides;r&&r.length===i&&r.forEach((s,a)=>s.id=o[a])},(e,n)=>{let t=n.gridAndGuidesInformation.guides||[];(0,P.writeUint32)(e,t.length);for(let i of t)(0,P.writeUint32)(e,i.id.length),(0,P.writeAsciiString)(e,i.id),(0,P.writeUint32)(e,0),(0,P.writeUint32)(e,Sc.length),(0,P.writeAsciiString)(e,Sc)});j(1065,e=>e.layerComps!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e,!0);n.layerComps={list:[]};for(let i of t.list)n.layerComps.list.push({id:i.compID,name:i["Nm "],capturedInfo:i.capturedInfo}),i.comment!==void 0&&(n.layerComps.list[n.layerComps.list.length-1].comment=i.comment),i.Expn!==void 0&&(n.layerComps.list[n.layerComps.list.length-1].expanded=i.Expn);t.lastAppliedComp!==void 0&&(n.layerComps.lastApplied=t.lastAppliedComp)},(e,n)=>{let t=n.layerComps,i={list:[]};for(let o of t.list){let r={};r._classID="Comp",r["Nm "]=o.name,o.comment!==void 0&&(r.comment=o.comment),r.compID=o.id,r.capturedInfo=o.capturedInfo,o.expanded!==void 0&&(r.Expn=!!o.expanded),i.list.push(r)}t.lastApplied!==void 0&&(i.lastAppliedComp=t.lastApplied),(0,z.writeVersionAndDescriptor)(e,"","CompList",i)});cn.MOCK_HANDLERS&&j(1092,e=>e._ir1092!==void 0,(e,n,t)=>{Eh&&console.log("image resource 1092",t()),n._ir1092=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n._ir1092)});var xc=["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"];j(1078,e=>e.onionSkins!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.onionSkins={enabled:t.enab,framesBefore:t.numBefore,framesAfter:t.numAfter,frameSpacing:t.Spcn,minOpacity:t.minOpacity/100,maxOpacity:t.maxOpacity/100,blendMode:xc[t.BlnM]||"normal"}},(e,n)=>{let t=n.onionSkins,i={Vrsn:1,enab:t.enabled,numBefore:t.framesBefore,numAfter:t.framesAfter,Spcn:t.frameSpacing,minOpacity:Math.round(t.minOpacity*100),maxOpacity:Math.round(t.maxOpacity*100),BlnM:Math.max(0,xc.indexOf(t.blendMode))};(0,z.writeVersionAndDescriptor)(e,"","null",i)});j(1075,e=>e.timelineInformation!==void 0,(e,n)=>{var t,i;let o=(0,z.readVersionAndDescriptor)(e);n.timelineInformation={enabled:o.enab,frameStep:(0,z.frac)(o.frameStep),frameRate:o.frameRate,time:(0,z.frac)(o.time),duration:(0,z.frac)(o.duration),workInTime:(0,z.frac)(o.workInTime),workOutTime:(0,z.frac)(o.workOutTime),repeats:o.LCnt,hasMotion:o.hasMotion,globalTracks:(0,z.parseTrackList)(o.globalTrackList,e)},!((i=(t=o.audioClipGroupList)===null||t===void 0?void 0:t.audioClipGroupList)===null||i===void 0)&&i.length&&(n.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:f})=>({id:s,start:(0,z.frac)(a.Strt),duration:(0,z.frac)(a.duration),inTime:(0,z.frac)(a.inTime),outTime:(0,z.frac)(a.outTime),muted:l,audioLevel:c,frameReader:{type:f.frameReaderType,mediaDescriptor:f.mediaDescriptor,link:{name:f["Lnk "]["Nm "],fullPath:f["Lnk "].fullPath,relativePath:f["Lnk "].relPath}}}))})))},(e,n)=>{var t;let i=n.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,z.serializeTrackList)(i.globalTracks,e),audioClipGroupList:{audioClipGroupList:((t=i.audioClipGroups)!==null&&t!==void 0?t:[]).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,z.writeVersionAndDescriptor)(e,"","null",o,"anim")});j(1076,e=>e.sheetDisclosure!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.sheetDisclosure={},t.sheetTimelineOptions&&(n.sheetDisclosure.sheetTimelineOptions=t.sheetTimelineOptions.map(i=>({sheetID:i.sheetID,sheetDisclosed:i.sheetDisclosed,lightsDisclosed:i.lightsDisclosed,meshesDisclosed:i.meshesDisclosed,materialsDisclosed:i.materialsDisclosed})))},(e,n)=>{let t=n.sheetDisclosure,i={Vrsn:1};t.sheetTimelineOptions&&(i.sheetTimelineOptions=t.sheetTimelineOptions.map(o=>({Vrsn:2,sheetID:o.sheetID,sheetDisclosed:o.sheetDisclosed,lightsDisclosed:o.lightsDisclosed,meshesDisclosed:o.meshesDisclosed,materialsDisclosed:o.materialsDisclosed}))),(0,z.writeVersionAndDescriptor)(e,"","null",i)});j(1054,e=>e.urlsList!==void 0,(e,n)=>{let t=(0,I.readUint32)(e);n.urlsList=[];for(let i=0;i<t;i++){if((0,I.readSignature)(e)!=="slic"&&e.throwForMissingFeatures)throw new Error("Unknown long");let r=(0,I.readUint32)(e),s=(0,I.readUnicodeString)(e);n.urlsList.push({id:r,url:s,ref:"slice"})}},(e,n)=>{let t=n.urlsList;(0,P.writeUint32)(e,t.length);for(let i=0;i<t.length;i++)(0,P.writeSignature)(e,"slic"),(0,P.writeUint32)(e,t[i].id),(0,P.writeUnicodeString)(e,t[i].url)});function kc(e){return{"Top ":e.top,Left:e.left,Btom:e.bottom,Rght:e.right}}function _c(e){return{top:e["Top "],left:e.Left,bottom:e.Btom,right:e.Rght}}function co(e,n){return e[Math.max(0,Math.min(e.length-1,n))]}var Ac=["autoGenerated","layer","userGenerated"],Ic=["noImage","image"],fo=["default"];j(1050,e=>e.slices?e.slices.length:0,(e,n,t)=>{var i;let o=(0,I.readUint32)(e);if(o===6){n.slices||(n.slices=[]);let r=(0,I.readInt32)(e),s=(0,I.readInt32)(e),a=(0,I.readInt32)(e),l=(0,I.readInt32)(e),c=(0,I.readUnicodeString)(e),f=(0,I.readUint32)(e);n.slices.push({bounds:{top:r,left:s,bottom:a,right:l},groupName:c,slices:[]});let u=n.slices[n.slices.length-1].slices;for(let d=0;d<f;d++){let p=(0,I.readUint32)(e),h=(0,I.readUint32)(e),m=co(Ac,(0,I.readUint32)(e)),y=m=="layer"?(0,I.readUint32)(e):0,g=(0,I.readUnicodeString)(e),k=co(Ic,(0,I.readUint32)(e)),x=(0,I.readInt32)(e),S=(0,I.readInt32)(e),A=(0,I.readInt32)(e),D=(0,I.readInt32)(e),C=(0,I.readUnicodeString)(e),O=(0,I.readUnicodeString)(e),E=(0,I.readUnicodeString)(e),L=(0,I.readUnicodeString)(e),M=!!(0,I.readUint8)(e),J=(0,I.readUnicodeString)(e),pe=co(fo,(0,I.readUint32)(e)),R=co(fo,(0,I.readUint32)(e)),ie=(0,I.readUint8)(e),he=(0,I.readUint8)(e),ce=(0,I.readUint8)(e),Ce=(0,I.readUint8)(e),W=ie+he+ce+Ce===0?"none":ie===0?"matte":"color";u.push({id:p,groupId:h,origin:m,associatedLayerId:y,name:g,target:O,message:E,altTag:L,cellTextIsHTML:M,cellText:J,horizontalAlignment:pe,verticalAlignment:R,type:k,url:C,bounds:{top:S,left:x,bottom:D,right:A},backgroundColorType:W,backgroundColor:{r:he,g:ce,b:Ce,a:ie}})}if(t()){let d=(0,z.readVersionAndDescriptor)(e),p=new Map;for(let h of u)p.has(h.id)||p.set(h.id,h);d.slices.forEach(h=>{let m=p.get(h.sliceID);m&&(m.topOutset=h.topOutset,m.leftOutset=h.leftOutset,m.bottomOutset=h.bottomOutset,m.rightOutset=h.rightOutset)})}}else if(o===7||o===8){let r=(0,z.readVersionAndDescriptor)(e);n.slices||(n.slices=[]),n.slices.push({groupName:(i=r.baseName)!==null&&i!==void 0?i:"",bounds:_c(r.bounds),slices:r.slices.map(s=>{var a;return Object.assign(Object.assign({},s["Nm "]?{name:s["Nm "]}:{}),{id:s.sliceID,groupId:s.groupID,associatedLayerId:(a=s.associatedLayer)!==null&&a!==void 0?a:0,origin:z.ESliceOrigin.decode(s.origin),type:z.ESliceType.decode(s.Type),bounds:_c(s.bounds),url:s.url,target:s.null,message:s.Msge,altTag:s.altTag,cellTextIsHTML:s.cellTextIsHTML,cellText:s.cellText,horizontalAlignment:z.ESliceHorzAlign.decode(s.horzAlign),verticalAlignment:z.ESliceVertAlign.decode(s.vertAlign),backgroundColorType:z.ESliceBGColorType.decode(s.bgColorType),backgroundColor:s.bgColor?{r:s.bgColor["Rd "],g:s.bgColor["Grn "],b:s.bgColor["Bl "],a:s.bgColor.alpha}:{r:0,g:0,b:0,a:0},topOutset:s.topOutset||0,leftOutset:s.leftOutset||0,bottomOutset:s.bottomOutset||0,rightOutset:s.rightOutset||0})})})}else throw new Error(`Invalid slices version (${o})`)},(e,n,t)=>{let{bounds:i,groupName:o,slices:r}=n.slices[t];(0,P.writeUint32)(e,6),(0,P.writeInt32)(e,i.top),(0,P.writeInt32)(e,i.left),(0,P.writeInt32)(e,i.bottom),(0,P.writeInt32)(e,i.right),(0,P.writeUnicodeString)(e,o),(0,P.writeUint32)(e,r.length);for(let a=0;a<r.length;a++){let l=r[a],{a:c,r:f,g:u,b:d}=l.backgroundColor;l.backgroundColorType==="none"?c=f=u=d=0:l.backgroundColorType==="matte"&&(c=0,f=u=d=255),(0,P.writeUint32)(e,l.id),(0,P.writeUint32)(e,l.groupId),(0,P.writeUint32)(e,Ac.indexOf(l.origin)),l.origin==="layer"&&(0,P.writeUint32)(e,l.associatedLayerId),(0,P.writeUnicodeString)(e,l.name||""),(0,P.writeUint32)(e,Ic.indexOf(l.type)),(0,P.writeInt32)(e,l.bounds.left),(0,P.writeInt32)(e,l.bounds.top),(0,P.writeInt32)(e,l.bounds.right),(0,P.writeInt32)(e,l.bounds.bottom),(0,P.writeUnicodeString)(e,l.url),(0,P.writeUnicodeString)(e,l.target),(0,P.writeUnicodeString)(e,l.message),(0,P.writeUnicodeString)(e,l.altTag),(0,P.writeUint8)(e,l.cellTextIsHTML?1:0),(0,P.writeUnicodeString)(e,l.cellText),(0,P.writeUint32)(e,fo.indexOf(l.horizontalAlignment)),(0,P.writeUint32)(e,fo.indexOf(l.verticalAlignment)),(0,P.writeUint8)(e,c),(0,P.writeUint8)(e,f),(0,P.writeUint8)(e,u),(0,P.writeUint8)(e,d)}let s={bounds:kc(i),slices:[]};r.forEach(a=>{let l=Object.assign(Object.assign({sliceID:a.id,groupID:a.groupId,origin:z.ESliceOrigin.encode(a.origin),Type:z.ESliceType.encode(a.type),bounds:kc(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:z.ESliceHorzAlign.encode(a.horizontalAlignment),vertAlign:z.ESliceVertAlign.encode(a.verticalAlignment),bgColorType:z.ESliceBGColorType.encode(a.backgroundColorType)});if(a.backgroundColorType==="color"){let{r:c,g:f,b:u,a:d}=a.backgroundColor;l.bgColor={"Rd ":c,"Grn ":f,"Bl ":u,alpha:d}}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,z.writeVersionAndDescriptor)(e,"","null",s,"slices")});j(1064,e=>e.pixelAspectRatio!==void 0,(e,n)=>{if((0,I.readUint32)(e)>2)throw new Error("Invalid pixelAspectRatio version");n.pixelAspectRatio={aspect:(0,I.readFloat64)(e)}},(e,n)=>{(0,P.writeUint32)(e,2),(0,P.writeFloat64)(e,n.pixelAspectRatio.aspect)});j(1041,e=>e.iccUntaggedProfile!==void 0,(e,n)=>{n.iccUntaggedProfile=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.iccUntaggedProfile?1:0)});j(1039,e=>e.iccProfile!==void 0,(e,n,t)=>{n.iccProfile=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.iccProfile)});j(1044,e=>e.idsSeedNumber!==void 0,(e,n)=>n.idsSeedNumber=(0,I.readUint32)(e),(e,n)=>(0,P.writeUint32)(e,n.idsSeedNumber));j(1038,e=>e.colorSamplers!==void 0&&!e.colorSamplers.some(n=>n.depth!==void 0),(e,n,t)=>{var i;let o=(0,I.readUint32)(e);if(o!==1)throw new Error(`Invalid color samplers version: ${o}`);if(!((i=n.colorSamplers)===null||i===void 0)&&i.some(s=>s.depth!==void 0))return(0,I.skipBytes)(e,t());let r=(0,I.readUint32)(e);n.colorSamplers=[];for(let s=0;s<r&&t()>=10;s++){let a=(0,I.readInt32)(e)/16,l=(0,I.readInt32)(e)/16,c=(0,I.readInt16)(e);n.colorSamplers.push({x:l,y:a,colorSpace:c})}},(e,n)=>{(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,n.colorSamplers.length);for(let t of n.colorSamplers)(0,P.writeInt32)(e,Math.round(t.y*16)),(0,P.writeInt32)(e,Math.round(t.x*16)),(0,P.writeInt16)(e,t.colorSpace)});j(1073,e=>e.colorSamplers!==void 0&&e.colorSamplers.some(n=>n.depth!==void 0),(e,n,t)=>{let i=(0,I.readUint32)(e);if(i<1||i>3)throw new Error(`Invalid color samplers version: ${i}`);let o=(0,I.readUint32)(e);n.colorSamplers=[];for(let r=0;r<o&&t()>=10;r++){let s=i===3?(0,I.readUint32)(e):i,a=s===1?(0,I.readInt32)(e)/16:(0,I.readFloat32)(e),l=s===1?(0,I.readInt32)(e)/16:(0,I.readFloat32)(e),c=(0,I.readInt16)(e),f=i>=2?(0,I.readInt16)(e):1;n.colorSamplers.push({x:l,y:a,colorSpace:c,depth:f})}},(e,n)=>{var t;(0,P.writeUint32)(e,3),(0,P.writeUint32)(e,n.colorSamplers.length);for(let i of n.colorSamplers)(0,P.writeUint32)(e,1),(0,P.writeInt32)(e,Math.round(i.y*16)),(0,P.writeInt32)(e,Math.round(i.x*16)),(0,P.writeInt16)(e,i.colorSpace),(0,P.writeInt16)(e,(t=i.depth)!==null&&t!==void 0?t:1)});j(1022,e=>e.quickMaskInfo!==void 0,(e,n)=>{let t=(0,I.readUint16)(e),i=!!(0,I.readUint8)(e);n.quickMaskInfo={channelId:t,initiallyEmpty:i}},(e,n)=>{(0,P.writeUint16)(e,n.quickMaskInfo.channelId),(0,P.writeUint8)(e,n.quickMaskInfo.initiallyEmpty?1:0)});j(1074,e=>e.measurementScale!==void 0,(e,n,t)=>{n.measurementScale=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.measurementScale)});j(1042,e=>e.effectsVisible!==void 0,(e,n)=>{n.effectsVisible=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.effectsVisible?1:0)});j(1036,e=>e.thumbnail!==void 0||e.thumbnailRaw!==void 0,(e,n,t)=>{let i=(0,I.readUint32)(e),o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e);(0,I.readUint32)(e),(0,I.readUint32)(e);let a=(0,I.readUint16)(e);if((0,I.readUint16)(e),i===0&&a===24&&s>=o*3&&s*r<=t()){if(e.useRawThumbnail){e.logMissingFeatures&&e.log("Raw thumbnail data is not supported with useRawThumbnail option"),(0,I.skipBytes)(e,t());return}let f=(0,I.readBytes)(e,s*r),u=(0,cn.createImageData)(o,r);for(let d=0,p=0;d<r;d++)for(let h=0,m=d*s;h<o;h++,m+=3,p+=4)u.data[p+0]=f[m+0],u.data[p+1]=f[m+1],u.data[p+2]=f[m+2],u.data[p+3]=255;n.thumbnail=(0,cn.imageDataToCanvas)(u),(0,I.skipBytes)(e,t());return}if(i!==1||a!==24){e.logMissingFeatures&&e.log(`Invalid thumbnail data (format: ${i}, bitsPerPixel: ${a})`),(0,I.skipBytes)(e,t());return}let l=t(),c=(0,I.readBytes)(e,l);e.useRawThumbnail?n.thumbnailRaw={width:o,height:r,data:c}:c.byteLength&&(n.thumbnail=(0,cn.createCanvasFromData)(c,e))},(e,n)=>{var t;let i=0,o=0,r=new Uint8Array(0);if(n.thumbnailRaw)i=n.thumbnailRaw.width,o=n.thumbnailRaw.height,r=n.thumbnailRaw.data;else try{let u=(t=n.thumbnail.toDataURL("image/jpeg",1))===null||t===void 0?void 0:t.substring(23);u&&(r=(0,Ch.toByteArray)(u),i=n.thumbnail.width,o=n.thumbnail.height)}catch{}let s=24,a=Math.floor((i*s+31)/32)*4,l=1,c=a*o*l,f=r.length;(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,i),(0,P.writeUint32)(e,o),(0,P.writeUint32)(e,a),(0,P.writeUint32)(e,c),(0,P.writeUint32)(e,f),(0,P.writeUint16)(e,s),(0,P.writeUint16)(e,l),(0,P.writeBytes)(e,r)});j(1057,e=>e.versionInfo!==void 0,(e,n,t)=>{if((0,I.readUint32)(e)!==1)throw new Error("Invalid versionInfo version");n.versionInfo={hasRealMergedData:!!(0,I.readUint8)(e),writerName:(0,I.readUnicodeString)(e),readerName:(0,I.readUnicodeString)(e),fileVersion:(0,I.readUint32)(e)},(0,I.skipBytes)(e,t())},(e,n)=>{let t=n.versionInfo;(0,P.writeUint32)(e,1),(0,P.writeUint8)(e,t.hasRealMergedData?1:0),(0,P.writeUnicodeString)(e,t.writerName),(0,P.writeUnicodeString)(e,t.readerName),(0,P.writeUint32)(e,t.fileVersion)});j(1058,e=>e.exifData!==void 0,(e,n,t)=>{n.exifData=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.exifData)});j(7e3,e=>e.imageReadyVariables!==void 0,(e,n,t)=>{n.imageReadyVariables=Vr(e,t())},(e,n)=>{Nr(e,n.imageReadyVariables)});j(7001,e=>e.imageReadyDataSets!==void 0,(e,n,t)=>{n.imageReadyDataSets=Vr(e,t())},(e,n)=>{Nr(e,n.imageReadyDataSets)});j(1088,e=>e.pathSelectionState!==void 0,(e,n,t)=>{let i=(0,z.readVersionAndDescriptor)(e);n.pathSelectionState=i.null},(e,n)=>{let t={null:(0,z.pathSelectionStateToReference)(n.pathSelectionState)};(0,z.writeVersionAndDescriptor)(e,"","null",t)});j(1025,e=>e.workPath!==void 0,(e,n,t,{width:i,height:o})=>{n.workPath={paths:[]},(0,Fn.readVectorMask)(e,n.workPath,i,o,t()),(0,I.skipBytes)(e,t())},(e,n,t,{width:i,height:o})=>{(0,Fn.writeVectorMask)(e,n.workPath,i,o)});var $r=999;j(2e3,e=>e.savedPaths?Math.min(e.savedPaths.length,$r):0,(e,n,t,{signature:i,id:o,name:r,width:s,height:a})=>{var l,c;if(i!=="8BIM"){e.logMissingFeatures&&e.log(`Unhandled image resource: ${i} ${o}`),(0,I.skipBytes)(e,t());return}let f=(l=n.savedPaths)!==null&&l!==void 0?l:n.savedPaths=[],u={name:Ec(e,r),paths:[]};(0,Fn.readVectorMask)(e,u,s,a,t()),(0,I.skipBytes)(e,t());let d=(c=n.savedPathsOrigination)===null||c===void 0?void 0:c[f.length];d&&(u.vectorOrigination={keyDescriptorList:d}),f.push(u)},(e,n,t,{width:i,height:o})=>{(0,Fn.writeVectorMask)(e,n.savedPaths[t],i,o)},{keyCount:$r,name:(e,n)=>Fc(e.savedPaths[n].name)});j(3e3,e=>{var n;return!!(!((n=e.savedPaths)===null||n===void 0)&&n.some(t=>t.vectorOrigination))},(e,n,t)=>{(0,z.readVersionAndDescriptor)(e).keyRootDescriptorList.forEach((o,r)=>{var s,a;let l=(0,Fn.parseKeyDescriptorList)(o);if(!l.length)return;let c=(s=n.savedPaths)===null||s===void 0?void 0:s[r];c?c.vectorOrigination={keyDescriptorList:l}:((a=n.savedPathsOrigination)!==null&&a!==void 0?a:n.savedPathsOrigination=[])[r]=l}),(0,I.skipBytes)(e,t())},(e,n)=>{let t={keyRootDescriptorList:n.savedPaths.slice(0,$r).map(i=>{var o,r;return(0,Fn.serializeKeyDescriptorList)((r=(o=i.vectorOrigination)===null||o===void 0?void 0:o.keyDescriptorList)!==null&&r!==void 0?r:[])})};(0,z.writeVersionAndDescriptor)(e,"","null",t)},{name:()=>"OriginDataIRB"});j(2999,e=>e.clippingPath!==void 0,(e,n,t)=>{let i=Oc(e),o=(0,I.readFixedPoint32)(e);(0,I.skipBytes)(e,t()),n.clippingPath={name:i,flatness:o}},(e,n)=>{Lc(e,n.clippingPath.name),(0,P.writeFixedPoint32)(e,n.clippingPath.flatness),(0,P.writeUint16)(e,1)});var Cc=(0,cn.createEnum)("FrmD","auto",{auto:"Auto",none:"None",dispose:"Disp"});function Pc(e){let n=[];return e.outputSettings!==void 0&&n.push("mset"),e.animations!==void 0&&n.push("mani","mfri"),n}j(4e3,e=>Pc(e).length,(e,n,t)=>{let i=(0,I.readSignature)(e);if(i==="mset")n.outputSettings=(0,z.readVersionAndDescriptor)(e,!0),(0,I.skipBytes)(e,t());else if(i==="mfri")(0,I.skipBytes)(e,t());else if(i==="mani")(0,I.checkSignature)(e,"IRFR"),(0,I.readSection)(e,1,o=>{for(;o()>0;){(0,I.checkSignature)(e,"8BIM");let r=(0,I.readSignature)(e);(0,I.readSection)(e,1,s=>{if(r==="AnDs"){let a=(0,z.readVersionAndDescriptor)(e);n.animations={frames:a.FrIn.map(l=>{let c={id:l.FrID,delay:(l.FrDl||0)/100,dispose:l.FrDs?Cc.decode(l.FrDs):"auto"};return l.FrGA!==void 0&&(c.globalAngle=l.FrGA),l.FrGL!==void 0&&(c.globalAltitude=l.FrGL),c}),animations:a.FSts.map(l=>({id:l.FsID,frames:l.FsFr,repeats:l.LCnt,activeFrame:l.AFrm||0}))},a.AFSt!==void 0&&(n.animations.activeAnimation=a.AFSt),(0,I.skipBytes)(e,s())}else if(r==="Roll"){let a=(0,I.readBytes)(e,s());e.logDevFeatures&&e.log("#4000 Roll",a)}else e.logMissingFeatures&&e.log("Unhandled subsection in #4000",r),(0,I.skipBytes)(e,s())})}}),(0,I.skipBytes)(e,t());else if(i==="mopt"){let o=(0,I.readBytes)(e,t());e.logDevFeatures&&e.log("#4000 mopt",o)}else e.logMissingFeatures&&e.log(`Unhandled plug-in resource key: ${i}`),(0,I.skipBytes)(e,t())},(e,n,t)=>{var i,o;let r=Pc(n)[t];if(r==="mset")(0,P.writeSignature)(e,"mset"),(0,z.writeVersionAndDescriptor)(e,"","null",n.outputSettings,z.outputSettingsRoot);else if(r==="mfri"){let s=n.animations;(0,P.writeSignature)(e,"mfri"),(0,P.writeUint32)(e,2),(0,P.writeUint32)(e,16),(0,P.writeUint32)(e,s.frames.length),(0,P.writeUint32)(e,(o=(i=s.animations[0])===null||i===void 0?void 0:i.activeFrame)!==null&&o!==void 0?o:0),(0,P.writeUint32)(e,s.animations.length),(0,P.writeUint32)(e,0)}else r==="mani"&&((0,P.writeSignature)(e,"mani"),(0,P.writeSignature)(e,"IRFR"),(0,P.writeSection)(e,1,()=>{(0,P.writeSignature)(e,"8BIM"),(0,P.writeSignature)(e,"AnDs"),(0,P.writeSection)(e,1,()=>{let s=Object.assign(Object.assign({},n.animations.activeAnimation!==void 0?{AFSt:n.animations.activeAnimation}:{}),{FrIn:[],FSts:[]});for(let a=0;a<n.animations.frames.length;a++){let l=n.animations.frames[a],c={FrID:l.id};l.delay&&(c.FrDl=Math.round(l.delay*100)),c.FrDs=Cc.encode(l.dispose),l.globalAngle!==void 0&&(c.FrGA=l.globalAngle),l.globalAltitude!==void 0&&(c.FrGL=l.globalAltitude),s.FrIn.push(c)}for(let a=0;a<n.animations.animations.length;a++){let l=n.animations.animations[a],c={FsID:l.id,AFrm:l.activeFrame|0,FsFr:l.frames,LCnt:l.repeats|0};s.FSts.push(c)}(0,z.writeVersionAndDescriptor)(e,"","null",s)}),(0,P.writeSignature)(e,"8BIM"),(0,P.writeSignature)(e,"Roll"),(0,P.writeSection)(e,1,()=>{(0,P.writeZeros)(e,8)})}))},{keyCount:1e3})});var st=ae(N=>{"use strict";var Uh=N&&N.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(N,"__esModule",{value:!0});N.supportedColorModes=void 0;N.getUtf8Decoder=Nc;N.getUtf8StrictDecoder=zh;N.getGbkStrictDecoder=$h;N.decodeUtf8=Vh;N.createReader=gi;N.warnOrThrow=qt;N.readUint8=ve;N.peekUint8=Gc;N.readInt16=Xt;N.readUint16=de;N.readUint16LE=Nh;N.readInt32=Re;N.readInt32LE=Gh;N.readUint32=we;N.readFloat32=Hh;N.readFloat64=es;N.readFixedPoint32=Wh;N.readFixedPointPath32=Xh;N.readBytes=xt;N.readSignature=mi;N.validSignatureAt=Hc;N.readPascalString=ss;N.readUnicodeString=Wc;N.readUnicodeStringWithLength=Kc;N.readUnicodeStringWithLengthLE=qh;N.readAsciiString=Zh;N.skipBytes=_e;N.checkSignature=ls;N.readPsd=Yh;N.readLayerInfo=Jc;N.getCompositeImageData=ef;N.getCompositeCanvas=ig;N.getLayerImageData=tf;N.getLayerMaskImageData=nf;N.getLayerRealMaskImageData=of;N.getLayerCanvas=og;N.getLayerMaskCanvas=rg;N.getLayerRealMaskCanvas=sg;N.getFilterEffectsMaskImageData=rf;N.getFilterEffectsMaskExtraImageData=sf;N.getFilterEffectsMaskCanvas=ag;N.getFilterEffectsMaskExtraCanvas=lg;N.decodeLayerPixels=cg;N.readGlobalLayerMaskInfo=lf;N.readAdditionalLayerInfo=cs;N.readDataZip=os;N.readDataRLE=yi;N.readSection=at;N.readColor=wg;N.readPatternSafe=vg;N.readPattern=pf;N.consumeMemory=Mn;var Bh=Gi(),Te=Ot(),Rh=di(),Th=Mr(),Tc=qr();N.supportedColorModes=[0,1,3,2,4];var jh=["bitmap","grayscale","indexed","RGB","CMYK","","","multichannel","duotone","lab"];function pi(e){let n=e.width*e.height*4;for(let t=0;t<n;t+=4){let i=e.data[t];e.data[t+1]=i,e.data[t+2]=i}}function rs(e,n){try{return typeof TextDecoder<"u"?new TextDecoder(e,n):null}catch{return null}}function Nc(e){return e.utf8Decoder===void 0&&(e.utf8Decoder=rs("utf-8",{ignoreBOM:!0})),e.utf8Decoder}function zh(e){return e.utf8StrictDecoder===void 0&&(e.utf8StrictDecoder=rs("utf-8",{ignoreBOM:!0,fatal:!0})),e.utf8StrictDecoder}function $h(e){return e.gbkDecoder===void 0&&(e.gbkDecoder=rs("gbk",{fatal:!0})),e.gbkDecoder}function Vh(e,n){let t=n.byteLength>1e3?Nc(e):null;return t?t.decode(n):(0,Th.decodeString)(n)}function gi(e,n,t){return{view:new DataView(e,n,t),offset:0,strict:!1,debug:!1,large:!1,globalAlpha:!1,log:console.log}}function qt(e,n){if(e.strict)throw new Error(n);e.debug&&e.log(n)}function ve(e){return e.offset+=1,e.view.getUint8(e.offset-1)}function Gc(e){return e.view.getUint8(e.offset)}function Xt(e){return e.offset+=2,e.view.getInt16(e.offset-2,!1)}function de(e){return e.offset+=2,e.view.getUint16(e.offset-2,!1)}function Nh(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 Gh(e){return e.offset+=4,e.view.getInt32(e.offset-4,!0)}function we(e){return e.offset+=4,e.view.getUint32(e.offset-4,!1)}function Hh(e){return e.offset+=4,e.view.getFloat32(e.offset-4,!1)}function es(e){return e.offset+=8,e.view.getFloat64(e.offset-8,!1)}function Wh(e){return Re(e)/65536}function Xh(e){return Re(e)/(1<<24)}function xt(e,n){if(!(n>=0))throw new Error(`Invalid length: ${n}`);let t=e.offset,i=e.view.byteLength;if(e.offset+=n,t+n>i){if(qt(e,"Reading bytes exceeding buffer length"),n>100*1024*1024)throw new Error("Reading past end of file");Mn(e,n);let o=new Uint8Array(n),r=Math.min(n,i-t);return r>0&&o.set(new Uint8Array(e.view.buffer,e.view.byteOffset+t,r)),o}else return new Uint8Array(e.view.buffer,e.view.byteOffset+t,n)}function mi(e){return Yc(e,4)}function Hc(e,n){let t=String.fromCharCode(e.view.getUint8(n))+String.fromCharCode(e.view.getUint8(n+1))+String.fromCharCode(e.view.getUint8(n+2))+String.fromCharCode(e.view.getUint8(n+3));return t=="8BIM"||t=="8B64"}function ss(e,n){let t=ve(e),i=t?Yc(e,t):"";for(;++t%n;)e.offset++;return i}function Wc(e){let n=we(e);return Kc(e,n)}var ui=8192,as=64;function Xc(e,n){if(e.offset<0||e.offset+n>e.view.byteLength)throw new RangeError("Offset is outside the bounds of the DataView")}function qc(e,n,t){if(!(n>0))return"";Xc(e,n*2);let i=e.view,o=e.offset,r="";if(n<=as){for(let a=0;a<n;a++,o+=2)r+=String.fromCharCode(i.getUint16(o,t));return e.offset=o,r.charCodeAt(r.length-1)===0&&(r=r.substring(0,r.length-1)),r}let s=new Uint16Array(Math.min(n,ui));for(let a=0;a<n;a+=ui){let l=Math.min(ui,n-a);for(let c=0;c<l;c++,o+=2)s[c]=i.getUint16(o,t);r+=String.fromCharCode.apply(null,l===s.length?s:s.subarray(0,l))}return e.offset=o,r.charCodeAt(r.length-1)===0&&(r=r.substring(0,r.length-1)),r}function Zc(e){let n="";for(let t=0;t<e.length;t+=ui)n+=String.fromCharCode.apply(null,e.subarray(t,t+ui));return n}function Kc(e,n){return qc(e,n,!1)}function qh(e,n){return qc(e,n,!0)}function Zh(e,n){if(!(n>0))return"";if(Xc(e,n),n<=as){let i=e.view,o="";for(let r=0,s=e.offset;r<n;r++,s++)o+=String.fromCharCode(i.getUint8(s));return e.offset+=n,o}let t=Zc(new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,n));return e.offset+=n,t}function _e(e,n){e.offset+=n}function ls(e,n,t){let i=e.offset,o=mi(e);if(o!==n&&o!==t)throw new Error(`Invalid signature: '${o}' at 0x${i.toString(16)}`)}function Yc(e,n){let t=xt(e,n);if(n>as)return Zc(t);let i="";for(let o=0;o<t.length;o++)i+=String.fromCharCode(t[o]);return i}function Kh(e){return e==="8BIM"||e==="MeSa"||e==="AgHg"||e==="PHUT"||e==="DCSR"}function Yh(e,n={}){var t;ls(e,"8BPS");let i=de(e);if(i!==1&&i!==2)throw new Error(`Invalid PSD file version: ${i}`);_e(e,6);let o=de(e),r=we(e),s=we(e),a=de(e),l=de(e),c=i===1?3e4:3e5;if(s>c||r>c)throw new Error(`Invalid size: ${s}x${r}`);if(o<1||o>57)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: ${(t=jh[l])!==null&&t!==void 0?t:l}`);let f={width:s,height:r,channels:o,bitsPerChannel:a,colorMode:l};Object.assign(e,n),e.large=i===2,e.globalAlpha=!1,e.layersInGlobalInfo=!1;let u=e.imageResourcesWhitelist;e.imageResourcesWhitelistSet=u?u instanceof Set?u:new Set(u):void 0,"totalMemoryLimit"in e||(e.totalMemoryLimit=2*1024*1024*1024),at(e,1,S=>{if(S()){if(l===2){if(S()!=768)throw new Error("Invalid color palette size");f.palette=[];for(let A=0;A<256;A++)f.palette.push({r:ve(e),g:0,b:0});for(let A=0;A<256;A++)f.palette[A].g=ve(e);for(let A=0;A<256;A++)f.palette[A].b=ve(e)}_e(e,S())}});let d={},p=0;at(e,1,S=>{for(;S()>=12;){let A=cf(e,Kh),D=de(e),C=ve(e),O=xt(e,C);_e(e,(C+1)%2),at(e,2,E=>{let L=Tc.resourceHandlersMap[D];if(L)if(D===1036&&!!e.skipThumbnail||!(0,Tc.shouldReadResource)(L,e.imageResourcesWhitelistSet))_e(e,E());else try{L.read(e,d,E,{signature:A,id:D,name:O,width:s,height:r})}catch(J){if(e.throwForMissingFeatures)throw J;_e(e,E())}else e.logMissingFeatures&&e.log(`Unhandled image resource: ${D} (${E()})`),_e(e,E())})}p=S(),_e(e,S())}),p&&!jc(e,e.offset)&&jc(e,e.offset-p)&&(e.offset-=p);let{layersGroup:h,layerGroupsEnabledId:m,savedPathsOrigination:y}=d,g=Uh(d,["layersGroup","layerGroupsEnabledId","savedPathsOrigination"]);Object.keys(g).length&&(f.imageResources=g),at(e,1,S=>{if(at(e,2,A=>{Jc(e,f,d),_e(e,A())},void 0,e.large),S()>0){let A=lf(e);A&&(f.globalLayerMaskInfo=A)}else _e(e,S());for(;S()>0;){for(;S()&&Gc(e)===0;)_e(e,1);S()>=12?cs(e,f,f,d):_e(e,S())}},void 0,e.large);let k=f.children&&f.children.length;if(!(e.skipCompositeImageData&&(e.skipLayerImageData||k)))if(e.useRawData){let S=Math.min(e.offset,e.view.byteLength),A=new Uint8Array(e.view.buffer,e.view.byteOffset+S,e.view.byteLength-S);f.rawCompositeData=A,f.rawCompositeDataInfo={large:e.large,globalAlpha:e.globalAlpha},e.layersInGlobalInfo&&(f.rawCompositeDataInfo.layersInGlobalInfo=!0)}else{let S=ff(e,f);e.useImageData?f.imageData=S:f.canvas=(0,Te.imageDataToCanvas)(S)}return f}function Jc(e,n,t){var i,o;let{layersGroup:r=[],layerGroupsEnabledId:s=[]}=t,a=Xt(e);a<0&&(e.globalAlpha=!0,a=-a);let l=[],c=[];for(let u=0;u<a;u++){let{layer:d,channels:p}=Jh(e,n,t);r[u]!==void 0&&(d.linkGroup=r[u]),s[u]!==void 0&&(d.linkGroupEnabled=!!s[u]),l.push(d),c.push(p)}for(let u=0;u<a;u++)ng(e,n,l[u],c[u]);n.children||(n.children=[]);let f=[n];for(let u=l.length-1;u>=0;u--){let d=l[u],p=d.sectionDivider?d.sectionDivider.type:0;p===1||p===2?(d.opened=p===1,d.children=[],delete d.canvas,delete d.imageData,!((i=d.sectionDivider)===null||i===void 0)&&i.key&&(d.blendMode=(o=Te.toBlendMode[d.sectionDivider.key])!==null&&o!==void 0?o:d.blendMode),f[f.length-1].children.unshift(d),f.push(d)):p===3?f.length>1&&f.pop():f[f.length-1].children.unshift(d)}}function Jh(e,n,t){let i={};if(i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!ts(i,e))throw new Error("Invalid layer size");let o=de(e),r=[];for(let l=0;l<o;l++){let c=Xt(e),f=we(e);if(e.large){if(f!==0)throw new Error("Sizes larger than 4GB are not supported");f=we(e)}r.push({id:c,length:f})}ls(e,"8BIM");let s=mi(e);if(!Te.toBlendMode[s]){if(e.throwForMissingFeatures)throw new Error(`Invalid blend mode: '${s}'`);e.logMissingFeatures&&e.log(`Unknown blend mode: '${s}', using normal blend mode`)}i.blendMode=Te.toBlendMode[s]||"normal",i.opacity=ve(e)/255,i.clipping=ve(e)===1;let a=ve(e);return i.transparencyProtected=(a&1)!==0,i.hidden=(a&2)!==0,a&32&&(i.effectsOpen=!0),_e(e,1),at(e,1,l=>{Qh(e,i);let c=tg(e);for(c&&(i.blendingRanges=c),i.name=ss(e,1);l()>4&&!Hc(e,e.offset);)e.offset++;for(;l()>=12;)cs(e,i,n,t);_e(e,l())}),{layer:i,channels:r}}function jc(e,n){let t=e.large?8:4;if(n<0||n+t>e.view.byteLength)return!1;let i=e.large?e.view.getUint32(n)*4294967296+e.view.getUint32(n+4):e.view.getUint32(n);return n+t+i<=e.view.byteLength}function ts(e,n){let t=(e.right||0)-(e.left||0),i=(e.bottom||0)-(e.top||0),o=n.large?3e5:3e4;return t<=o&&i<=o}function Qh(e,n){return at(e,1,t=>{if(!t())return;let i={};if(n.mask=i,i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!ts(i,e))throw new Error("Invalid mask size");i.defaultColor=ve(e);let o=ve(e);if(i.positionRelativeToLayer=(o&1)!==0,i.disabled=(o&2)!==0,i.fromVectorData=(o&8)!==0,eg(e,o,t())){let r={};n.realMask=r;let s=ve(e);if(r.positionRelativeToLayer=(s&1)!==0,r.disabled=(s&2)!==0,r.fromVectorData=(s&8)!==0,r.defaultColor=ve(e),r.top=Re(e),r.left=Re(e),r.bottom=Re(e),r.right=Re(e),!ts(r,e))throw new Error("Invalid realMask size")}if(o&16){let r=ve(e);r&1&&(i.userMaskDensity=ve(e)/255),r&2&&(i.userMaskFeather=es(e)),r&4&&(i.vectorMaskDensity=ve(e)/255),r&8&&(i.vectorMaskFeather=es(e))}_e(e,t())})}function Qc(e){return 1+(e&1?1:0)+(e&2?8:0)+(e&4?1:0)+(e&8?8:0)}function zc(e,n,t){if(t<1)return!1;let i=e.getUint8(n);if(i===0||i&-16)return!1;let o=Qc(i);if(t<o||t-o>3)return!1;for(let r=o;r<t;r++)if(e.getUint8(n+r)!==0)return!1;return!0}function eg(e,n,t){if(t<18)return!1;if(!(n&16))return!0;let{view:i,offset:o}=e;return zc(i,o,t)?!1:zc(i,o+18,t-18)?!0:t===18||t-18>=Qc(i.getUint8(o+18))}function uo(e){return[ve(e),ve(e),ve(e),ve(e)]}function tg(e){return at(e,1,n=>{let t=uo(e),i=uo(e),o=[];for(;n()>0;){let r=uo(e),s=uo(e);o.push({sourceRange:r,destRange:s})}return{compositeGrayBlendSource:t,compositeGraphBlendDestinationRange:i,ranges:o}})}function ng(e,n,t,i){if(e.skipLayerImageData)return;let{colorMode:o=3,bitsPerChannel:r=8}=n;t.rawData={colorMode:o,bitsPerChannel:r,channels:[],large:e.large};for(let s of i){let a=e.offset,l=0,c;if(s.length>=2){if(l=de(e),l>3&&(e.offset-=1,l=de(e)),l>3&&(e.offset-=4,l=de(e)),l>3)throw new Error(`Invalid compression: ${l}`);s.length>2&&(c=xt(e,s.length-2))}e.offset=a+s.length,t.rawData.channels.push({id:s.id,compression:l,data:c})}if(!e.useRawData)try{af(t,e)}catch(s){if(e.throwForMissingFeatures||s.message==="Exceeded memory limit")throw s;e.logMissingFeatures&&e.log(`Failed to decode layer image data: ${s.message}`),delete t.rawData}}function hi({data:e},n){let t=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255,i=(n?4:3)|0,o=e.length|0,r=(n?5:4)|0;for(let s=i;s<o;s=s+r|0)e[s]=t}function ef(e){let n=e.rawCompositeData;if(!n)return;let t=gi(n.buffer,n.byteOffset,n.byteLength),i=e.rawCompositeDataInfo;return i&&(t.large=i.large,t.globalAlpha=i.globalAlpha,t.layersInGlobalInfo=!!i.layersInGlobalInfo),ff(t,e)}function ig(e){return Un(ef(e))}function tf(e){return Ln(e,qe.Layer,!1,void 0)}function nf(e){return Ln(e,qe.Mask,!1,void 0)}function of(e){return Ln(e,qe.RealMask,!1,void 0)}function og(e){return Un(tf(e))}function rg(e){return Un(nf(e))}function sg(e){return Un(of(e))}function rf(e){let{depth:n,channels:t,colorMode:i=3}=e,o=Math.max(0,e.right-e.left),r=Math.max(0,e.bottom-e.top);if(!o||!r)return;let s=i===4;if(s&&n!==8&&n!==16)throw new Error("bitsPerChannel not supported");let a=s?5:4,l=t.length-1,c=Math.min(s?4:i===1?1:3,t.length-2),f=Ft(o,r,n,a,void 0);for(let u=0;u<t.length;u++){let d=t[u];d&&(u<c?ns(d,f,o,r,n,u,a):u===l&&ns(d,f,o,r,n,a-1,a))}if(i===1&&pi(f),t[l]||hi(f,s),s){let u=f;f=Ft(u.width,u.height,n,4,void 0),ho(u,f,!1)}return f}function sf(e){let{extra:n,depth:t}=e;if(!n)return;let i=Math.max(0,n.right-n.left),o=Math.max(0,n.bottom-n.top);if(!i||!o)return;let r=Ft(i,o,t,4,void 0);return ns(n,r,i,o,t,0,4),pi(r),hi(r,!1),r}function ag(e){return Un(rf(e))}function lg(e){return Un(sf(e))}function ns({compressionMode:e,data:n},t,i,o,r,s,a){let l=gi(n.buffer,n.byteOffset,n.byteLength);is(l,n.byteLength,t,e,i,o,r,s,!0,a)}function Un(e){return e&&(0,Te.imageDataToCanvas)(e)}function Zr(e,n,t){n&&(t?e.imageData=n:e.canvas=(0,Te.imageDataToCanvas)(n))}function cg(e,n){af(e,{useImageData:n})}function af(e,n){var t,i,o;let{throwForMissingFeatures:r,useImageData:s}=n,a=Ln(e,qe.Layer,r,n.totalMemoryLimit,n);if(Zr(e,a,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(t=a?.data.byteLength)!==null&&t!==void 0?t:0),e.mask){let l=Ln(e,qe.Mask,r,n.totalMemoryLimit,n);Zr(e.mask,l,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(i=l?.data.byteLength)!==null&&i!==void 0?i:0)}if(e.realMask){let l=Ln(e,qe.RealMask,r,n.totalMemoryLimit,n);Zr(e.realMask,l,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(o=l?.data.byteLength)!==null&&o!==void 0?o:0)}delete e.rawData}var qe;(function(e){e[e.Layer=0]="Layer",e[e.Mask=1]="Mask",e[e.RealMask=2]="RealMask"})(qe||(qe={}));function Ln(e,n,t,i,o){var r;if(!e.rawData)return;let{colorMode:s,bitsPerChannel:a,channels:l,large:c}=e.rawData,f=Math.max(0,(e.right||0)-(e.left||0)),u=Math.max(0,(e.bottom||0)-(e.top||0)),d=s===4,p,h,m=!1;if(f&&u&&n===qe.Layer)if(d){if(a!==8&&a!==16)throw new Error("bitsPerChannel not supported");p=Ft(f,u,a,5,i)}else p=Ft(f,u,a,4,i);for(let{id:y,compression:g,data:k}of l){if(!k)continue;let x=gi(k.buffer,k.byteOffset,k.byteLength);if(x.debug=!!o?.debug,o?.log&&(x.log=o.log),i!==void 0&&(x.totalMemoryLimit=Math.max(0,i-((r=p?.data.byteLength)!==null&&r!==void 0?r:0))),y===-2||y===-3){if(y===-2&&n!==qe.Mask||y===-3&&n!==qe.RealMask)continue;let S=y===-2?e.mask:e.realMask;if(!S)throw new Error(`Missing layer ${y===-2?"mask":"real mask"} data`);let A=Math.max(0,(S.right||0)-(S.left||0)),D=Math.max(0,(S.bottom||0)-(S.top||0));A&&D&&(h=Ft(A,D,a,4,i),i!==void 0&&(x.totalMemoryLimit=Math.max(0,x.totalMemoryLimit-h.data.byteLength)),is(x,k.byteLength,h,g,A,D,a,0,c,4),pi(h),hi(h,!1))}else{if(n!==qe.Layer)continue;let S=(0,Te.offsetForChannel)(y,d),A=p;if(S<0&&(A=void 0,t))throw new Error(`Channel not supported: ${y}`);is(x,k.byteLength,A,g,f,u,a,S,c,d?5:4)}y===-1&&(m=!0)}if(p&&(s===1&&pi(p),m||hi(p,d),d)){let y=p,g=i===void 0?void 0:Math.max(0,i-y.data.byteLength);p=Ft(y.width,y.height,a,4,g),ho(y,p,!1)}return n===qe.Layer?p:h}function is(e,n,t,i,o,r,s,a,l,c){if(n)if(i===0){n!==o*r*Math.floor(s/8)&&qt(e,`Invalid length (${n}, ${o*r*Math.floor(s/8)})`);let f=xt(e,n);df(f,t,s,c,a)}else if(i===1)yi(e,t,o,r,s,c,[a],l);else if(i===2){let f=xt(e,n);os(f,t,o,r,s,c,a,!1,e)}else if(i===3){let f=xt(e,n);os(f,t,o,r,s,c,a,!0,e)}else throw new Error(`Invalid Compression type: ${i}`)}function lf(e){return at(e,1,n=>{if(!n())return;let t=de(e),i=de(e),o=de(e),r=de(e),s=de(e),a=Math.min(de(e),100)/100,l=ve(e);return _e(e,n()),{overlayColorSpace:t,colorSpace1:i,colorSpace2:o,colorSpace3:r,colorSpace4:s,opacity:a,kind:l}})}var fg=[0,1,-1,2,-2,3,-3,4,-4];function cf(e,n){let t=e.offset,i="";for(let o of fg){try{e.offset=t+o,i=mi(e)}catch{}if(n(i))break}if(!n(i))throw new Error(`Invalid signature: '${i}' at 0x${t.toString(16)}`);return i}function dg(e){return e==="8BIM"||e==="8B64"}function cs(e,n,t,i){let o=cf(e,dg),r=mi(e),s=o==="8B64"||e.large&&Te.largeAdditionalInfoKeys.indexOf(r)!==-1;if(e.large&&o==="8BIM"&&Te.largeAdditionalInfoKeysObserved.indexOf(r)!==-1){let a=e.offset+8<=e.view.byteLength?e.view.getUint32(e.offset+4):0,l=a===943868237||a===943863348;s=e.view.getUint32(e.offset)===0&&!l}at(e,2,a=>{let l=Rh.infoHandlersMap[r];l?l.read(e,n,a,t,i):(e.logMissingFeatures&&r!=="GenI"&&r!=="OCIO"&&r!=="CAI "&&e.log(`Unhandled additional info: ${r}`),_e(e,a())),a()&&(e.logMissingFeatures&&e.log(`Unread ${a()} bytes left for additional info: ${r}`),_e(e,a()))},!1,s)}function Ft(e,n,t,i,o){let r=e*n*i*Math.max(1,t/8);if(o!==void 0&&r>o)throw new Error("Exceeded memory limit");if(t===1||t===8)return i===4?(0,Te.createImageData)(e,n):{width:e,height:n,data:new Uint8ClampedArray(e*n*i)};if(t===16)return{width:e,height:n,data:new Uint16Array(e*n*i)};if(t===32)return{width:e,height:n,data:new Float32Array(e*n*i)};throw new Error(`Invalid bitDepth (${t})`)}function ff(e,n){var t,i,o;let r=de(e),s=(t=n.bitsPerChannel)!==null&&t!==void 0?t:8,{width:a,height:l}=n;if(N.supportedColorModes.indexOf(n.colorMode)===-1)throw new Error(`Color mode not supported: ${n.colorMode}`);if(r!==0&&r!==1)throw new Error(`Compression type not supported: ${r}`);let c=Ft(a,l,s,4,e.totalMemoryLimit);switch(e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit-=c.data.byteLength),(0,Te.resetImageData)(c),n.colorMode){case 0:{if(s!==1)throw new Error("Invalid bitsPerChannel for bitmap color mode");let f=Math.ceil(a/8),u;r===0?u=xt(e,f*l):(u=new Uint8Array(f*l),yi(e,{data:u,width:f,height:l},f,l,8,1,[0],e.large)),(0,Te.decodeBitmap)(u,c.data,a,l);break}case 3:case 1:{let f=n.colorMode===1?1:3,u=Kr(e,n,f,3);Yr(e,r,c,s,4,u),n.colorMode===1&&pi(c);break}case 2:{if(s!==8)throw new Error("bitsPerChannel not supported");if(!n.palette)throw new Error("Missing color palette");let f=Kr(e,n,1,-1),u={width:a,height:l,data:new Uint8Array(a*l)};Yr(e,r,u,8,1,f),pg(u,c,n.palette,(o=(i=n.imageResources)===null||i===void 0?void 0:i.transparencyIndex)!==null&&o!==void 0?o:-1);break}case 4:{if(s!==8&&s!==16)throw new Error("bitsPerChannel not supported");let f=Kr(e,n,4,4),u=Ft(a,l,s,5,e.totalMemoryLimit);hi(u,!0),Yr(e,r,u,s,5,f),ho(u,c,!!e.globalAlpha);break}default:throw new Error(`Color mode not supported: ${n.colorMode}`)}return e.globalAlpha&&n.colorMode!==4&&ug(c),c}function Kr(e,n,t,i){var o,r,s;let a=(o=n.channels)!==null&&o!==void 0?o:t+(e.globalAlpha?1:0);if(a<t)throw new Error(`Invalid channel count: ${a}`);let l=(s=(r=n.imageResources)===null||r===void 0?void 0:r.alphaChannelNames)!==null&&s!==void 0?s:[],c=l.length,f=!!e.layersInGlobalInfo&&l[0]==="Transparency"&&c===a-t,u=e.globalAlpha||f||a-t>c,d=[];for(let p=0;p<a;p++)p<t?d.push(p):p===t&&u&&i>=0?d.push(i):d.push(-1);return d}function Yr(e,n,t,i,o,r){if(n===0){let s=t.width*t.height*go(i);for(let a of r)a<0?_e(e,s):df(xt(e,s),t,i,o,a)}else if(n===1)yi(e,t,t.width,t.height,i,o,r,e.large);else throw new Error(`Compression not supported: ${n}`)}function ug({data:e,width:n,height:t}){let i=n*t*4;if(e instanceof Float32Array)for(let o=0;o<i;o+=4){let r=e[o+3];if(r>0&&r<1){let s=1/r,a=1-s;for(let l=0;l<3;l++){let c=e[o+l]*s+a;e[o+l]=c<0?0:c}}}else if(e instanceof Uint16Array)for(let o=0;o<i;o+=4){let r=e[o+3];if(r!==0&&r!==65535){let s=65535/r,a=65535*(1-s);for(let l=0;l<3;l++){let c=Math.round(e[o+l]*s+a);e[o+l]=c<0?0:c>65535?65535:c}}}else for(let o=0;o<i;o+=4){let r=e[o+3];if(r!=0&&r!=255){let a=1/(r/255),l=255*(1-a);e[o+0]=e[o+0]*a+l,e[o+1]=e[o+1]*a+l,e[o+2]=e[o+2]*a+l}}}function Jr(e,n){return e=Math.round(e*(n/255)),e<=0?0:e>=n?n:e}function ho(e,n,t){let i=n.width*n.height*4,o=e.data,r=n.data,s=o instanceof Uint16Array?65535:255,a=r instanceof Uint16Array?65535:255,l=[0,0,0];for(let c=0,f=0;f<i;c+=5,f+=4){let u=o[c+4],d=1-o[c]/s,p=1-o[c+1]/s,h=1-o[c+2]/s,m=1-o[c+3]/s;if(t&&u>0&&u<s){let y=s/u;d=Math.min(1,d*y),p=Math.min(1,p*y),h=Math.min(1,h*y),m=Math.min(1,m*y)}(0,Te.cmykToRgbValues)(d,p,h,m,l),r[f]=Jr(l[0],a),r[f+1]=Jr(l[1],a),r[f+2]=Jr(l[2],a),r[f+3]=s===a?u:Math.round(u*a/s)}}function pg(e,n,t,i){let o=e.width*e.height,r=e.data,s=n.data;for(let a=0,l=0;a<o;a++,l+=4){let c=r[a],f=t[c];s[l+0]=f.r,s[l+1]=f.g,s[l+2]=f.b,s[l+3]=c===i?0:255}}function go(e){switch(e){case 1:case 8:return 1;case 16:return 2;case 32:return 4;default:throw new Error(`Invalid bitDepth (${e})`)}}function fs(e,n){if(e.BYTES_PER_ELEMENT!==n)throw new Error("Invalid array types")}function df(e,n,t,i,o){let r=go(t);if(!n||o<0||o>=i)return;let s=n.data;fs(s,r);let a=Math.min(n.width*n.height,Math.floor(e.byteLength/r))|0;if(r===1)for(let l=0,c=o|0;l<a;l++,c=c+i|0)s[c]=e[l];else if(r===2)for(let l=0,c=0,f=o|0;l<a;l++,c+=2,f=f+i|0)s[f]=e[c]<<8|e[c+1];else{let l=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let c=0,f=0,u=o|0;c<a;c++,f+=4,u=u+i|0)s[u]=l.getFloat32(f,!1)}}function hg(e,n,t){for(let i=0;i<t;i++){let o=i*n;for(let r=1,s=o+1;r<n;r++,s++)e[s]=e[s-1]+e[s]}}var Qr=new Error("Decompressed data exceeds expected size");function uf(e,n,t,i=!1){let o=new Uint8Array(n),r=0,s=!1,a=new Bh.Inflate({chunkSize:Math.max(1024,Math.min(n,65536)),raw:i});a.onData=l=>{let c=l,f=Math.min(c.length,n-r);if(f>0&&o.set(f===c.length?c:c.subarray(0,f),r),r+=f,f<c.length)throw s=!0,Qr},a.onEnd=l=>{var c;a.err=l,a.msg=((c=a.strm)===null||c===void 0?void 0:c.msg)||""};try{a.push(e,!0)}catch(l){if(l!==Qr)throw l}if(s)t&&qt(t,Qr.message);else{if(a.err&&a.msg==="incorrect data check"&&!i)return t&&qt(t,`Invalid zip data: ${a.msg}`),uf(e.subarray(2),n,t,!0);if(a.err)throw new Error(`Invalid zip data: ${a.msg}`)}return o}function os(e,n,t,i,o,r,s,a,l){let c=go(o);if(!n||s<0||s>=r)return;let f=n.data;fs(f,c);let u=t*i*c;l&&Mn(l,u);try{let d=uf(e,u,l);if(c===1)for(let p=0,h=0;p<i;p++){let m=0;for(let y=0,g=s+p*t*r;y<t;y++,h++,g+=r){let k=d[h];a&&(k=m=m+k&255),f[g]=k}}else if(c===2)for(let p=0,h=0;p<i;p++){let m=0;for(let y=0,g=s+p*t*r;y<t;y++,h+=2,g+=r){let k=d[h]<<8|d[h+1];a&&(k=m=m+k&65535),f[g]=k}}else{let p=new Uint32Array(f.buffer,f.byteOffset,f.length);if(a){hg(d,t*4,i);for(let h=0,m=s;h<i;h++){let y=t*4*h;for(let g=0;g<t;g++,y++,m+=r){let k=y+t,x=k+t,S=x+t;p[m]=(d[y]<<24|d[k]<<16|d[x]<<8|d[S])>>>0}}}else{let h=new DataView(d.buffer,d.byteOffset,d.byteLength);for(let m=0,y=0,g=s,k=t*i;m<k;m++,y+=4,g+=r)p[g]=h.getUint32(y,!1)}}}finally{l&&po(l,u)}}function gg(e,n,t,i,o){let r=0;for(;n<t&&r<o;){let s=e[n++];if(s>128){if(n>=t)break;let a=e[n++],l=257-s;l>o-r&&(l=o-r),i.fill(a,r,r+l),r+=l}else if(s<128){let a=s+1;for(a>o-r&&(a=o-r),a>t-n&&(a=t-n);a>0;a--)i[r++]=e[n++]}}return r}function mg(e,n,t,i,o,r,s,a,l){let c=e.length|0;for(let f=0;f<r;f++,t++){let u=(i<c?i:c)|0;i+=n[t];let d=(i<c?i:c)|0,p=a+f*o*l|0,h=0;for(;u<d&&h<o;){let m=e[u++]|0;if(m>128){if(u>=d)break;let y=e[u++]|0,g=257-m|0;g>o-h&&(g=o-h|0),h=h+g|0;for(let k=p+g*l|0;p<k;p=p+l|0)s[p]=y}else if(m<128){let y=m+1|0;y>o-h&&(y=o-h|0),y>d-u&&(y=d-u|0),h=h+y|0;for(let g=u+y|0;u<g;u=u+1|0,p=p+l|0)s[p]=e[u]}}}}function yg(e,n,t,i,o,r){if(t===2)for(let s=0,a=0;s<n;s++,a+=2,o+=r)i[o]=e[a]<<8|e[a+1];else{let s=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=0,l=0;a<n;a++,l+=4,o+=r)i[o]=s.getFloat32(l,!1)}}function bg(e,n,t,i,o,r,s,a,l,c,f){let u=e.length,d=o*c;for(let p=0;p<r;p++,t++){let h=i<u?i:u;i+=n[t];let m=i<u?i:u;if(h>=m)continue;let y=gg(e,h,m,f,d);yg(f,Math.floor(y/c),c,s,a+p*o*l,l)}}function yi(e,n,t,i,o,r,s,a){let l=n&&n.data,c=s.length*i,u=c*(a?4:2),d=e.view.byteLength,p=go(o),h;Mn(e,u);try{if(e.offset+u>d)throw new Error("RLE row lengths exceed buffer length");h=a?new Uint32Array(c):new Uint16Array(c);let k=0;if(a)for(let x=0;x<c;x++)k+=h[x]=we(e);else for(let x=0;x<c;x++)k+=h[x]=de(e);k>d-e.offset&&qt(e,"RLE data exceeds buffer length"),l&&fs(l,p)}catch(k){throw po(e,u),k}let m=new Uint8Array(e.view.buffer,e.view.byteOffset,d),y=l&&p>1?new Uint8Array(t*p):void 0,g=e.offset;for(let k=0,x=0;k<s.length;k++,x+=i){let S=s[k]|0,A=g;for(let D=0;D<i;D++)g+=h[x+D];l&&S>=0&&S<r&&(p===1?mg(m,h,x,A,t,i,l,S,r):bg(m,h,x,A,t,i,l,S,r,p,y))}e.offset=g,po(e,u)}function at(e,n,t,i=!0,o=!1){let r=we(e);if(o){if(r!==0)throw new Error("Sizes larger than 4GB are not supported");r=we(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=t(()=>s-e.offset);for(e.offset!==s&&(e.offset>s?qt(e,"Exceeded section limits"):qt(e,"Unread section data"));r%n;)r++,s++;return e.offset=s,a}function wg(e){switch(de(e)){case 0:{let t=de(e)/257,i=de(e)/257,o=de(e)/257;return _e(e,2),{r:t,g:i,b:o}}case 1:{let t=de(e)/65535,i=de(e)/65535,o=de(e)/65535;return _e(e,2),{h:t,s:i,b:o}}case 2:{let t=(65535-de(e))/257,i=(65535-de(e))/257,o=(65535-de(e))/257,r=(65535-de(e))/257;return{c:t,m:i,y:o,k:r}}case 7:{let t=Xt(e)/1e4,i=Xt(e),o=Xt(e),r=(0,Te.normalizeLabAB)(i,100),s=(0,Te.normalizeLabAB)(o,100);return _e(e,2),{l:t,a:r,b:s}}case 8:{let t=de(e)*255/1e4;return _e(e,6),{k:t}}default:throw new Error("Invalid color space")}}var $c=3e4;function vg(e){let n=e.view.getUint32(e.offset);for(;n%4;)n++;let t=e.offset+4+n;try{return pf(e)}catch(i){if(e.throwForMissingFeatures)throw i;e.logMissingFeatures&&e.log(`Skipped pattern: ${i.message}`),e.offset=t;return}}function pf(e){let n=we(e);for(;n%4;)n++;let t=e.offset+n,i=we(e);if(i!==1)throw new Error(`Invalid pattern version: ${i}`);let o=we(e),r=Xt(e),s=Xt(e);if(o!==3&&o!==1&&o!==2&&o!==4)throw new Error(`Unsupported pattern color mode: ${o}`);let a=Wc(e),l=ss(e,1),c=[];if(o===2){for(let M=0;M<256;M++)c.push({r:ve(e),g:ve(e),b:ve(e)});e.view.getUint32(e.offset)!==3&&_e(e,4)}let f=we(e);if(f!==3)throw new Error(`Invalid pattern VMAL version: ${f}`);we(e);let u=we(e),d=we(e),p=we(e),h=we(e),m=we(e),y=h-d,g=p-u;if(y<0||g<0)throw new Error("Invalid pattern bounds");if(y>$c||g>$c)throw new Error(`Pattern too large (${y}x${g})`);if(m>64)throw new Error(`Invalid pattern channel count: ${m}`);if(y*g>(Math.min(t,e.view.byteLength)-e.offset)*64)throw new Error("Pattern data out of bounds");let k=o===3?3:o===4?4:1,x=o===4,S=x?4:3,A=[],D=0;for(let M=0,J=0;M<m+2&&e.offset+4<=t;M++){if(!we(e))continue;let R=we(e);if(!R)continue;if(R<23)throw new Error("Invalid pattern channel length");let ie=we(e),he=we(e),ce=we(e),Ce=we(e),W=we(e),B=de(e),$=ve(e),ne=xt(e,R-23),ge=B===8||B===16||B===32?B:ie;if(ge!==8&&ge!==16&&ge!==32)throw new Error(`Unsupported pattern pixel depth: ${ge}`);if(he<u||ce<d||Ce>p||W>h||Ce<he||W<ce)throw new Error("Pattern channel bounds outside of pattern bounds");let Q=J<k?J:J===k?S:-1;if(J++,Q===-1)continue;let ee=W-ce,be=Ce-he,Se=ee*(ge/8),xe=Se*be;if($===0){if(ne.byteLength<xe)throw new Error("Pattern channel data out of bounds")}else if($===1){if(xe>ne.byteLength*64)throw new Error("Pattern channel data out of bounds");D=Math.max(D,xe)}else throw new Error("Invalid pattern compression mode");A.push({target:Q,depth:ge,compressionMode:$,cdata:ne,ctop:he,cleft:ce,w:ee,h:be,rowBytes:Se,channelSize:xe})}let C=y*g*4,O=x?y*g*5:0;Mn(e,C+O+D),po(e,C+O+D);let E=new Uint8Array(C);for(let M=3;M<E.byteLength;M+=4)E[M]=255;let L=x?new Uint8Array(O).fill(255):void 0;for(let{target:M,depth:J,compressionMode:pe,cdata:R,ctop:ie,cleft:he,w:ce,h:Ce,rowBytes:W,channelSize:B}of A){let $=R;if(pe===1){$=new Uint8Array(B);let Q=gi(R.buffer,R.byteOffset,R.byteLength);yi(Q,{data:$,width:W,height:Ce},W,Ce,8,1,[0],!1)}J!==8&&($=Sg($,ce*Ce,J));let ne=he-d,ge=ie-u;if(L)Vc($,L,ce,Ce,(ne+ge*y)*5+M,y*5,5);else if(M===3||o===3)Vc($,E,ce,Ce,(ne+ge*y)*4+M,y*4,4);else if(o===2){let Q=new Uint8Array(768);for(let ee=0;ee<256;ee++)Q[ee*3+0]=c[ee].r,Q[ee*3+1]=c[ee].g,Q[ee*3+2]=c[ee].b;for(let ee=0;ee<Ce;ee++)for(let be=0,Se=ee*ce,xe=(ne+(ee+ge)*y)*4;be<ce;be++,Se++,xe+=4){let jt=$[Se]*3;E[xe+0]=Q[jt+0],E[xe+1]=Q[jt+1],E[xe+2]=Q[jt+2]}}else for(let Q=0;Q<Ce;Q++)for(let ee=0,be=Q*ce,Se=(ne+(Q+ge)*y)*4;ee<ce;ee++,be++,Se+=4){let xe=$[be];E[Se+0]=xe,E[Se+1]=xe,E[Se+2]=xe}}return L&&ho({width:y,height:g,data:L},{width:y,height:g,data:E},!1),Mn(e,C),e.offset=t,{id:l,name:a,x:r,y:s,bounds:{x:d,y:u,w:y,h:g},data:E}}function Sg(e,n,t){let i=new Uint8Array(n);if(t===16)for(let o=0;o<n;o++)i[o]=Math.round((e[o*2]<<8|e[o*2+1])/257);else{let o=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let r=0;r<n;r++){let s=o.getFloat32(r*4,!1);i[r]=s>0?s<1?Math.round(s*255):255:0}}return i}function Vc(e,n,t,i,o,r,s){for(let a=0,l=0;a<i;a++)for(let c=0,f=o+a*r;c<t;c++,l++,f+=s)n[f]=e[l]}function Mn(e,n){if(!(n>=0))throw new Error("Invalid size");if(e.totalMemoryLimit!==void 0){if(e.totalMemoryLimit<n)throw new Error("Exceeded memory limit");e.totalMemoryLimit-=n}}function po(e,n){e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit+=n)}});var mf=ae(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.readEffects=xg;mo.writeEffects=kg;var gf=Ot(),H=st(),T=En(),ds=[void 0,"outer bevel","inner bevel","emboss","pillow emboss","stroke emboss"];function Bn(e){return(0,H.checkSignature)(e,"8BIM"),gf.toBlendMode[(0,H.readSignature)(e)]||"normal"}function Tn(e,n){(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,gf.fromBlendMode[n]||"norm")}function Rn(e){return(0,H.readUint8)(e)/255}function jn(e,n){(0,T.writeUint8)(e,Math.round(n*255)|0)}function xg(e){let n=(0,H.readUint16)(e);if(n!==0)throw new Error(`Invalid effects layer version: ${n}`);let t=(0,H.readUint16)(e),i={};for(let o=0;o<t;o++){(0,H.checkSignature)(e,"8BIM");let r=(0,H.readSignature)(e);switch(r){case"cmnS":{let s=(0,H.readUint32)(e),a=(0,H.readUint32)(e);if((0,H.readUint8)(e),(0,H.skipBytes)(e,2),s!==7||a!==0)throw new Error("Invalid effects common state");break}case"dsdw":case"isdw":{let s=(0,H.readUint32)(e),a=(0,H.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,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readFixedPoint32)(e),f=(0,H.readFixedPoint32)(e),u=(0,H.readColor)(e),d=Bn(e),p=!!(0,H.readUint8)(e),h=!!(0,H.readUint8)(e),m=Rn(e);s>=51&&(0,H.readColor)(e);let y={size:{units:"Pixels",value:l},distance:{units:"Pixels",value:f},angle:c,color:u,blendMode:d,enabled:p,useGlobalLight:h,opacity:m};r==="dsdw"?i.dropShadow=[y]:i.innerShadow=[y];break}case"oglw":{let s=(0,H.readUint32)(e),a=(0,H.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,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readColor)(e),f=Bn(e),u=!!(0,H.readUint8)(e),d=Rn(e);s>=42&&(0,H.readColor)(e),i.outerGlow={size:{units:"Pixels",value:l},color:c,blendMode:f,enabled:u,opacity:d};break}case"iglw":{let s=(0,H.readUint32)(e),a=(0,H.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,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readColor)(e),f=Bn(e),u=!!(0,H.readUint8)(e),d=Rn(e);s>=43&&((0,H.readUint8)(e),(0,H.readColor)(e)),i.innerGlow={size:{units:"Pixels",value:l},color:c,blendMode:f,enabled:u,opacity:d};break}case"bevl":{let s=(0,H.readUint32)(e),a=(0,H.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,H.readFixedPoint32)(e),c=(0,H.readFixedPoint32)(e),f=(0,H.readFixedPoint32)(e),u=Bn(e),d=Bn(e),p=(0,H.readColor)(e),h=(0,H.readColor)(e),m=ds[(0,H.readUint8)(e)]||"inner bevel",y=Rn(e),g=Rn(e),k=!!(0,H.readUint8)(e),x=!!(0,H.readUint8)(e),S=(0,H.readUint8)(e)?"down":"up";s>=78&&((0,H.readColor)(e),(0,H.readColor)(e)),i.bevel={size:{units:"Pixels",value:f},angle:l,strength:c,highlightBlendMode:u,shadowBlendMode:d,highlightColor:p,shadowColor:h,style:m,highlightOpacity:y,shadowOpacity:g,enabled:k,useGlobalLight:x,direction:S};break}case"sofi":{let s=(0,H.readUint32)(e),a=(0,H.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=Bn(e),c=(0,H.readColor)(e),f=Rn(e),u=!!(0,H.readUint8)(e);(0,H.readColor)(e),i.solidFill=[{blendMode:l,color:c,opacity:f,enabled:u}];break}default:throw new Error(`Invalid effect type: '${r}'`)}}return i}function hf(e,n){var t;(0,T.writeUint32)(e,51),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,n.size&&n.size.value||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeFixedPoint32)(e,n.angle||0),(0,T.writeFixedPoint32)(e,n.distance&&n.distance.value||0),(0,T.writeColor)(e,n.color),Tn(e,n.blendMode),(0,T.writeUint8)(e,n.enabled?1:0),(0,T.writeUint8)(e,n.useGlobalLight?1:0),jn(e,(t=n.opacity)!==null&&t!==void 0?t:1),(0,T.writeColor)(e,n.color)}function kg(e,n){var t,i,o,r,s,a,l,c,f,u,d;let p=(t=n.dropShadow)===null||t===void 0?void 0:t[0],h=(i=n.innerShadow)===null||i===void 0?void 0:i[0],m=n.outerGlow,y=n.innerGlow,g=n.bevel,k=(o=n.solidFill)===null||o===void 0?void 0:o[0],x=1;if(p&&x++,h&&x++,m&&x++,y&&x++,g&&x++,k&&x++,(0,T.writeUint16)(e,0),(0,T.writeUint16)(e,x),(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"cmnS"),(0,T.writeUint32)(e,7),(0,T.writeUint32)(e,0),(0,T.writeUint8)(e,1),(0,T.writeZeros)(e,2),p&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"dsdw"),hf(e,p)),h&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"isdw"),hf(e,h)),m&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"oglw"),(0,T.writeUint32)(e,42),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,((r=m.size)===null||r===void 0?void 0:r.value)||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeColor)(e,m.color),Tn(e,m.blendMode),(0,T.writeUint8)(e,m.enabled?1:0),jn(e,(s=m.opacity)!==null&&s!==void 0?s:1),(0,T.writeColor)(e,m.color)),y&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"iglw"),(0,T.writeUint32)(e,43),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,((a=y.size)===null||a===void 0?void 0:a.value)||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeColor)(e,y.color),Tn(e,y.blendMode),(0,T.writeUint8)(e,y.enabled?1:0),jn(e,(l=y.opacity)!==null&&l!==void 0?l:1),(0,T.writeUint8)(e,0),(0,T.writeColor)(e,y.color)),g){(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"bevl"),(0,T.writeUint32)(e,78),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,g.angle||0),(0,T.writeFixedPoint32)(e,g.strength||0),(0,T.writeFixedPoint32)(e,((c=g.size)===null||c===void 0?void 0:c.value)||0),Tn(e,g.highlightBlendMode),Tn(e,g.shadowBlendMode),(0,T.writeColor)(e,g.highlightColor),(0,T.writeColor)(e,g.shadowColor);let S=ds.indexOf(g.style);(0,T.writeUint8)(e,S<=0?ds.indexOf("inner bevel"):S),jn(e,(f=g.highlightOpacity)!==null&&f!==void 0?f:1),jn(e,(u=g.shadowOpacity)!==null&&u!==void 0?u:1),(0,T.writeUint8)(e,g.enabled?1:0),(0,T.writeUint8)(e,g.useGlobalLight?1:0),(0,T.writeUint8)(e,g.direction==="down"?1:0),(0,T.writeColor)(e,g.highlightColor),(0,T.writeColor)(e,g.shadowColor)}k&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"sofi"),(0,T.writeUint32)(e,34),(0,T.writeUint32)(e,2),Tn(e,k.blendMode),(0,T.writeColor)(e,k.color),jn(e,(d=k.opacity)!==null&&d!==void 0?d:1),(0,T.writeUint8)(e,k.enabled?1:0),(0,T.writeColor)(e,k.color))}});var us=ae(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.setProperty=vf;bi.parseEngineData=_g;bi.serializeEngineData=Cg;var yo=st();function yf(e){return e===32||e===10||e===13||e===9}function bf(e){return e>=48&&e<=57||e===46||e===45}function vf(e,n,t){n==="__proto__"?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}var wf=64;function _g(e,n){let t=0;function i(){for(;t<e.length&&yf(e[t]);)t++}function o(){let m=e[t];return t++,m===92&&(m=e[t],t++),m}function r(){let m="";if(e[t]===41)return t++,m;if(e[t]!==254||e[t+1]!==255){for(;t<e.length&&e[t]!==41;)m+=String.fromCharCode(o());return(0,yo.consumeMemory)(n,m.length*2),t++,m}for(t+=2;t<e.length&&e[t]!==41;){let y=o(),g=o(),k=y<<8|g;m+=String.fromCharCode(k)}return(0,yo.consumeMemory)(n,m.length*2),t++,m}let s=null,a=[];function l(m){a.length?(c(m),a.push(m)):(a.push(m),s=m)}function c(m){if(!a.length)throw new Error("Invalid data");(0,yo.consumeMemory)(n,wf);let y=a[a.length-1];if(typeof y=="string"){let g=a[a.length-2];vf(g,y,m),u()}else if(Array.isArray(y))y.push(m);else throw new Error("Invalid data")}function f(m){a.length||l({});let y=a[a.length-1];if(typeof y=="string"||Array.isArray(y))c(m==="nil"?null:`/${m}`);else if(y&&typeof y=="object")(0,yo.consumeMemory)(n,wf+m.length*2),a.push(m);else throw new Error("Invalid data")}function u(){if(!a.length)throw new Error("Invalid data");a.pop()}i();let d=e.length,p=0,h="";for(;d>0&&e[d-1]===0;)d--;for(;t<d;){let m=t,y=e[m];if(y===60&&e[m+1]===60)t+=2,l({});else if(y===62&&e[m+1]===62)t+=2,u();else if(y===47){t+=1;let g=t;for(;t<e.length&&!yf(e[t]);)t++;let k="";for(let x=g;x<t;x++)k+=String.fromCharCode(e[x]);f(k)}else if(y===40)t+=1,c(r());else if(y===91)t+=1,l([]);else if(y===93)t+=1,u();else if(y===110&&e[m+1]===117&&e[m+2]===108&&e[m+3]===108)t+=4,c(null);else if(y===116&&e[m+1]===114&&e[m+2]===117&&e[m+3]===101)t+=4,c(!0);else if(y===102&&e[m+1]===97&&e[m+2]===108&&e[m+3]===115&&e[m+4]===101)t+=5,c(!1);else if(bf(y)){let g="";for(;t<e.length&&bf(e[t]);)g+=String.fromCharCode(e[t]),t++;c(parseFloat(g))}else t+=1,p||(h=`'${String.fromCharCode(y)}' (${y}) at ${t}`),p++;i()}return p&&n.log(`Invalid tokens in engine data (${p} in total, first: ${h})`),s}var Ag=["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"],Ig=["RunLengthArray"];function Cg(e,n=!1){let t=new Uint8Array(1024),i=0,o=0;function r(y){if(i>=t.length){let g=new Uint8Array(t.length*2);g.set(t),t=g}t[i]=y,i++}function s(y){for(let g=0;g<y.length;g++)r(y.charCodeAt(g))}function a(){if(n)s(" ");else for(let y=0;y<o;y++)s(" ")}function l(y,g){a(),s(`/${y}`),m(g,y,!0),n||s(`
2
+ `)}function c(y){return Number.isFinite(y)?y:0}function f(y){return c(y).toString()}function u(y){return c(y).toFixed(5).replace(/(\d)0+$/g,"$1").replace(/^0+\.([1-9])/g,".$1").replace(/^-0+\.0(\d)/g,"-.0$1")}function d(y,g){return y=c(y),g&&Ag.indexOf(g)!==-1||(y|0)!==y?u(y):f(y)}function p(y){let g=Object.keys(y);return g.indexOf("98")!==-1&&g.unshift(...g.splice(g.indexOf("98"),1)),g.indexOf("99")!==-1&&g.unshift(...g.splice(g.indexOf("99"),1)),g}function h(y){(y===40||y===41||y===92)&&r(92),r(y)}function m(y,g,k=!1){function x(){k?s(" "):a()}if(y==null)x(),s(n?"/nil":"null");else if(typeof y=="number")x(),s(d(y,g));else if(typeof y=="boolean")x(),s(y?"true":"false");else if(typeof y=="string")if(x(),(g==="99"||g==="98")&&y.charAt(0)==="/")s(y);else{s("("),r(254),r(255);for(let S=0;S<y.length;S++){let A=y.charCodeAt(S);h(A>>8&255),h(A&255)}s(")")}else if(Array.isArray(y))if(x(),y.every(S=>typeof S=="number")){s("[");let S=Ig.indexOf(g)!==-1;for(let A of y)s(" "),s(S?d(A):u(A));s(" ]")}else{s("["),n||s(`
3
3
  `);for(let S of y)m(S,g),n||s(`
4
4
  `);a(),s("]")}else if(typeof y=="object"){k&&!n&&s(`
5
5
  `),a(),s("<<"),n||s(`
6
6
  `),o++;for(let S of p(y))y[S]!==void 0&&l(S,y[S]);o--,a(),s(">>")}}if(n){if(typeof e=="object")for(let y of p(e))e[y]!==void 0&&l(y,e[y])}else s(`
7
7
 
8
- `),m(e);return t.slice(0,i)}});var Ff=ae(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.decodeEngineData=Bg;Si.decodeLegacyTextData=Rg;Si.encodeEngineData=Tg;var zn=Ot(),Cf={name:"MyriadPro-Regular",script:0,type:0,synthetic:0},vo={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},Og={font:Cf,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},fn={isOn:!1,show:!1,size:18,leading:22,color:{r:0,g:0,b:255},leadingFillColor:{r:0,g:0,b:255},alignLineHeightToGridFlags:!1},ys=["justification","firstLineIndent","startIndent","endIndent","spaceBefore","spaceAfter","autoHyphenate","hyphenatedWordSize","preHyphen","postHyphen","consecutiveHyphens","zone","wordSpacing","letterSpacing","glyphSpacing","autoLeading","leadingType","hanging","burasagari","kinsokuOrder","everyLineComposer"],xo=["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"],hs=["none","crisp","strong","smooth","sharp",void 0,"platformLCD","platform"],bs=["left","right","center","justify-left","justify-right","justify-center","justify-all"];function Pf(e){return e.substring(0,1).toUpperCase()+e.substring(1)}function Df(e){let n=e.Values;switch(e.Type){case 0:return{k:n[1]*255};case 1:return n[0]===1?{r:n[1]*255,g:n[2]*255,b:n[3]*255}:{r:n[1]*255,g:n[2]*255,b:n[3]*255,a:n[0]*255};case 2:return{c:n[1]*255,m:n[2]*255,y:n[3]*255,k:n[4]*255};default:throw new Error("Unknown color type in text layer")}}function Eg(e,n,t){e=(0,zn.clamp)(e||0,0,1),n=(0,zn.clamp)(n||0,0,1),t=(0,zn.clamp)(t||0,0,1);let i=e*6%6,o=Math.floor(i),r=i-o,s=t*(1-n),a=t*(1-n*r),l=t*(1-n*(1-r));switch(o){case 0:return[t,l,s];case 1:return[a,t,s];case 2:return[s,t,l];case 3:return[s,a,t];case 4:return[l,s,t];default:return[t,s,a]}}function gs(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("fr"in e)return{Type:1,Values:[1,(0,zn.clamp)(e.fr||0,0,1),(0,zn.clamp)(e.fg||0,0,1),(0,zn.clamp)(e.fb||0,0,1)]};if("h"in e){let[n,t,i]=Eg(e.h,e.s,e.b);return{Type:1,Values:[1,n,t,i]}}else{if("c"in e)return{Type:2,Values:[1,e.c/255,e.m/255,e.y/255,e.k/255]};if("l"in e)throw new Error("LAB colors are not supported in text layers, use RGB, CMYK or grayscale color instead");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 xf(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function kf(e,n){if(!e||!n)return!1;for(let t of Object.keys(e))if(e[t]!==n[t])return!1;for(let t of Object.keys(n))if(e[t]!==n[t])return!1;return!0}function Fg(e,n){for(let t=0;t<e.length;t++)if(e[t].name===n.name&&(e[t].synthetic||0)===(n.synthetic||0))return t;return e.push(n),e.length-1}function Of(e,n,t){var i;let o={};for(let r of n){let s=Pf(r);if(e[s]!==void 0)if(r==="justification")o[r]=(i=bs[e[s]])!==null&&i!==void 0?i:"left";else if(r==="font"){let a=t[e[s]];a&&(o[r]=a)}else r==="fillColor"||r==="strokeColor"?o[r]=Df(e[s]):o[r]=e[s]}return o}function Ef(e,n,t){var i;let o={};for(let r of n){let s=Pf(r);e[r]!==void 0&&(r==="justification"?o[s]=Math.max(0,bs.indexOf((i=e[r])!==null&&i!==void 0?i:"left")):r==="font"?o[s]=Fg(t,e[r]):r==="fillColor"||r==="strokeColor"?o[s]=gs(e[r]):o[s]=e[r])}return o}function Lg(e,n){return Of(e,ys,n)}function Mg(e,n){return Of(e,xo,n)}function So(e,n){return Ef(e,ys,n)}function ps(e,n){return Ef(e,xo,n)}function ms(e,n,t){if(n.length){for(let i of t){let o=n[0].style[i];if(o!==void 0){let s=!1;Array.isArray(o)?s=n.every(a=>xf(a.style[i],o)):typeof o=="object"?s=n.every(a=>kf(a.style[i],o)):s=n.every(a=>a.style[i]===o),s&&(e[i]=o)}if(e[i]!==void 0)for(let s of n){let a=!1;Array.isArray(o)?a=xf(s.style[i],o):typeof o=="object"?a=kf(s.style[i],o):a=s.style[i]===o,a&&delete s.style[i]}}n.every(i=>Object.keys(i.style).length===0)&&(n.length=0)}}function _f(e){return!!e&&"r"in e&&e.r===0&&e.g===0&&e.b===255}function Af(e,n){try{return e?Df(e):n}catch{return n}}function Ug(e){var n,t;if(!e||typeof e!="object")return;let i={isOn:!!e.GridIsOn,show:!!e.ShowGrid,size:(n=e.GridSize)!==null&&n!==void 0?n:fn.size,leading:(t=e.GridLeading)!==null&&t!==void 0?t:fn.leading,color:Af(e.GridColor,fn.color),leadingFillColor:Af(e.GridLeadingFillColor,fn.leadingFillColor),alignLineHeightToGridFlags:!!e.AlignLineHeightToGridFlags};return!i.isOn&&!i.show&&i.size===fn.size&&i.leading===fn.leading&&!i.alignLineHeightToGridFlags&&_f(i.color)&&_f(i.leadingFillColor)?void 0:i}function Bg(e){var n,t,i,o,r,s,a,l,c,f;let u=e.EngineDict,d=e.ResourceDict,p=d.FontSet.map(O=>({name:O.Name,script:O.Script,type:O.FontType,synthetic:O.Synthetic})),h=u.Editor.Text.replace(/\r/g,`
9
- `),m=0;/\n$/.test(h)&&(h=h.substring(0,h.length-1),m=1);let y={text:h,antiAlias:(n=hs[u.AntiAlias])!==null&&n!==void 0?n:"smooth",useFractionalGlyphWidths:!!u.UseFractionalGlyphWidths,superscriptSize:d.SuperscriptSize,superscriptPosition:d.SuperscriptPosition,subscriptSize:d.SubscriptSize,subscriptPosition:d.SubscriptPosition,smallCapSize:d.SmallCapSize},g=(s=(r=(o=(i=(t=u.Rendered)===null||t===void 0?void 0:t.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;g&&(y.shapeType=g.ShapeType===1?"box":"point",g.PointBase&&(y.pointBase=g.PointBase),g.BoxBounds&&(y.boxBounds=g.BoxBounds));let k=Ug(u.GridInfo);k&&(y.gridInfo=k);let x=u.ParagraphRun;y.paragraphStyle={},y.paragraphStyleRuns=[];for(let O=0;O<x.RunArray.length;O++){let E=x.RunArray[O],L=x.RunLengthArray[O],M=Lg(E.ParagraphSheet.Properties,p);y.paragraphStyleRuns.push({length:L,style:M})}for(let O=m;y.paragraphStyleRuns.length&&O>0;O--)--y.paragraphStyleRuns[y.paragraphStyleRuns.length-1].length===0&&y.paragraphStyleRuns.length===1&&y.paragraphStyleRuns.pop();ms(y.paragraphStyle,y.paragraphStyleRuns,ys),y.paragraphStyleRuns.length||delete y.paragraphStyleRuns;let S=u.StyleRun,A=(c=(a=d.StyleSheetSet)===null||a===void 0?void 0:a[(l=d.TheNormalStyleSheet)!==null&&l!==void 0?l:0])===null||c===void 0?void 0:c.StyleSheetData,D=A?.Font,C=(f=D!==void 0?p[D]:void 0)!==null&&f!==void 0?f:p[0];y.style={},y.styleRuns=[];for(let O=0;O<S.RunArray.length;O++){let E=S.RunLengthArray[O],L=Mg(S.RunArray[O].StyleSheet.StyleSheetData,p);!L.font&&C&&(L.font=C),y.styleRuns.push({length:E,style:L})}for(let O=m;y.styleRuns.length&&O>0;O--)--y.styleRuns[y.styleRuns.length-1].length===0&&y.styleRuns.pop();return ms(y.style,y.styleRuns,xo),y.styleRuns.length||delete y.styleRuns,y}var vi=e=>e/65536;function Rg(e){var n,t,i,o;let r=[],s="";for(let c of e.lines)for(let{code:f,style:u}of c.chars){s+=String.fromCharCode(f);let d=r[r.length-1];d&&d.mark===u?d.length++:r.push({length:1,mark:u})}s.endsWith("\r")&&(s=s.slice(0,-1),--r[r.length-1].length===0&&r.pop());let a=r.map(({length:c,mark:f})=>{var u,d;let p=(u=e.styles.find(y=>y.mark===f))!==null&&u!==void 0?u:e.styles[0],h=p&&((d=e.faces.find(y=>y.mark===p.faceMark))!==null&&d!==void 0?d:e.faces[0]),m={};return h&&(m.font={name:h.name,script:h.script}),p&&(m.fontSize=vi(p.size),m.autoLeading=p.leading===0,p.leading&&(m.leading=vi(p.leading)),m.tracking=Math.round(vi(p.tracking)*1e3),m.autoKerning=p.autoKerning,m.kerning=Math.round(vi(p.kerning)*1e3),m.baselineShift=vi(p.baselineShift)),m.fillColor=e.color,{length:c,style:m}}),l={text:s.replace(/\r/g,`
10
- `),transform:e.transform,antiAlias:e.antiAlias?"smooth":"none",orientation:((n=e.lines[0])===null||n===void 0?void 0:n.orientation)===1?"vertical":"horizontal",paragraphStyle:{justification:(o=bs[(i=(t=e.lines[0])===null||t===void 0?void 0:t.alignment)!==null&&i!==void 0?i:0])!==null&&o!==void 0?o:"left"},style:{},styleRuns:a};return ms(l.style,l.styleRuns,xo),l.styleRuns.length||delete l.styleRuns,l}function If(e,n){if(!e||!n.length)return e;let t=0,i=0;return e.map(o=>{let r=Math.max(0,o.length||0),s=t+r,a=0;for(;i<n.length&&n[i]<s;)n[i]>=t&&a++,i++;return t=s,Object.assign(Object.assign({},o),{length:r-a})})}function Tg(e){var n,t,i,o,r,s,a,l,c,f,u,d,p;let h=e.text||"",m=[];for(let W=0;W<h.length-1;W++)h.charCodeAt(W)===13&&h.charCodeAt(W+1)===10&&m.push(W);let y=`${h.replace(/\r?\n/g,"\r")}\r`,g=[{name:"AdobeInvisFont",script:0,type:0,synthetic:0}],k=((n=e.style)===null||n===void 0?void 0:n.font)||((i=(t=e.styleRuns)===null||t===void 0?void 0:t.find(W=>W.style.font))===null||i===void 0?void 0:i.style.font)||Cf,x=[],S=[],A=If(e.paragraphStyleRuns,m);if(A&&A.length){let W=y.length;for(let B of A){let $=Math.min(B.length,W);W-=$,W===1&&B===A[A.length-1]&&($++,W--),$&&(S.push($),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:So(Object.assign(Object.assign(Object.assign({},vo),e.paragraphStyle),B.style),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}W&&(S.push(W),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:So(Object.assign(Object.assign({},vo),e.paragraphStyle),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}else for(let W=0,B=0;W<y.length;W++)y.charCodeAt(W)===13&&(S.push(W-B+1),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:So(Object.assign(Object.assign({},vo),e.paragraphStyle),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}),B=W+1);let D=ps(Object.assign(Object.assign({},Og),{font:k}),g),C=!((o=e.styleRuns)===null||o===void 0)&&o.length?If(e.styleRuns,m):[{length:y.length,style:e.style||{}}],O=[],E=[],L=y.length;for(let W of C){let B=Math.min(W.length,L);L-=B,B&&(L===1&&W===C[C.length-1]&&(B++,L--),E.push(B),O.push({StyleSheet:{StyleSheetData:ps(Object.assign(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),W.style),g)}}))}L&&(E.push(L),O.push({StyleSheet:{StyleSheetData:ps(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),g)}}));let M=Object.assign(Object.assign({},fn),e.gridInfo),J=hs.indexOf((r=e.antiAlias)!==null&&r!==void 0?r:"sharp"),pe=e.orientation==="vertical"?2:0,R=e.orientation==="vertical"?1:0,ie=e.shapeType==="box"?1:0,he={ShapeType:ie};ie===0?he.PointBase=e.pointBase||[0,0]:he.BoxBounds=e.boxBounds||[0,0,0,0],he.Base={ShapeType:ie,TransformPoint0:[1,0],TransformPoint1:[0,1],TransformPoint2:[0,0]};let ce={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:So(Object.assign(Object.assign({},vo),e.paragraphStyle),g)}],StyleSheetSet:[{Name:"Normal RGB",StyleSheetData:D}],FontSet:g.map(W=>({Name:W.name,Script:W.script||0,FontType:W.type||0,Synthetic:W.synthetic||0})),SuperscriptSize:(s=e.superscriptSize)!==null&&s!==void 0?s:.583,SuperscriptPosition:(a=e.superscriptPosition)!==null&&a!==void 0?a:.333,SubscriptSize:(l=e.subscriptSize)!==null&&l!==void 0?l:.583,SubscriptPosition:(c=e.subscriptPosition)!==null&&c!==void 0?c:.333,SmallCapSize:(f=e.smallCapSize)!==null&&f!==void 0?f:.7};return{EngineDict:{Editor:{Text:y},ParagraphRun:{DefaultRunData:{ParagraphSheet:{DefaultStyleSheet:0,Properties:{}},Adjustments:{Axis:[1,0,1],XY:[0,0]}},RunArray:x,RunLengthArray:S,IsJoinable:1},StyleRun:{DefaultRunData:{StyleSheet:{StyleSheetData:{}}},RunArray:O,RunLengthArray:E,IsJoinable:2},GridInfo:{GridIsOn:!!M.isOn,ShowGrid:!!M.show,GridSize:(u=M.size)!==null&&u!==void 0?u:18,GridLeading:(d=M.leading)!==null&&d!==void 0?d:22,GridColor:gs(M.color),GridLeadingFillColor:gs(M.leadingFillColor),AlignLineHeightToGridFlags:!!M.alignLineHeightToGridFlags},AntiAlias:J===-1?hs.indexOf("sharp"):J,UseFractionalGlyphWidths:(p=e.useFractionalGlyphWidths)!==null&&p!==void 0?p:!0,Rendered:{Version:1,Shapes:{WritingDirection:pe,Children:[{ShapeType:ie,Procession:R,Lines:{WritingDirection:pe,Children:[]},Cookie:{Photoshop:he}}]}}},ResourceDict:Object.assign({},ce),DocumentResources:Object.assign({},ce)}}});var Bf=ae(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.decodeEngineData2=$g;var jg=us(),ws={0:{uproot:!0,children:{0:{name:"Type"},1:{name:"Values"}}}},xs={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:ws},54:{name:"StrokeColor",children:ws},55:{children:{99:{uproot:!0}}},79:{children:ws}},vs={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:xs}},Lf={name:"StyleSheetData",children:xs},zg={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:Lf}}}}}},6:{name:"ParagraphSheetSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},5:{name:"Properties",children:vs},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:vs},6:{name:"6"}}}}},1:{name:"RunLength"}}}}},6:{name:"StyleRun",children:{0:{name:"RunArray",children:{0:{name:"StyleSheet",children:{0:{uproot:!0,children:{6:Lf}}}},1:{name:"RunLength"}}}}}}},1:{name:"FontVectorData ???"}}},2:{name:"StyleSheet",children:xs},3:{name:"ParagraphSheet",children:vs}}}},Mf=256;function Ss(e,n){return Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0}function ko(e,n,t){var i,o;if(t>Mf)throw new Error(`Engine data is nested too deeply (more than ${Mf} levels)`);if(e==null)return e;if(Array.isArray(e))return e.map(l=>ko(l,n,t+1));if(typeof e!="object")return e;let r=Object.keys(e),s=r.find(l=>{var c;return l!=="99"&&((c=Ss(n,l))===null||c===void 0?void 0:c.uproot)}),a;if(s!==void 0){if(a=ko(e[s],(i=Ss(n,s).children)!==null&&i!==void 0?i:{},t+1),a===null||typeof a!="object"||(e[99]&&(a._type=e[99]),Array.isArray(a)))return a}else a={};for(let l of r){if(l===s)continue;let c=Ss(n,l);if(l==="99")s===void 0&&(a._type=e[l]);else{let f=c?.name||l;(s===void 0||!(f in a))&&(0,jg.setProperty)(a,f,ko(e[l],(o=c?.children)!==null&&o!==void 0?o:{},t+1))}}return a}function Uf(){return{FontSet:[],StyleSheetSet:[],ParagraphSheetSet:[]}}function $g(e){let n=ko(e,zg,0);return!n||typeof n!="object"||Array.isArray(n)?{ResourceDict:Uf(),EngineDict:{}}:((!n.ResourceDict||typeof n.ResourceDict!="object")&&(n.ResourceDict=Uf()),n)}});var ui=ae(Ae=>{"use strict";var Vg=Ae&&Ae.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.booleanOperations=Ae.infoHandlersMap=Ae.infoHandlers=void 0;Ae.readBezierKnot=td;Ae.readVectorMask=nd;Ae.writeVectorMask=id;Ae.parseKeyDescriptorList=od;Ae.serializeKeyDescriptorList=rd;Ae.hasMultiEffects=Do;var Rf=no(),Tf=yf(),De=Ot(),b=st(),w=En(),v=ao(),Es=us(),Fs=Ff(),Ng=Bf(),Ze="abcdefghijklmnopqrstuvwxyz";Ae.infoHandlers=[];Ae.infoHandlersMap={};function U(e,n,t,i){let o={key:e,has:n,read:t,write:i};Ae.infoHandlers.push(o),Ae.infoHandlersMap[o.key]=o}function lt(e,n){Ae.infoHandlersMap[e]=Ae.infoHandlersMap[n]}function le(e){return n=>n[e]!==void 0}function Io(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)}U("TySh",le("text"),(e,n,t)=>{var i;if((0,b.readInt16)(e)!==1)throw new Error("Invalid TySh version");let o=[];for(let a=0;a<6;a++)o.push((0,b.readFloat64)(e));if((0,b.readInt16)(e)!==50)throw new Error("Invalid TySh text version");let r=(0,v.readVersionAndDescriptor)(e);if((0,b.readInt16)(e)!==1)throw new Error("Invalid TySh warp version");let s=(0,v.readVersionAndDescriptor)(e);if(n.text={transform:o,left:(0,b.readFloat32)(e),top:(0,b.readFloat32)(e),right:(0,b.readFloat32)(e),bottom:(0,b.readFloat32)(e),text:r["Txt "].replace(/\r/g,`
11
- `),index:r.TextIndex||0,gridding:v.textGridding.decode(r.textGridding),antiAlias:v.Annt.decode(r.AntA),orientation:v.Ornt.decode(r.Ornt),warp:{style:v.warpStyle.decode(s.warpStyle),value:s.warpValue||0,perspective:s.warpPerspective||0,perspectiveOther:s.warpPerspectiveOther||0,rotate:v.Ornt.decode(s.warpRotate)}},r.bounds&&(n.text.bounds=(0,v.descBoundsToBounds)(r.bounds)),r.boundingBox&&(n.text.boundingBox=(0,v.descBoundsToBounds)(r.boundingBox)),r.substitutesUsed!==void 0&&(n.text.substitutesUsed=r.substitutesUsed),r.TxtC&&(n.text.clickPoint=(0,v.horzVrtcToXY)(r.TxtC)),(r.TxPT!==void 0||r.TxPR!==void 0||r.TxMP!==void 0)&&(n.text.textOnPath={},r.TxPT!==void 0&&(n.text.textOnPath.type=r.TxPT.split(".")[1]),r.TxPR!==void 0&&(n.text.textOnPath.direction=r.TxPR.split(".")[1]),r.TxMP!==void 0&&(n.text.textOnPath.mirror=r.TxMP)),r.VAlign!==void 0&&(n.text.verticalAlignment=r.VAlign),r.EngineData){let a=(0,Es.parseEngineData)(r.EngineData,e),l=(0,Fs.decodeEngineData)(a);n.text=Object.assign(Object.assign(Object.assign({},n.text),l),{antiAlias:(i=n.text.antiAlias)!==null&&i!==void 0?i:l.antiAlias})}(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s,a,l;let c=n.text,f=c.warp||{},u=c.transform||[1,0,0,1,0,0],d=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({"Txt ":(c.text||"").replace(/\r?\n/g,"\r")},c.clickPoint?{TxtC:(0,v.xyToHorzVrtc)(c.clickPoint)}:{}),c.substitutesUsed!==void 0?{substitutesUsed:!!c.substitutesUsed}:{}),{textGridding:v.textGridding.encode(c.gridding),Ornt:v.Ornt.encode(c.orientation),AntA:v.Annt.encode(c.antiAlias)}),((t=c.textOnPath)===null||t===void 0?void 0:t.type)!==void 0?{TxPT:`TxPT.${c.textOnPath.type}`}:{}),((i=c.textOnPath)===null||i===void 0?void 0:i.direction)!==void 0?{TxPR:`TxPR.${c.textOnPath.direction}`}:{}),((o=c.textOnPath)===null||o===void 0?void 0:o.mirror)!==void 0?{TxMP:!!c.textOnPath.mirror}:{}),c.bounds?{bounds:(0,v.boundsToDescBounds)(c.bounds)}:{}),c.boundingBox?{boundingBox:(0,v.boundsToDescBounds)(c.boundingBox)}:{}),{TextIndex:c.index||0}),c.verticalAlignment!==void 0?{VAlign:c.verticalAlignment}:{}),{EngineData:(0,Es.serializeEngineData)((0,Fs.encodeEngineData)(c))});(0,w.writeInt16)(e,1);for(let p=0;p<6;p++)(0,w.writeFloat64)(e,u[p]);(0,w.writeInt16)(e,50),(0,v.writeVersionAndDescriptor)(e,"","TxLr",d,"text"),(0,w.writeInt16)(e,1),(0,v.writeVersionAndDescriptor)(e,"","warp",Po(f)),(0,w.writeFloat32)(e,(r=c.left)!==null&&r!==void 0?r:0),(0,w.writeFloat32)(e,(s=c.top)!==null&&s!==void 0?s:0),(0,w.writeFloat32)(e,(a=c.right)!==null&&a!==void 0?a:0),(0,w.writeFloat32)(e,(l=c.bottom)!==null&&l!==void 0?l:0)});U("tySh",()=>!1,(e,n,t)=>{if((0,b.readInt16)(e)!==1)throw new Error("Invalid tySh version");let i=[];for(let l=0;l<6;l++)i.push((0,b.readFloat64)(e));if((0,b.readInt16)(e)!==6)throw new Error("Invalid tySh font version");let o={transform:i,faces:[],styles:[],lines:[],color:{r:0,g:0,b:0},antiAlias:!1},r=(0,b.readInt16)(e);for(let l=0;l<r;l++){let c=(0,b.readInt16)(e);(0,b.readInt32)(e);let f=(0,b.readPascalString)(e,1),u=(0,b.readPascalString)(e,1),d=(0,b.readPascalString)(e,1),p=(0,b.readInt16)(e),h=(0,b.readInt32)(e);if(h<0||h*4>t())throw new Error("Invalid tySh design axes count");(0,b.skipBytes)(e,h*4),o.faces.push({mark:c,name:f,familyName:u,styleName:d,script:p})}let s=(0,b.readInt16)(e);for(let l=0;l<s;l++){let c=(0,b.readInt16)(e),f=(0,b.readInt16)(e),u=(0,b.readInt32)(e),d=(0,b.readInt32)(e),p=(0,b.readInt32)(e),h=(0,b.readInt32)(e),m=(0,b.readInt32)(e),y=!!(0,b.readUint8)(e);(0,b.readUint8)(e),o.styles.push({mark:c,faceMark:f,size:u,tracking:d,kerning:p,leading:h,baselineShift:m,autoKerning:y})}(0,b.readInt16)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e);let a=(0,b.readInt16)(e);for(let l=0;l<a;l++){let c=(0,b.readInt32)(e),f=(0,b.readInt16)(e),u=(0,b.readInt16)(e);if(c<0||c*4>t())throw new Error("Invalid tySh character count");let d=[];for(let p=0;p<c;p++){let h=(0,b.readUint16)(e),m=(0,b.readInt16)(e);d.push({code:h,style:m})}o.lines.push({orientation:f,alignment:u,chars:d})}o.color=(0,b.readColor)(e),o.antiAlias=!!(0,b.readUint8)(e),n.text||(n.text=(0,Fs.decodeLegacyTextData)(o)),(0,b.skipBytes)(e,t())},()=>{});U("SoCo",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="color",(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("GdFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&(e.vectorFill.type==="solid"||e.vectorFill.type==="noise"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("PtFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="pattern",(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("vscg",e=>e.vectorFill!==void 0&&e.vectorStroke!==void 0,(e,n,t)=>{(0,b.readSignature)(e);let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t,key:i}=(0,v.serializeVectorContent)(n.vectorFill);(0,w.writeSignature)(e,i),(0,v.writeVersionAndDescriptor)(e,"","null",t)});function td(e,n,t){let i=(0,b.readFixedPointPath32)(e)*t,o=(0,b.readFixedPointPath32)(e)*n,r=(0,b.readFixedPointPath32)(e)*t,s=(0,b.readFixedPointPath32)(e)*n,a=(0,b.readFixedPointPath32)(e)*t,l=(0,b.readFixedPointPath32)(e)*n;return[o,i,s,r,l,a]}function Gg(e,n,t,i){(0,w.writeFixedPointPath32)(e,n[1]/i),(0,w.writeFixedPointPath32)(e,n[0]/t),(0,w.writeFixedPointPath32)(e,n[3]/i),(0,w.writeFixedPointPath32)(e,n[2]/t),(0,w.writeFixedPointPath32)(e,n[5]/i),(0,w.writeFixedPointPath32)(e,n[4]/t)}Ae.booleanOperations=["exclude","combine","subtract","intersect"];function nd(e,n,t,i,o){let r=e.offset+o,s=n.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),f=(0,b.readUint16)(e);(0,b.skipBytes)(e,18),a={open:l===3,knots:[],fillRule:f===2?"non-zero":"even-odd"},c!==-1&&(a.operation=Ae.booleanOperations[c]),s.push(a);break}case 1:case 2:case 4:case 5:if(!a)throw new Error("Bezier knot record without subpath length record");a.knots.push({linked:l===1||l===4,points:td(e,t,i)});break;case 6:(0,b.skipBytes)(e,24);break;case 7:{let c=(0,b.readFixedPointPath32)(e),f=(0,b.readFixedPointPath32)(e),u=(0,b.readFixedPointPath32)(e),d=(0,b.readFixedPointPath32)(e),p=(0,b.readFixedPointPath32)(e);(0,b.skipBytes)(e,4),n.clipboard={top:c,left:f,bottom:u,right:d,resolution:p};break}case 8:n.fillStartsWithAllPixels=!!(0,b.readUint16)(e),(0,b.skipBytes)(e,22);break;default:throw new Error("Invalid vmsk section")}}return s}function id(e,n,t,i,o=!1){(0,w.writeUint16)(e,6),(0,w.writeZeros)(e,24);let r=n.clipboard;r&&((0,w.writeUint16)(e,7),(0,w.writeFixedPointPath32)(e,r.top),(0,w.writeFixedPointPath32)(e,r.left),(0,w.writeFixedPointPath32)(e,r.bottom),(0,w.writeFixedPointPath32)(e,r.right),(0,w.writeFixedPointPath32)(e,r.resolution),(0,w.writeZeros)(e,4)),(0,w.writeUint16)(e,8),(0,w.writeUint16)(e,n.fillStartsWithAllPixels?1:0),(0,w.writeZeros)(e,22);let s=-1;for(let a of n.paths){(a.operation||s<0)&&s++,(0,w.writeUint16)(e,a.open?3:0),(0,w.writeUint16)(e,a.knots.length),(0,w.writeUint16)(e,a.operation?Ae.booleanOperations.indexOf(a.operation):-1),(0,w.writeUint16)(e,a.fillRule==="non-zero"?2:1),(0,w.writeZeros)(e,4),(0,w.writeUint32)(e,o?s:0),(0,w.writeZeros)(e,10);let l=a.open?4:1,c=a.open?5:2;for(let{linked:f,points:u}of a.knots)(0,w.writeUint16)(e,f?l:c),Gg(e,u,t,i)}}U("vmsk",le("vectorMask"),(e,n,t,{width:i,height:o})=>{if((0,b.readUint32)(e)!==3)throw new Error("Invalid vmsk version");n.vectorMask={paths:[]};let r=n.vectorMask,s=(0,b.readUint32)(e);r.invert=(s&1)!==0,r.notLink=(s&2)!==0,r.disable=(s&4)!==0,nd(e,r,i,o,t()),(0,b.skipBytes)(e,t())},(e,n,{width:t,height:i})=>{let o=n.vectorMask,r=(o.invert?1:0)|(o.notLink?2:0)|(o.disable?4:0);(0,w.writeUint32)(e,3),(0,w.writeUint32)(e,r),id(e,o,t,i,!0)});lt("vsms","vmsk");U("vowv",le("vowv"),(e,n)=>{n.vowv=(0,b.readUint32)(e)},(e,n)=>{(0,w.writeUint32)(e,n.vowv)});function _s(e){return[(0,v.horzVrtcToXY)(e.rectangleCornerA),(0,v.horzVrtcToXY)(e.rectangleCornerB),(0,v.horzVrtcToXY)(e.rectangleCornerC),(0,v.horzVrtcToXY)(e.rectangleCornerD)]}function As(e){return{rectangleCornerA:(0,v.xyToHorzVrtc)(e[0]),rectangleCornerB:(0,v.xyToHorzVrtc)(e[1]),rectangleCornerC:(0,v.xyToHorzVrtc)(e[2]),rectangleCornerD:(0,v.xyToHorzVrtc)(e[3])}}function od(e){let n=[];for(let t of e.keyDescriptorList){let i={};t.keyShapeInvalidated!=null&&(i.keyShapeInvalidated=t.keyShapeInvalidated),t.keyOriginType!=null&&(i.keyOriginType=t.keyOriginType),t.keyOriginResolution!=null&&(i.keyOriginResolution=t.keyOriginResolution),t.keyOriginShapeBBox&&(i.keyOriginShapeBoundingBox={top:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox["Top "]),left:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Left),bottom:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Btom),right:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Rght)});let o=t.keyOriginRRectRadii;o&&(i.keyOriginRRectRadii={topRight:(0,v.parseUnits)(o.topRight),topLeft:(0,v.parseUnits)(o.topLeft),bottomLeft:(0,v.parseUnits)(o.bottomLeft),bottomRight:(0,v.parseUnits)(o.bottomRight)}),t.keyOriginBoxCorners&&(i.keyOriginBoxCorners=_s(t.keyOriginBoxCorners)),t.keyOriginPolySides!=null&&(i.keyOriginPolySides=t.keyOriginPolySides),t.keyOriginPolyCornerRadius!=null&&(i.keyOriginPolyCornerRadius=t.keyOriginPolyCornerRadius),t.keyOriginPolyStarRatio&&(i.keyOriginPolyStarRatio=(0,v.parsePercent)(t.keyOriginPolyStarRatio)),t.keyOriginPolyPreviousTightBoxCorners&&(i.keyOriginPolyPreviousTightBoxCorners=_s(t.keyOriginPolyPreviousTightBoxCorners)),t.keyOriginPolyTrueRectCorners&&(i.keyOriginPolyTrueRectCorners=_s(t.keyOriginPolyTrueRectCorners)),t.keyOriginPolyPixelHSF!=null&&(i.keyOriginPolyPixelHSF=t.keyOriginPolyPixelHSF),t.keyOriginLineStart&&(i.keyOriginLineStart=(0,v.horzVrtcToXY)(t.keyOriginLineStart)),t.keyOriginLineEnd&&(i.keyOriginLineEnd=(0,v.horzVrtcToXY)(t.keyOriginLineEnd)),t.keyOriginLineWeight!=null&&(i.keyOriginLineWeight=t.keyOriginLineWeight),t.keyOriginLineArrowSt!=null&&(i.keyOriginLineArrowStart=t.keyOriginLineArrowSt),t.keyOriginLineArrowEnd!=null&&(i.keyOriginLineArrowEnd=t.keyOriginLineArrowEnd),t.keyOriginLineArrWdth!=null&&(i.keyOriginLineArrowWidth=t.keyOriginLineArrWdth),t.keyOriginLineArrLngth!=null&&(i.keyOriginLineArrowLength=t.keyOriginLineArrLngth),t.keyOriginLineArrConc!=null&&(i.keyOriginLineArrowConcavity=t.keyOriginLineArrConc);let r=t.Trnf;r&&(i.transform=[r.xx,r.xy,r.yx,r.yy,r.tx,r.ty]),n.push(i)}return n}function rd(e){let n={keyDescriptorList:[]};for(let t=0;t<e.length;t++){let i=e[t];n.keyDescriptorList.push({});let o=n.keyDescriptorList[n.keyDescriptorList.length-1];i.keyOriginType!=null&&(o.keyOriginType=i.keyOriginType),i.keyOriginResolution!=null&&(o.keyOriginResolution=i.keyOriginResolution);let r=i.keyOriginRRectRadii;r&&(o.keyOriginRRectRadii={unitValueQuadVersion:1,topRight:(0,v.unitsValue)(r.topRight,"topRight"),topLeft:(0,v.unitsValue)(r.topLeft,"topLeft"),bottomLeft:(0,v.unitsValue)(r.bottomLeft,"bottomLeft"),bottomRight:(0,v.unitsValue)(r.bottomRight,"bottomRight")});let s=i.keyOriginShapeBoundingBox;s&&(o.keyOriginShapeBBox={unitValueQuadVersion:1,"Top ":(0,v.unitsValue)(s.top,"top"),Left:(0,v.unitsValue)(s.left,"left"),Btom:(0,v.unitsValue)(s.bottom,"bottom"),Rght:(0,v.unitsValue)(s.right,"right")});let a=i.keyOriginBoxCorners;a&&a.length===4&&(o.keyOriginBoxCorners=As(a)),i.keyOriginPolySides!=null&&(o.keyOriginPolySides=i.keyOriginPolySides),i.keyOriginPolyCornerRadius!=null&&(o.keyOriginPolyCornerRadius=i.keyOriginPolyCornerRadius),i.keyOriginPolyStarRatio!=null&&(o.keyOriginPolyStarRatio=(0,v.unitsPercentF)(i.keyOriginPolyStarRatio));let l=i.keyOriginPolyPreviousTightBoxCorners;l&&l.length===4&&(o.keyOriginPolyPreviousTightBoxCorners=As(l));let c=i.keyOriginPolyTrueRectCorners;c&&c.length===4&&(o.keyOriginPolyTrueRectCorners=As(c)),i.keyOriginPolyPixelHSF!=null&&(o.keyOriginPolyPixelHSF=i.keyOriginPolyPixelHSF),i.keyOriginLineEnd&&(o.keyOriginLineEnd=(0,v.xyToHorzVrtc)(i.keyOriginLineEnd)),i.keyOriginLineStart&&(o.keyOriginLineStart=(0,v.xyToHorzVrtc)(i.keyOriginLineStart)),i.keyOriginLineWeight!=null&&(o.keyOriginLineWeight=i.keyOriginLineWeight),i.keyOriginLineArrowStart!=null&&(o.keyOriginLineArrowSt=!!i.keyOriginLineArrowStart),i.keyOriginLineArrowEnd!=null&&(o.keyOriginLineArrowEnd=!!i.keyOriginLineArrowEnd),i.keyOriginLineArrowWidth!=null&&(o.keyOriginLineArrWdth=i.keyOriginLineArrowWidth),i.keyOriginLineArrowLength!=null&&(o.keyOriginLineArrLngth=i.keyOriginLineArrowLength),i.keyOriginLineArrowConcavity!=null&&(o.keyOriginLineArrConc=i.keyOriginLineArrowConcavity);let f=i.transform;f&&f.length===6&&(o.Trnf={xx:f[0],xy:f[1],yx:f[2],yy:f[3],tx:f[4],ty:f[5]}),i.keyShapeInvalidated!=null&&(o.keyShapeInvalidated=i.keyShapeInvalidated),o.keyOriginIndex=t}return n}U("vogk",le("vectorOrigination"),(e,n,t)=>{if((0,b.readInt32)(e)!==1)throw new Error("Invalid vogk version");let i=(0,v.readVersionAndDescriptor)(e);n.vectorOrigination={keyDescriptorList:od(i)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=rd(n.vectorOrigination.keyDescriptorList);(0,w.writeInt32)(e,1),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("lmfx",e=>e.effects!==void 0&&!Ts(e)&&Do(e.effects),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lmfx version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("lrFX",le("effects"),(e,n,t)=>{n.effects||(n.effects=(0,Tf.readEffects)(e)),(0,b.skipBytes)(e,t())},(e,n)=>{(0,Tf.writeEffects)(e,n.effects)});U("luni",le("name"),(e,n,t)=>{if(t()>4){let i=(0,b.readUint32)(e);t()>=i*2?n.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,t())},(e,n)=>{(0,w.writeUnicodeString)(e,n.name)});U("lnsr",le("nameSource"),(e,n)=>n.nameSource=(0,b.readSignature)(e),(e,n)=>(0,w.writeSignature)(e,n.nameSource));function Hg(e){return!!(e.animationFrames||e.timeline||e.comps)}function jf(e,n){if(!n.explicitLayerIds){let t=new Set,i=o=>{for(let r of o??[])r.id!==void 0&&t.add(r.id),i(r.children)};i(e.children),n.explicitLayerIds=t}return n.explicitLayerIds}function Is(e,n){var t;let i=(t=n.layerToId.get(e))!==null&&t!==void 0?t:e.id;if(i===void 0)throw new Error("Missing layer id");return i}U("lyid",e=>e.id!==void 0||Hg(e),(e,n)=>{n.id=(0,b.readUint32)(e)},(e,n,t,i)=>{var o;let r;if(n.id!==void 0){if(r=n.id,i.layerIds.has(r)){let s=jf(t,i);for(;i.layerIds.has(r)||s.has(r);)r+=100}}else{let s=jf(t,i);for(r=(o=i.nextGeneratedLayerId)!==null&&o!==void 0?o:1;i.layerIds.has(r)||s.has(r);)r++;i.nextGeneratedLayerId=r+1}(0,w.writeUint32)(e,r),i.layerIds.add(r),i.layerToId.set(n,r)});U("lsct",le("sectionDivider"),(e,n,t)=>{n.sectionDivider={type:(0,b.readUint32)(e)},t()&&((0,b.checkSignature)(e,"8BIM"),n.sectionDivider.key=(0,b.readSignature)(e)),t()&&(n.sectionDivider.subType=(0,b.readUint32)(e))},(e,n)=>{(0,w.writeUint32)(e,n.sectionDivider.type),n.sectionDivider.key&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,n.sectionDivider.key),n.sectionDivider.subType!==void 0&&(0,w.writeUint32)(e,n.sectionDivider.subType))});lt("lsdk","lsct");U("clbl",le("blendClippendElements"),(e,n)=>{n.blendClippendElements=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.blendClippendElements?1:0),(0,w.writeZeros)(e,3)});U("infx",le("blendInteriorElements"),(e,n)=>{n.blendInteriorElements=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.blendInteriorElements?1:0),(0,w.writeZeros)(e,3)});U("knko",le("knockout"),(e,n)=>{n.knockout=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.knockout?1:0),(0,w.writeZeros)(e,3)});U("lmgm",le("layerMaskAsGlobalMask"),(e,n)=>{n.layerMaskAsGlobalMask=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.layerMaskAsGlobalMask?1:0),(0,w.writeZeros)(e,3)});U("vmgm",le("vectorMaskAsGlobalMask"),(e,n)=>{n.vectorMaskAsGlobalMask=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.vectorMaskAsGlobalMask?1:0),(0,w.writeZeros)(e,3)});U("ffxi",le("foreignEffectId"),(e,n)=>{n.foreignEffectId=(0,b.readInt32)(e)},(e,n)=>{(0,w.writeInt32)(e,n.foreignEffectId)});U("shpa",le("patternData"),(e,n,t)=>{if((0,b.readInt32)(e)!==0)throw new Error("Invalid shpa version");let i=(0,b.readInt32)(e);n.patternData=[];for(let o=0;o<i&&t()>0;o++){let r=(0,b.readSignature)(e),s=(0,b.readSignature)(e),a=(0,b.readInt32)(e),l=!!(0,b.readUint8)(e);(0,b.skipBytes)(e,3);let c=[];for(let f=0;f<a&&t()>0;f++){let u=v.patternColorHandling.decode("."+(0,b.readSignature)(e));(0,b.readPascalString)(e,1);let d=(0,b.readUnicodeString)(e),p=(0,b.readPascalString)(e,1);c.push({colorHandling:u,name:d,id:p})}n.patternData.push({signature:r,key:s,copyOnSheetDuplication:l,patterns:c})}(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.patternData;(0,w.writeInt32)(e,0),(0,w.writeInt32)(e,t.length);for(let i of t){(0,w.writeSignature)(e,i.signature),(0,w.writeSignature)(e,i.key),(0,w.writeInt32)(e,i.patterns.length),(0,w.writeUint8)(e,i.copyOnSheetDuplication?1:0),(0,w.writeZeros)(e,3);for(let o of i.patterns)(0,w.writeSignature)(e,v.patternColorHandling.encode(o.colorHandling).split(".")[1]),(0,w.writePascalString)(e,o.name.replace(/[^\x20-\x7e]/g,"?"),1),(0,w.writeUnicodeString)(e,o.name),(0,w.writePascalString)(e,o.id,1)}});U("lspf",le("protected"),(e,n)=>{let t=(0,b.readUint32)(e);n.protected={transparency:(t&1)!==0,composite:(t&2)!==0,position:(t&4)!==0},t&8&&(n.protected.artboards=!0),t&2147483648&&(n.protected.all=!0)},(e,n)=>{let t=(n.protected.transparency?1:0)|(n.protected.composite?2:0)|(n.protected.position?4:0)|(n.protected.artboards?8:0)|(n.protected.all?2147483648:0);(0,w.writeUint32)(e,t>>>0)});U("lclr",le("layerColor"),(e,n)=>{let t=(0,b.readUint16)(e);(0,b.skipBytes)(e,6),n.layerColor=De.layerColors[t]},(e,n)=>{let t=De.layerColors.indexOf(n.layerColor);(0,w.writeUint16)(e,t===-1?0:t),(0,w.writeZeros)(e,6)});function Us(e){let n={};return e.exportAs&&(n.exportAs={},e.exportAs.exportOption!==void 0&&(n.exportAs.exportOption=e.exportAs.exportOption),e.exportAs.scaleSettings!==void 0&&(n.exportAs.scaleSettings=e.exportAs.scaleSettings)),e.generator_45_assets&&(n.assets=e.generator_45_assets.json),e.layerTime!==void 0&&(n.layerTime=e.layerTime),e.crema&&(n.crema=e.crema.json),n}function sd(e){let n={_name:"",_classID:e.assets!==void 0?"generatorSettings":"null"};return e.exportAs&&(n.exportAs={_name:"",_classID:"null"},e.exportAs.exportOption!==void 0&&(n.exportAs.exportOption=e.exportAs.exportOption),e.exportAs.scaleSettings!==void 0&&(n.exportAs.scaleSettings=e.exportAs.scaleSettings)),e.assets!==void 0&&(n.generator_45_assets={_name:"",_classID:"generatorSettings",json:e.assets}),e.layerTime!==void 0&&(n.layerTime=e.layerTime),e.crema!==void 0&&(n.crema={_name:"",_classID:"null",json:e.crema}),{generatorSettings:n}}function Ls(e){return e.width!==void 0}var ad=(0,De.createEnum)("knockout","none",{none:"none",shallow:"shallow",deep:"deep"});function zf(e,n){e["Md "]!==void 0&&(n.blendMode=v.BlnM.decode(e["Md "])),e.Opct!==void 0&&(n.opacity=(0,v.parsePercent)(e.Opct)),e.fillOpacity!==void 0&&(n.fillOpacity=(0,v.parsePercent)(e.fillOpacity)),e.blendInterior!==void 0&&(n.blendInteriorElements=e.blendInterior),e.blendClipped!==void 0&&(n.blendClippedElements=e.blendClipped),e.knockout!==void 0&&(n.knockout=ad.decode(e.knockout))}function $f(e){let n={};return e.blendMode!==void 0&&(n["Md "]=v.BlnM.encode(e.blendMode)),e.opacity!==void 0&&(n.Opct=(0,v.unitsPercentF)(e.opacity)),e.fillOpacity!==void 0&&(n.fillOpacity=(0,v.unitsPercentF)(e.fillOpacity)),e.blendInteriorElements!==void 0&&(n.blendInterior=!!e.blendInteriorElements),e.blendClippedElements!==void 0&&(n.blendClipped=!!e.blendClippedElements),e.knockout!==void 0&&(n.knockout=ad.encode(e.knockout)),Object.keys(n).length?n:void 0}function Vf(e,n){let t=e.textLayerSettings;t&&(n.text={warp:{style:v.warpStyle.decode(t.warpStyle),value:t.warpValue||0,perspective:t.warpPerspective||0,perspectiveOther:t.warpPerspectiveOther||0,rotate:v.Ornt.decode(t.warpRotate)},warpRect:t.textLayerSettingsWarpRect||[0,0,0,0]}),e.placedLayerSettings&&(n.placedLayerCompId=e.placedLayerSettings.placedLayerCompID)}function Nf(e){let n={},t=e.text;return t&&(n.textLayerSettings={warpStyle:v.warpStyle.encode(t.warp.style),warpValue:t.warp.value||0,warpPerspective:t.warp.perspective||0,warpPerspectiveOther:t.warp.perspectiveOther||0,warpRotate:v.Ornt.encode(t.warp.rotate),textLayerSettingsWarpRect:t.warpRect||[0,0,0,0]}),e.placedLayerCompId!==void 0&&(n.placedLayerSettings={placedLayerCompID:e.placedLayerCompId}),Object.keys(n).length?n:void 0}U("shmd",e=>e.timestamp!==void 0||e.animationFrames!==void 0||e.animationFrameFlags!==void 0||e.timeline!==void 0||e.comps!==void 0||e.generatorSettings!==void 0&&!Ls(e),(e,n,t)=>{let i=(0,b.readUint32)(e);for(let o=0;o<i;o++){let r=(0,b.readSignature)(e);if(r!=="8BIM"&&r!=="8ELE")throw new Error(`Invalid shmd signature: '${r}'`);let s=(0,b.readSignature)(e);(0,b.readUint8)(e),(0,b.skipBytes)(e,3);let a=e.offset+4+e.view.getUint32(e.offset);try{(0,b.readSection)(e,1,l=>{var c,f,u;if(s==="cust"){let d=(0,v.readVersionAndDescriptor)(e);d.layerTime!==void 0&&(n.timestamp=d.layerTime)}else if(s==="mlst"){let d=(0,v.readVersionAndDescriptor)(e);n.animationFrames=[];for(let p=0;p<d.LaSt.length;p++){let h=d.LaSt[p],m={frames:h.FrLs};h.enab!==void 0&&(m.enable=h.enab),h.Ofst&&(m.offset=(0,v.horzVrtcToXY)(h.Ofst)),!((c=h.IMsk)===null||c===void 0)&&c.Ofst&&(m.maskOffset=(0,v.horzVrtcToXY)(h.IMsk.Ofst)),!((f=h.VMsk)===null||f===void 0)&&f.Ofst&&(m.vectorMaskOffset=(0,v.horzVrtcToXY)(h.VMsk.Ofst)),h.FXRf&&(m.referencePoint=(0,v.horzVrtcToXY)(h.FXRf)),h.Lefx&&(m.effects=(0,v.parseEffects)(h.Lefx,e)),h.blendOptions&&zf(h.blendOptions,m),h.LSpc&&Vf(h.LSpc,m),n.animationFrames.push(m)}}else if(s==="mdyn"){(0,b.readUint16)(e);let d=(0,b.readUint8)(e),p=(0,b.readUint8)(e);n.animationFrameFlags={propagateFrameOne:!d,unifyLayerPosition:(p&1)!==0,unifyLayerStyle:(p&2)!==0,unifyLayerVisibility:(p&4)!==0}}else if(s==="tmln"){let d=(0,v.readVersionAndDescriptor)(e),p=d.timeScope,h={start:(0,v.frac)(p.Strt),duration:(0,v.frac)(p.duration),inTime:(0,v.frac)(p.inTime),outTime:(0,v.frac)(p.outTime),autoScope:d.autoScope,audioLevel:d.audioLevel};d.trackList&&(h.tracks=(0,v.parseTrackList)(d.trackList,e)),n.timeline=h}else if(s==="cmls"){let d=(0,v.readVersionAndDescriptor)(e);n.comps={settings:[]},d.origFXRefPoint&&(n.comps.originalEffectsReferencePoint={x:d.origFXRefPoint.Hrzn,y:d.origFXRefPoint.Vrtc});for(let p of d.layerSettings){n.comps.settings.push({compList:p.compList});let h=n.comps.settings[n.comps.settings.length-1];"enab"in p&&(h.enabled=p.enab),p.Ofst&&(h.offset={x:p.Ofst.Hrzn,y:p.Ofst.Vrtc}),!((u=p.vectorMask)===null||u===void 0)&&u.Ofst&&(h.vectorMaskOffset=(0,v.horzVrtcToXY)(p.vectorMask.Ofst)),p.Lefx&&(h.effects=(0,v.parseEffects)(p.Lefx,e)),p.blendOptions&&zf(p.blendOptions,h),p.FXRefPoint&&(h.effectsReferencePoint={x:p.FXRefPoint.Hrzn,y:p.FXRefPoint.Vrtc}),p.layerSpecific&&Vf(p.layerSpecific,h)}}else if(s==="extn"){let d=(0,v.readVersionAndDescriptor)(e);d.generatorSettings&&(n.generatorSettings=Us(d.generatorSettings))}else e.logMissingFeatures&&e.log('Unhandled "shmd" section key',s);(0,b.skipBytes)(e,l())})}catch(l){if(e.throwForMissingFeatures)throw l;e.logMissingFeatures&&e.log(`Failed to read "shmd" section key ${s}: ${l.message}`),e.offset=a}}(0,b.skipBytes)(e,t())},(e,n,t,i)=>{let{animationFrames:o,animationFrameFlags:r,timestamp:s,timeline:a,comps:l}=n,c=Ls(n)?void 0:n.generatorSettings,f=0;o&&f++,r&&f++,a&&f++,s!==void 0&&f++,l&&f++,c&&f++,(0,w.writeUint32)(e,f),o&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"mlst"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={LaID:Is(n,i),LaSt:[]};for(let d=0;d<o.length;d++){let p=o[d],h={};p.enable!==void 0&&(h.enab=p.enable),h.FrLs=p.frames,p.offset&&(h.Ofst=(0,v.xyToHorzVrtc)(p.offset)),p.maskOffset&&(h.IMsk={Ofst:(0,v.xyToHorzVrtc)(p.maskOffset)}),p.vectorMaskOffset&&(h.VMsk={Ofst:(0,v.xyToHorzVrtc)(p.vectorMaskOffset)}),p.referencePoint&&(h.FXRf=(0,v.xyToHorzVrtc)(p.referencePoint));let m=Nf(p);m&&(h.LSpc=m),p.effects&&(h.Lefx=(0,v.serializeEffects)(p.effects,e,Do(p.effects)));let y=$f(p);y&&(h.blendOptions=y),u.LaSt.push(h)}(0,v.writeVersionAndDescriptor)(e,"","null",u,v.layerStateRoot)},!0)),r&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"mdyn"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{(0,w.writeUint16)(e,0),(0,w.writeUint8)(e,r.propagateFrameOne?0:15),(0,w.writeUint8)(e,(r.unifyLayerPosition?1:0)|(r.unifyLayerStyle?2:0)|(r.unifyLayerVisibility?4:0))})),a&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"tmln"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={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&&(u.trackList=(0,v.serializeTrackList)(a.tracks,e)),u.LyrI=Is(n,i),(0,v.writeVersionAndDescriptor)(e,"","null",u,"anim")},!0)),s!==void 0&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"cust"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={layerTime:s};(0,v.writeVersionAndDescriptor)(e,"","metadata",u)},!0)),l&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"cmls"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={};l.originalEffectsReferencePoint&&(u.origFXRefPoint={Hrzn:l.originalEffectsReferencePoint.x,Vrtc:l.originalEffectsReferencePoint.y}),u.LyrI=Is(n,i),u.layerSettings=[];for(let d of l.settings){let p={};if(d.enabled!==void 0&&(p.enab=d.enabled),d.offset&&(p.Ofst=(0,v.xyToHorzVrtc)(d.offset)),d.vectorMaskOffset&&(p.vectorMask={Ofst:(0,v.xyToHorzVrtc)(d.vectorMaskOffset)}),d.effects){let y=(0,v.serializeEffects)(d.effects,e,!0),{numModifyingFX:g}=y,k=Vg(y,["numModifyingFX"]);p.Lefx=k}let h=$f(d);h&&(p.blendOptions=h),d.effectsReferencePoint&&(p.FXRefPoint={Hrzn:d.effectsReferencePoint.x,Vrtc:d.effectsReferencePoint.y});let m=Nf(d);m&&(p.layerSpecific=m),p.compList=d.compList,u.layerSettings.push(p)}(0,v.writeVersionAndDescriptor)(e,"","null",u,v.layerStateRoot)},!0)),c&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"extn"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{(0,v.writeVersionAndDescriptor)(e,"","null",sd(c))},!0))});U("PxSc",le("pixelSource"),(e,n)=>{let t=(0,v.readVersionAndDescriptor)(e,!0);t.pixelSourceType===1986285651?n.pixelSource={type:"vdPS",origin:{x:t.origin.Hrzn,y:t.origin.Vrtc},interpretation:{interpretAlpha:t.interpretation.interpretAlpha.split(".")[1],profile:t.interpretation.profile},frameReader:{type:"QTFR",link:{name:t.frameReader["Lnk "]["Nm "],fullPath:t.frameReader["Lnk "].fullPath,originalPath:t.frameReader["Lnk "].originalPath,relativePath:t.frameReader["Lnk "].relPath,alias:t.frameReader["Lnk "].alis},mediaDescriptor:t.frameReader.mediaDescriptor},showAlteredVideo:t.showAlteredVideo}:e.log("Unknown pixelSourceType")},(e,n)=>{let t=n.pixelSource,i={_name:"",_classID:"PixelSource",pixelSourceType:1986285651,descVersion:1,origin:{Hrzn:t.origin.x,Vrtc:t.origin.y},interpretation:{_name:"",_classID:"footageInterpretation",Vrsn:1,interpretAlpha:`alphaInterpretation.${t.interpretation.interpretAlpha}`,profile:t.interpretation.profile},frameReader:{_name:"",_classID:"FrameReader",frameReaderType:1364477522,descVersion:1,"Lnk ":{_name:"",_classID:"ExternalFileLink",descVersion:2,"Nm ":t.frameReader.link.name,fullPath:t.frameReader.link.fullPath,originalPath:t.frameReader.link.originalPath,alis:t.frameReader.link.alias,relPath:t.frameReader.link.relativePath},mediaDescriptor:t.frameReader.mediaDescriptor},showAlteredVideo:t.showAlteredVideo};(0,v.writeVersionAndDescriptor)(e,"","PixelSource",i)});U("vstk",le("vectorStroke"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorStroke={strokeEnabled:i.strokeEnabled,fillEnabled:i.fillEnabled,lineWidth:(0,v.parseUnits)(i.strokeStyleLineWidth),lineDashOffset:(0,v.parseUnits)(i.strokeStyleLineDashOffset),miterLimit:i.strokeStyleMiterLimit,lineCapType:v.strokeStyleLineCapType.decode(i.strokeStyleLineCapType),lineJoinType:v.strokeStyleLineJoinType.decode(i.strokeStyleLineJoinType),lineAlignment:v.strokeStyleLineAlignment.decode(i.strokeStyleLineAlignment),scaleLock:i.strokeStyleScaleLock,strokeAdjust:i.strokeStyleStrokeAdjust,lineDashSet:(i.strokeStyleLineDashSet||[]).map(v.parseUnits),blendMode:v.BlnM.decode(i.strokeStyleBlendMode),opacity:(0,v.parsePercent)(i.strokeStyleOpacity),content:(0,v.parseVectorContent)(i.strokeStyleContent),resolution:i.strokeStyleResolution},(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o;let r=n.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:(t=r.miterLimit)!==null&&t!==void 0?t:100,strokeStyleLineCapType:v.strokeStyleLineCapType.encode(r.lineCapType),strokeStyleLineJoinType:v.strokeStyleLineJoinType.encode(r.lineJoinType),strokeStyleLineAlignment:v.strokeStyleLineAlignment.encode(r.lineAlignment),strokeStyleScaleLock:!!r.scaleLock,strokeStyleStrokeAdjust:!!r.strokeAdjust,strokeStyleLineDashSet:r.lineDashSet||[],strokeStyleBlendMode:v.BlnM.encode(r.blendMode),strokeStyleOpacity:(0,v.unitsPercent)((i=r.opacity)!==null&&i!==void 0?i:1),strokeStyleContent:(0,v.serializeVectorContent)(r.content||{type:"color",color:{r:0,g:0,b:0}}).descriptor,strokeStyleResolution:(o=r.resolution)!==null&&o!==void 0?o:72};(0,v.writeVersionAndDescriptor)(e,"","strokeStyle",s)});U("artb",le("artboard"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=i.artboardRect;n.artboard={rect:{top:o["Top "],left:o.Left,bottom:o.Btom,right:o.Rght},guideIndices:i.guideIndeces,presetName:i.artboardPresetName},i["Clr "]&&(n.artboard.color=(0,v.parseColor)(i["Clr "])),i.artboardBackgroundType!==void 0&&(n.artboard.backgroundType=i.artboardBackgroundType),(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.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,v.serializeColor)(i.color),artboardBackgroundType:(t=i.backgroundType)!==null&&t!==void 0?t:1};(0,v.writeVersionAndDescriptor)(e,"","artboard",r)});U("sn2P",le("usingAlignedRendering"),(e,n)=>n.usingAlignedRendering=!!(0,b.readUint32)(e),(e,n)=>(0,w.writeUint32)(e,n.usingAlignedRendering?1:0));var Nn=["unknown","vector","raster","image stack"];function ld(e){var n,t,i,o,r,s;let a=Object.assign(Object.assign({style:v.warpStyle.decode(e.warpStyle)},e.warpValues?{values:e.warpValues}:{value:e.warpValue||0}),{perspective:e.warpPerspective||0,perspectiveOther:e.warpPerspectiveOther||0,rotate:v.Ornt.decode(e.warpRotate),bounds:e.bounds&&{top:(0,v.parseUnitsOrNumber)(e.bounds["Top "]),left:(0,v.parseUnitsOrNumber)(e.bounds.Left),bottom:(0,v.parseUnitsOrNumber)(e.bounds.Btom),right:(0,v.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=((n=l.meshPoints.find(u=>u.type==="Hrzn"))===null||n===void 0?void 0:n.values)||[],f=((t=l.meshPoints.find(u=>u.type==="Vrtc"))===null||t===void 0?void 0:t.values)||[];for(let u=0;u<c.length;u++)a.customEnvelopeWarp.meshPoints.push({x:c[u],y:f[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 Bs(e){var n,t;return e.deformNumCols!=null||e.deformNumRows!=null||((n=e.customEnvelopeWarp)===null||n===void 0?void 0:n.quiltSliceX)||((t=e.customEnvelopeWarp)===null||t===void 0?void 0:t.quiltSliceY)}function Po(e){let n=e.bounds,t=Object.assign(Object.assign({warpStyle:v.warpStyle.encode(e.style)},e.values?{warpValues:e.values}:{warpValue:e.value||0}),{warpPerspective:e.perspective||0,warpPerspectiveOther:e.perspectiveOther||0,warpRotate:v.Ornt.encode(e.rotate),bounds:{"Top ":(0,v.unitsValue)(n&&n.top||{units:"Pixels",value:0},"bounds.top"),Left:(0,v.unitsValue)(n&&n.left||{units:"Pixels",value:0},"bounds.left"),Btom:(0,v.unitsValue)(n&&n.bottom||{units:"Pixels",value:0},"bounds.bottom"),Rght:(0,v.unitsValue)(n&&n.right||{units:"Pixels",value:0},"bounds.right")},uOrder:e.uOrder||0,vOrder:e.vOrder||0}),i=Bs(e);if(i){let r=t;r.deformNumRows=e.deformNumRows||0,r.deformNumCols=e.deformNumCols||0}let o=e.customEnvelopeWarp;if(o){let r=o.meshPoints||[];if(i){let s=t;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 t.customEnvelopeWarp={_name:"",_classID:"customEnvelopeWarp",meshPoints:[{type:"Hrzn",values:r.map(s=>s.x)},{type:"Vrtc",values:r.map(s=>s.y)}]}}return t}U("PlLd",e=>!!e.placedLayer&&!e.placedLayer.external,(e,n,t)=>{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(!Nn[s])throw new Error("Invalid PlLd type");let a=[];for(let f=0;f<8;f++)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,v.readVersionAndDescriptor)(e);n.placedLayer=n.placedLayer||{id:i,type:Nn[s],pageNumber:o,totalPages:r,transform:a,warp:ld(c)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.placedLayer;if((0,w.writeSignature)(e,"plcL"),(0,w.writeInt32)(e,3),!t.id||typeof t.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(t.id))throw new Error("Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,w.writePascalString)(e,t.id,1),(0,w.writeInt32)(e,t.pageNumber||1),(0,w.writeInt32)(e,t.totalPages||1),(0,w.writeInt32)(e,16),Nn.indexOf(t.type)===-1)throw new Error("Invalid placedLayer type");(0,w.writeInt32)(e,Nn.indexOf(t.type));for(let s=0;s<8;s++)(0,w.writeFloat64)(e,t.transform[s]);(0,w.writeInt32)(e,0);let i=fd(t),r=Bs(i)?"quiltWarp":"warp";(0,v.writeVersionAndDescriptor)(e,"",r,Po(i),r)});var Wg=["_name","_classID","presetKind","Adjs"],Xg=["_name","_classID","Chnl","Inpt","Otpt","Gmm "];function qg(e){let n=Math.floor(e.byteLength/4);return new Float32Array(e.buffer.slice(e.byteOffset,e.byteOffset+n*4),0,n)}function Zg(e){let n=Math.floor(e.byteLength/4);return new Uint32Array(e.buffer.slice(e.byteOffset,e.byteOffset+n*4),0,n)}function Cs(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Co(e){let n=[];for(let t=0;t<e.length;t+=2)n.push({x:e[t],y:e[t+1]});return n}function xi(e){let n=[];for(let t=0;t<e.length;t++)n.push(e[t].x,e[t].y);return n}function Gf(e){return Co(qg(e))}function ki(e){return{x:(0,v.parseUnits)(e.Hrzn),y:(0,v.parseUnits)(e.Vrtc)}}function _i(e){return{_name:"",_classID:"Pnt ",Hrzn:(0,v.unitsValue)(e.x,"x"),Vrtc:(0,v.unitsValue)(e.y,"y")}}var Ps=[["red","R"],["orange","O"],["yellow","Y"],["green","G"],["aqua","A"],["blue","B"],["purple","P"],["magenta","M"]],Ms=[["version","CrVe"],["processVersion","PrVN"],["processVersionCode","PrVe"],["whiteBalance","WBal"],["temperature","Temp"],["tint","Tint"],["exposure","Ex12"],["contrast","Cr12"],["highlights","Hi12"],["shadows","Sh12"],["whites","Wh12"],["blacks","Bk12"],["texture","CrTx"],["clarity","Cl12"],["dehaze","Dhze"],["vibrance","Vibr"],["saturation","Strt"],["parametricCurve.shadows","PC_S"],["parametricCurve.darks","PC_D"],["parametricCurve.lights","PC_L"],["parametricCurve.highlights","PC_H"],["parametricCurve.shadowSplit","PC_1"],["parametricCurve.midtoneSplit","PC_2"],["parametricCurve.highlightSplit","PC_3"],["pointCurve.composite","Crv "],["pointCurve.red","CrvR"],["pointCurve.green","CrvG"],["pointCurve.blue","CrvB"],...Ps.map(([e,n])=>[`hsl.hue.${e}`,`HA_${n}`]),...Ps.map(([e,n])=>[`hsl.saturation.${e}`,`SA_${n}`]),...Ps.map(([e,n])=>[`hsl.luminance.${e}`,`LA_${n}`]),["colorGrading.shadows.hue","STSH"],["colorGrading.shadows.saturation","STSS"],["colorGrading.shadows.luminance","CgSL"],["colorGrading.midtones.hue","CgMH"],["colorGrading.midtones.saturation","CgMS"],["colorGrading.midtones.luminance","CgML"],["colorGrading.highlights.hue","STHH"],["colorGrading.highlights.saturation","STHS"],["colorGrading.highlights.luminance","CgHL"],["colorGrading.global.hue","CgGH"],["colorGrading.global.saturation","CgGS"],["colorGrading.global.luminance","CgGL"],["colorGrading.blending","CgBl"],["colorGrading.balance","STB "],["sharpening.amount","Shrp"],["sharpening.radius","ShpR"],["sharpening.detail","ShpD"],["sharpening.masking","ShpM"],["noiseReduction.luminance","LNR "],["noiseReduction.luminanceDetail","LNRD"],["noiseReduction.luminanceContrast","LNRC"],["noiseReduction.color","CNR "],["noiseReduction.colorDetail","CNRD"],["noiseReduction.colorSmoothness","CNRS"],["grain.amount","GRNA"],["grain.size","GRNS"],["grain.roughness","GRNF"],["postCropVignette.amount","PCVA"],["postCropVignette.midpoint","PCVM"],["postCropVignette.feather","PCVF"],["postCropVignette.roundness","PCVR"]],cd=["Crv ","CrvR","CrvG","CrvB"],Kg=2783;function Yg(e,n){var t;let i={};for(let[o,r]of Ms){let s=e[r];if(s===void 0)continue;if(r==="WBal")s=s.split(".")[1];else if(cd.includes(r)){let c=s;s=[];for(let f=0;f+1<c.length;f+=2)s.push({input:c[f],output:c[f+1]})}let a=o.split("."),l=i;for(let c=0;c<a.length-1;c++)l=l[a[c]]=(t=l[a[c]])!==null&&t!==void 0?t:{};l[a[a.length-1]]=s}for(let o of Object.keys(e))o!=="_name"&&o!=="_classID"&&!Ms.some(r=>r[1]===o)&&n.logMissingFeatures&&n.log(`Unhandled Camera Raw Filter setting: ${o}`);return i}function Jg(e){let n={_name:"",_classID:v.cameraRawFilterClassID};for(let[t,i]of Ms){let o=e;for(let r of t.split("."))o=o?.[r];o!==void 0&&(i==="WBal"?o=`WBal.${o}`:cd.includes(i)?o=o.flatMap(r=>[Math.round(r.input),Math.round(r.output)]):typeof o=="number"&&i!=="Ex12"&&i!=="ShpR"&&(o=Math.round(o)),n[i]=o)}return n}function Qg(e,n){let t={name:e["Nm "],opacity:(0,v.parsePercent)(e.blendOptions.Opct),blendMode:v.BlnM.decode(e.blendOptions["Md "]),enabled:e.enab,hasOptions:e.hasoptions,foregroundColor:(0,v.parseColor)(e.FrgC),backgroundColor:(0,v.parseColor)(e.BckC)};if("Fltr"in e&&e.Fltr._classID===v.cameraRawFilterClassID)return Object.assign(Object.assign({},t),{type:"camera raw",filter:Yg(e.Fltr,n)});if("Fltr"in e)switch(e.Fltr._classID){case"boxblur":return Object.assign(Object.assign({},t),{type:"box blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"GsnB":return Object.assign(Object.assign({},t),{type:"gaussian blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"MtnB":return Object.assign(Object.assign({},t),{type:"motion blur",filter:{angle:e.Fltr.Angl,distance:(0,v.parseUnits)(e.Fltr.Dstn)}});case"RdlB":return Object.assign(Object.assign({},t),{type:"radial blur",filter:{amount:e.Fltr.Amnt,method:v.BlrM.decode(e.Fltr.BlrM),quality:v.BlrQ.decode(e.Fltr.BlrQ)}});case"shapeBlur":return Object.assign(Object.assign({},t),{type:"shape blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "]),customShape:{name:e.Fltr.customShape["Nm "],id:e.Fltr.customShape.Idnt}}});case"SmrB":return Object.assign(Object.assign({},t),{type:"smart blur",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh,quality:v.SmBQ.decode(e.Fltr.SmBQ),mode:v.SmBM.decode(e.Fltr.SmBM)}});case"surfaceBlur":return Object.assign(Object.assign({},t),{type:"surface blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dspl":return Object.assign(Object.assign({},t),{type:"displace",filter:{horizontalScale:e.Fltr.HrzS,verticalScale:e.Fltr.VrtS,displacementMap:v.DspM.decode(e.Fltr.DspM),undefinedAreas:v.UndA.decode(e.Fltr.UndA),displacementFile:{signature:e.Fltr.DspF.sig,path:e.Fltr.DspF.path}}});case"Pnch":return Object.assign(Object.assign({},t),{type:"pinch",filter:{amount:e.Fltr.Amnt}});case"Plr ":return Object.assign(Object.assign({},t),{type:"polar coordinates",filter:{conversion:v.Cnvr.decode(e.Fltr.Cnvr)}});case"Rple":return Object.assign(Object.assign({},t),{type:"ripple",filter:{amount:e.Fltr.Amnt,size:v.RplS.decode(e.Fltr.RplS)}});case"Shr ":return Object.assign(Object.assign({},t),{type:"shear",filter:{shearPoints:e.Fltr.ShrP.map(i=>({x:i.Hrzn,y:i.Vrtc})),shearStart:e.Fltr.ShrS,shearEnd:e.Fltr.ShrE,undefinedAreas:v.UndA.decode(e.Fltr.UndA)}});case"Sphr":return Object.assign(Object.assign({},t),{type:"spherize",filter:{amount:e.Fltr.Amnt,mode:v.SphM.decode(e.Fltr.SphM)}});case"Twrl":return Object.assign(Object.assign({},t),{type:"twirl",filter:{angle:e.Fltr.Angl}});case"Wave":return Object.assign(Object.assign({},t),{type:"wave",filter:{numberOfGenerators:e.Fltr.NmbG,type:v.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:v.UndA.decode(e.Fltr.UndA)}});case"ZgZg":return Object.assign(Object.assign({},t),{type:"zigzag",filter:{amount:e.Fltr.Amnt,ridges:e.Fltr.NmbR,style:v.ZZTy.decode(e.Fltr.ZZTy)}});case"AdNs":return Object.assign(Object.assign({},t),{type:"add noise",filter:{amount:(0,v.parsePercent)(e.Fltr.Nose),distribution:v.Dstr.decode(e.Fltr.Dstr),monochromatic:e.Fltr.Mnch,randomSeed:e.Fltr.FlRs}});case"DstS":return Object.assign(Object.assign({},t),{type:"dust and scratches",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh}});case"Mdn ":return Object.assign(Object.assign({},t),{type:"median",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"denoise":return Object.assign(Object.assign({},t),{type:"reduce noise",filter:{preset:e.Fltr.preset,removeJpegArtifact:e.Fltr.removeJPEGArtifact,reduceColorNoise:(0,v.parsePercent)(e.Fltr.ClNs),sharpenDetails:(0,v.parsePercent)(e.Fltr.Shrp),channelDenoise:e.Fltr.channelDenoise.map(i=>Object.assign({channels:i.Chnl.map(v.Chnl.decode),amount:i.Amnt},i.EdgF?{preserveDetails:i.EdgF}:{}))}});case"ClrH":return Object.assign(Object.assign({},t),{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({},t),{type:"crystallize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Mztn":return Object.assign(Object.assign({},t),{type:"mezzotint",filter:{type:v.MztT.decode(e.Fltr.MztT),randomSeed:e.Fltr.FlRs}});case"Msc ":return Object.assign(Object.assign({},t),{type:"mosaic",filter:{cellSize:(0,v.parseUnits)(e.Fltr.ClSz)}});case"Pntl":return Object.assign(Object.assign({},t),{type:"pointillize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Clds":return Object.assign(Object.assign({},t),{type:"clouds",filter:{randomSeed:e.Fltr.FlRs}});case"DfrC":return Object.assign(Object.assign({},t),{type:"difference clouds",filter:{randomSeed:e.Fltr.FlRs}});case"Fbrs":return Object.assign(Object.assign({},t),{type:"fibers",filter:{variance:e.Fltr.Vrnc,strength:e.Fltr.Strg,randomSeed:e.Fltr.RndS}});case"LnsF":return Object.assign(Object.assign({},t),{type:"lens flare",filter:{brightness:e.Fltr.Brgh,position:{x:e.Fltr.FlrC.Hrzn,y:e.Fltr.FlrC.Vrtc},lensType:v.Lns.decode(e.Fltr["Lns "])}});case"smartSharpen":return Object.assign(Object.assign({},t),{type:"smart sharpen",filter:{amount:(0,v.parsePercent)(e.Fltr.Amnt),radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh,angle:e.Fltr.Angl,moreAccurate:e.Fltr.moreAccurate,blur:v.blurType.decode(e.Fltr.blur),preset:e.Fltr.preset,shadow:{fadeAmount:(0,v.parsePercent)(e.Fltr.sdwM.Amnt),tonalWidth:(0,v.parsePercent)(e.Fltr.sdwM.Wdth),radius:e.Fltr.sdwM["Rds "]},highlight:{fadeAmount:(0,v.parsePercent)(e.Fltr.hglM.Amnt),tonalWidth:(0,v.parsePercent)(e.Fltr.hglM.Wdth),radius:e.Fltr.hglM["Rds "]}}});case"UnsM":return Object.assign(Object.assign({},t),{type:"unsharp mask",filter:{amount:(0,v.parsePercent)(e.Fltr.Amnt),radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dfs ":return Object.assign(Object.assign({},t),{type:"diffuse",filter:{mode:v.DfsM.decode(e.Fltr["Md "]),randomSeed:e.Fltr.FlRs}});case"Embs":return Object.assign(Object.assign({},t),{type:"emboss",filter:{angle:e.Fltr.Angl,height:e.Fltr.Hght,amount:e.Fltr.Amnt}});case"Extr":return Object.assign(Object.assign({},t),{type:"extrude",filter:{type:v.ExtT.decode(e.Fltr.ExtT),size:e.Fltr.ExtS,depth:e.Fltr.ExtD,depthMode:v.ExtR.decode(e.Fltr.ExtR),randomSeed:e.Fltr.FlRs,solidFrontFaces:e.Fltr.ExtF,maskIncompleteBlocks:e.Fltr.ExtM}});case"Tls ":return Object.assign(Object.assign({},t),{type:"tiles",filter:{numberOfTiles:e.Fltr.TlNm,maximumOffset:e.Fltr.TlOf,fillEmptyAreaWith:v.FlCl.decode(e.Fltr.FlCl),randomSeed:e.Fltr.FlRs}});case"TrcC":return Object.assign(Object.assign({},t),{type:"trace contour",filter:{level:e.Fltr["Lvl "],edge:v.CntE.decode(e.Fltr["Edg "])}});case"Wnd ":return Object.assign(Object.assign({},t),{type:"wind",filter:{method:v.WndM.decode(e.Fltr.WndM),direction:v.Drct.decode(e.Fltr.Drct)}});case"Dntr":return Object.assign(Object.assign({},t),{type:"de-interlace",filter:{eliminate:v.IntE.decode(e.Fltr.IntE),newFieldsBy:v.IntC.decode(e.Fltr.IntC)}});case"Cstm":return Object.assign(Object.assign({},t),{type:"custom",filter:{scale:e.Fltr["Scl "],offset:e.Fltr.Ofst,matrix:e.Fltr.Mtrx}});case"HghP":return Object.assign(Object.assign({},t),{type:"high pass",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Mxm ":return Object.assign(Object.assign({},t),{type:"maximum",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Mnm ":return Object.assign(Object.assign({},t),{type:"minimum",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Ofst":return Object.assign(Object.assign({},t),{type:"offset",filter:{horizontal:e.Fltr.Hrzn,vertical:e.Fltr.Vrtc,undefinedAreas:v.FlMd.decode(e.Fltr["Fl "])}});case"rigidTransform":return Object.assign(Object.assign({},t),{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:Gf(i.originalVertexArray),deformedVertexArray:Gf(i.deformedVertexArray),indexArray:Array.from(Zg(i.indexArray)),pinOffsets:Co(i.pinOffsets),posFinalPins:Co(i.posFinalPins),pinVertexIndices:i.pinVertexIndices,selectedPin:i.selectedPin,pinPosition:Co(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:ki(s.Anch),forward:ki(s["Fwd "]),backward:ki(s["Bwd "]),smooth:s.Smoo}))}))}))}}))}});case"PbPl":{let i=[],o=e.Fltr;for(let r=0;r<Ze.length&&o[`PN${Ze[r]}a`];r++)for(let s=0;s<Ze.length&&o[`PN${Ze[r]}${Ze[s]}`];s++)i.push({name:o[`PN${Ze[r]}${Ze[s]}`],value:o[`PF${Ze[r]}${Ze[s]}`]});return Object.assign(Object.assign({},t),{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({},t),{type:"hsb/hsl",filter:{inputMode:v.ClrS.decode(e.Fltr.Inpt),rowOrder:v.ClrS.decode(e.Fltr.Otpt)}});case"oilPaint":return Object.assign(Object.assign({},t),{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({},t),{type:"liquify",filter:{liquifyMesh:e.Fltr.LqMe}});case"perspectiveWarpTransform":return Object.assign(Object.assign({},t),{type:"perspective warp",filter:{vertices:e.Fltr.vertices.map(ki),warpedVertices:e.Fltr.warpedVertices.map(ki),quads:e.Fltr.quads.map(i=>i.indices)}});case"Crvs":return Object.assign(Object.assign({},t),{type:"curves",filter:Object.assign(Object.assign({},e.Fltr.presetKind!==void 0?{presetKind:v.presetKindType.decode(e.Fltr.presetKind)}:{}),e.Fltr.Adjs?{adjustments:e.Fltr.Adjs.map(i=>{let o=i.Chnl.map(v.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"Lvls":{let i=e.Fltr.Adjs,o=(r,s)=>Object.keys(r).every(a=>s.indexOf(a)!==-1);if(!o(e.Fltr,Wg)||i&&!i.every(r=>o(r,Xg))){if(n.throwForMissingFeatures)throw new Error("Unknown levels filter settings");n.logMissingFeatures&&n.log("Skipped levels smart filter with unknown settings");return}return Object.assign(Object.assign({},t),{type:"levels",filter:Object.assign(Object.assign({},e.Fltr.presetKind!==void 0?{presetKind:v.presetKindType.decode(e.Fltr.presetKind)}:{}),i?{adjustments:i.map(r=>{let s={channels:r.Chnl.map(v.Chnl.decode)};return r.Inpt&&(s.shadowInput=r.Inpt[0],s.highlightInput=r.Inpt[1]),r.Otpt&&(s.shadowOutput=r.Otpt[0],s.highlightOutput=r.Otpt[1]),r["Gmm "]!==void 0&&(s.midtoneInput=r["Gmm "]),s})}:{})})}case"BrgC":return Object.assign(Object.assign({},t),{type:"brightness/contrast",filter:{brightness:e.Fltr.Brgh,contrast:e.Fltr.Cntr,useLegacy:!!e.Fltr.useLegacy}});default:if(n.throwForMissingFeatures)throw new Error(`Unknown filter classId: ${e.Fltr._classID}`);n.logMissingFeatures&&n.log(`Unhandled smart filter: ${e.Fltr._classID} (${e["Nm "]})`);return}else switch(e.filterID){case 1098281575:return Object.assign(Object.assign({},t),{type:"average"});case 1114403360:return Object.assign(Object.assign({},t),{type:"blur"});case 1114403405:return Object.assign(Object.assign({},t),{type:"blur more"});case 1148416099:return Object.assign(Object.assign({},t),{type:"despeckle"});case 1180922912:return Object.assign(Object.assign({},t),{type:"facet"});case 1181902701:return Object.assign(Object.assign({},t),{type:"fragment"});case 1399353968:return Object.assign(Object.assign({},t),{type:"sharpen"});case 1399353925:return Object.assign(Object.assign({},t),{type:"sharpen edges"});case 1399353933:return Object.assign(Object.assign({},t),{type:"sharpen more"});case 1181639749:return Object.assign(Object.assign({},t),{type:"find edges"});case 1399616122:return Object.assign(Object.assign({},t),{type:"solarize"});case 1314149187:return Object.assign(Object.assign({},t),{type:"ntsc colors"});case 1231976050:return Object.assign(Object.assign({},t),{type:"invert"});default:if(n.throwForMissingFeatures)throw new Error(`Unknown filterID: ${e.filterID}`);n.logMissingFeatures&&n.log(`Unhandled smart filter: ${e.filterID} (${e["Nm "]})`);return}}function em(e,n){return{enabled:e.enab,validAtPosition:e.validAtPosition,maskEnabled:e.filterMaskEnable,maskLinked:e.filterMaskLinked,maskExtendWithWhite:e.filterMaskExtendWithWhite,list:e.filterFXList.map(t=>Qg(t,n)).filter(t=>!!t)}}function kt(e){return(0,v.unitsValue)(e.radius,"radius")}function tm(e){let n={_name:"",_classID:"filterFX","Nm ":e.name,blendOptions:{_name:"",_classID:"blendOptions",Opct:(0,v.unitsPercentF)(e.opacity),"Md ":v.BlnM.encode(e.blendMode)},enab:e.enabled,hasoptions:e.hasOptions,FrgC:(0,v.serializeColor)(e.foregroundColor),BckC:(0,v.serializeColor)(e.backgroundColor)};switch(e.type){case"average":return Object.assign(Object.assign({},n),{filterID:1098281575});case"blur":return Object.assign(Object.assign({},n),{filterID:1114403360});case"blur more":return Object.assign(Object.assign({},n),{filterID:1114403405});case"box blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Box Blur",_classID:"boxblur","Rds ":kt(e.filter)},filterID:697});case"gaussian blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Gaussian Blur",_classID:"GsnB","Rds ":kt(e.filter)},filterID:1198747202});case"motion blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Motion Blur",_classID:"MtnB",Angl:e.filter.angle,Dstn:(0,v.unitsValue)(e.filter.distance,"distance")},filterID:1299476034});case"radial blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Radial Blur",_classID:"RdlB",Amnt:e.filter.amount,BlrM:v.BlrM.encode(e.filter.method),BlrQ:v.BlrQ.encode(e.filter.quality)},filterID:1382313026});case"shape blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Shape Blur",_classID:"shapeBlur","Rds ":kt(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({},n),{Fltr:{_name:"Smart Blur",_classID:"SmrB","Rds ":e.filter.radius,Thsh:e.filter.threshold,SmBQ:v.SmBQ.encode(e.filter.quality),SmBM:v.SmBM.encode(e.filter.mode)},filterID:1399681602});case"surface blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Surface Blur",_classID:"surfaceBlur","Rds ":kt(e.filter),Thsh:e.filter.threshold},filterID:701});case"displace":return Object.assign(Object.assign({},n),{Fltr:{_name:"Displace",_classID:"Dspl",HrzS:e.filter.horizontalScale,VrtS:e.filter.verticalScale,DspM:v.DspM.encode(e.filter.displacementMap),UndA:v.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({},n),{Fltr:{_name:"Pinch",_classID:"Pnch",Amnt:e.filter.amount},filterID:1349411688});case"polar coordinates":return Object.assign(Object.assign({},n),{Fltr:{_name:"Polar Coordinates",_classID:"Plr ",Cnvr:v.Cnvr.encode(e.filter.conversion)},filterID:1349284384});case"ripple":return Object.assign(Object.assign({},n),{Fltr:{_name:"Ripple",_classID:"Rple",Amnt:e.filter.amount,RplS:v.RplS.encode(e.filter.size)},filterID:1383099493});case"shear":return Object.assign(Object.assign({},n),{Fltr:{_name:"Shear",_classID:"Shr ",ShrP:e.filter.shearPoints.map(t=>({_name:"",_classID:"Pnt ",Hrzn:t.x,Vrtc:t.y})),UndA:v.UndA.encode(e.filter.undefinedAreas),ShrS:e.filter.shearStart,ShrE:e.filter.shearEnd},filterID:1399353888});case"spherize":return Object.assign(Object.assign({},n),{Fltr:{_name:"Spherize",_classID:"Sphr",Amnt:e.filter.amount,SphM:v.SphM.encode(e.filter.mode)},filterID:1399875698});case"twirl":return Object.assign(Object.assign({},n),{Fltr:{_name:"Twirl",_classID:"Twrl",Angl:e.filter.angle},filterID:1417114220});case"wave":return Object.assign(Object.assign({},n),{Fltr:{_name:"Wave",_classID:"Wave",Wvtp:v.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:v.UndA.encode(e.filter.undefinedAreas),RndS:e.filter.randomSeed},filterID:1466005093});case"zigzag":return Object.assign(Object.assign({},n),{Fltr:{_name:"ZigZag",_classID:"ZgZg",Amnt:e.filter.amount,NmbR:e.filter.ridges,ZZTy:v.ZZTy.encode(e.filter.style)},filterID:1516722791});case"add noise":return Object.assign(Object.assign({},n),{Fltr:{_name:"Add Noise",_classID:"AdNs",Dstr:v.Dstr.encode(e.filter.distribution),Nose:(0,v.unitsPercentF)(e.filter.amount),Mnch:e.filter.monochromatic,FlRs:e.filter.randomSeed},filterID:1097092723});case"despeckle":return Object.assign(Object.assign({},n),{filterID:1148416099});case"dust and scratches":return Object.assign(Object.assign({},n),{Fltr:{_name:"Dust & Scratches",_classID:"DstS","Rds ":e.filter.radius,Thsh:e.filter.threshold},filterID:1148417107});case"median":return Object.assign(Object.assign({},n),{Fltr:{_name:"Median",_classID:"Mdn ","Rds ":kt(e.filter)},filterID:1298427424});case"reduce noise":return Object.assign(Object.assign({},n),{Fltr:{_name:"Reduce Noise",_classID:"denoise",ClNs:(0,v.unitsPercentF)(e.filter.reduceColorNoise),Shrp:(0,v.unitsPercentF)(e.filter.sharpenDetails),removeJPEGArtifact:e.filter.removeJpegArtifact,channelDenoise:e.filter.channelDenoise.map(t=>Object.assign({_name:"",_classID:"channelDenoiseParams",Chnl:t.channels.map(i=>v.Chnl.encode(i)),Amnt:t.amount},t.preserveDetails?{EdgF:t.preserveDetails}:{})),preset:e.filter.preset},filterID:633});case"color halftone":return Object.assign(Object.assign({},n),{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({},n),{Fltr:{_name:"Crystallize",_classID:"Crst",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1131574132});case"facet":return Object.assign(Object.assign({},n),{filterID:1180922912});case"fragment":return Object.assign(Object.assign({},n),{filterID:1181902701});case"mezzotint":return Object.assign(Object.assign({},n),{Fltr:{_name:"Mezzotint",_classID:"Mztn",MztT:v.MztT.encode(e.filter.type),FlRs:e.filter.randomSeed},filterID:1299870830});case"mosaic":return Object.assign(Object.assign({},n),{Fltr:{_name:"Mosaic",_classID:"Msc ",ClSz:(0,v.unitsValue)(e.filter.cellSize,"cellSize")},filterID:1299407648});case"pointillize":return Object.assign(Object.assign({},n),{Fltr:{_name:"Pointillize",_classID:"Pntl",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1349416044});case"clouds":return Object.assign(Object.assign({},n),{Fltr:{_name:"Clouds",_classID:"Clds",FlRs:e.filter.randomSeed},filterID:1131177075});case"difference clouds":return Object.assign(Object.assign({},n),{Fltr:{_name:"Difference Clouds",_classID:"DfrC",FlRs:e.filter.randomSeed},filterID:1147564611});case"fibers":return Object.assign(Object.assign({},n),{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({},n),{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 ":v.Lns.encode(e.filter.lensType)},filterID:1282306886});case"sharpen":return Object.assign(Object.assign({},n),{filterID:1399353968});case"sharpen edges":return Object.assign(Object.assign({},n),{filterID:1399353925});case"sharpen more":return Object.assign(Object.assign({},n),{filterID:1399353933});case"smart sharpen":return Object.assign(Object.assign({},n),{Fltr:{_name:"Smart Sharpen",_classID:"smartSharpen",Amnt:(0,v.unitsPercentF)(e.filter.amount),"Rds ":kt(e.filter),Thsh:e.filter.threshold,Angl:e.filter.angle,moreAccurate:e.filter.moreAccurate,blur:v.blurType.encode(e.filter.blur),preset:e.filter.preset,sdwM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,v.unitsPercentF)(e.filter.shadow.fadeAmount),Wdth:(0,v.unitsPercentF)(e.filter.shadow.tonalWidth),"Rds ":e.filter.shadow.radius},hglM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,v.unitsPercentF)(e.filter.highlight.fadeAmount),Wdth:(0,v.unitsPercentF)(e.filter.highlight.tonalWidth),"Rds ":e.filter.highlight.radius}},filterID:698});case"unsharp mask":return Object.assign(Object.assign({},n),{Fltr:{_name:"Unsharp Mask",_classID:"UnsM",Amnt:(0,v.unitsPercentF)(e.filter.amount),"Rds ":kt(e.filter),Thsh:e.filter.threshold},filterID:1433301837});case"diffuse":return Object.assign(Object.assign({},n),{Fltr:{_name:"Diffuse",_classID:"Dfs ","Md ":v.DfsM.encode(e.filter.mode),FlRs:e.filter.randomSeed},filterID:1147564832});case"emboss":return Object.assign(Object.assign({},n),{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({},n),{Fltr:{_name:"Extrude",_classID:"Extr",ExtS:e.filter.size,ExtD:e.filter.depth,ExtF:e.filter.solidFrontFaces,ExtM:e.filter.maskIncompleteBlocks,ExtT:v.ExtT.encode(e.filter.type),ExtR:v.ExtR.encode(e.filter.depthMode),FlRs:e.filter.randomSeed},filterID:1165522034});case"find edges":return Object.assign(Object.assign({},n),{filterID:1181639749});case"solarize":return Object.assign(Object.assign({},n),{filterID:1399616122});case"tiles":return Object.assign(Object.assign({},n),{Fltr:{_name:"Tiles",_classID:"Tls ",TlNm:e.filter.numberOfTiles,TlOf:e.filter.maximumOffset,FlCl:v.FlCl.encode(e.filter.fillEmptyAreaWith),FlRs:e.filter.randomSeed},filterID:1416393504});case"trace contour":return Object.assign(Object.assign({},n),{Fltr:{_name:"Trace Contour",_classID:"TrcC","Lvl ":e.filter.level,"Edg ":v.CntE.encode(e.filter.edge)},filterID:1416782659});case"wind":return Object.assign(Object.assign({},n),{Fltr:{_name:"Wind",_classID:"Wnd ",WndM:v.WndM.encode(e.filter.method),Drct:v.Drct.encode(e.filter.direction)},filterID:1466852384});case"de-interlace":return Object.assign(Object.assign({},n),{Fltr:{_name:"De-Interlace",_classID:"Dntr",IntE:v.IntE.encode(e.filter.eliminate),IntC:v.IntC.encode(e.filter.newFieldsBy)},filterID:1148089458});case"ntsc colors":return Object.assign(Object.assign({},n),{filterID:1314149187});case"invert":return Object.assign(Object.assign({},n),{filterID:1231976050});case"custom":return Object.assign(Object.assign({},n),{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({},n),{Fltr:{_name:"High Pass",_classID:"HghP","Rds ":kt(e.filter)},filterID:1214736464});case"maximum":return Object.assign(Object.assign({},n),{Fltr:{_name:"Maximum",_classID:"Mxm ","Rds ":kt(e.filter)},filterID:1299737888});case"minimum":return Object.assign(Object.assign({},n),{Fltr:{_name:"Minimum",_classID:"Mnm ","Rds ":kt(e.filter)},filterID:1299082528});case"offset":return Object.assign(Object.assign({},n),{Fltr:{_name:"Offset",_classID:"Ofst",Hrzn:e.filter.horizontal,Vrtc:e.filter.vertical,"Fl ":v.FlMd.encode(e.filter.undefinedAreas)},filterID:1332114292});case"puppet":return Object.assign(Object.assign({},n),{Fltr:{_name:"Rigid Transform",_classID:"rigidTransform",null:["Ordn.Trgt"],rigidType:e.filter.rigidType,puppetShapeList:(e.filter.puppetShapeList||[]).map(t=>({_name:"",_classID:"puppetShape",rigidType:t.rigidType,VrsM:1,VrsN:0,originalVertexArray:Cs(new Float32Array(xi(t.originalVertexArray))),deformedVertexArray:Cs(new Float32Array(xi(t.deformedVertexArray))),indexArray:Cs(new Uint32Array(t.indexArray)),pinOffsets:xi(t.pinOffsets),posFinalPins:xi(t.posFinalPins),pinVertexIndices:t.pinVertexIndices,PinP:xi(t.pinPosition),PnRt:t.pinRotation,PnOv:t.pinOverlay,PnDp:t.pinDepth,meshQuality:t.meshQuality,meshExpansion:t.meshExpansion,meshRigidity:t.meshRigidity,imageResolution:t.imageResolution,meshBoundaryPath:{_name:"",_classID:"pathClass",pathComponents:t.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:_i(r.anchor),"Fwd ":_i(r.forward),"Bwd ":_i(r.backward),Smoo:r.smooth}))}))}))},selectedPin:t.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 t={};for(let i=0;i<e.filter.parameters.length;i++){let{name:o,value:r}=e.filter.parameters[i],s=`${Ze[Math.floor(i/Ze.length)]}${Ze[i%Ze.length]}`;t[`PN${s}`]=o,t[`PT${s}`]=0,t[`PF${s}`]=r}return Object.assign(Object.assign({},n),{Fltr:Object.assign({_name:"Oil Paint Plugin",_classID:"PbPl",KnNm:e.filter.name,GpuY:e.filter.gpu,LIWy:e.filter.lighting,FPth:"1"},t),filterID:1348620396})}case"oil paint":return Object.assign(Object.assign({},n),{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({},n),{Fltr:{_name:"Liquify",_classID:"LqFy",LqMe:e.filter.liquifyMesh},filterID:1282492025});case"perspective warp":return Object.assign(Object.assign({},n),{Fltr:{_name:"Perspective Warp",_classID:"perspectiveWarpTransform",vertices:e.filter.vertices.map(_i),warpedVertices:e.filter.warpedVertices.map(_i),quads:e.filter.quads.map(t=>({_name:"",_classID:"quadIndices",indices:t}))},filterID:442});case"curves":return Object.assign(Object.assign({},n),{Fltr:Object.assign(Object.assign({_name:"Curves",_classID:"Crvs"},e.filter.presetKind!==void 0?{presetKind:v.presetKindType.encode(e.filter.presetKind)}:{}),e.filter.adjustments?{Adjs:e.filter.adjustments.map(t=>"curve"in t?{_name:"",_classID:"CrvA",Chnl:t.channels.map(v.Chnl.encode),"Crv ":t.curve.map(i=>Object.assign({_name:"",_classID:"Pnt ",Hrzn:i.x,Vrtc:i.y},i.curved?{Cnty:!0}:{}))}:{_name:"",_classID:"CrvA",Chnl:t.channels.map(v.Chnl.encode),Mpng:t.values})}:{}),filterID:1131574899});case"levels":return Object.assign(Object.assign({},n),{Fltr:Object.assign(Object.assign({_name:"Levels",_classID:"Lvls"},e.filter.presetKind!==void 0?{presetKind:v.presetKindType.encode(e.filter.presetKind)}:{}),e.filter.adjustments?{Adjs:e.filter.adjustments.map(t=>{var i,o,r,s;let a={_name:"",_classID:"LvlA",Chnl:t.channels.map(v.Chnl.encode)};return(t.shadowInput!==void 0||t.highlightInput!==void 0)&&(a.Inpt=[Math.round((i=t.shadowInput)!==null&&i!==void 0?i:0),Math.round((o=t.highlightInput)!==null&&o!==void 0?o:255)]),(t.shadowOutput!==void 0||t.highlightOutput!==void 0)&&(a.Otpt=[Math.round((r=t.shadowOutput)!==null&&r!==void 0?r:0),Math.round((s=t.highlightOutput)!==null&&s!==void 0?s:255)]),t.midtoneInput!==void 0&&(a["Gmm "]=t.midtoneInput),a})}:{}),filterID:1282829427});case"camera raw":return Object.assign(Object.assign({},n),{Fltr:Jg(e.filter),filterID:Kg});case"brightness/contrast":return Object.assign(Object.assign({},n),{Fltr:{_name:"Brightness/Contrast",_classID:"BrgC",Brgh:e.filter.brightness,Cntr:e.filter.contrast,useLegacy:!!e.filter.useLegacy},filterID:1114793795});case"hsb/hsl":return Object.assign(Object.assign({},n),{Fltr:{_name:"HSB/HSL",_classID:"HsbP",Inpt:v.ClrS.encode(e.filter.inputMode),Otpt:v.ClrS.encode(e.filter.rowOrder)},filterID:1215521360});default:throw new Error(`Unknown filter type: ${e.type}`)}}function fd(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 n=e.width,t=e.height,i=0,o=n/3,r=n*2/3,s=n,a=0,l=t/3,c=t*2/3,f=t;return{style:"custom",value:0,perspective:0,perspectiveOther:0,rotate:"horizontal",bounds:{top:{value:0,units:"Pixels"},left:{value:0,units:"Pixels"},bottom:{value:t,units:"Pixels"},right:{value:n,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:f},{x:o,y:f},{x:r,y:f},{x:s,y:f}]}}}U("SoLd",e=>!!e.placedLayer&&!e.placedLayer.external,(e,n,t)=>{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,v.readVersionAndDescriptor)(e,!0);n.placedLayer={id:o.Idnt,placed:o.placed,type:Nn[o.Type],pageNumber:o.PgNm,totalPages:o.totalPages,frameStep:(0,v.frac)(o.frameStep),duration:(0,v.frac)(o.duration),frameCount:o.frameCount,transform:o.Trnf,width:o["Sz "].Wdth,height:o["Sz "].Hght,resolution:(0,v.parseUnits)(o.Rslt),warp:ld(o.quiltWarp||o.warp)},o.nonAffineTransform&&o.nonAffineTransform.some((r,s)=>r!==o.Trnf[s])&&(n.placedLayer.nonAffineTransform=o.nonAffineTransform),o.Crop&&(n.placedLayer.crop=o.Crop),o.comp&&(n.placedLayer.comp=o.comp),o.compInfo&&(n.placedLayer.compInfo={compID:o.compInfo.compID,originalCompID:o.compInfo.originalCompID}),o.filterFX&&(n.placedLayer.filter=em(o.filterFX,e)),o.Impr&&(n.placedLayer.imported=!0),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i;(0,w.writeSignature)(e,"soLD"),(0,w.writeInt32)(e,4);let o=n.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=Nn.indexOf(o.type);if(r===-1)throw new Error("Invalid placedLayer type");let s=fd(o),a=s.bounds,l=o.width||(a?a.right.value-a.left.value:0),c=o.height||(a?a.bottom.value-a.top.value:0),f=Object.assign(Object.assign({Idnt:o.id,placed:(t=o.placed)!==null&&t!==void 0?t: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:r,Trnf:o.transform,nonAffineTransform:(i=o.nonAffineTransform)!==null&&i!==void 0?i:o.transform,warp:Po(s),"Sz ":{_name:"",_classID:"Pnt ",Wdth:l,Hght:c},Rslt:o.resolution?(0,v.unitsValue)(o.resolution,"resolution"):{units:"Density",value:72}});if(o.filter&&(f.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(u=>tm(u))}),o.warp&&Bs(o.warp)){let u=Po(o.warp);f.quiltWarp=u,f.warp={warpStyle:"warpStyle.warpNone",warpValue:u.warpValue,warpPerspective:u.warpPerspective,warpPerspectiveOther:u.warpPerspectiveOther,warpRotate:u.warpRotate,bounds:u.bounds,uOrder:u.uOrder,vOrder:u.vOrder}}else delete f.quiltWarp;o.comp&&(f.comp=o.comp),o.compInfo&&(f.compInfo=o.compInfo),o.imported&&(f.Impr={}),(0,v.writeVersionAndDescriptor)(e,"","null",f,f.quiltWarp?"quiltWarp":"warp")});var Hf=Ae.infoHandlersMap.SoLd;U("SoLE",e=>{var n;return!!(!((n=e.placedLayer)===null||n===void 0)&&n.external)},(e,n,t,i,o)=>{Hf.read(e,n,t,i,o),n.placedLayer.external=!0},Hf.write);U("fxrp",le("referencePoint"),(e,n)=>{n.referencePoint={x:(0,b.readFloat64)(e),y:(0,b.readFloat64)(e)}},(e,n)=>{(0,w.writeFloat64)(e,n.referencePoint.x),(0,w.writeFloat64)(e,n.referencePoint.y)});function Rs(e,n){U(e,()=>!1,(t,i,o,r,s)=>{var a;if(!t.layersInGlobalInfo&&(r.bitsPerChannel===n||!(!((a=r.children)===null||a===void 0)&&a.length))){let l=r.children;r.children=[];try{(0,b.readLayerInfo)(t,r,s)}catch(c){throw r.children=l,c}t.layersInGlobalInfo=!0}(0,b.skipBytes)(t,o())},()=>{})}Rs("Lr16",16);Rs("Lr32",32);Rs("Layr",void 0);for(let e of["Mtrn","Mt16","Mt32"])U(e,()=>!1,(n,t,i)=>{n.globalAlpha=!0,(0,b.skipBytes)(n,i())},()=>{});U("LMsk",le("userMask"),(e,n)=>{if(n.userMask={colorSpace:(0,b.readColor)(e),opacity:(0,b.readUint16)(e)/100},(0,b.readUint8)(e)!==128)throw new Error("Invalid flag value");(0,b.skipBytes)(e,1)},(e,n)=>{let t=n.userMask;(0,w.writeColor)(e,t.colorSpace),(0,w.writeUint16)(e,Math.round((0,De.clamp)(t.opacity,0,1)*100)),(0,w.writeUint8)(e,128),(0,w.writeZeros)(e,1)});U("Patt",e=>!!(e.patterns&&e.patterns.length>0),(e,n,t)=>{for(;t()>0;){let i=(0,b.readPatternSafe)(e);i&&(n.patterns===void 0&&(n.patterns=[]),n.patterns.push(i))}},(e,n,t,i)=>{let o=n.patterns||[];for(let r of o)(0,w.writePattern)(e,r)});lt("Pat2","Patt");lt("Pat3","Patt");De.MOCK_HANDLERS&&U("CAI ",e=>e._CAI_!==void 0,(e,n,t)=>{n._CAI_=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._CAI_)});De.MOCK_HANDLERS&&U("OCIO",e=>e._OCIO!==void 0,(e,n,t)=>{n._OCIO=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._OCIO)});De.MOCK_HANDLERS&&U("GenI",e=>e._GenI!==void 0,(e,n,t)=>{n._GenI=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._GenI)});function Wf(e){let n=(0,b.readInt32)(e),t=(0,b.readInt32)(e),i=(0,b.readInt32)(e),o=(0,b.readInt32)(e);return{top:n,left:t,bottom:i,right:o}}function Xf(e,n){(0,w.writeInt32)(e,n.top),(0,w.writeInt32)(e,n.left),(0,w.writeInt32)(e,n.bottom),(0,w.writeInt32)(e,n.right)}U("Anno",e=>e.annotations!==void 0,(e,n,t)=>{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++){let l=e.offset,c=(0,b.readUint32)(e),f=(0,b.readSignature)(e),u=!!(0,b.readUint8)(e);(0,b.readUint8)(e),(0,b.readUint16)(e);let d=Wf(e),p=Wf(e),h=(0,b.readColor)(e),m=(0,b.readPascalString)(e,2),y=(0,b.readPascalString)(e,2),g=(0,b.readPascalString)(e,2);(0,b.readUint32)(e),(0,b.readSignature)(e);let k=(0,b.readUint32)(e),x;if(f==="txtA"){let S=e.offset;k>=2&&(0,b.readUint16)(e)===65279?x=(0,b.readUnicodeStringWithLength)(e,Math.floor((k-2)/2)):(e.offset=S,x=(0,b.readAsciiString)(e,k)),x=x.replace(/\r/g,`
12
- `)}else if(f==="sndA")x=(0,b.readBytes)(e,k);else throw new Error("Unknown annotation type");s.push({type:f==="txtA"?"text":"sound",open:u,iconLocation:d,popupLocation:p,color:h,author:m,name:y,date:g,data:x}),c>=e.offset-l&&(e.offset=l+c)}n.annotations=s,(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.annotations;(0,w.writeUint16)(e,2),(0,w.writeUint16)(e,1),(0,w.writeUint32)(e,t.length);for(let i of t){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,w.writeUint32)(e,0),(0,w.writeSignature)(e,o?"sndA":"txtA"),(0,w.writeUint8)(e,i.open?1:0),(0,w.writeUint8)(e,28),(0,w.writeUint16)(e,1),Xf(e,i.iconLocation),Xf(e,i.popupLocation),(0,w.writeColor)(e,i.color),(0,w.writePascalString)(e,i.author||"",2),(0,w.writePascalString)(e,i.name||"",2),(0,w.writePascalString)(e,i.date||"",2);let s=e.offset;(0,w.writeUint32)(e,0),(0,w.writeSignature)(e,o?"sndM":"txtC"),(0,w.writeUint32)(e,0);let a=e.offset;if(o)(0,w.writeBytes)(e,i.data);else{(0,w.writeUint16)(e,65279);let l=i.data.replace(/\n/g,"\r");for(let c=0;c<l.length;c++)(0,w.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 qf(e){let n=(0,b.readSignature)(e);return/^[\0 ]*$/.test(n)?"":n.trim()}function dd(e){U(e,n=>{let t=n;return!(!t.linkedFiles||!t.linkedFiles.length||e==="lnkE"&&!t.linkedFiles.some(i=>i.linkedFile))},(n,t,i,o)=>{let r=t;for(r.linkedFiles=r.linkedFiles||[];i()>8;){let s=Io(n),a=n.offset,l=(0,b.readSignature)(n),c=(0,b.readInt32)(n),f=(0,b.readPascalString)(n,1),u=(0,b.readUnicodeString)(n),d=qf(n),p=qf(n),h=Io(n),y=(0,b.readUint8)(n)?(0,v.readVersionAndDescriptor)(n):void 0,g=l==="liFE"?(0,v.readVersionAndDescriptor)(n):void 0,k={id:f,name:u};if(d&&(k.type=d),p&&(k.creator=p),y&&(k.descriptor={compInfo:{compID:y.compInfo.compID,originalCompID:y.compInfo.originalCompID}}),l==="liFE"&&c>3){let S=(0,b.readInt32)(n),A=(0,b.readUint8)(n),D=(0,b.readUint8)(n),C=(0,b.readUint8)(n),O=(0,b.readUint8)(n),E=(0,b.readFloat64)(n),L=Math.floor(E),M=(E-L)*1e3;try{k.time=new Date(Date.UTC(S,A,D,C,O,L,M)).toISOString()}catch{k.time=new Date(0).toISOString()}}let x=l==="liFE"?Io(n):0;if(l==="liFD"&&h>i())throw new Error("Invalid linked file data size");if(l==="liFA"&&(0,b.skipBytes)(n,8),l==="liFD"&&(k.data=(0,b.readBytes)(n,h)),c>=5&&(k.childDocumentID=(0,b.readUnicodeString)(n)),c>=6&&(k.assetModTime=(0,b.readFloat64)(n)),c>=7&&(k.assetLockedState=(0,b.readUint8)(n)),l==="liFE"&&c===2){if(x>i())throw new Error("Invalid linked file size");k.data=(0,b.readBytes)(n,x)}for(n.skipLinkedFilesData&&(k.data=void 0),e==="lnkE"&&(k.linkedFile={fileSize:x,name:g?.["Nm "]||"",fullPath:g?.fullPath||"",originalPath:g?.originalPath||"",relativePath:g?.relPath||""},g?.alis!==void 0&&(k.linkedFile.alias=g.alis)),r.linkedFiles.push(k);s%4;)s++;n.offset=a+s}(0,b.skipBytes)(n,i())},(n,t)=>{var i,o,r,s,a,l,c,f,u,d,p;let h=t;for(let m of h.linkedFiles){if(e==="lnkE"!=!!m.linkedFile)continue;let y=e==="lnkE",g=2;m.assetLockedState!=null?g=7:m.assetModTime!=null?g=6:m.childDocumentID!=null?g=5:y&&!m.data&&(g=4),(0,w.writeUint64)(n,0);let k=n.offset;if((0,w.writeSignature)(n,y?"liFE":m.data?"liFD":"liFA"),(0,w.writeInt32)(n,g),!m.id||typeof m.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(m.id))throw new Error("Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,w.writePascalString)(n,m.id,1),(0,w.writeUnicodeStringWithPadding)(n,m.name||""),(0,w.writeSignature)(n,m.type?`${m.type} `.substring(0,4):" "),(0,w.writeSignature)(n,m.creator?`${m.creator} `.substring(0,4):"\0\0\0\0"),(0,w.writeUint64)(n,!y&&m.data?m.data.byteLength:0),m.descriptor&&m.descriptor.compInfo){let S={compInfo:{compID:m.descriptor.compInfo.compID,originalCompID:m.descriptor.compInfo.originalCompID}};(0,w.writeUint8)(n,1),(0,v.writeVersionAndDescriptor)(n,"","null",S)}else(0,w.writeUint8)(n,0);if(y){let S=Object.assign(Object.assign({descVersion:2,"Nm ":(o=(i=m.linkedFile)===null||i===void 0?void 0:i.name)!==null&&o!==void 0?o:"",fullPath:(s=(r=m.linkedFile)===null||r===void 0?void 0:r.fullPath)!==null&&s!==void 0?s:""},((a=m.linkedFile)===null||a===void 0?void 0:a.alias)!==void 0?{alis:m.linkedFile.alias}:{}),{originalPath:(c=(l=m.linkedFile)===null||l===void 0?void 0:l.originalPath)!==null&&c!==void 0?c:"",relPath:(u=(f=m.linkedFile)===null||f===void 0?void 0:f.relativePath)!==null&&u!==void 0?u:""});(0,v.writeVersionAndDescriptor)(n,"","ExternalFileLink",S)}if(y&&g>3){let S=m.time?new Date(m.time):new Date;(0,w.writeInt32)(n,S.getUTCFullYear()),(0,w.writeUint8)(n,S.getUTCMonth()),(0,w.writeUint8)(n,S.getUTCDate()),(0,w.writeUint8)(n,S.getUTCHours()),(0,w.writeUint8)(n,S.getUTCMinutes()),(0,w.writeFloat64)(n,S.getUTCSeconds()+S.getUTCMilliseconds()/1e3)}y?(0,w.writeUint64)(n,(g===2?(d=m.data)===null||d===void 0?void 0:d.byteLength:(p=m.linkedFile)===null||p===void 0?void 0:p.fileSize)||0):m.data?(0,w.writeBytes)(n,m.data):(0,w.writeZeros)(n,8),g>=5&&(0,w.writeUnicodeStringWithPadding)(n,m.childDocumentID||""),g>=6&&(0,w.writeFloat64)(n,m.assetModTime||0),g>=7&&(0,w.writeUint8)(n,m.assetLockedState||0),y&&g===2&&m.data&&(0,w.writeBytes)(n,m.data);let x=n.offset-k;for(n.view.setUint32(k-4,x,!1);x%4;)x++,(0,w.writeUint8)(n,0)}})}dd("lnk2");dd("lnkE");lt("lnkD","lnk2");lt("lnk3","lnk2");U("pths",e=>{var n;return((n=e.imageResources)===null||n===void 0?void 0:n.savedPaths)!==void 0},(e,n,t,i)=>{var o,r;if(!t())return;if(e.imageResourcesWhitelistSet&&!e.imageResourcesWhitelistSet.has("savedPaths")){(0,b.skipBytes)(e,t());return}let s=(0,v.readVersionAndDescriptor)(e,!0),a=(o=i.imageResources)!==null&&o!==void 0?o:i.imageResources={},l=(r=a.savedPaths)!==null&&r!==void 0?r:a.savedPaths=[];for(let c=0;c<s.pathList.length&&c<l.length;c++){let{pathUnicodeName:f,pathSymmetryClass:u}=s.pathList[c],d=l[c];a.clippingPath&&a.clippingPath.name===d.name&&(a.clippingPath.name=f),d.name=f,u&&(d.symmetryMode=u.pathSymmetryMode.split(".")[1])}(0,b.skipBytes)(e,t())},(e,n,t)=>{let i={pathList:t.imageResources.savedPaths.map(o=>Object.assign({_name:"",_classID:"pathInfoClass",pathUnicodeName:o.name},o.symmetryMode?{pathSymmetryClass:{_name:"",_classID:"pathSymmetryClass",pathSymmetryMode:`pathSymmetryModeEnum.${o.symmetryMode}`}}:{}))};(0,v.writeVersionAndDescriptor)(e,"","pathsDataClass",i)});U("lyvr",le("version"),(e,n)=>n.version=(0,b.readUint32)(e),(e,n)=>(0,w.writeUint32)(e,n.version));U("lfxs",e=>e.effects!==void 0&&Ts(e),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lfxs version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});function Ee(e){return n=>!!n.adjustment&&n.adjustment.type===e}U("brit",Ee("brightness/contrast"),(e,n,t)=>{n.adjustment||(n.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,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeInt16)(e,i.brightness||0),(0,w.writeInt16)(e,i.contrast||0),(0,w.writeInt16)(e,(t=i.meanValue)!==null&&t!==void 0?t:127),(0,w.writeUint8)(e,i.labColorOnly?1:0),(0,w.writeZeros)(e,1)});function Zf(e){let n=(0,b.readInt16)(e),t=(0,b.readInt16)(e),i=(0,b.readInt16)(e),o=(0,b.readInt16)(e),r=(0,b.readInt16)(e)/100;return{shadowInput:n,highlightInput:t,shadowOutput:i,highlightOutput:o,midtoneInput:r}}var Kf={shadowInput:0,highlightInput:255,shadowOutput:0,highlightOutput:255,midtoneInput:1};function nm(e){return e.shadowInput===0&&e.highlightInput===255&&e.shadowOutput===0&&e.highlightOutput===255&&e.midtoneInput===1}function Yf(e,n){(0,w.writeInt16)(e,n.shadowInput),(0,w.writeInt16)(e,n.highlightInput),(0,w.writeInt16)(e,n.shadowOutput),(0,w.writeInt16)(e,n.highlightOutput),(0,w.writeInt16)(e,Math.round(n.midtoneInput*100))}U("levl",Ee("levels"),(e,n,t)=>{if((0,b.readUint16)(e)!==2)throw new Error("Invalid levl version");let i=[];for(let o=0;o<29&&t()>=10;o++)i.push(Zf(e));if(t()>=8){let o=(0,b.readSignature)(e),r;if(o==="ls\0")r=(0,b.readUint16)(e);else{if(o!=="Lvls")throw new Error("Invalid levl signature");if((0,b.readUint16)(e)!==3)throw new Error("Invalid levl version");r=(0,b.readUint16)(e)}for(;i.length<r&&t()>=10;)i.push(Zf(e))}for(;i.length&&nm(i[i.length-1]);)i.pop();n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"levels",channels:i}),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment.channels||[];(0,w.writeUint16)(e,2);for(let i=0;i<29;i++)Yf(e,t[i]||Kf);(0,w.writeSignature)(e,"Lvls"),(0,w.writeUint16)(e,3),(0,w.writeUint16)(e,62);for(let i=29;i<62;i++)Yf(e,t[i]||Kf)});function im(e){let n=(0,b.readUint16)(e),t=[];for(let i=0;i<n;i++){let o=(0,b.readInt16)(e),r=(0,b.readInt16)(e);t.push({input:r,output:o})}return t}function om(e,n){(0,w.writeUint16)(e,n.length);for(let t of n)(0,w.writeUint16)(e,t.output),(0,w.writeUint16)(e,t.input)}U("curv",Ee("curves"),(e,n,t)=>{let i=!!(0,b.readUint8)(e),o=(0,b.readUint16)(e);if(o!==1&&o!==4)throw new Error("Invalid curv version");let r=(0,b.readUint32)(e),s=[],a=()=>i?Array.from((0,b.readBytes)(e,256)):im(e);if(o===1){for(let l=0;l<32;l++)if(r&1<<l){for(;s.length<l;)s.push([]);s.push(a())}}else{if(r>64)throw new Error("Invalid curv channel count");for(let l=0;l<r;l++)s.push(a())}if(o===1&&t()>=10&&(0,b.readSignature)(e)==="Crv "){(0,b.readUint16)(e);let l=(0,b.readUint32)(e);for(let c=0;c<l&&t()>=2;c++){let f=(0,b.readUint16)(e),u=a();for(;s.length<f;)s.push([]);s[f]=u}}n.adjustment=Object.assign(Object.assign(Object.assign({},n.adjustment),{type:"curves"}),i?{values:s}:{channels:s}),(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment,o=!!i.values,r=(o?i.values:i.channels)||[],s=[],a=0;for(let c=0;c<r.length;c++)!((t=r[c])===null||t===void 0)&&t.length&&(c<32&&(a|=1<<c),s.push(c));let l=c=>{var f;if(o)for(let u=0;u<256;u++)(0,w.writeUint8)(e,(0,De.clamp)(Math.round((f=c[u])!==null&&f!==void 0?f:u),0,255));else om(e,c)};(0,w.writeUint8)(e,o?1:0),(0,w.writeUint16)(e,1),(0,w.writeUint32)(e,a>>>0);for(let c of s)c<32&&l(r[c]);(0,w.writeSignature)(e,"Crv "),(0,w.writeUint16)(e,4),(0,w.writeUint32)(e,s.length);for(let c of s)(0,w.writeUint16)(e,c),l(r[c])});U("expA",Ee("exposure"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid expA version");n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"exposure",exposure:(0,b.readFloat32)(e),offset:(0,b.readFloat32)(e),gamma:(0,b.readFloat32)(e)}),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeFloat32)(e,t.exposure),(0,w.writeFloat32)(e,t.offset),(0,w.writeFloat32)(e,t.gamma),(0,w.writeZeros)(e,2)});U("vibA",Ee("vibrance"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.adjustment={type:"vibrance"},i.vibrance!==void 0&&(n.adjustment.vibrance=i.vibrance),i.Strt!==void 0&&(n.adjustment.saturation=i.Strt),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={};t.vibrance!==void 0&&(i.vibrance=t.vibrance),t.saturation!==void 0&&(i.Strt=t.saturation),(0,v.writeVersionAndDescriptor)(e,"","null",i)});function $n(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 Vn(e,n){let t=n||{};(0,w.writeInt16)(e,t.a||0),(0,w.writeInt16)(e,t.b||0),(0,w.writeInt16)(e,t.c||0),(0,w.writeInt16)(e,t.d||0),(0,w.writeInt16)(e,t.hue||0),(0,w.writeInt16)(e,t.saturation||0),(0,w.writeInt16)(e,t.lightness||0)}U("hue2",Ee("hue/saturation"),(e,n,t)=>{if((0,b.readUint16)(e)!==2)throw new Error("Invalid hue2 version");let i=!!(0,b.readUint8)(e);(0,b.skipBytes)(e,1);let o=(0,b.readInt16)(e),r=(0,b.readInt16)(e),s=(0,b.readInt16)(e);n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"hue/saturation",colorize:i,colorization:{hue:o<0?o+360:o,saturation:r,lightness:s},master:{hue:(0,b.readInt16)(e),saturation:(0,b.readInt16)(e),lightness:(0,b.readInt16)(e)},reds:$n(e),yellows:$n(e),greens:$n(e),cyans:$n(e),blues:$n(e),magentas:$n(e)}),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s,a,l,c,f,u,d,p;let h=n.adjustment;(0,w.writeUint16)(e,2),(0,w.writeUint8)(e,h.colorize?1:0),(0,w.writeUint8)(e,0);let m=Math.round((i=(t=h.colorization)===null||t===void 0?void 0:t.hue)!==null&&i!==void 0?i:0);(0,w.writeInt16)(e,m>180?m-360:m),(0,w.writeInt16)(e,Math.round((r=(o=h.colorization)===null||o===void 0?void 0:o.saturation)!==null&&r!==void 0?r:0)),(0,w.writeInt16)(e,Math.round((a=(s=h.colorization)===null||s===void 0?void 0:s.lightness)!==null&&a!==void 0?a:0)),(0,w.writeInt16)(e,Math.round((c=(l=h.master)===null||l===void 0?void 0:l.hue)!==null&&c!==void 0?c:0)),(0,w.writeInt16)(e,Math.round((u=(f=h.master)===null||f===void 0?void 0:f.saturation)!==null&&u!==void 0?u:0)),(0,w.writeInt16)(e,Math.round((p=(d=h.master)===null||d===void 0?void 0:d.lightness)!==null&&p!==void 0?p:0)),Vn(e,h.reds),Vn(e,h.yellows),Vn(e,h.greens),Vn(e,h.cyans),Vn(e,h.blues),Vn(e,h.magentas)});function Ds(e){return{cyanRed:(0,b.readInt16)(e),magentaGreen:(0,b.readInt16)(e),yellowBlue:(0,b.readInt16)(e)}}function Os(e,n){(0,w.writeInt16)(e,n.cyanRed||0),(0,w.writeInt16)(e,n.magentaGreen||0),(0,w.writeInt16)(e,n.yellowBlue||0)}U("blnc",Ee("color balance"),(e,n,t)=>{n.adjustment={type:"color balance",shadows:Ds(e),midtones:Ds(e),highlights:Ds(e),preserveLuminosity:!!(0,b.readUint8)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;Os(e,t.shadows||{}),Os(e,t.midtones||{}),Os(e,t.highlights||{}),(0,w.writeUint8)(e,t.preserveLuminosity?1:0),(0,w.writeZeros)(e,1)});U("blwh",Ee("black & white"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.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&&(n.adjustment.tintColor=(0,v.parseColor)(i.tintColor)),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={"Rd ":t.reds||0,Yllw:t.yellows||0,"Grn ":t.greens||0,"Cyn ":t.cyans||0,"Bl ":t.blues||0,Mgnt:t.magentas||0,useTint:!!t.useTint,tintColor:(0,v.serializeColor)(t.tintColor),bwPresetKind:t.presetKind||0,blackAndWhitePresetFileName:t.presetFileName||""};(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("phfl",Ee("photo filter"),(e,n,t)=>{let i=(0,b.readUint16)(e);if(i!==2&&i!==3)throw new Error("Invalid phfl version");let o;if(i===2)o=(0,b.readColor)(e);else{let r=(0,b.readInt32)(e)/32768,s=(0,b.readInt32)(e)/32768,a=(0,b.readInt32)(e)/32768;if(!(r>=0&&s>=0&&a>=0&&r<=2&&s<=2&&a<=2))throw new Error("Invalid phfl XYZ color");let l=c=>c>216/24389?Math.cbrt(c):(24389/27*c+16)/116;o={l:Math.max(0,116*l(s)-16)/100,a:(0,De.normalizeLabAB)(500*(l(r)-l(s))),b:(0,De.normalizeLabAB)(200*(l(s)-l(a)))}}n.adjustment={type:"photo filter",color:o,density:(0,b.readUint32)(e)/100,preserveLuminosity:!!(0,b.readUint8)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,2),(0,w.writeColor)(e,t.color||{l:0,a:0,b:0}),(0,w.writeUint32)(e,Math.round(Math.max(0,t.density||0)*100)),(0,w.writeUint8)(e,t.preserveLuminosity?1:0),(0,w.writeZeros)(e,3)});function _o(e){let n=(0,b.readInt16)(e),t=(0,b.readInt16)(e),i=(0,b.readInt16)(e);(0,b.skipBytes)(e,2);let o=(0,b.readInt16)(e);return{red:n,green:t,blue:i,constant:o}}function Ai(e,n){let t=n||{};(0,w.writeInt16)(e,t.red),(0,w.writeInt16)(e,t.green),(0,w.writeInt16)(e,t.blue),(0,w.writeZeros)(e,2),(0,w.writeInt16)(e,t.constant)}U("mixr",Ee("channel mixer"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid mixr version");let i=n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"channel mixer",monochrome:!!(0,b.readUint16)(e)});i.monochrome||(i.red=_o(e),i.green=_o(e),i.blue=_o(e)),i.gray=_o(e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeUint16)(e,t.monochrome?1:0),t.monochrome?(Ai(e,t.gray),(0,w.writeZeros)(e,30)):(Ai(e,t.red),Ai(e,t.green),Ai(e,t.blue),Ai(e,t.gray))});var Jf=(0,De.createEnum)("colorLookupType","3dlut",{"3dlut":"3DLUT",abstractProfile:"abstractProfile",deviceLinkProfile:"deviceLinkProfile"}),Qf=(0,De.createEnum)("LUTFormatType","look",{look:"LUTFormatLOOK",cube:"LUTFormatCUBE","3dl":"LUTFormat3DL"}),Ao=(0,De.createEnum)("colorLookupOrder","rgb",{rgb:"rgbOrder",bgr:"bgrOrder"});U("clrL",Ee("color lookup"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid clrL version");let i=(0,v.readVersionAndDescriptor)(e);n.adjustment={type:"color lookup"};let o=n.adjustment;i.lookupType!==void 0&&(o.lookupType=Jf.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=Qf.decode(i.LUTFormat)),i.dataOrder!==void 0&&(o.dataOrder=Ao.decode(i.dataOrder)),i.tableOrder!==void 0&&(o.tableOrder=Ao.decode(i.tableOrder)),i.LUT3DFileData!==void 0&&(o.lut3DFileData=i.LUT3DFileData),i.LUT3DFileName!==void 0&&(o.lut3DFileName=i.LUT3DFileName),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={};t.lookupType!==void 0&&(i.lookupType=Jf.encode(t.lookupType)),t.name!==void 0&&(i["Nm "]=t.name),t.dither!==void 0&&(i.Dthr=t.dither),t.profile!==void 0&&(i.profile=t.profile),t.lutFormat!==void 0&&(i.LUTFormat=Qf.encode(t.lutFormat)),t.dataOrder!==void 0&&(i.dataOrder=Ao.encode(t.dataOrder)),t.tableOrder!==void 0&&(i.tableOrder=Ao.encode(t.tableOrder)),t.lut3DFileData!==void 0&&(i.LUT3DFileData=t.lut3DFileData),t.lut3DFileName!==void 0&&(i.LUT3DFileName=t.lut3DFileName),(0,w.writeUint16)(e,1),(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("nvrt",Ee("invert"),(e,n,t)=>{n.adjustment={type:"invert"},(0,b.skipBytes)(e,t())},()=>{});U("post",Ee("posterize"),(e,n,t)=>{n.adjustment={type:"posterize",levels:(0,b.readUint16)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeUint16)(e,(t=i.levels)!==null&&t!==void 0?t:4),(0,w.writeZeros)(e,2)});U("thrs",Ee("threshold"),(e,n,t)=>{n.adjustment={type:"threshold",level:(0,b.readUint16)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeUint16)(e,(t=i.level)!==null&&t!==void 0?t:128),(0,w.writeZeros)(e,2)});var ed=["","","","rgb","hsb","","lab"];U("grdm",Ee("gradient map"),(e,n,t)=>{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=v.gradientInterpolationMethodType.decode(`gradientInterpolationMethodType.${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=ed[(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,t());for(let u of o.colorStops)u.location/=4096;for(let u of o.opacityStops)u.location/=4096;n.adjustment=o},(e,n)=>{var t,i,o;let r=n.adjustment;(0,w.writeUint16)(e,r.method!==void 0?3:1),(0,w.writeUint8)(e,r.reverse?1:0),(0,w.writeUint8)(e,r.dither?1:0),r.method!==void 0&&(0,w.writeSignature)(e,v.gradientInterpolationMethodType.encode(r.method).split(".")[1]),(0,w.writeUnicodeStringWithPadding)(e,r.name||""),(0,w.writeUint16)(e,r.colorStops&&r.colorStops.length||0);let s=Math.round((0,De.clamp)((t=r.smoothness)!==null&&t!==void 0?t:1,0,1)*4096);for(let l of r.colorStops||[])(0,w.writeUint32)(e,Math.round((0,De.clamp)(l.location,0,1)*4096)),(0,w.writeUint32)(e,Math.round(l.midpoint*100)),(0,w.writeColor)(e,l.color),(0,w.writeZeros)(e,2);(0,w.writeUint16)(e,r.opacityStops&&r.opacityStops.length||0);for(let l of r.opacityStops||[])(0,w.writeUint32)(e,Math.round((0,De.clamp)(l.location,0,1)*4096)),(0,w.writeUint32)(e,Math.round(l.midpoint*100)),(0,w.writeUint16)(e,Math.round((0,De.clamp)(l.opacity,0,1)*255));(0,w.writeUint16)(e,2),(0,w.writeUint16)(e,s),(0,w.writeUint16)(e,32),(0,w.writeUint16)(e,r.gradientType==="noise"?1:0),(0,w.writeUint32)(e,r.randomSeed||0),(0,w.writeUint16)(e,r.addTransparency?1:0),(0,w.writeUint16)(e,r.restrictColors?1:0),(0,w.writeUint32)(e,Math.round(((i=r.roughness)!==null&&i!==void 0?i:1)*4096));let a=ed.indexOf((o=r.colorModel)!==null&&o!==void 0?o:"rgb");(0,w.writeUint16)(e,a===-1?3:a);for(let l=0;l<4;l++)(0,w.writeUint16)(e,Math.round((r.min&&r.min[l]||0)*32768));for(let l=0;l<4;l++)(0,w.writeUint16)(e,Math.round((r.max&&r.max[l]||0)*32768));(0,w.writeZeros)(e,4)});function Lt(e){return{c:(0,b.readInt16)(e),m:(0,b.readInt16)(e),y:(0,b.readInt16)(e),k:(0,b.readInt16)(e)}}function Mt(e,n){let t=n||{};(0,w.writeInt16)(e,t.c),(0,w.writeInt16)(e,t.m),(0,w.writeInt16)(e,t.y),(0,w.writeInt16)(e,t.k)}U("selc",Ee("selective color"),(e,n)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid selc version");let t=(0,b.readUint16)(e)?"absolute":"relative";(0,b.skipBytes)(e,8),n.adjustment={type:"selective color",mode:t,reds:Lt(e),yellows:Lt(e),greens:Lt(e),cyans:Lt(e),blues:Lt(e),magentas:Lt(e),whites:Lt(e),neutrals:Lt(e),blacks:Lt(e)}},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeUint16)(e,t.mode==="absolute"?1:0),(0,w.writeZeros)(e,8),Mt(e,t.reds),Mt(e,t.yellows),Mt(e,t.greens),Mt(e,t.cyans),Mt(e,t.blues),Mt(e,t.magentas),Mt(e,t.whites),Mt(e,t.neutrals),Mt(e,t.blacks)});U("CgEd",e=>{let n=e.adjustment;return n?n.type==="brightness/contrast"&&!n.useLegacy||(n.type==="levels"||n.type==="curves"||n.type==="exposure"||n.type==="channel mixer"||n.type==="hue/saturation")&&n.presetFileName!==void 0:!1},(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);if(i.Vrsn!==1)throw new Error("Invalid CgEd version");"presetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.presetKind,presetFileName:i.presetFileName}):"curvesPresetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.curvesPresetKind,presetFileName:i.curvesPresetFileName}):"mixerPresetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.mixerPresetKind,presetFileName:i.mixerPresetFileName}):n.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,t())},(e,n)=>{var t,i,o,r;let s=n.adjustment;if(s.type==="levels"||s.type==="exposure"||s.type==="hue/saturation"){let a={Vrsn:1,presetKind:(t=s.presetKind)!==null&&t!==void 0?t:1,presetFileName:s.presetFileName||""};(0,v.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,v.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,v.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,v.writeVersionAndDescriptor)(e,"","null",a)}else throw new Error("Unhandled CgEd case")});function rm(e){let n=[];function t(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&&(n[r.text.index]=r),t(r)}return t(e),n}U("Txt2",le("engineData"),(e,n,t,i)=>{let o=(0,b.readBytes)(e,t());n.engineData=(0,Rf.fromByteArray)(o);let r=rm(i),s=(0,Es.parseEngineData)(o,e),l=(0,Ng.decodeEngineData2)(s).ResourceDict.TextFrameSet;if(l)for(let c=0;c<l.length;c++){let f=r[c];l[c].path&&f?.text&&(f.text.textPath=l[c].path)}},(e,n)=>{let t=(0,Rf.toByteArray)(n.engineData);(0,w.writeBytes)(e,t)});U("FEid",le("filterEffectsMasks"),(e,n,t,i)=>{let o=(0,b.readInt32)(e);if(o<1||o>3)throw new Error(`Invalid filterEffects version ${o}`);for(n.filterEffectsMasks=[];t()>8;){if((0,b.readUint32)(e))throw new Error("filterEffects: 64 bit length is not supported");let r=(0,b.readUint32)(e),s=e.offset+r,a=(0,b.readPascalString)(e,1),l=(0,b.readInt32)(e);if(l!==1)throw new Error(`Invalid filterEffect version ${l}`);if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");(0,b.readUint32)(e);let c=(0,b.readInt32)(e),f=(0,b.readInt32)(e),u=(0,b.readInt32)(e),d=(0,b.readInt32)(e),p=(0,b.readInt32)(e),h=(0,b.readInt32)(e),m=[];for(let g=0;g<h+2;g++)if((0,b.readInt32)(e)){if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let x=(0,b.readUint32)(e);if(!x)throw new Error("filterEffect: Empty channel");let S=(0,b.readUint16)(e);if(x-2>t())throw new Error("filterEffect: Invalid channel length");let A=(0,b.readBytes)(e,x-2);m.push({compressionMode:S,data:A})}else m.push(void 0);if(n.filterEffectsMasks.push({id:a,top:c,left:f,bottom:u,right:d,depth:p,colorMode:i.colorMode,channels:m}),e.offset<s&&(0,b.readUint8)(e)){let g=(0,b.readInt32)(e),k=(0,b.readInt32)(e),x=(0,b.readInt32)(e),S=(0,b.readInt32)(e);if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let A=(0,b.readUint32)(e),D=(0,b.readUint16)(e);if(A-2>t())throw new Error("filterEffect: Invalid extra channel length");let C=(0,b.readBytes)(e,A-2);n.filterEffectsMasks[n.filterEffectsMasks.length-1].extra={top:g,left:k,bottom:x,right:S,compressionMode:D,data:C}}e.offset=s;let y=r;for(;y%4;)e.offset++,y++}},(e,n)=>{(0,w.writeInt32)(e,3);for(let t of n.filterEffectsMasks){(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,0);let i=e.offset;(0,w.writePascalString)(e,t.id,1),(0,w.writeInt32)(e,1),(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,0);let o=e.offset;(0,w.writeInt32)(e,t.top),(0,w.writeInt32)(e,t.left),(0,w.writeInt32)(e,t.bottom),(0,w.writeInt32)(e,t.right),(0,w.writeInt32)(e,t.depth);let r=Math.max(0,t.channels.length-2);(0,w.writeInt32)(e,r);for(let l=0;l<r+2;l++){let c=t.channels[l];(0,w.writeInt32)(e,c?1:0),c&&((0,w.writeUint32)(e,0),(0,w.writeUint32)(e,c.data.length+2),(0,w.writeUint16)(e,c.compressionMode),(0,w.writeBytes)(e,c.data))}e.view.setUint32(o-4,e.offset-o,!1);let s=t.extra;s&&((0,w.writeUint8)(e,1),(0,w.writeInt32)(e,s.top),(0,w.writeInt32)(e,s.left),(0,w.writeInt32)(e,s.bottom),(0,w.writeInt32)(e,s.right),(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,s.data.byteLength+2),(0,w.writeUint16)(e,s.compressionMode),(0,w.writeBytes)(e,s.data));let a=e.offset-i;for(e.view.setUint32(i-4,a,!1);a%4;)(0,w.writeZeros)(e,1),a++}});lt("FXid","FEid");lt("FELS","FEid");lt("hue ","hue2");lt("plLd","PlLd");lt("abdd","artb");U("FMsk",le("filterMask"),(e,n)=>{n.filterMask={colorSpace:(0,b.readColor)(e),opacity:(0,b.readUint16)(e)/100}},(e,n)=>{var t;(0,w.writeColor)(e,n.filterMask.colorSpace),(0,w.writeUint16)(e,Math.round((0,De.clamp)((t=n.filterMask.opacity)!==null&&t!==void 0?t:1,0,1)*100))});U("artd",e=>e.artboards!==void 0,(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=n.artboards={count:i["Cnt "]};i.autoExpandOffset&&(o.autoExpandOffset={horizontal:i.autoExpandOffset.Hrzn,vertical:i.autoExpandOffset.Vrtc}),i.origin&&(o.origin={horizontal:i.origin.Hrzn,vertical:i.origin.Vrtc}),i.autoExpandEnabled!==void 0&&(o.autoExpandEnabled=i.autoExpandEnabled),i.autoNestEnabled!==void 0&&(o.autoNestEnabled=i.autoNestEnabled),i.autoPositionEnabled!==void 0&&(o.autoPositionEnabled=i.autoPositionEnabled),o.shrinkwrapOnSaveEnabled=!!i.shrinkwrapOnSaveEnabled,i.docDefaultNewArtboardBackgroundColor&&(o.docDefaultNewArtboardBackgroundColor=(0,v.parseColor)(i.docDefaultNewArtboardBackgroundColor)),i.docDefaultNewArtboardBackgroundType!==void 0&&(o.docDefaultNewArtboardBackgroundType=i.docDefaultNewArtboardBackgroundType),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s;let a=n.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:(t=a.autoExpandEnabled)!==null&&t!==void 0?t:!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,v.serializeColor)(a.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:(s=a.docDefaultNewArtboardBackgroundType)!==null&&s!==void 0?s:1};(0,v.writeVersionAndDescriptor)(e,"","null",l,"artd")});function Ts(e){return!!e.children}function Do(e){return Object.keys(e).map(n=>e[n]).some(n=>Array.isArray(n)&&n.length>1)}U("lfx2",e=>e.effects!==void 0&&!Ts(e)&&!Do(e.effects),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lfx2 version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("cinf",le("compositorUsed"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);function o(r){return r.split(".")[1]}n.compositorUsed={description:i.description,reason:i.reason,engine:o(i.Engn)},i.Vrsn&&(n.compositorUsed.version=i.Vrsn),i.psVersion&&(n.compositorUsed.photoshopVersion=i.psVersion),i.enableCompCore&&(n.compositorUsed.enableCompCore=o(i.enableCompCore)),i.enableCompCoreGPU&&(n.compositorUsed.enableCompCoreGPU=o(i.enableCompCoreGPU)),i.enableCompCoreThreads&&(n.compositorUsed.enableCompCoreThreads=o(i.enableCompCoreThreads)),i.compCoreSupport&&(n.compositorUsed.compCoreSupport=o(i.compCoreSupport)),i.compCoreGPUSupport&&(n.compositorUsed.compCoreGPUSupport=o(i.compCoreGPUSupport)),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.compositorUsed,i={Vrsn:t.version||{major:1,minor:0,fix:0}};t.photoshopVersion&&(i.psVersion=t.photoshopVersion),i.description=t.description,i.reason=t.reason,i.Engn=`Engn.${t.engine}`,t.enableCompCore&&(i.enableCompCore=`enable.${t.enableCompCore}`),t.enableCompCoreGPU&&(i.enableCompCoreGPU=`enable.${t.enableCompCoreGPU}`),t.enableCompCoreThreads&&(i.enableCompCoreThreads=`enable.${t.enableCompCoreThreads}`),t.compCoreSupport&&(i.compCoreSupport=`reason.${t.compCoreSupport}`),t.compCoreGPUSupport&&(i.compCoreGPUSupport=`reason.${t.compCoreGPUSupport}`),(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("extn",e=>e.generatorSettings!==void 0&&Ls(e),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);i.generatorSettings&&(n.generatorSettings=Us(i.generatorSettings)),(0,b.skipBytes)(e,t())},(e,n)=>{(0,v.writeVersionAndDescriptor)(e,"","null",sd(n.generatorSettings))});U("extd",()=>!1,(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);i.generatorSettings&&n.generatorSettings===void 0&&(n.generatorSettings=Us(i.generatorSettings)),(0,b.skipBytes)(e,t())},()=>{});U("frgb",le("framedGroup"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=i.framedGroupRect;n.framedGroup={rect:{top:o["Top "],left:o.Left,bottom:o.Btom,right:o.Rght},type:i.framedGroupType},i.LockPPI!==void 0&&(n.framedGroup.lockPPI=i.LockPPI),i.PreferredResolution!==void 0&&(n.framedGroup.preferredResolution=i.PreferredResolution),i.SavedIteratedName!==void 0&&(n.framedGroup.savedIteratedName=i.SavedIteratedName),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.framedGroup,i=t.rect,o={framedGroupRect:{_name:"",_classID:"classFloatRect","Top ":i.top,Left:i.left,Btom:i.bottom,Rght:i.right},framedGroupType:t.type};t.lockPPI!==void 0&&(o.LockPPI=t.lockPPI),t.preferredResolution!==void 0&&(o.PreferredResolution=t.preferredResolution),t.savedIteratedName!==void 0&&(o.SavedIteratedName=t.savedIteratedName),(0,v.writeVersionAndDescriptor)(e,"","framedGroup",o)});U("anFX",le("animationEffects"),(e,n,t)=>{n.animationEffects=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n.animationEffects)});U("PxSD",le("pixelSourceData"),(e,n,t)=>{for(n.pixelSourceData=[];t()>=8;){let i=Io(e);if(i>t())throw new Error("Invalid PxSD data length");n.pixelSourceData.push((0,b.readBytes)(e,i))}(0,b.skipBytes)(e,t())},(e,n)=>{for(let t of n.pixelSourceData)(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,t.byteLength),(0,w.writeBytes)(e,t)});U("iOpa",le("fillOpacity"),(e,n)=>{n.fillOpacity=(0,b.readUint8)(e)/255,(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,Math.round((0,De.clamp)(n.fillOpacity,0,1)*255)),(0,w.writeZeros)(e,3)});U("brst",le("channelBlendingRestrictions"),(e,n,t)=>{for(n.channelBlendingRestrictions=[];t()>=4;)n.channelBlendingRestrictions.push((0,b.readInt32)(e))},(e,n)=>{for(let t of n.channelBlendingRestrictions)(0,w.writeInt32)(e,t)});U("tsly",le("transparencyShapesLayer"),(e,n)=>{n.transparencyShapesLayer=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.transparencyShapesLayer?1:0),(0,w.writeZeros)(e,3)})});var En=ae(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.createWriter=lm;ue.getWriterBuffer=cm;ue.getWriterBufferNoCopy=fm;ue.writeUint8=ye;ue.writeInt16=Zt;ue.writeUint16=q;ue.writeUint16LE=yd;ue.writeInt32=je;ue.writeInt32LE=dm;ue.writeUint32=me;ue.writeFloat32=um;ue.writeFloat64=Vs;ue.writeFixedPoint32=pm;ue.writeFixedPointPath32=hm;ue.writeBytes=Ii;ue.writeZeros=Gn;ue.writeSignature=Ut;ue.writeAsciiString=gm;ue.writePascalString=Fo;ue.writeUnicodeStringWithoutLength=bd;ue.writeUnicodeStringWithoutLengthLE=mm;ue.writeUnicodeString=wd;ue.writeUnicodeStringWithPadding=ym;ue.getRLEChannelBound=Lo;ue.writeUint64=vd;ue.writeSection=Ke;ue.writePsd=vm;ue.writeColor=Um;ue.writePattern=Bm;var re=Ot(),sm=Hi(),ud=ui(),am=qr(),Eo=st();function lm(e=4096){let n=new ArrayBuffer(e),t=new DataView(n);return{buffer:n,view:t,offset:0,tempBuffer:void 0,log:console.log}}function cm(e){return e.buffer.slice(0,e.offset)}function fm(e){return new Uint8Array(e.buffer,0,e.offset)}function ye(e,n){let t=Bt(e,1);e.view.setUint8(t,n)}function Zt(e,n){let t=Bt(e,2);e.view.setInt16(t,n,!1)}function q(e,n){let t=Bt(e,2);e.view.setUint16(t,n,!1)}function yd(e,n){let t=Bt(e,2);e.view.setUint16(t,n,!0)}function je(e,n){let t=Bt(e,4);e.view.setInt32(t,n,!1)}function dm(e,n){let t=Bt(e,4);e.view.setInt32(t,n,!0)}function me(e,n){let t=Bt(e,4);e.view.setUint32(t,n,!1)}function um(e,n){let t=Bt(e,4);e.view.setFloat32(t,n,!1)}function Vs(e,n){let t=Bt(e,8);e.view.setFloat64(t,n,!1)}function pm(e,n){je(e,n*65536)}function hm(e,n){je(e,n*(1<<24))}function Ii(e,n){n&&(Ws(e,e.offset+n.length),new Uint8Array(e.buffer).set(n,e.offset),e.offset+=n.length)}function Gn(e,n){for(let t=0;t<n;t++)ye(e,0)}function Ut(e,n){if(n.length!==4)throw new Error(`Invalid signature: '${n}'`);for(let t=0;t<4;t++)ye(e,n.charCodeAt(t))}function gm(e,n){for(let t=0;t<n.length;t++)ye(e,n.charCodeAt(t))}function Fo(e,n,t){let i=n.length;if(i>255)throw new Error("String too long");ye(e,i);for(let o=0;o<i;o++){let r=n.charCodeAt(o);ye(e,r<128?r:63)}for(;++i%t;)ye(e,0)}function bd(e,n){for(let t=0;t<n.length;t++)q(e,n.charCodeAt(t))}function mm(e,n){for(let t=0;t<n.length;t++)yd(e,n.charCodeAt(t))}function wd(e,n){me(e,n.length),bd(e,n)}function ym(e,n){me(e,n.length+1);for(let t=0;t<n.length;t++)q(e,n.charCodeAt(t));q(e,0)}function Lo(e,n,t){return n*((t?4:2)+e+Math.ceil(e/128))}function Gs(e=[],n){let t=0;for(let i of e){for(let o of[i,i.mask,i.realMask])if(o){let{width:r,height:s}=Xs(o);t=Math.max(t,Lo(r,s,n))}i.children&&(t=Math.max(t,Gs(i.children,n)))}return t}function vd(e,n){me(e,Math.floor(n/4294967296)),me(e,n>>>0)}function Ke(e,n,t,i=!1,o=!1){let r=e.offset;o&&me(e,0),me(e,0);let s=e.offset;t();let a=e.offset-s,l=a;for(;l%n;)ye(e,0),l++;if(i&&(a=l),o)e.view.setUint32(r,Math.floor(a/4294967296),!1),e.view.setUint32(r+4,a>>>0,!1);else{if(a>4294967295)throw new Error("Section too large, use PSB format instead");e.view.setUint32(r,a,!1)}}function js(e,n){let t=e&&e.data.BYTES_PER_ELEMENT;if(t!==void 0&&t!==1&&t!==2&&!(e.data instanceof Float32Array))throw new Error(`${n} has incorrect bitDepth (only Uint8Array, Uint8ClampedArray, Uint16Array and Float32Array data is supported for writing)`)}var bm={0:[1],1:[8,16,32],2:[8],3:[8,16,32],4:[8,16]},zs={0:"Bitmap",1:"Grayscale",2:"Indexed",3:"RGB",4:"CMYK",7:"Multichannel",8:"Duotone",9:"Lab"};function Sd(e){return e===3?3:e===4?4:1}var wm=[104,100,114,116,0,0,0,3,62,107,133,31,0,0,0,2,0,0,0,7,0,76,0,105,0,110,0,101,0,97,0,114,0,0,0,2,0,2,0,0,0,0,0,255,0,255,1,1,0,0,0,0,0,0,0,0,65,128,0,0,0,0,0,1,0,0,0,0,63,128,0,0,104,100,114,97,0,0,0,6,0,0,0,0,65,160,0,0,65,240,0,0,0,0,0,0,0,0,0,0,63,128,0,0,0,0,0,0,0,0];function xd(e){var n,t,i;(n=e.children)===null||n===void 0||n.forEach(xd),js(e.imageData,"imageData"),"mask"in e&&js((t=e.mask)===null||t===void 0?void 0:t.imageData,"mask imageData"),"realMask"in e&&js((i=e.realMask)===null||i===void 0?void 0:i.imageData,"realMask imageData")}function vm(e,n,t={}){var i,o,r,s;if(!(+n.width>0&&+n.height>0))throw new Error("Invalid document size");if((n.width>3e4||n.height>3e4)&&!t.psb)throw new Error("Document size is too large (max is 30000x30000, use PSB format instead)");let a=(i=n.colorMode)!==null&&i!==void 0?i:3,l=(o=n.bitsPerChannel)!==null&&o!==void 0?o:a===0?1:8,c=bm[a];if(!c)throw new Error(`${(r=zs[a])!==null&&r!==void 0?r:a} color mode is not supported for writing`);if(c.indexOf(l)===-1)throw new Error(`bitsPerChannel ${l} is not supported for writing in ${zs[a]} color mode`);let f=a!==0&&a!==2;if(!f&&(!((s=n.children)===null||s===void 0)&&s.length))throw new Error(`Layers are not supported in ${zs[a]} color mode`);if(a===2&&!n.palette)throw new Error("Missing color palette for Indexed color mode");t.log&&(e.log=t.log),t.logMissingFeatures&&(e.logMissingFeatures=!0);let u=[];Id(u,n.children),!u.length&&f&&u.push({}),xd(n);let d=Object.assign({},n.imageResources),p=Object.assign(Object.assign({},t),{layerIds:new Set,layerToId:new Map,colorMode:a,bitsPerChannel:l}),h=l===16||l===32;p.generateThumbnail&&(d.thumbnail=Om(n));let m=n.imageData;if(!m&&n.canvas&&(m=n.canvas.getContext("2d").getImageData(0,0,n.canvas.width,n.canvas.height)),!m&&n.rawCompositeData&&(m=(0,Eo.getCompositeImageData)(n)),m&&(n.width!==m.width||n.height!==m.height))throw new Error("Document canvas must have the same size as document");let y=!!m&&f&&(0,re.hasAlpha)(m);if(e.tempBuffer=new Uint8Array(Gs(n.children,!!t.psb)),Ut(e,"8BPS"),q(e,t.psb?2:1),Gn(e,6),q(e,Sd(a)+(y?1:0)),me(e,n.height),me(e,n.width),q(e,l),q(e,a),Ke(e,1,()=>{var g,k,x,S,A,D;if(a===2){let C=n.palette;for(let O=0;O<256;O++)ye(e,(k=(g=C[O])===null||g===void 0?void 0:g.r)!==null&&k!==void 0?k:0);for(let O=0;O<256;O++)ye(e,(S=(x=C[O])===null||x===void 0?void 0:x.g)!==null&&S!==void 0?S:0);for(let O=0;O<256;O++)ye(e,(D=(A=C[O])===null||A===void 0?void 0:A.b)!==null&&D!==void 0?D:0)}else l===32&&Ii(e,new Uint8Array(wm))}),d.layersGroup=u.map(g=>g.linkGroup||0),d.layerGroupsEnabledId=u.map(g=>g.linkGroupEnabled==!1?0:1),Ke(e,1,()=>{for(let g of am.resourceHandlers){let k=g.has(d),x=k===!1?0:k===!0?1:k;for(let S=0;S<x;S++){let A=g.keyCount>1?g.key+S:g.key,D=g.name?g.name(d,S):"";Ut(e,"8BIM"),q(e,A),Fo(e,D,2),Ke(e,2,()=>g.write(e,d,S,n))}}}),Ke(e,2,()=>{h||!f?Ke(e,4,()=>{},!0,p.psb):Am(e,u,n,y,p),Pm(e,n.globalLayerMaskInfo),h&&(y&&pd(e,l===16?"Mt16":"Mt32",!!p.psb,()=>{}),pd(e,l===16?"Lr16":"Lr32",!!p.psb,()=>{_d(e,u,n,y,p)})),Ad(e,n,n,p)},void 0,!!p.psb),e.tempBuffer=void 0,a===3&&l===8&&(!m||Mo(m))){q(e,1);let g=y?[0,1,2,3]:[0,1,2],k=_m(m,n.width,n.height,y),x=g.length*Lo(k.width,k.height,!!t.psb);Ws(e,e.offset+x);let S=new Uint8Array(e.buffer,e.offset,x);e.offset+=(0,re.writeDataRLE)(S,k,g,!!t.psb).length}else Sm(e,n,m,a,l,y,!!t.psb)}function pd(e,n,t,i){Ut(e,t?"8B64":"8BIM"),Ut(e,n),Ke(e,4,i,!1,t)}function Mo(e){return e.data.BYTES_PER_ELEMENT===1}function Hs(e,n,t,i){let{data:o,width:r,height:s}=e,a=r*s,l=o instanceof Float32Array,c=l?1:o instanceof Uint16Array?65535:255,f=t===32,u=f?1:t===16?65535:255,d=Sd(n),p=()=>f?new Float32Array(a):t===16?new Uint16Array(a):new Uint8Array(a),h=[];for(let D=0;D<d;D++)h.push(p());let m=p(),y=D=>l?Math.pow((0,re.clamp)(D,0,1),1/2.2):D/c,g=D=>f?Math.pow(D,2.2):Math.round((0,re.clamp)(D,0,1)*u),k=l===f&&c===u,x=D=>k?f?D:Math.round(D):g(y(D)),S=D=>k?D:f?D/c:Math.round((0,re.clamp)(D/c,0,1)*u),A=[0,0,0,0];for(let D=0,C=0;D<a;D++,C+=4){let O=o[C+3],E=S(O);m[D]=E;let L=i&&O!==c&&O>0?(0,re.clamp)(O/c,0,1):1;if(n===4){(0,re.rgbToCmykValues)(y(o[C]),y(o[C+1]),y(o[C+2]),A);for(let M=0;M<4;M++)h[M][D]=Math.round((1-(0,re.clamp)(A[M]*L,0,1))*u)}else for(let M=0;M<d;M++){let J;if(n===3)J=x(o[C+M]);else{let pe=o[C],R=o[C+1],ie=o[C+2];J=x(pe===R&&R===ie?pe:.299*pe+.587*R+.114*ie)}L!==1&&(J=f?J*L+1-L:Math.round(J*L+u*(1-L))),h[M][D]=J}}return{colors:h,alpha:m}}function kd(e,n,t,i){return e instanceof Uint8Array?i.compress?{data:(0,sm.deflate)(e),compression:2}:{data:(0,re.writeDataRLEBytes)(e,n,t,!!i.psb),compression:1}:{data:(0,re.writeDataZipWithPrediction)(e,n,t),compression:3}}function Sm(e,n,t,i,o,r,s){var a;let{width:l,height:c}=n,f=t??{data:new Uint8Array(l*c*4),width:l,height:c},u=[];if(i===0||i===2){let d=i===0?xm(f):km(f,n.palette,(a=n.imageResources)===null||a===void 0?void 0:a.transparencyIndex),p=i===0?Math.ceil(l/8):l;i===0?(q(e,0),u.push(d)):(q(e,1),u.push((0,re.writeDataRLEBytes)(d,p,c,s)))}else{let{colors:d,alpha:p}=Hs(f,i,o,r),h=r?[...d,p]:d;if(o===8){let m=h.map(g=>(0,re.writeDataRLEBytes)(g,l,c,s)),y=c*(s?4:2);q(e,1);for(let g of m)u.push(g.subarray(0,y));for(let g of m)u.push(g.subarray(y))}else{q(e,0);for(let m of h)u.push((0,re.planarToBytes)(m))}}for(let d of u)Ii(e,d)}function xm({data:e,width:n,height:t}){let i=Math.ceil(n/8),o=new Uint8Array(i*t),r=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let s=0,a=0;s<t;s++)for(let l=0;l<n;l++,a+=4){let c=e[a+3]/r;(.299*e[a]+.587*e[a+1]+.114*e[a+2])/r*c+(1-c)<.5&&(o[s*i+(l>>3)]|=128>>(l&7))}return o}function km({data:e,width:n,height:t},i,o){let r=n*t,s=new Uint8Array(r),a=e instanceof Uint16Array?8:0,l=new Map;for(let c=0;c<i.length&&c<256;c++){let f=i[c].r<<16|i[c].g<<8|i[c].b;c!==o&&!l.has(f)&&l.set(f,c)}for(let c=0,f=0;c<r;c++,f+=4){let u=k=>e instanceof Float32Array?Math.round(Math.pow((0,re.clamp)(k,0,1),.45454545454545453)*255):k>>>a,d=e instanceof Float32Array?e[f+3]*255:e[f+3]>>>a;if(o!==void 0&&o>=0&&d<128){s[c]=o;continue}let p=u(e[f]),h=u(e[f+1]),m=u(e[f+2]),y=p<<16|h<<8|m,g=l.get(y);if(g===void 0){let k=1/0;g=0;for(let x=0;x<i.length&&x<256;x++){if(x===o)continue;let S=i[x].r-p,A=i[x].g-h,D=i[x].b-m,C=S*S+A*A+D*D;C<k&&(k=C,g=x)}l.set(y,g)}s[c]=g}return s}function _m(e,n,t,i){if(!e)return{data:new Uint8Array(n*t*4),width:n,height:t};let o=n*t*4,r=e.data,s;if(i)for(let a=0;a<o;a+=4){let l=r[a+3];if(l!=0&&l!=255){s||(s=new Uint8Array(r.buffer,r.byteOffset,o).slice());let c=l/255,f=255*(1-c);s[a+0]=r[a+0]*c+f,s[a+1]=r[a+1]*c+f,s[a+2]=r[a+2]*c+f}}return s?{data:s,width:n,height:t}:e}function Am(e,n,t,i,o){Ke(e,4,()=>_d(e,n,t,i,o),!0,o.psb)}function _d(e,n,t,i,o){var r;Zt(e,i?-n.length:n.length);let s=n.map((a,l)=>Em(e,a,l===0,o));for(let a of s){let{layer:l,top:c,left:f,bottom:u,right:d,channels:p}=a;je(e,c),je(e,f),je(e,u),je(e,d),q(e,p.length);for(let m of p)Zt(e,m.id),o.psb?vd(e,m.length):me(e,m.length);Ut(e,"8BIM"),Ut(e,re.fromBlendMode[l.blendMode]||"norm"),ye(e,Math.round((0,re.clamp)((r=l.opacity)!==null&&r!==void 0?r:1,0,1)*255)),ye(e,l.clipping?1:0);let h=8;l.transparencyProtected&&(h|=1),l.hidden&&(h|=2),(l.vectorMask||l.sectionDivider&&l.sectionDivider.type!==0||l.adjustment)&&(h|=16),l.effectsOpen&&(h|=32),ye(e,h),ye(e,0),Ke(e,1,()=>{Im(e,l,a),Cm(e,l),Fo(e,(l.name||"").substring(0,255),4),Ad(e,l,t,o)})}for(let a of s)for(let l of a.channels)q(e,l.compression),l.data&&Ii(e,l.data)}function Ns(e){return e.mask?{mask:e.mask,realMask:e.realMask}:{mask:e.realMask,realMask:void 0}}function Im(e,n,t){let{mask:i,realMask:o}=Ns(n);Ke(e,4,()=>{if(!i&&!o)return;let r=0,s=0,a=0;i&&(i.userMaskDensity!==void 0&&(r|=1),i.userMaskFeather!==void 0&&(r|=2),i.vectorMaskDensity!==void 0&&(r|=4),i.vectorMaskFeather!==void 0&&(r|=8),i.disabled&&(s|=2),i.positionRelativeToLayer&&(s|=1),i.fromVectorData&&(s|=8),r&&(s|=16));let l=t.mask||{};if(je(e,l.top||0),je(e,l.left||0),je(e,l.bottom||0),je(e,l.right||0),ye(e,i&&i.defaultColor||0),ye(e,s),o){o.disabled&&(a|=2),o.positionRelativeToLayer&&(a|=1),o.fromVectorData&&(a|=8);let c=t.realMask||{};ye(e,a),ye(e,o.defaultColor||0),je(e,c.top||0),je(e,c.left||0),je(e,c.bottom||0),je(e,c.right||0)}r&&i&&(ye(e,r),i.userMaskDensity!==void 0&&ye(e,Math.round(i.userMaskDensity*255)),i.userMaskFeather!==void 0&&Vs(e,i.userMaskFeather),i.vectorMaskDensity!==void 0&&ye(e,Math.round(i.vectorMaskDensity*255)),i.vectorMaskFeather!==void 0&&Vs(e,i.vectorMaskFeather))},!0)}function Oo(e,n){ye(e,n[0]),ye(e,n[1]),ye(e,n[2]),ye(e,n[3])}function Cm(e,n){Ke(e,1,()=>{let t=n.blendingRanges;if(t){Oo(e,t.compositeGrayBlendSource),Oo(e,t.compositeGraphBlendDestinationRange);for(let i of t.ranges)Oo(e,i.sourceRange),Oo(e,i.destRange)}})}function Pm(e,n){Ke(e,1,()=>{n&&(q(e,n.overlayColorSpace),q(e,n.colorSpace1),q(e,n.colorSpace2),q(e,n.colorSpace3),q(e,n.colorSpace4),q(e,Math.round((0,re.clamp)(n.opacity,0,1)*100)),ye(e,n.kind),Gn(e,3))})}function Ad(e,n,t,i){for(let o of ud.infoHandlers){let r=o.key;if(!(r==="Txt2"&&i.invalidateTextLayers)&&(r==="vmsk"&&ud.infoHandlersMap.vscg.has(n)&&(r="vsms"),o.has(n))){let s=i.psb&&re.largeAdditionalInfoKeys.indexOf(r)!==-1,a=r!=="Txt2"&&r!=="cinf"&&r!=="extn"&&r!=="CAI "&&r!=="OCIO",l=r==="levl"||r==="Txt2"||r==="luni"||r==="vmsk"||r==="artb"||r==="artd"||r==="vogk"||r==="SoLd"||r==="SoLE"||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";Ut(e,s?"8B64":"8BIM"),Ut(e,r),Ke(e,l?4:2,()=>{o.write(e,n,t,i)},a,s)}}}function Id(e,n){if(n)for(let t of n){if(t.children&&t.canvas)throw new Error("Invalid layer, cannot have both 'canvas' and 'children' properties");if(t.children&&t.imageData)throw new Error("Invalid layer, cannot have both 'imageData' and 'children' properties");t.children?(e.push({name:"</Layer group>",sectionDivider:{type:3}}),Id(e,t.children),e.push(Object.assign(Object.assign({},t),{blendMode:t.blendMode==="pass through"?"normal":t.blendMode,sectionDivider:{type:t.opened===!1?2:1,key:re.fromBlendMode[t.blendMode]||"pass",subType:0}}))):e.push(Object.assign({},t))}}function Dm(e,n){let t=Math.max(e.buffer.byteLength*2,n),i=new ArrayBuffer(t),o=new Uint8Array(i),r=new Uint8Array(e.buffer);o.set(r),e.buffer=i,e.view=new DataView(e.buffer)}function Ws(e,n){n>e.buffer.byteLength&&Dm(e,n)}function Bt(e,n){let t=e.offset;return Ws(e,e.offset+=n),t}function Om(e){let n=(0,re.createCanvas)(10,10),t=1;e.width>e.height?(n.width=160,n.height=Math.max(1,Math.floor(e.height*(n.width/e.width))),t=n.width/e.width):(n.height=160,n.width=Math.max(1,Math.floor(e.width*(n.height/e.height))),t=n.height/e.height);let i=n.getContext("2d");return i.scale(t,t),e.imageData?i.drawImage((0,re.imageDataToCanvas)(e.imageData),0,0):e.canvas&&i.drawImage(e.canvas,0,0),n}function hd(e,n,t,i,o){var r;let s=t.top|0,a=t.left|0,l=t.right|0,c=t.bottom|0,{width:f,height:u}=Xs(t),d=t.imageData;if(!d&&t.canvas&&f&&u&&(d=t.canvas.getContext("2d").getImageData(0,0,f,u)),d&&(d.width!==f||d.height!==u))throw new Error("Invalid imageData dimentions");l=a+f,c=s+u;let p,h,m=(r=i.bitsPerChannel)!==null&&r!==void 0?r:8;if(!d)p=new Uint8Array(0),h=1;else if(m!==8||!Mo(d)){let{colors:y}=Hs(d,3,m,!1);({data:p,compression:h}=kd(y[0],f,u,i))}else i.compress?(p=(0,re.writeDataZipWithoutPrediction)(d,[0]),h=2):(p=(0,re.writeDataRLE)(e,d,[0],!!i.psb).slice(),h=1);n.channels.push({id:o?-3:-2,compression:h,data:p,length:2+p.length}),n[o?"realMask":"mask"]={top:s,left:a,right:l,bottom:c}}function $s(e){return e?{top:e.top||0,left:e.left||0,right:e.right||0,bottom:e.bottom||0}:void 0}function Em(e,n,t,i){var o,r;let s=n;if(n.rawData){let{colorMode:u,bitsPerChannel:d,large:p}=n.rawData,h=i;if(p===!!i.psb&&u===((o=h.colorMode)!==null&&o!==void 0?o:3)&&d===((r=h.bitsPerChannel)!==null&&r!==void 0?r:8)){let{mask:y,realMask:g}=Ns(n);return Object.assign(Object.assign({layer:n,channels:n.rawData.channels.map(k=>{var x,S;return Object.assign(Object.assign({},k),{length:2+((S=(x=k.data)===null||x===void 0?void 0:x.byteLength)!==null&&S!==void 0?S:0)})})},$s(n)),{mask:$s(y),realMask:$s(g)})}s=Object.assign(Object.assign({},n),{rawData:void 0,canvas:void 0,imageData:(0,Eo.getLayerImageData)(n),mask:n.mask&&Object.assign(Object.assign({},n.mask),{canvas:void 0,imageData:(0,Eo.getLayerMaskImageData)(n)}),realMask:n.realMask&&Object.assign(Object.assign({},n.realMask),{canvas:void 0,imageData:(0,Eo.getLayerRealMaskImageData)(n)})});let m=Gs([Object.assign(Object.assign({},s),{children:void 0})],!!i.psb);e.tempBuffer.byteLength<m&&(e.tempBuffer=new Uint8Array(m))}let a=e.tempBuffer,{mask:l,realMask:c}=Ns(s),f=Lm(a,s,t,i);return l&&hd(a,f,l,i,!1),c&&hd(a,f,c,i,!0),f.layer=n,f}function Xs({canvas:e,imageData:n}){var t,i,o,r;let s=(i=(t=n?.width)!==null&&t!==void 0?t:e?.width)!==null&&i!==void 0?i:0,a=(r=(o=n?.height)!==null&&o!==void 0?o:e?.height)!==null&&r!==void 0?r:0;return{width:s,height:a}}function Fm(e,n,t,i,o){let r=Mo(e)?(0,re.createImageData)(i,o):{width:i,height:o,data:new e.data.constructor(i*o*4)},s=e.data,a=r.data;for(let l=0;l<o;l++)for(let c=0;c<i;c++){let f=(c+n+(l+t)*e.width)*4,u=(c+l*i)*4;a[u]=s[f],a[u+1]=s[f+1],a[u+2]=s[f+2],a[u+3]=s[f+3]}return r}function Lm(e,n,t,i){var o,r;let s=n.top|0,a=n.left|0,l=n.right|0,c=n.bottom|0,f=[{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:u,height:d}=Xs(n);if(!(n.canvas||n.imageData)||!u||!d)return(n.right===void 0||l>a)&&(l=a),(n.bottom===void 0||c>s)&&(c=s),{layer:n,top:s,left:a,right:l,bottom:c,channels:f};l=a+u,c=s+d;let p=n.imageData||n.canvas.getContext("2d").getImageData(0,0,u,d);if(i.trimImageData){let g=Mm(p);if(g.left!==0||g.top!==0||g.right!==p.width||g.bottom!==p.height){if(a+=g.left,s+=g.top,l-=p.width-g.right,c-=p.height-g.bottom,u=l-a,d=c-s,!u||!d)return{layer:n,top:s,left:a,right:l,bottom:c,channels:f};p=Fm(p,g.left,g.top,u,d)}}let h=[0,1,2];(!t||i.noBackground||n.mask||(0,re.hasAlpha)(p))&&h.unshift(-1);let m=(o=i.colorMode)!==null&&o!==void 0?o:3,y=(r=i.bitsPerChannel)!==null&&r!==void 0?r:8;if(m!==3||y!==8||!Mo(p)){let{colors:g,alpha:k}=Hs(p,m,y,!1),x=h[0]===-1?[-1]:[];for(let S=0;S<g.length;S++)x.push(S);return f=x.map(S=>{let{data:A,compression:D}=kd(S===-1?k:g[S],u,d,i);return{id:S,compression:D,data:A,length:2+A.length}}),{layer:n,top:s,left:a,right:l,bottom:c,channels:f}}return f=h.map(g=>{let k=(0,re.offsetForChannel)(g,!1),x,S;return i.compress?(x=(0,re.writeDataZipWithoutPrediction)(p,[k]),S=2):(x=(0,re.writeDataRLE)(e,p,[k],!!i.psb).slice(),S=1),{id:g,compression:S,data:x,length:2+x.length}}),{layer:n,top:s,left:a,right:l,bottom:c,channels:f}}function gd({data:e,width:n},t,i,o){let r=(t*n+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 md({data:e,width:n},t,i,o){let r=n*4|0,s=i*r+t*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 Mm(e){let n=0,t=0,i=e.width,o=e.height;for(;n<o&&gd(e,n,t,i);)n++;for(;o>n&&gd(e,o-1,t,i);)o--;for(;t<i&&md(e,t,n,o);)t++;for(;i>t&&md(e,i-1,n,o);)i--;return{top:n,left:t,right:i,bottom:o}}function Um(e,n){n?"r"in n?(q(e,0),q(e,Math.round(n.r*257)),q(e,Math.round(n.g*257)),q(e,Math.round(n.b*257)),q(e,0)):"fr"in n?(q(e,0),q(e,Math.round(n.fr*255*257)),q(e,Math.round(n.fg*255*257)),q(e,Math.round(n.fb*255*257)),q(e,0)):"l"in n?(q(e,7),Zt(e,Math.round(n.l*1e4)),Zt(e,Math.round((0,re.denormalizeLabAB)(n.a,100))),Zt(e,Math.round((0,re.denormalizeLabAB)(n.b,100))),q(e,0)):"h"in n?(q(e,1),q(e,Math.round(n.h*65535)),q(e,Math.round(n.s*65535)),q(e,Math.round(n.b*65535)),q(e,0)):"c"in n?(q(e,2),q(e,65535-Math.round((0,re.clamp)(n.c,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.m,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.y,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.k,0,255)*257))):(q(e,8),q(e,Math.round(n.k*1e4/255)),Gn(e,6)):(q(e,0),Gn(e,8))}function Bm(e,n){let t=n.bounds.w,i=n.bounds.h,o={width:t,height:i,data:n.data};me(e,0);let r=e.offset;me(e,1),me(e,3),Zt(e,n.x),Zt(e,n.y),wd(e,n.name+"\0"),Fo(e,n.id,1),me(e,3),me(e,0);let s=e.offset,a=n.bounds.y,l=n.bounds.x,c=a+i,f=l+t;me(e,a),me(e,l),me(e,c),me(e,f),me(e,24);let u=new Uint8Array(Lo(t,i,!1));for(let h=0;h<26;h++){let m=h<3?h:h===25?3:-1;if(m<0){me(e,0);continue}let y=(0,re.writeDataRLE)(u,o,[m],!1);me(e,1),me(e,y.length+4+16+2+1),me(e,8),me(e,a),me(e,l),me(e,c),me(e,f),q(e,8),ye(e,1),Ii(e,y)}let d=e.offset-s,p=e.offset-r;for(;p%4;)Gn(e,1),p++;e.view.setUint32(s-4,d,!1),e.view.setUint32(r-4,p,!1)}});var Ld=ae(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.readAbr=$m;var K=ao(),se=st(),Rm=["off","fade","pen pressure","pen tilt","stylus wheel","initial direction","direction","initial rotation","rotation"],Cd=["round point","round blunt","round curve","round angle","round fan","flat point","flat blunt","flat curve","flat angle","flat fan"],Tm=["erodible point","erodible flat","erodible round","erodible square","erodible triangle","custom"],Pd=1e4,jm={_:"brush",MixB:"mixer brush",SmTl:"smudge brush"};function Fe(e){return{control:Rm[e.bVTy],steps:e.fStp,jitter:(0,K.parsePercent)(e.jitter),minimum:(0,K.parsePercent)(e["Mnm "])}}function Dd(e){switch(e._classID){case"computedBrush":return{type:"computed",size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,K.parseAngle)(e.Angl),roundness:(0,K.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,K.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,hardness:(0,K.parsePercent)(e.Hrdn)};case"sampledBrush":return{type:"sampled",size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,K.parseAngle)(e.Angl),roundness:(0,K.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,K.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,name:e["Nm "],sampledData:e.sampledData};case"dBrush":return{type:"dynamic",shape:Cd[e["Shp "]],angle:(0,K.parseAngle)(e.Angl),size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),density:(0,K.parsePercent)(e.Dnst),length:(0,K.parsePercent)(e.Lngt),clumping:(0,K.parsePercent)(e.clumping),thickness:(0,K.parsePercent)(e.thickness),stiffness:(0,K.parsePercent)(e.stiffness),physics:e.physics,spacing:(0,K.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY};case"dTips":return Object.assign(Object.assign({type:"tips",angle:(0,K.parseAngle)(e.Angl),size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),shape:Cd[e["Shp "]],physics:e.physics,spacing:(0,K.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY,tipsType:Tm[e.dtipsType],tipsLengthRatio:(0,K.parsePercent)(e.dtipsLengthRatio),tipsHardness:(0,K.parsePercent)(e.dtipsHardness)},e.dtipsGridSize&&e.dtipsErodibleTipHeightMap?{tipsGridSize:e.dtipsGridSize,tipsErodibleTipHeightMap:zm(e.dtipsErodibleTipHeightMap)}:{}),{tipsAirbrushCutoffAngle:e.dtipsAirbrushCutoffAngle,tipsAirbrushGranularity:(0,K.parsePercent)(e.dtipsAirbrushGranularity),tipsAirbrushStreakiness:(0,K.parsePercent)(e.dtipsAirbrushStreakiness),tipsAirbrushSplatSize:(0,K.parsePercent)(e.dtipsAirbrushSplatSize),tipsAirbrushSplatCount:e.dtipsAirbrushSplatCount});default:throw new Error(`Unknown brush classId: ${e._classID}`)}}function zm(e){let n=[];for(let t=0;t<e.byteLength;t++)n.push(e[t]);return n}function Od(e,n){let t=(0,se.createReader)(e.view.buffer,e.view.byteOffset+e.offset,n-e.offset);return(0,K.readVersionAndDescriptor)(t,!0)}function $m(e,n={}){let t=(0,se.createReader)(e.buffer,e.byteOffset,e.byteLength);t.logMissingFeatures=n.logMissingFeatures,t.throwForMissingFeatures=n.throwForMissingFeatures,t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024;let i=(f,u)=>{if(n.throwForMissingFeatures)throw f;n.logMissingFeatures&&t.log(`Skipped ${u}: ${f.message}`)};if(t.view.byteLength<4)throw new Error("Invalid ABR file");let o=(0,se.readInt16)(t),r=[],s=[],a=[],l=[],c;if(o===1||o===2)Nm(t,o,r,s,i);else if(o===6||o===7||o===9||o===10){let f=(0,se.readInt16)(t);if(f!==1&&f!==2)throw new Error("Unsupported ABR minor version");for(;t.offset+12<=t.view.byteLength;){(0,se.checkSignature)(t,"8BIM");let u=(0,se.readSignature)(t),d=(0,se.readUint32)(t),p=Math.min(t.offset+d,t.view.byteLength);try{switch(u){case"samp":{for(;t.offset+4<=p;){let h=(0,se.readUint32)(t);for(;h&3;)h++;let m=Math.min(t.offset+h,p);try{let y=Vm(t,m,f);r.push(y)}catch(y){i(y,"brush sample")}t.offset=m}break}case"desc":{let h=Od(t,p);for(let[m,y]of(h.Brsh||[]).entries())try{let g=Gm(y);s.push(g),l[m]=g}catch(g){i(g,`brush "${y["Nm "]}"`)}break}case"patt":{for(;t.offset+4<=p;){let h=(0,se.readPatternSafe)(t);h&&a.push(h)}break}case"phry":{c=Od(t,p).hierarchy;break}default:n.logMissingFeatures&&t.log(`Unhandled brush section: ${u}`);break}}catch(h){i(h,`brush section ${u}`)}for(t.offset=p;t.offset%4;)t.offset++}}else throw new Error(`Unsupported ABR version (${o})`);if(c){let f=[],u=0;for(let d of c)if(d._classID==="Grup")f.push(d["Nm "]);else if(d._classID==="groupEnd")f.pop();else if(d._classID==="preset"){let p=l[u];p&&f.length&&(p.group=f.slice()),u++}}return{samples:r,patterns:a,brushes:s}}function Vm(e,n,t){let i=(0,se.readPascalString)(e,1);return(0,se.skipBytes)(e,t===1?10:264),Fd(e,n,i)}function Fd(e,n,t){let i=(0,se.readInt32)(e),o=(0,se.readInt32)(e),r=(0,se.readInt32)(e)-i,s=(0,se.readInt32)(e)-o;if(s<=0||r<=0)throw new Error("Invalid bounds");if(s>Pd||r>Pd)throw new Error(`Brush sample too large (${s}x${r})`);let a=(0,se.readInt16)(e),l=(0,se.readUint8)(e);if(a!==8&&a!==16)throw new Error("Invalid depth");if(l!==0&&l!==1)throw new Error("Invalid compression");let c=s*(a===16?2:1);if((l===0?r*c:r*(2+Math.ceil(c/128)*2))>n-e.offset)throw new Error("Brush sample data out of bounds");(0,se.consumeMemory)(e,s*r*(a===16?3:1));let u=new Uint8Array(s*r);if(a===8)if(l===0)u.set((0,se.readBytes)(e,u.byteLength));else if(l===1)(0,se.readDataRLE)(e,{width:s,height:r,data:u},s,r,a,1,[0],!1);else throw new Error("Invalid compression");else if(a===16){let d=new Uint16Array(s*r);if(l===0)for(let m=0;m<d.length;m++)d[m]=(0,se.readUint16)(e);else if(l===1)(0,se.readDataRLE)(e,{width:s,height:r,data:d},s,r,a,1,[0],!1);else throw new Error("Invalid compression");let p=0;for(let m=0;m<d.length;m++)p=Math.max(p,d[m]);let h=p>32768?255/65535:255/32768;for(let m=0;m<u.byteLength;m++)u[m]=Math.round(d[m]*h)}else throw new Error("Invalid depth");return{id:t,bounds:{x:o,y:i,w:s,h:r},alpha:u}}function Nm(e,n,t,i,o){let r=(0,se.readUint16)(e);for(let s=0;s<r;s++){let a=(0,se.readUint16)(e),l=(0,se.readUint32)(e),c=e.offset+l;if(c>e.view.byteLength){o(new Error("Brush data out of bounds"),`brush ${s+1}`);break}try{if(a===1){(0,se.skipBytes)(e,4);let f=(0,se.readUint16)(e),u=(0,se.readUint16)(e),d=(0,se.readUint16)(e),p=(0,se.readInt16)(e),h=(0,se.readUint16)(e);if(e.offset>c)throw new Error("Brush data out of bounds");i.push(Ed("",{type:"computed",size:u,angle:p,roundness:d/100,spacingOn:f!==0,spacing:f/100,flipX:!1,flipY:!1,hardness:h/100}))}else if(a===2){(0,se.skipBytes)(e,4);let f=(0,se.readUint16)(e),u=n===2?(0,se.readUnicodeString)(e):"";(0,se.skipBytes)(e,9);let d=Fd(e,c,`brush-${s+1}`);t.push(d),i.push(Ed(u,{type:"sampled",size:Math.max(d.bounds.w,d.bounds.h),angle:0,roundness:1,spacingOn:f!==0,spacing:f/100,flipX:!1,flipY:!1,name:u,sampledData:d.id}))}else throw new Error(`Unknown brush type: ${a}`)}catch(f){o(f,`brush ${s+1}`)}e.offset=c}}function Ed(e,n){return{name:e,shape:n,spacing:1,wetEdges:!1,noise:!1,buildUp:!1,useBrushSize:!0}}function Gm(e){var n,t,i;let o={name:e["Nm "],shape:Dd(e.Brsh),spacing:(0,K.parsePercent)(e.Spcn),wetEdges:e.Wtdg,noise:e.Nose,buildUp:!!e["Rpt "],useBrushSize:e.useBrushSize};e.interpretation!=null&&(o.interpretation=e.interpretation),e.protectTexture!=null&&(o.protectTexture=e.protectTexture),e.useTipDynamics&&(o.shapeDynamics={tiltScale:(0,K.parsePercent)(e.tiltScale),sizeDynamics:Fe(e.szVr),angleDynamics:Fe(e.angleDynamics),roundnessDynamics:Fe(e.roundnessDynamics),flipX:e.flipX,flipY:e.flipY,brushProjection:e.brushProjection,minimumDiameter:(0,K.parsePercent)(e.minimumDiameter),minimumRoundness:(0,K.parsePercent)(e.minimumRoundness)}),e.useScatter&&(o.scatter={count:e["Cnt "],bothAxes:e.bothAxes,countDynamics:Fe(e.countDynamics),scatterDynamics:Fe(e.scatterDynamics)}),e.useTexture&&e.Txtr&&(o.texture={id:e.Txtr.Idnt,name:e.Txtr["Nm "],blendMode:K.BlnM.decode(e.textureBlendMode),depth:(0,K.parsePercent)(e.textureDepth),depthMinimum:(0,K.parsePercent)(e.minimumDepth),depthDynamics:Fe(e.textureDepthDynamics),scale:(0,K.parsePercent)(e.textureScale),invert:e.InvT,brightness:e.textureBrightness,contrast:e.textureContrast,textureEachTip:!!e.TxtC});let r=e.dualBrush;r&&r.useDualBrush&&(o.dualBrush={flip:r.Flip,shape:Dd(r.Brsh),blendMode:K.BlnM.decode(r.BlnM),useScatter:r.useScatter,spacing:(0,K.parsePercent)(r.Spcn),count:r["Cnt "],bothAxes:r.bothAxes,countDynamics:Fe(r.countDynamics),scatterDynamics:Fe(r.scatterDynamics)}),e.useColorDynamics&&(o.colorDynamics={foregroundBackground:Fe(e.clVr),hue:(0,K.parsePercent)(e["H "]),saturation:(0,K.parsePercent)(e.Strt),brightness:(0,K.parsePercent)(e.Brgh),purity:(0,K.parsePercent)(e.purity),perTip:e.colorDynamicsPerTip}),e.usePaintDynamics&&(o.transfer={flowDynamics:Fe(e.prVr),opacityDynamics:Fe(e.opVr)},e.wtVr&&(o.transfer.wetnessDynamics=Fe(e.wtVr)),e.mxVr&&(o.transfer.mixDynamics=Fe(e.mxVr))),e.useBrushPose&&(o.brushPose={overrideAngle:e.overridePoseAngle,overrideTiltX:e.overridePoseTiltX,overrideTiltY:e.overridePoseTiltY,overridePressure:e.overridePosePressure,pressure:(0,K.parsePercent)(e.brushPosePressure),tiltX:e.brushPoseTiltX,tiltY:e.brushPoseTiltY,angle:e.brushPoseAngle});let s=e.toolOptions;return s&&(o.toolOptions={type:jm[s._classID]||"brush",brushPreset:s.brushPreset,flow:(n=s.flow)!==null&&n!==void 0?n:100,smooth:(t=s.Smoo)!==null&&t!==void 0?t:0,mode:K.BlnM.decode(s["Md "]||"BlnM.Nrml"),opacity:(i=s.Opct)!==null&&i!==void 0?i:100,smoothing:!!s.smoothing,smoothingValue:s.smoothingValue||0,smoothingRadiusMode:!!s.smoothingRadiusMode,smoothingCatchup:!!s.smoothingCatchup,smoothingCatchupAtEnd:!!s.smoothingCatchupAtEnd,smoothingZoomCompensation:!!s.smoothingZoomCompensation,pressureSmoothing:!!s.pressureSmoothing,usePressureOverridesSize:!!s.usePressureOverridesSize,usePressureOverridesOpacity:!!s.usePressureOverridesOpacity,useLegacy:!!s.useLegacy},s.prVr&&(o.toolOptions.flowDynamics=Fe(s.prVr)),s.opVr&&(o.toolOptions.opacityDynamics=Fe(s.opVr)),s.szVr&&(o.toolOptions.sizeDynamics=Fe(s.szVr)),"wetness"in s&&(o.toolOptions.wetness=s.wetness),"dryness"in s&&(o.toolOptions.dryness=s.dryness),"mix"in s&&(o.toolOptions.mix=s.mix),"autoFill"in s&&(o.toolOptions.autoFill=s.autoFill),"autoClean"in s&&(o.toolOptions.autoClean=s.autoClean),"loadSolidColorOnly"in s&&(o.toolOptions.loadSolidColorOnly=s.loadSolidColorOnly),"sampleAllLayers"in s&&(o.toolOptions.sampleAllLayers=s.sampleAllLayers),"SmdF"in s&&(o.toolOptions.smudgeFingerPainting=s.SmdF),"SmdS"in s&&(o.toolOptions.smudgeSampleAllLayers=s.SmdS),"Prs "in s&&(o.toolOptions.strength=s["Prs "])),o}});var Md=ae(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.readCsh=Wm;var Hm=ui(),tt=st();function Wm(e,n={}){let t=(0,tt.createReader)(e.buffer,e.byteOffset,e.byteLength);t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024;let i={shapes:[]};if((0,tt.checkSignature)(t,"cush"),(0,tt.readUint32)(t)!==2)throw new Error("Invalid version");let o=(0,tt.readUint32)(t);for(let r=0;r<o;r++){let s=(0,tt.readUnicodeString)(t);for(;t.offset%4;)t.offset++;if((0,tt.readUint32)(t)!==1)throw new Error("Invalid shape version");let a=(0,tt.readUint32)(t),l=t.offset+a,c=(0,tt.readPascalString)(t,1),f=(0,tt.readUint32)(t),u=(0,tt.readUint32)(t),d=(0,tt.readUint32)(t),h=(0,tt.readUint32)(t)-u,m=d-f,y={paths:[]};(0,Hm.readVectorMask)(t,y,h,m,l-t.offset),i.shapes.push(Object.assign({name:s,id:c,width:h,height:m},y)),t.offset=l}return i}});var Ud=ae(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.readAse=Xm;var ze=st();function Xm(e,n={}){let t=(0,ze.createReader)(e.buffer,e.byteOffset,e.byteLength);if(t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024,(0,ze.readSignature)(t)!=="ASEF")throw new Error("Invalid signature");let o=(0,ze.readUint16)(t);if((0,ze.readUint16)(t),o!==1)throw new Error("Invalid version");let r=(0,ze.readUint32)(t),s={colors:[]},a=s;for(let l=0;l<r&&t.offset+6<=t.view.byteLength;l++){let c=(0,ze.readUint16)(t),f=(0,ze.readUint32)(t),u=Math.min(t.offset+f,t.view.byteLength),d=(0,ze.createReader)(t.view.buffer,t.view.byteOffset+t.offset,u-t.offset);d.totalMemoryLimit=t.totalMemoryLimit;try{switch(c){case 1:{let p=qm(d);if(p)a.colors.push(p);else{if(n.throwForMissingFeatures)throw new Error("Unsupported color mode");n.logMissingFeatures&&t.log("Skipped color with unsupported color mode")}break}case 49153:{let p=(0,ze.readUint16)(d),h=(0,ze.readUnicodeStringWithLength)(d,p);s.colors.push(a={name:h,colors:[]});break}case 49154:a=s;break;default:if(n.throwForMissingFeatures)throw new Error(`Invalid block type: ${c}`);n.logMissingFeatures&&t.log(`Skipped unknown block type: ${c}`)}}catch(p){if(n.throwForMissingFeatures)throw p;n.logMissingFeatures&&t.log(`Skipped invalid block: ${p.message}`)}t.totalMemoryLimit=d.totalMemoryLimit,t.offset=u}return s}function qm(e){let n=(0,ze.readUint16)(e),t=(0,ze.readUnicodeStringWithLength)(e,n),i=(0,ze.readSignature)(e),o=()=>{let s=(0,ze.readFloat32)(e);return isFinite(s)?s:0},r=()=>{let s=e.offset+2<=e.view.byteLength?(0,ze.readUint16)(e):2;return Zm[s]||"normal"};switch(i){case"RGB ":return{name:t,color:{r:o(),g:o(),b:o(),type:r()}};case"CMYK":return{name:t,color:{c:o(),m:o(),y:o(),k:o(),type:r()}};case"Gray":return{name:t,color:{k:o(),type:r()}};case"LAB ":return{name:t,color:{l:o(),a:o(),b:o(),type:r()}};default:return}}var Zm=["global","spot","normal"]});var $d=ae(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.Compression=nt.ChannelID=nt.LayerCompCapturedInfo=nt.SectionDividerType=nt.ColorMode=void 0;var Bd;(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"})(Bd||(nt.ColorMode=Bd={}));var Rd;(function(e){e[e.Other=0]="Other",e[e.OpenFolder=1]="OpenFolder",e[e.ClosedFolder=2]="ClosedFolder",e[e.BoundingSectionDivider=3]="BoundingSectionDivider"})(Rd||(nt.SectionDividerType=Rd={}));var Td;(function(e){e[e.None=0]="None",e[e.Visibility=1]="Visibility",e[e.Position=2]="Position",e[e.Appearance=4]="Appearance"})(Td||(nt.LayerCompCapturedInfo=Td={}));var jd;(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"})(jd||(nt.ChannelID=jd={}));var zd;(function(e){e[e.RawData=0]="RawData",e[e.RleCompressed=1]="RleCompressed",e[e.ZipWithoutPrediction=2]="ZipWithoutPrediction",e[e.ZipWithPrediction=3]="ZipWithPrediction"})(zd||(nt.Compression=zd={}))});var Nd=ae(Y=>{"use strict";var Km=Y&&Y.__createBinding||(Object.create?(function(e,n,t,i){i===void 0&&(i=t);var o=Object.getOwnPropertyDescriptor(n,t);(!o||("get"in o?!n.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,o)}):(function(e,n,t,i){i===void 0&&(i=t),e[i]=n[t]})),Uo=Y&&Y.__exportStar||function(e,n){for(var t in e)t!=="default"&&!Object.prototype.hasOwnProperty.call(n,t)&&Km(n,e,t)};Object.defineProperty(Y,"__esModule",{value:!0});Y.getFilterEffectsMaskExtraCanvas=Y.getFilterEffectsMaskCanvas=Y.getFilterEffectsMaskExtraImageData=Y.getFilterEffectsMaskImageData=Y.getCompositeCanvas=Y.getCompositeImageData=Y.getLayerRealMaskCanvas=Y.getLayerMaskCanvas=Y.getLayerCanvas=Y.getLayerRealMaskImageData=Y.getLayerMaskImageData=Y.getLayerImageData=Y.decodeLayerPixels=Y.byteArrayToBase64=Y.initializeCanvas=void 0;Y.readPsd=Qm;Y.writePsd=ey;Y.writePsdUint8Array=Vd;Y.writePsdBuffer=ty;var Hn=En(),Le=st();Object.defineProperty(Y,"decodeLayerPixels",{enumerable:!0,get:function(){return Le.decodeLayerPixels}});Object.defineProperty(Y,"getLayerImageData",{enumerable:!0,get:function(){return Le.getLayerImageData}});Object.defineProperty(Y,"getLayerMaskImageData",{enumerable:!0,get:function(){return Le.getLayerMaskImageData}});Object.defineProperty(Y,"getLayerRealMaskImageData",{enumerable:!0,get:function(){return Le.getLayerRealMaskImageData}});Object.defineProperty(Y,"getLayerCanvas",{enumerable:!0,get:function(){return Le.getLayerCanvas}});Object.defineProperty(Y,"getLayerMaskCanvas",{enumerable:!0,get:function(){return Le.getLayerMaskCanvas}});Object.defineProperty(Y,"getLayerRealMaskCanvas",{enumerable:!0,get:function(){return Le.getLayerRealMaskCanvas}});Object.defineProperty(Y,"getCompositeImageData",{enumerable:!0,get:function(){return Le.getCompositeImageData}});Object.defineProperty(Y,"getCompositeCanvas",{enumerable:!0,get:function(){return Le.getCompositeCanvas}});Object.defineProperty(Y,"getFilterEffectsMaskImageData",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskImageData}});Object.defineProperty(Y,"getFilterEffectsMaskExtraImageData",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskExtraImageData}});Object.defineProperty(Y,"getFilterEffectsMaskCanvas",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskCanvas}});Object.defineProperty(Y,"getFilterEffectsMaskExtraCanvas",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskExtraCanvas}});var Ym=no();Uo(Ld(),Y);Uo(Md(),Y);Uo(Ud(),Y);var Jm=Ot();Object.defineProperty(Y,"initializeCanvas",{enumerable:!0,get:function(){return Jm.initializeCanvas}});Uo($d(),Y);Y.byteArrayToBase64=Ym.fromByteArray;function Qm(e,n){let t="buffer"in e?(0,Le.createReader)(e.buffer,e.byteOffset,e.byteLength):(0,Le.createReader)(e);return(0,Le.readPsd)(t,n)}function ey(e,n){let t=(0,Hn.createWriter)();return(0,Hn.writePsd)(t,e,n),(0,Hn.getWriterBuffer)(t)}function Vd(e,n){let t=(0,Hn.createWriter)();return(0,Hn.writePsd)(t,e,n),(0,Hn.getWriterBufferNoCopy)(t)}function ty(e,n){if(typeof Buffer>"u")throw new Error("Buffer not supported on this platform");return Buffer.from(Vd(e,n))}});var To=mu(Nd(),1);var Ro=class{view;offset=0;constructor(n){this.view=new DataView(n)}get length(){return this.view.byteLength}ensure(n,t=this.length,i="Adobe resource"){if(!Number.isSafeInteger(n)||n<0||this.offset+n>t||t>this.length)throw new Error(`${i} is truncated or has an invalid length.`)}u8(n,t){return this.ensure(1,n,t),this.view.getUint8(this.offset++)}i16(n,t){this.ensure(2,n,t);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u16(n,t){this.ensure(2,n,t);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i32(n,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}u32(n,t){this.ensure(4,n,t);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32le(n,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!0);return this.offset+=4,i}ascii(n,t,i){this.ensure(n,t,i);let o="";for(let r=0;r<n;r+=1)o+=String.fromCharCode(this.view.getUint8(this.offset++));return o}skip(n,t,i){this.ensure(n,t,i),this.offset+=n}},Ys=e=>{let n=e+3&-4;if(!Number.isSafeInteger(n)||n<e)throw new Error("Adobe resource alignment overflowed.");return n},_t=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} overflows the safe integer range.`);return i},Gd=(e,n,t)=>{if(e.byteLength>n.maxFileBytes)throw new Error(`${t.toUpperCase()} source exceeds the ${n.maxFileBytes}-byte safety limit.`)},un=(e,n,t)=>{if(!Number.isSafeInteger(e)||e<0||e>n.maxResourceItems)throw new Error(`${t} exceeds the ${n.maxResourceItems}-item safety limit.`)},Hd=(e,n,t,i)=>{un(n,t,i),e.descriptorItems+=n;let o=Math.min(1e6,t.maxResourceItems*64);if(e.descriptorItems>o)throw new Error(`Adobe descriptor complexity exceeds the ${o}-record safety limit.`)},Wd=(e,n,t,i,o)=>{if(n<=0||n>i.maxResourcePreviewPixels)throw new Error(`${o} exceeds the ${i.maxResourcePreviewPixels}-pixel preview limit.`);if(e.previewPixels+=n,e.decodedBytes+=t,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.`)},Wn=(e,n,t,i)=>{let o=e.u32(n,i);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(_t(o,2,`${i} length`),n,i)},Js=(e,n,t,i)=>{let o=e.u8(n,i);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(o,n,i)},Rt=(e,n,t,i)=>{let o=e.i32(n,i);if(o<0)throw new Error(`${i} has a negative string length.`);let r=o||4;if(r>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-character identifier limit.`);e.skip(r,n,i)},dn=(e,n,t,i)=>{Wn(e,n,t,`${i} name`),Rt(e,n,t,`${i} class id`)},Bo=(e,n,t,i,o)=>{let r=e.i32(n,o);if(r<0)throw new Error(`${o} has a negative item count.`);return Hd(t,r,i,o),r},Xd=(e,n,t,i,o,r)=>{if(i>r.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${r.maxNestingDepth}-level safety limit.`);switch(t){case"obj ":{let s=Bo(e,n,o,r,"Adobe descriptor reference");for(let a=0;a<s;a+=1){let l=e.ascii(4,n,"Adobe descriptor reference type");if(l==="prop")dn(e,n,r,"Adobe property reference"),Rt(e,n,r,"Adobe property key");else if(l==="Clss")dn(e,n,r,"Adobe class reference");else if(l==="Enmr")dn(e,n,r,"Adobe enum reference"),Rt(e,n,r,"Adobe enum type"),Rt(e,n,r,"Adobe enum value");else if(l==="rele")dn(e,n,r,"Adobe offset reference"),e.skip(4,n,"Adobe offset reference");else if(l==="Idnt"||l==="indx")e.skip(4,n,"Adobe integer reference");else if(l==="name")dn(e,n,r,"Adobe name reference"),Wn(e,n,r,"Adobe reference name");else throw new Error(`Unsupported Adobe descriptor reference type ${JSON.stringify(l)}.`)}return}case"Objc":case"GlbO":qd(e,n,i+1,o,r);return;case"VlLs":{let s=Bo(e,n,o,r,"Adobe descriptor list");for(let a=0;a<s;a+=1){let l=e.ascii(4,n,"Adobe descriptor list type");Xd(e,n,l,i+1,o,r)}return}case"doub":e.skip(8,n,"Adobe double");return;case"UntF":e.skip(12,n,"Adobe unit double");return;case"UnFl":e.skip(8,n,"Adobe unit float");return;case"TEXT":Wn(e,n,r,"Adobe descriptor text");return;case"enum":Rt(e,n,r,"Adobe enum type"),Rt(e,n,r,"Adobe enum value");return;case"long":e.skip(4,n,"Adobe integer");return;case"comp":e.skip(8,n,"Adobe large integer");return;case"bool":e.skip(1,n,"Adobe boolean");return;case"type":case"GlbC":dn(e,n,r,"Adobe descriptor class");return;case"alis":case"tdta":{let s=e.i32(n,"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,n,"Adobe descriptor data");return}case"ObAr":{e.skip(4,n,"Adobe object-array version"),Wn(e,n,r,"Adobe object-array name"),Rt(e,n,r,"Adobe object-array class");let s=Bo(e,n,o,r,"Adobe object array");for(let a=0;a<s;a+=1){Rt(e,n,r,"Adobe object-array item type");let l=e.ascii(4,n,"Adobe object-array value type");if(l!=="UnFl")throw new Error(`Unsupported Adobe object-array value type ${JSON.stringify(l)}.`);e.skip(4,n,"Adobe object-array units");let c=Bo(e,n,o,r,"Adobe object-array values");e.skip(_t(c,8,"Adobe object-array values"),n,"Adobe object-array values")}return}case"Pth ":{let s=e.i32(n,"Adobe path length");if(s<0||s>r.maxDecodedBytes)throw new Error("Adobe descriptor path length is invalid.");e.skip(4,n,"Adobe path signature");let a=e.i32le(n,"Adobe path size"),l=e.i32le(n,"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(_t(l,2,"Adobe path characters"),n,"Adobe descriptor path");return}default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(t)}.`)}},qd=(e,n,t,i,o)=>{if(t>o.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${o.maxNestingDepth}-level safety limit.`);dn(e,n,o,"Adobe descriptor");let r=e.u32(n,"Adobe descriptor item count");Hd(i,r,o,"Adobe descriptor item count");for(let s=0;s<r;s+=1){Rt(e,n,o,"Adobe descriptor key");let a=e.ascii(4,n,"Adobe descriptor value type");Xd(e,n,a,t+1,i,o)}},ny=(e,n,t,i)=>{let o=e.u32(n,"Adobe descriptor version");if(o!==16)throw new Error(`Unsupported Adobe descriptor version ${o}.`);qd(e,n,0,t,i)},Zd=(e,n,t,i,o)=>{let r=_t(i,2,`${o} row table`);e.ensure(r,n,o);let s=Array.from({length:i},()=>e.u16(n,`${o} row length`));for(let a=0;a<i;a+=1){let l=e.offset+s[a];if(l>n)throw new Error(`${o} compressed row ${a} is truncated.`);let c=0;for(;e.offset<l;){let f=e.u8(l,`${o} PackBits header`);if(f<=127){let u=f+1;e.skip(u,l,`${o} PackBits literal`),c+=u}else f>=129&&(e.skip(1,l,`${o} PackBits repeat value`),c+=257-f);if(c>t)throw new Error(`${o} PackBits row ${a} expands beyond its declared width.`)}if(c!==t)throw new Error(`${o} PackBits row ${a} does not expand to its declared width.`)}},iy=(e,n,t,i,o)=>{let r=0;for(;e.offset<n;){un(++r,o,"ABR sample count");let s=e.u32(n,"ABR sample length"),a=e.offset,l=a+s,c=a+Ys(s);if(l>n||c>n)throw new Error("ABR sample record is truncated.");Js(e,l,o,"ABR sample id"),e.skip(t===1?10:264,l,"ABR sample header");let f=e.i32(l,"ABR sample top"),u=e.i32(l,"ABR sample left"),d=e.i32(l,"ABR sample bottom"),h=e.i32(l,"ABR sample right")-u,m=d-f;if(h<=0||m<=0||h>o.maxCanvasDimension||m>o.maxCanvasDimension)throw new Error(`ABR sample dimensions exceed the ${o.maxCanvasDimension}-pixel side limit.`);let y=_t(h,m,"ABR sample pixels"),g=e.i16(l,"ABR sample depth"),k=e.u8(l,"ABR sample compression");if(g!==8&&g!==16)throw new Error(`Unsupported ABR sample depth ${g}.`);if(k!==0&&k!==1)throw new Error(`Unsupported ABR sample compression ${k}.`);if(g===16&&k===1)throw new Error("ABR 16-bit RLE samples are not supported by the decoding engine.");if(Wd(i,y,y,o,"ABR sample"),k===0?e.skip(_t(y,g/8,"ABR raw sample bytes"),l,"ABR raw sample"):Zd(e,l,h,m,"ABR sample"),e.offset>l)throw new Error("ABR sample payload exceeded its declared record boundary.");e.offset=l,e.offset=c}return r},oy=(e,n,t,i)=>{let o=e.u32(n,"ABR pattern length"),s=e.offset+Ys(o);if(s>n)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"),Wn(e,s,i,"ABR pattern name"),Js(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"),f=e.u32(s,"ABR pattern bottom"),u=e.u32(s,"ABR pattern right"),d=e.u32(s,"ABR pattern channel count");if(f<=l||u<=c||d>16)throw new Error("ABR pattern bounds or channel count is invalid.");let p=u-c,h=f-l;if(p>i.maxCanvasDimension||h>i.maxCanvasDimension)throw new Error(`ABR pattern dimensions exceed the ${i.maxCanvasDimension}-pixel side limit.`);let m=_t(p,h,"ABR pattern pixels");Wd(t,m,_t(m,4,"ABR pattern RGBA bytes"),i,"ABR pattern");for(let y=0;y<d+2;y+=1){if(!e.u32(s,"ABR pattern channel presence"))continue;let k=e.u32(s,"ABR pattern channel length");if(k<23)throw new Error("ABR pattern channel length is invalid.");let x=e.offset+k;if(x>s)throw new Error("ABR pattern channel is truncated.");let S=e.u32(x,"ABR pattern channel depth"),A=e.u32(x,"ABR pattern channel top"),D=e.u32(x,"ABR pattern channel left"),C=e.u32(x,"ABR pattern channel bottom"),O=e.u32(x,"ABR pattern channel right"),E=e.u16(x,"ABR pattern channel depth duplicate"),L=e.u8(x,"ABR pattern channel compression");if(S!==8||E!==8||L!==0&&L!==1)throw new Error("ABR pattern channel uses an unsupported depth or compression mode.");if(C<A||O<D||A<l||D<c||C>f||O>u)throw new Error("ABR pattern channel bounds are invalid.");let M=O-D,J=C-A,pe=_t(M,J,"ABR pattern channel pixels");if(L===0){if(x-e.offset!==pe)throw new Error("ABR raw pattern channel length does not match its dimensions.");e.skip(pe,x,"ABR raw pattern channel")}else if(Zd(e,x,M,J,"ABR pattern channel"),e.offset!==x)throw new Error("ABR RLE pattern channel has trailing bytes.")}e.offset=s},Kd=(e,n)=>{Gd(e,n,"ABR");let t=new Ro(e),i=t.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=t.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(;t.offset<t.length;){if(un(++s,n,"ABR section count"),t.ascii(4,void 0,"ABR section signature")!=="8BIM")throw new Error("Invalid ABR section signature.");let c=t.ascii(4,void 0,"ABR section type"),f=t.u32(void 0,"ABR section length"),u=t.offset,d=u+f,p=u+Ys(f);if(d>t.length||p>t.length)throw new Error("ABR section is truncated.");if(c==="samp")a+=iy(t,d,o,r,n);else if(c==="desc"||c==="phry"){if(ny(t,d,r,n),t.offset!==d)throw new Error(`ABR ${c} descriptor does not consume its declared section.`)}else if(c==="patt")for(;t.offset<d;)un(++l,n,"ABR pattern count"),oy(t,d,r,n);else throw new Error(`Unsupported ABR section type ${JSON.stringify(c)}.`);if(t.offset>d)throw new Error(`ABR ${c} section exceeded its declared boundary.`);t.offset=p}return un(a+l,n,"ABR decoded resource count"),{format:"abr",majorVersion:i,minorVersion:o,sections:s,samples:a,patterns:l,previewPixels:r.previewPixels,decodedBytes:r.decodedBytes}},Yd=(e,n)=>{Gd(e,n,"CSH");let t=new Ro(e);if(t.ascii(4,void 0,"CSH signature")!=="cush")throw new Error("Invalid CSH signature.");let i=t.u32(void 0,"CSH version");if(i!==2)throw new Error(`Unsupported CSH version ${i}; version 2 is required.`);let o=t.u32(void 0,"CSH shape count");un(o,n,"CSH shape count");let r=0,s=0,a=Math.min(1e6,n.maxResourceItems*64);for(let l=0;l<o;l+=1){for(Wn(t,t.length,n,`CSH shape ${l} name`);t.offset%4;)t.skip(1,t.length,"CSH name padding");if(t.u32(void 0,"CSH shape version")!==1)throw new Error("Unsupported CSH shape record version.");let c=t.u32(void 0,"CSH shape record length"),f=t.offset+c;if(f>t.length)throw new Error("CSH shape record is truncated.");Js(t,f,n,`CSH shape ${l} id`);let u=t.u32(f,"CSH shape top"),d=t.u32(f,"CSH shape left"),p=t.u32(f,"CSH shape bottom"),h=t.u32(f,"CSH shape right");if(p<=u||h<=d)throw new Error("CSH shape bounds are invalid.");let m=h-d,y=p-u;if(m>n.maxCanvasDimension||y>n.maxCanvasDimension)throw new Error(`CSH shape dimensions exceed the ${n.maxCanvasDimension}-pixel side limit.`);let g=_t(m,y,"CSH shape preview pixels");if(s+=g,s>n.maxResourcePreviewPixels)throw new Error(`CSH previews exceed the ${n.maxResourcePreviewPixels}-pixel collection limit.`);if((f-t.offset)%26!==0)throw new Error("CSH vector record section is not aligned to 26-byte path records.");let k=0,x=0,S=!1;for(;t.offset<f;){if(r+=1,r>a)throw new Error(`CSH path complexity exceeds the ${a}-record safety limit.`);let A=t.u16(f,"CSH vector selector");if(A===0||A===3){if(S&&x!==k)throw new Error("CSH path knot count does not match its declared count.");k=t.u16(f,"CSH path knot count"),un(k,n,"CSH path knot count");let D=t.i16(f,"CSH path boolean operation");if(D<-1||D>3)throw new Error("CSH path boolean operation is invalid.");t.skip(20,f,"CSH path header"),x=0,S=!0}else if(A===1||A===2||A===4||A===5){if(!S)throw new Error("CSH knot appears before a path header.");if(t.skip(24,f,"CSH Bezier knot"),x+=1,x>k)throw new Error("CSH path contains more knots than declared.")}else if(A===6||A===7||A===8)t.skip(24,f,"CSH vector metadata record");else throw new Error(`Unsupported CSH vector selector ${A}.`)}if(S&&x!==k)throw new Error("CSH path knot count does not match its declared count.")}if(t.offset!==t.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 Tt=(e,n)=>{if(!Number.isFinite(e))throw new Error(`${n} is not finite.`);return e},pn=(e,n,t)=>{if(e.length>n.maxResourceNameCodeUnits)throw new Error(`${t} exceeds the ${n.maxResourceNameCodeUnits}-code-unit name limit.`);return e},ry=(e,n,t)=>{let i=Tt(e.size,`${t} size`),o=Tt(e.angle,`${t} angle`);if(i<0||i>n.maxCanvasDimension)throw new Error(`${t} size exceeds the ${n.maxCanvasDimension}-pixel side limit.`);let r={type:e.type,size:i,angle:o};return"roundness"in e&&(r.roundness=Tt(e.roundness,`${t} roundness`)),"hardness"in e&&(r.hardness=Tt(e.hardness,`${t} hardness`)),"spacing"in e&&(r.spacing=Tt(e.spacing,`${t} spacing`)),e.type==="sampled"&&(r.sampledDataId=pn(e.sampledData,n,`${t} sampled-data id`)),r},sy=(e,n)=>({name:pn(e.name,n,"ABR brush name"),shape:ry(e.shape,n,`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}:{}}),ay=(e,n)=>{let t=Kd(e,n),i=(0,To.readAbr)(new Uint8Array(e),{logMissingFeatures:!1,totalMemoryLimit:n.maxDecodedBytes});if(i.brushes.length+i.samples.length+i.patterns.length>n.maxResourceItems)throw new Error(`ABR decoded resources exceed the ${n.maxResourceItems}-item safety limit.`);let r=0,s=0,a=i.samples.map((c,f)=>{let{w:u,h:d,x:p,y:h}=c.bounds,m=u*d;if(!Number.isSafeInteger(m)||m<=0||c.alpha.byteLength!==m)throw new Error(`ABR sample ${f} returned inconsistent decoded pixels.`);return s+=m,r+=c.alpha.byteLength,{id:pn(c.id,n,`ABR sample ${f} id`),x:Tt(p,`ABR sample ${f} x`),y:Tt(h,`ABR sample ${f} y`),width:u,height:d,alpha:c.alpha}}),l=i.patterns.map((c,f)=>{let{w:u,h:d,x:p,y:h}=c.bounds,m=u*d;if(!Number.isSafeInteger(m)||m<=0||c.data.byteLength!==m*4)throw new Error(`ABR pattern ${f} returned inconsistent decoded pixels.`);return s+=m,r+=c.data.byteLength,{id:pn(c.id,n,`ABR pattern ${f} id`),name:pn(c.name,n,`ABR pattern ${f} name`),x:Tt(p,`ABR pattern ${f} x`),y:Tt(h,`ABR pattern ${f} y`),width:u,height:d,rgba:c.data}});if(s!==t.previewPixels||s>n.maxResourcePreviewPixels)throw new Error("ABR decoded preview pixels do not match the bounded preflight result.");if(r!==t.decodedBytes||r>n.maxDecodedBytes)throw new Error("ABR decoded byte count does not match the bounded preflight result.");return{format:"abr",version:`${t.majorVersion}.${t.minorVersion}`,engine:"ag-psd",fidelity:"decoded-tip-and-metadata-preview",brushes:i.brushes.map(c=>sy(c,n)),samples:a,patterns:l,limitations:["The preview shows decoded tip alpha, embedded pattern pixels, and preset metadata; it does not simulate a painted stroke.","The bounded decoder rejects legacy ABR versions 1 and 2 and 16-bit RLE brush samples."]}},Ne=e=>{let n=Math.abs(e)<1e-9?0:e;return Number(n.toFixed(4)).toString()},ly=(e,n)=>{if(!e.knots.length)return{d:"",fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}};let t=e.knots.map((r,s)=>{if(r.points.length!==6||r.points.some(a=>!Number.isFinite(a)))throw new Error(`${n} knot ${s} has invalid Bezier coordinates.`);return r.points}),i=t[0],o=`M ${Ne(i[2])} ${Ne(i[3])}`;for(let r=1;r<t.length;r+=1){let s=t[r-1],a=t[r];o+=` C ${Ne(s[4])} ${Ne(s[5])} ${Ne(a[0])} ${Ne(a[1])} ${Ne(a[2])} ${Ne(a[3])}`}if(!e.open){let r=t.at(-1);o+=` C ${Ne(r[4])} ${Ne(r[5])} ${Ne(i[0])} ${Ne(i[1])} ${Ne(i[2])} ${Ne(i[3])} Z`}return{d:o,fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}}},cy=(e,n)=>{let t=Yd(e,n),i=(0,To.readCsh)(new Uint8Array(e),{totalMemoryLimit:n.maxDecodedBytes});if(i.shapes.length!==t.shapes)throw new Error("CSH decoded shape count does not match its bounded preflight result.");let o=0,r=0,s=Math.min(1e6,n.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 f=l.paths.map((u,d)=>(r+=u.knots.length,ly(u,`CSH shape ${c} path ${d}`)));if(o+r>s)throw new Error(`CSH decoded path complexity exceeds the ${s}-record safety limit.`);return{id:pn(l.id,n,`CSH shape ${c} id`),name:pn(l.name,n,`CSH shape ${c} name`),width:l.width,height:l.height,paths:f,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."]}},Jd=(e,n,t)=>n==="abr"?ay(e,t):cy(e,t);var fy=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},dy=(e,n)=>{if(!Number.isFinite(e))throw new Error(`${n} is not finite.`);return e},Xn=class{bytes;view;offset=0;constructor(n){this.bytes=n instanceof Uint8Array?n:new Uint8Array(n),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(n,t=this.length,i="Adobe binary data"){if(!Number.isSafeInteger(n)||n<0||this.offset>t||n>t-this.offset)throw new Error(`${i} is truncated.`)}u8(n=this.length,t){return this.ensure(1,n,t),this.view.getUint8(this.offset++)}u16(n=this.length,t){this.ensure(2,n,t);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i16(n=this.length,t){this.ensure(2,n,t);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u32(n=this.length,t){this.ensure(4,n,t);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32(n=this.length,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}i64(n=this.length,t){this.ensure(8,n,t);let i=this.view.getBigInt64(this.offset,!1);return this.offset+=8,i}f64(n=this.length,t){this.ensure(8,n,t);let i=this.view.getFloat64(this.offset,!1);return this.offset+=8,dy(i,t||"Adobe double")}ascii(n,t=this.length,i="Adobe ASCII data"){this.ensure(n,t,i);let o="";for(let r=0;r<n;r+=1)o+=String.fromCharCode(this.bytes[this.offset+r]);return this.offset+=n,o}slice(n,t=this.length,i="Adobe binary data"){this.ensure(n,t,i);let o=this.bytes.subarray(this.offset,this.offset+n);return this.offset+=n,o}skip(n,t=this.length,i="Adobe binary data"){this.ensure(n,t,i),this.offset+=n}},Pi=(e,n,t,i)=>{let o=e.u32(n,`${i} length`);if(o>t.maxResourceNameCodeUnits+1)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit safety limit.`);let r=e.slice(fy(o,2,`${i} bytes`),n,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>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit safety limit.`);return s},Kt=(e,n,t,i)=>{let o=e.u32(n,`${i} length`),r=o===0?4:o;if(r===0||r>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-byte safety limit.`);return e.ascii(r,n,i)},Ci=(e,n,t)=>{if(!Number.isSafeInteger(n)||n<0||n>e.maximum-e.values)throw new Error(`${t} exceeds the ${e.maximum}-value descriptor safety limit.`);e.values+=n},Qd=(e,n,t,i)=>({name:Pi(e,n,t,`${i} name`),classId:Kt(e,n,t,`${i} id`)}),uy=(e,n,t,i)=>{let o=e.u32(n,"Adobe reference count");Ci(i,o,"Adobe reference count");let r=[];for(let s=0;s<o;s+=1){let a=e.ascii(4,n,"Adobe reference form"),{name:l,classId:c}=Qd(e,n,t,"Adobe reference class"),f={form:a,className:l,classId:c};if(a==="prop")f.property=Kt(e,n,t,"Adobe reference property");else if(a==="Enmr")f.enumType=Kt(e,n,t,"Adobe reference enum type"),f.enumValue=Kt(e,n,t,"Adobe reference enum value");else if(a==="rele"||a==="Idnt"||a==="indx")f.index=e.i32(n,"Adobe reference index");else if(a==="name")f.name=Pi(e,n,t,"Adobe reference name");else if(a!=="Clss")throw new Error(`Unsupported Adobe reference form ${JSON.stringify(a)}.`);r.push(f)}return r},py=(e,n,t)=>{let i=e.u32(n,"Adobe descriptor path length");if(i>t.maxDecodedBytes)throw new Error(`Adobe descriptor path exceeds the ${t.maxDecodedBytes}-byte safety limit.`);return e.skip(i,n,"Adobe descriptor path"),{type:"path",length:i}},eu=(e,n,t,i,o,r)=>{if(r>i.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${i.maxNestingDepth}-level safety limit.`);switch(t){case"bool":return{type:"boolean",value:e.u8(n,"Adobe boolean")!==0};case"long":return{type:"integer",value:e.i32(n,"Adobe integer")};case"comp":return{type:"large-integer",value:e.i64(n,"Adobe large integer")};case"doub":return{type:"double",value:e.f64(n,"Adobe double")};case"UntF":return{type:"unit-double",unit:e.ascii(4,n,"Adobe unit"),value:e.f64(n,"Adobe unit double")};case"TEXT":return{type:"text",value:Pi(e,n,i,"Adobe descriptor text")};case"enum":return{type:"enum",enumType:Kt(e,n,i,"Adobe enum type"),value:Kt(e,n,i,"Adobe enum value")};case"Objc":case"GlbO":return{type:"object",value:hn(e,n,i,o,r+1)};case"VlLs":{let s=e.u32(n,"Adobe list count");Ci(o,s,"Adobe list count");let a=[];for(let l=0;l<s;l+=1)a.push(eu(e,n,e.ascii(4,n,"Adobe list value type"),i,o,r+1));return{type:"list",value:a}}case"alis":case"tdta":{let s=e.u32(n,"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,n,"Adobe raw data"),{type:"raw",length:s,alias:t==="alis"}}case"type":case"GlbC":{let s=Qd(e,n,i,"Adobe class reference");return{type:"class",name:s.name,classId:s.classId}}case"UnFl":{let s=e.ascii(4,n,"Adobe unit-float-array unit"),a=e.u32(n,"Adobe unit-float-array count");Ci(o,a,"Adobe unit-float-array count");let l=Array.from({length:a},()=>e.f64(n,"Adobe unit-float-array value"));return{type:"unit-double-array",unit:s,value:l}}case"ObAr":{let s=e.u32(n,"Adobe object-array count");return Ci(o,s,"Adobe object-array count"),{type:"object-array",count:s,value:hn(e,n,i,o,r+1)}}case"obj ":return{type:"reference",value:uy(e,n,i,o)};case"Pth ":return py(e,n,i);default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(t)}.`)}},Di=e=>{let n=Number.isSafeInteger(e.maxResourceItems)&&e.maxResourceItems>0?Math.min(1e6,e.maxResourceItems):1;return{values:0,maximum:n>3906?1e6:n*256}},hn=(e,n,t,i=Di(t),o=0)=>{if(o>t.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${t.maxNestingDepth}-level safety limit.`);let r=Pi(e,n,t,"Adobe descriptor name"),s=Kt(e,n,t,"Adobe descriptor class"),a=e.u32(n,"Adobe descriptor item count");Ci(i,a,"Adobe descriptor item count");let l=new Map,c=[];for(let f=0;f<a;f+=1){let u=Kt(e,n,t,"Adobe descriptor key");if(l.has(u))throw new Error(`Adobe descriptor contains duplicate key ${JSON.stringify(u)}.`);let d=e.ascii(4,n,"Adobe descriptor value type");l.set(u,eu(e,n,d,t,i,o+1)),c.push(u)}return{name:r,classId:s,entries:l,keys:c}},Me=(e,n)=>e?.entries.get(n),Oi=(e,n)=>{let t=Me(e,n);return t?.type==="object"?t.value:void 0},gn=(e,n)=>{let t=Me(e,n);return t?.type==="text"?t.value:void 0},Ei=(e,n)=>{let t=Me(e,n);return t?.type==="enum"?t.value:void 0},Fi=(e,n,t=!1)=>{let i=Me(e,n);return i?.type==="boolean"?i.value:t},Ie=(e,n,t=0)=>{let i=Me(e,n);return i?i.type==="integer"||i.type==="double"||i.type==="unit-double"?i.value:i.type==="large-integer"?Number(i.value):t:t},tu=Pi;var hy=["maxFileBytes","maxCanvasPixels","maxCanvasDimension","maxLayers","maxNestingDepth","maxLayerPixels","maxDecodedBytes","maxLayerCacheBytes","maxResourceItems","maxResourceNameCodeUnits","maxResourcePreviewPixels"],gy=e=>{for(let n of hy){let t=e[n];if(!Number.isSafeInteger(t)||t<=0)throw new Error(`Invalid Adobe preset safety limit ${n}.`)}},ru=e=>e+3&-4,ct=(e,n,t)=>{let i=e+n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},zo=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},ea=(e,n,t)=>{if(e.byteLength>n.maxFileBytes)throw new Error(`${t} source exceeds the ${n.maxFileBytes}-byte safety limit.`);if(!e.byteLength)throw new Error(`${t} source is empty.`)},su=(e,n,t,i,o)=>{if(e.previewPixels=ct(e.previewPixels,n,`${o} preview pixels`),e.decodedBytes=ct(e.decodedBytes,t,`${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.`)},my=(e,n,t,i)=>{let o=e.u8(n,`${i} length`);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-byte safety limit.`);let r=e.ascii(o,n,i),s=r.length;for(;s>0&&r.charCodeAt(s-1)===0;)s-=1;return r.slice(0,s)},yy=(e,n,t,i,o,r)=>{let s=Array.from({length:i},(l,c)=>e.u16(n,`${r} row ${c} length`)),a=o?new Uint8Array(zo(t,i,`${r} pixels`)):void 0;for(let l=0;l<i;l+=1){let c=ct(e.offset,s[l],`${r} row ${l} end`);if(c>n)throw new Error(`${r} compressed row ${l} is truncated.`);let f=0;for(;e.offset<c;){let u=e.u8(c,`${r} PackBits header`);if(u<=127){let d=u+1,p=e.slice(d,c,`${r} PackBits literal`);if(f+d>t)throw new Error(`${r} row ${l} expands beyond its declared width.`);a&&a.set(p,l*t+f),f+=d}else if(u>=129){let d=257-u,p=e.u8(c,`${r} PackBits repeat value`);if(f+d>t)throw new Error(`${r} row ${l} expands beyond its declared width.`);a?.fill(p,l*t+f,l*t+f+d),f+=d}}if(f!==t)throw new Error(`${r} row ${l} expands to ${f} instead of ${t} pixels.`)}if(e.offset!==n)throw new Error(`${r} has trailing compressed bytes.`);return a},by=(e,n,t,i,o,r,s)=>{let a=zo(t,i,`${s} pixels`);if(o===0){if(e.offset+a!==n)throw new Error(`${s} raw byte length does not match its dimensions.`);return r?Uint8Array.from(e.slice(a,n,s)):(e.skip(a,n,s),void 0)}if(o===1)return yy(e,n,t,i,r,s);throw new Error(`${s} uses unsupported compression mode ${o}.`)},nu=(e,n,t,i,o,r,s,a)=>{for(let l=0;l<i.height;l+=1)for(let c=0;c<i.width;c+=1){let f=l*i.width+c,u=((i.top-n.top+l)*n.width+i.left-n.left+c)*4,d=t[f];r===1&&o===0?(e[u]=d,e[u+1]=d,e[u+2]=d):r===2&&o===0&&s?(e[u]=s[d*3],e[u+1]=s[d*3+1],e[u+2]=s[d*3+2],a&&(a[(i.top-n.top+l)*n.width+i.left-n.left+c]=d)):e[u+o]=d}},au=(e,n,t,i,o,r)=>{if(e.u32(n,`PAT pattern ${r} version`)!==1)throw new Error(`PAT pattern ${r} uses an unsupported record version.`);let s=e.u32(n,`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(n,`PAT pattern ${r} vertical value`),l=e.i16(n,`PAT pattern ${r} horizontal value`),c=tu(e,n,t,`PAT pattern ${r} name`),f=my(e,n,t,`PAT pattern ${r} id`);if(!f)throw new Error(`PAT pattern ${r} has an empty unique id.`);let u,d=65535;if(s===2&&(u=Uint8Array.from(e.slice(768,n,`PAT pattern ${r} indexed palette`)),o?(e.u16(n,`PAT pattern ${r} indexed color count`),d=e.u16(n,`PAT pattern ${r} transparent palette index`)):e.skip(4,n,`PAT pattern ${r} indexed footer`)),e.u32(n,`PAT pattern ${r} VMAL version`)!==3)throw new Error(`PAT pattern ${r} uses an unsupported VMAL version.`);let p=e.u32(n,`PAT pattern ${r} VMAL length`),h=ct(e.offset,p,`PAT pattern ${r} VMAL end`);if(h>n)throw new Error(`PAT pattern ${r} VMAL is truncated.`);let m=e.i32(h,`PAT pattern ${r} top`),y=e.i32(h,`PAT pattern ${r} left`),g=e.i32(h,`PAT pattern ${r} bottom`),k=e.i32(h,`PAT pattern ${r} right`),x=k-y,S=g-m,A=e.u32(h,`PAT pattern ${r} channel count`);if(x<=0||S<=0||x>t.maxCanvasDimension||S>t.maxCanvasDimension)throw new Error(`PAT pattern ${r} dimensions exceed the ${t.maxCanvasDimension}-pixel side safety limit.`);if(o&&(l!==x||a!==S))throw new Error(`PAT pattern ${r} header dimensions disagree with its decoded VMAL bounds.`);if(A>64)throw new Error(`PAT pattern ${r} channel count exceeds the 64-channel safety limit.`);let D=zo(x,S,`PAT pattern ${r} pixels`);su(i,D,zo(D,4,`PAT pattern ${r} RGBA bytes`),t,`PAT pattern ${r}`);let C=new Uint8Array(D*4);for(let R=3;R<C.length;R+=4)C[R]=255;let O=s===2?new Uint8Array(D):void 0,E=s===3?3:1,L=new Set,M=!1,J={top:m,left:y,width:x,height:S};for(let R=0;R<A+2;R+=1){let ie=e.u32(h,`PAT pattern ${r} channel ${R} presence`);if(!ie)continue;if(ie!==1)throw new Error(`PAT pattern ${r} channel ${R} has an invalid presence marker.`);let he=e.u32(h,`PAT pattern ${r} channel ${R} length`);if(he<23)throw new Error(`PAT pattern ${r} channel ${R} is shorter than its header.`);let ce=ct(e.offset,he,`PAT pattern ${r} channel ${R} end`);if(ce>h)throw new Error(`PAT pattern ${r} channel ${R} is truncated.`);let Ce=e.u32(ce,`PAT pattern ${r} channel ${R} depth`),W=e.i32(ce,`PAT pattern ${r} channel ${R} top`),B=e.i32(ce,`PAT pattern ${r} channel ${R} left`),$=e.i32(ce,`PAT pattern ${r} channel ${R} bottom`),ne=e.i32(ce,`PAT pattern ${r} channel ${R} right`),ge=e.u16(ce,`PAT pattern ${r} channel ${R} depth copy`),Q=e.u8(ce,`PAT pattern ${r} channel ${R} compression`);if(Ce!==8||ge!==8)throw new Error(`PAT pattern ${r} channel ${R} is not 8-bit.`);if(W<m||B<y||$>g||ne>k||$<=W||ne<=B)throw new Error(`PAT pattern ${r} channel ${R} bounds are outside the tile.`);let ee=ne-B,be=$-W,Se=R<E,xe=R===A+1,jt=by(e,ce,ee,be,Q,Se||xe,`PAT pattern ${r} channel ${R}`);jt&&Se?(L.add(R),nu(C,J,jt,{top:W,left:B,width:ee,height:be},R,s,u,O)):jt&&xe&&(M=!0,nu(C,J,jt,{top:W,left:B,width:ee,height:be},3,s))}if(e.offset!==h)throw new Error(`PAT pattern ${r} VMAL has trailing or unparsed bytes.`);if(L.size!==E)throw new Error(`PAT pattern ${r} is missing one or more required color planes.`);if(s===2&&!M&&d<256&&O)for(let R=0;R<O.length;R+=1)O[R]===d&&(C[R*4+3]=0);let pe=!1;for(let R=0;R<D;R+=1)if(C[R*4+3]!==255){pe=!0;break}return{name:c||`Pattern ${r}`,id:f,width:x,height:S,colorMode:s===1?"grayscale":s===2?"indexed":"rgb",rgba:C,hasTransparency:pe}},wy=(e,n,t,i)=>{let o=[];for(;e.offset<n;){if(o.length>=t.maxResourceItems)throw new Error(`Embedded pattern count exceeds the ${t.maxResourceItems}-item safety limit.`);let r=e.u32(n,"Embedded PAT record length"),s=ct(e.offset,r,"Embedded PAT record end"),a=ct(e.offset,ru(r),"Embedded PAT padded end");if(!r||s>n||a>n)throw new Error("Embedded PAT record is truncated.");if(o.push(au(e,s,t,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!==n)throw new Error("Embedded PAT block length is invalid.");return o},vy=(e,n)=>{ea(e,n,"PAT");let t=new Xn(e);if(t.ascii(4,t.length,"PAT signature")!=="8BPT")throw new Error("Invalid Photoshop PAT signature.");if(t.u16(t.length,"PAT version")!==1)throw new Error("Unsupported Photoshop PAT version; expected version 1.");let i=t.u32(t.length,"PAT pattern count");if(!i||i>n.maxResourceItems)throw new Error(`PAT pattern count must be between 1 and ${n.maxResourceItems}.`);let o={previewPixels:0,decodedBytes:0},r=Array.from({length:i},(s,a)=>au(t,t.length,n,o,!0,a+1));return na(t,n,Di(n),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."]}},Ue=(e,n,t,i)=>{if(!Number.isFinite(e)||e<n||e>t)throw new Error(`${i} is outside ${n}\u2026${t}.`);return e},$e=e=>Math.max(0,Math.min(255,Math.round(e))),Sy=(e,n,t)=>{let i=(e%360+360)%360/60,o=Math.max(0,Math.min(1,n/100)),r=Math.max(0,Math.min(1,t/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(f=>$e((f+l)*255))},xy=(e,n,t)=>{let i=.20689655172413793,o=p=>p>i?p**3:3*i*i*(p-4/29),r=(e+16)/116,s=.96422*o(r+n/500),a=o(r),l=.82521*o(r-t/200),c=.9555766*s-.0230393*a+.0631636*l,f=-.0282895*s+1.0099416*a+.0210077*l,u=.0122982*s-.020483*a+1.3299098*l;return[3.2404542*c-1.5371385*f-.4985314*u,-.969266*c+1.8760108*f+.041556*u,.0556434*c-.2040259*f+1.0572252*u].map(p=>$e((p<=.0031308?12.92*p:1.055*Math.max(0,p)**(1/2.4)-.055)*255))},ky=e=>{if(!e)return{rgb:[0,0,0],colorSpace:"unknown"};if(e.classId==="RGBC")return{rgb:[$e(Ie(e,"Rd ")),$e(Ie(e,"Grn ")),$e(Ie(e,"Bl "))],colorSpace:"rgb"};if(e.classId==="Grsc"){let n=$e(Ue(Ie(e,"Gry "),0,100,"GRD gray")*2.55);return{rgb:[n,n,n],colorSpace:"gray"}}if(e.classId==="HSBC"||e.classId==="HSBl")return{rgb:Sy(Ie(e,"H "),Ie(e,"Strt"),Ie(e,"Brgh")),colorSpace:"hsb"};if(e.classId==="LbCl")return{rgb:xy(Ie(e,"Lmnc"),Ie(e,"A "),Ie(e,"B ")),colorSpace:"lab"};if(e.classId==="CMYC"){let n=Ue(Ie(e,"Cyn "),0,100,"GRD cyan")/100,t=Ue(Ie(e,"Mgnt"),0,100,"GRD magenta")/100,i=Ue(Ie(e,"Ylw "),0,100,"GRD yellow")/100,o=Ue(Ie(e,"Blck"),0,100,"GRD black")/100;return{rgb:[$e((1-n)*(1-o)*255),$e((1-t)*(1-o)*255),$e((1-i)*(1-o)*255)],colorSpace:"cmyk"}}return{rgb:[0,0,0],colorSpace:"unknown"}},Qs=(e,n,t)=>{if(!e||e.type!=="list")throw new Error(`${n} list is missing.`);if(e.value.length>t)throw new Error(`${n} exceeds the ${t}-item safety limit.`);return e.value.map((i,o)=>{if(i.type!=="object")throw new Error(`${n} item ${o+1} is not an object.`);return i.value})},_y=(e,n)=>e<=n?n<=0?.5:.5*e/n:n>=1?.5:.5+.5*(e-n)/(1-n),iu=(e,n,t)=>{if(n<=e[0].location)return e[0].value;if(n>=e.at(-1).location)return e.at(-1).value;let i=e.findIndex(l=>l.location>=n),o=e[i-1],r=e[i],s=Math.max(1e-9,r.location-o.location),a=_y((n-o.location)/s,Math.max(.001,Math.min(.999,o.midpoint)));return Array.from({length:t},(l,c)=>o.value[c]+(r.value[c]-o.value[c])*a)},Ay=(e,n)=>{let t=new Uint8Array(1024),i=e.map(r=>({location:r.location,midpoint:r.midpoint,value:r.rgb})),o=n.map(r=>({location:r.location,midpoint:r.midpoint,value:[r.opacity]}));for(let r=0;r<256;r+=1){let s=r/255,a=iu(i,s,3),l=iu(o,s,1)[0];t.set([$e(a[0]),$e(a[1]),$e(a[2]),$e(l*255)],r*4)}return t},ou=(e,n,t)=>{let i=Me(e,n),o=i?.type==="list"?i.value:[];return[0,1,2,3].map(r=>{let s=o[r];return s?.type==="integer"?Ue(s.value,0,100,`GRD ${n} range`):t})},Iy=(e,n,t,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]=$e((n[l]+s()*(t[l]-n[l]))*2.55);o[a*4+3]=i?$e((n[3]+s()*(t[3]-n[3]))*2.55):255}return o},ta=e=>{if(!e.startsWith("$$$/"))return e;let n=e.lastIndexOf("=");if(n>=0&&n+1<e.length)return e.slice(n+1);let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e},Cy=(e,n,t,i)=>{su(i,256,1024,t,`GRD gradient ${n}`);let o=Oi(e,"Grad")||e,r=ta(gn(o,"Nm ")||`Gradient ${n}`),s=Ei(o,"GrdF")||"CstS";if(s==="ClNs"){let u=ou(o,"Mnm ",0),d=ou(o,"Mxm ",100);d.forEach((k,x)=>{if(k<u[x])throw new Error(`${r}: noise maximum is below its minimum.`)});let p=Ue(Ie(o,"RndS",0),0,4294967295,`${r} random seed`),h=Ue(Ie(o,"Smth",2048),0,4096,`${r} roughness`),m=Ei(o,"ClrS")||"RGBC",y=m==="HSBl"||m==="HSBC"?"hsb":m==="LbCl"||m==="LABC"?"lab":"rgb",g=Fi(o,"ShTr",!1);return{name:r,definition:{form:"noise",seed:p,roughness:h,colorModel:y,restrictColors:Fi(o,"VctC",!0),addTransparency:g,minimum:u,maximum:d},previewRgba:Iy(p,u,d,g)}}if(s!=="CstS")throw new Error(`${r}: unsupported GRD gradient form ${JSON.stringify(s)}.`);let l=Qs(Me(o,"Clrs"),`${r} color stops`,Math.min(256,t.maxResourceItems)).map((u,d)=>{let p=Ue(Ie(u,"Lctn")/4096,0,1,`${r} color stop ${d+1} location`),h=Ue(Ie(u,"Mdpn",50)/100,0,1,`${r} color stop ${d+1} midpoint`),m=Ei(u,"Type")||"UsrS",y=m==="FrgC"?"foreground":m==="BckC"?"background":"user",g=y==="foreground"?{rgb:[0,0,0],colorSpace:"unknown"}:y==="background"?{rgb:[255,255,255],colorSpace:"unknown"}:ky(Oi(u,"Clr "));if(y==="user"&&g.colorSpace==="unknown")throw new Error(`${r} color stop ${d+1} uses an unsupported color object.`);return{location:p,midpoint:h,kind:y,...g}}).sort((u,d)=>u.location-d.location);if(l.length<2)throw new Error(`${r} has fewer than two usable color stops.`);let c=Me(o,"Trns"),f=c?Qs(c,`${r} transparency stops`,Math.min(256,t.maxResourceItems)).map((u,d)=>({location:Ue(Ie(u,"Lctn")/4096,0,1,`${r} alpha stop ${d+1} location`),midpoint:Ue(Ie(u,"Mdpn",50)/100,0,1,`${r} alpha stop ${d+1} midpoint`),opacity:Ue(Ie(u,"Opct",100)/100,0,1,`${r} alpha stop ${d+1} opacity`)})).sort((u,d)=>u.location-d.location):[{location:0,midpoint:.5,opacity:1},{location:1,midpoint:.5,opacity:1}];if(!f.length)throw new Error(`${r} declares an empty transparency-stop list.`);return{name:r,definition:{form:"solid",smoothness:Ue(Ie(o,"Intr",4096),0,4096,`${r} smoothness`),colorStops:l,alphaStops:f},previewRgba:Ay(l,f)}},Py=(e,n)=>{let t=Me(e,"hierarchy");if(!t||t.type!=="list")return Array.from({length:n},()=>"");let i=Array.from({length:n},()=>""),o=[],r=0;for(let s of t.value)s.type==="object"&&(s.value.classId==="Grup"?o.push(ta(gn(s.value,"Nm ")||"")):s.value.classId==="groupEnd"?o.pop():s.value.classId==="preset"&&r<i.length&&(i[r++]=o.filter(Boolean).join(" / ")));return i},na=(e,n,t,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=ct(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=hn(e,r,n,t);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 Py(s,i)},Dy=(e,n)=>{ea(e,n,"GRD");let t=new Xn(e);if(t.ascii(4,t.length,"GRD signature")!=="8BGR")throw new Error("Invalid Photoshop GRD signature.");if(t.u16(t.length,"GRD version")!==5)throw new Error("Unsupported Photoshop GRD version; only descriptor-based version 5 is decoded.");if(t.u32(t.length,"GRD descriptor version")!==16)throw new Error("Unsupported GRD Action Descriptor version.");let i=Di(n),o=hn(t,t.length,n,i),r={previewPixels:0,decodedBytes:0},s=Qs(Me(o,"GrdL"),"GRD gradients",n.maxResourceItems).map((l,c)=>Cy(l,c+1,n,r));if(!s.length)throw new Error("GRD file contains no gradients.");let a=na(t,n,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."]}},Oy=[{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"}],Ey=e=>{if(!e)return[];let n=[];for(let t of Oy){let i=Me(e,t.single),o=Me(e,t.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&&n.push({kind:t.kind,enabled:r.some(s=>Fi(s,"enab",!0)),instances:r.length})}return n},jo=(e,n)=>{if(e.type==="object"){n(e.value);for(let t of e.value.entries.values())jo(t,n)}else if(e.type==="list")e.value.forEach(t=>jo(t,n));else if(e.type==="object-array"){n(e.value);for(let t of e.value.entries.values())jo(t,n)}},Fy=e=>{let n=new Map;if(!e)return[];let t=i=>{if(i.classId!=="Ptrn"&&!i.entries.has("Idnt"))return;let o=gn(i,"Idnt")||"",r=gn(i,"Nm ")||"";o&&n.set(o,{name:r,id:o})};t(e);for(let i of e.entries.values())jo(i,t);return[...n.values()]},Ly=(e,n,t,i,o)=>{if(e.u32(n,`ASL style ${o} identity descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported identity descriptor version.`);let r=hn(e,n,t,i),s=ta(gn(r,"Nm ")||""),a=gn(r,"Idnt")||"";if(!s||!a)throw new Error(`ASL style ${o} is missing its name or unique id.`);if(e.u32(n,`ASL style ${o} effect descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported effect descriptor version.`);let l=hn(e,n,t,i),c=Oi(l,"Lefx"),f=Oi(l,"blendOptions"),u=Me(f,"Blnd"),d={name:s,id:a,effectsVisible:Fi(c,"masterFXSwitch",!0),effects:Ey(c),blendIfChannels:u?.type==="list"?u.value.length:0,referencedPatterns:Fy(c)},p=Ei(f,"Md ");p&&(d.blendMode=p);let h=Me(f,"Opct");(h?.type==="unit-double"||h?.type==="double"||h?.type==="integer")&&(d.opacity=Ue(h.value,0,100,`${s} opacity`));let m=Me(f,"fillOpacity");if((m?.type==="unit-double"||m?.type==="double"||m?.type==="integer")&&(d.fillOpacity=Ue(m.value,0,100,`${s} fill opacity`)),!d.effects.length&&!f)throw new Error(`${s} contains no supported effect graph or blending options.`);return d},My=(e,n)=>{ea(e,n,"ASL");let t=new Xn(e);if(t.u16(t.length,"ASL version")!==2)throw new Error("Unsupported Photoshop ASL version; expected version 2.");if(t.ascii(4,t.length,"ASL signature")!=="8BSL")throw new Error("Invalid Photoshop ASL signature.");if(t.u16(t.length,"ASL pattern section version")!==3)throw new Error("Unsupported ASL embedded-pattern section version.");let i=t.u32(t.length,"ASL embedded-pattern section length"),o=ct(t.offset,i,"ASL embedded-pattern section end");if(o>t.length)throw new Error("ASL embedded-pattern section is truncated.");let s=i?wy(t,o,n,{previewPixels:0,decodedBytes:0}):[],a=t.u32(t.length,"ASL style count");if(!a||a>n.maxResourceItems)throw new Error(`ASL style count must be between 1 and ${n.maxResourceItems}.`);let l=Di(n),c=[];for(let f=0;f<a;f+=1){let u=t.u32(t.length,`ASL style ${f+1} length`),d=ct(t.offset,u,`ASL style ${f+1} end`),p=ct(t.offset,ru(u),`ASL style ${f+1} padded end`);if(!u||d>t.length||p>t.length)throw new Error(`ASL style ${f+1} record is truncated.`);c.push(Ly(t,d,n,l,f+1));for(let h of t.slice(d-t.offset,d,`ASL style ${f+1} padding`))if(h!==0)throw new Error(`ASL style ${f+1} has unparsed non-zero bytes.`);for(let h of t.slice(p-d,p,`ASL style ${f+1} alignment`))if(h!==0)throw new Error(`ASL style ${f+1} has non-zero alignment bytes.`)}return na(t,n,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."]}},lu=(e,n,t)=>{if(gy(t),n==="pat")return vy(e,t);if(n==="grd")return Dy(e,t);if(n==="asl")return My(e,t);throw new Error(`Unsupported Adobe preset format ${JSON.stringify(n)}.`)};var $o=self,cu=e=>e.format==="abr"?[...e.samples.map(n=>n.alpha.buffer),...e.patterns.map(n=>n.rgba.buffer)].filter(n=>n instanceof ArrayBuffer):e.format==="pat"?e.patterns.map(n=>n.rgba.buffer).filter(n=>n instanceof ArrayBuffer):e.format==="grd"?e.gradients.map(n=>n.previewRgba.buffer).filter(n=>n instanceof ArrayBuffer):e.format==="asl"?e.patterns.map(n=>n.rgba.buffer).filter(n=>n instanceof ArrayBuffer):[];$o.addEventListener("message",e=>{let n=e.data;try{if(!n||n.type!=="parse"&&n.type!=="parse-preset")throw new Error("Invalid Adobe resource Worker request.");if(n.type==="parse-preset"){let t=lu(n.buffer,n.format,n.limits),i={id:n.id,ok:!0,result:t};$o.postMessage(i,cu(t))}else{let t=Jd(n.buffer,n.format,n.limits),i={id:n.id,ok:!0,result:t};$o.postMessage(i,cu(t))}}catch(t){let i={id:n?.id??0,ok:!1,error:{name:t instanceof Error?t.name:"Error",message:t instanceof Error?t.message:String(t)}};$o.postMessage(i)}});
8
+ `),m(e);return t.slice(0,i)}});var Ef=ae(vi=>{"use strict";Object.defineProperty(vi,"__esModule",{value:!0});vi.decodeEngineData=Mg;vi.decodeLegacyTextData=Ug;vi.encodeEngineData=Bg;var zn=Ot(),If={name:"MyriadPro-Regular",script:0,type:0,synthetic:0},bo={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},Pg={font:If,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},fn={isOn:!1,show:!1,size:18,leading:22,color:{r:0,g:0,b:255},leadingFillColor:{r:0,g:0,b:255},alignLineHeightToGridFlags:!1},ys=["justification","firstLineIndent","startIndent","endIndent","spaceBefore","spaceAfter","autoHyphenate","hyphenatedWordSize","preHyphen","postHyphen","consecutiveHyphens","zone","wordSpacing","letterSpacing","glyphSpacing","autoLeading","leadingType","hanging","burasagari","kinsokuOrder","everyLineComposer"],vo=["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"],hs=["none","crisp","strong","smooth","sharp",void 0,"platformLCD","platform"],bs=["left","right","center","justify-left","justify-right","justify-center","justify-all"];function Cf(e){return e.substring(0,1).toUpperCase()+e.substring(1)}function Pf(e){let n=e.Values;switch(e.Type){case 0:return{k:n[1]*255};case 1:return n[0]===1?{r:n[1]*255,g:n[2]*255,b:n[3]*255}:{r:n[1]*255,g:n[2]*255,b:n[3]*255,a:n[0]*255};case 2:return{c:n[1]*255,m:n[2]*255,y:n[3]*255,k:n[4]*255};default:throw new Error("Unknown color type in text layer")}}function Dg(e,n,t){e=(0,zn.clamp)(e||0,0,1),n=(0,zn.clamp)(n||0,0,1),t=(0,zn.clamp)(t||0,0,1);let i=e*6%6,o=Math.floor(i),r=i-o,s=t*(1-n),a=t*(1-n*r),l=t*(1-n*(1-r));switch(o){case 0:return[t,l,s];case 1:return[a,t,s];case 2:return[s,t,l];case 3:return[s,a,t];case 4:return[l,s,t];default:return[t,s,a]}}function gs(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("fr"in e)return{Type:1,Values:[1,(0,zn.clamp)(e.fr||0,0,1),(0,zn.clamp)(e.fg||0,0,1),(0,zn.clamp)(e.fb||0,0,1)]};if("h"in e){let[n,t,i]=Dg(e.h,e.s,e.b);return{Type:1,Values:[1,n,t,i]}}else{if("c"in e)return{Type:2,Values:[1,e.c/255,e.m/255,e.y/255,e.k/255]};if("l"in e)throw new Error("LAB colors are not supported in text layers, use RGB, CMYK or grayscale color instead");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 Sf(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function xf(e,n){if(!e||!n)return!1;for(let t of Object.keys(e))if(e[t]!==n[t])return!1;for(let t of Object.keys(n))if(e[t]!==n[t])return!1;return!0}function Og(e,n){for(let t=0;t<e.length;t++)if(e[t].name===n.name&&(e[t].synthetic||0)===(n.synthetic||0))return t;return e.push(n),e.length-1}function Df(e,n,t){var i;let o={};for(let r of n){let s=Cf(r);if(e[s]!==void 0)if(r==="justification")o[r]=(i=bs[e[s]|0])!==null&&i!==void 0?i:"left";else if(r==="font"){let a=t[e[s]|0];a&&(o[r]=a)}else r==="fillColor"||r==="strokeColor"?o[r]=Pf(e[s]):o[r]=e[s]}return o}function Of(e,n,t){var i;let o={};for(let r of n){let s=Cf(r);e[r]!==void 0&&(r==="justification"?o[s]=Math.max(0,bs.indexOf((i=e[r])!==null&&i!==void 0?i:"left")):r==="font"?o[s]=Og(t,e[r]):r==="fillColor"||r==="strokeColor"?o[s]=gs(e[r]):o[s]=e[r])}return o}function Eg(e,n){return Df(e,ys,n)}function Fg(e,n){return Df(e,vo,n)}function wo(e,n){return Of(e,ys,n)}function ps(e,n){return Of(e,vo,n)}function ms(e,n,t){if(n.length){for(let i of t){let o=n[0].style[i];if(o!==void 0){let s=!1;Array.isArray(o)?s=n.every(a=>Sf(a.style[i],o)):typeof o=="object"?s=n.every(a=>xf(a.style[i],o)):s=n.every(a=>a.style[i]===o),s&&(e[i]=o)}if(e[i]!==void 0)for(let s of n){let a=!1;Array.isArray(o)?a=Sf(s.style[i],o):typeof o=="object"?a=xf(s.style[i],o):a=s.style[i]===o,a&&delete s.style[i]}}n.every(i=>Object.keys(i.style).length===0)&&(n.length=0)}}function kf(e){return!!e&&"r"in e&&e.r===0&&e.g===0&&e.b===255}function _f(e,n){try{return e?Pf(e):n}catch{return n}}function Lg(e){var n,t;if(!e||typeof e!="object")return;let i={isOn:!!e.GridIsOn,show:!!e.ShowGrid,size:(n=e.GridSize)!==null&&n!==void 0?n:fn.size,leading:(t=e.GridLeading)!==null&&t!==void 0?t:fn.leading,color:_f(e.GridColor,fn.color),leadingFillColor:_f(e.GridLeadingFillColor,fn.leadingFillColor),alignLineHeightToGridFlags:!!e.AlignLineHeightToGridFlags};return!i.isOn&&!i.show&&i.size===fn.size&&i.leading===fn.leading&&!i.alignLineHeightToGridFlags&&kf(i.color)&&kf(i.leadingFillColor)?void 0:i}function Mg(e){var n,t,i,o,r,s,a,l,c,f;let u=e.EngineDict,d=e.ResourceDict,p=d.FontSet.map(O=>({name:O.Name,script:O.Script,type:O.FontType,synthetic:O.Synthetic})),h=u.Editor.Text.replace(/\r/g,`
9
+ `),m=0;/\n$/.test(h)&&(h=h.substring(0,h.length-1),m=1);let y={text:h,antiAlias:(n=hs[u.AntiAlias])!==null&&n!==void 0?n:"smooth",useFractionalGlyphWidths:!!u.UseFractionalGlyphWidths,superscriptSize:d.SuperscriptSize,superscriptPosition:d.SuperscriptPosition,subscriptSize:d.SubscriptSize,subscriptPosition:d.SubscriptPosition,smallCapSize:d.SmallCapSize},g=(s=(r=(o=(i=(t=u.Rendered)===null||t===void 0?void 0:t.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;g&&(y.shapeType=g.ShapeType===1?"box":"point",g.PointBase&&(y.pointBase=g.PointBase),g.BoxBounds&&(y.boxBounds=g.BoxBounds));let k=Lg(u.GridInfo);k&&(y.gridInfo=k);let x=u.ParagraphRun;y.paragraphStyle={},y.paragraphStyleRuns=[];for(let O=0;O<x.RunArray.length;O++){let E=x.RunArray[O],L=x.RunLengthArray[O],M=Eg(E.ParagraphSheet.Properties,p);y.paragraphStyleRuns.push({length:L,style:M})}for(let O=m;y.paragraphStyleRuns.length&&O>0;O--)--y.paragraphStyleRuns[y.paragraphStyleRuns.length-1].length===0&&y.paragraphStyleRuns.length===1&&y.paragraphStyleRuns.pop();ms(y.paragraphStyle,y.paragraphStyleRuns,ys),y.paragraphStyleRuns.length||delete y.paragraphStyleRuns;let S=u.StyleRun,A=(c=(a=d.StyleSheetSet)===null||a===void 0?void 0:a[(l=d.TheNormalStyleSheet)!==null&&l!==void 0?l:0])===null||c===void 0?void 0:c.StyleSheetData,D=A?.Font,C=(f=D!==void 0?p[D]:void 0)!==null&&f!==void 0?f:p[0];y.style={},y.styleRuns=[];for(let O=0;O<S.RunArray.length;O++){let E=S.RunLengthArray[O],L=Fg(S.RunArray[O].StyleSheet.StyleSheetData,p);!L.font&&C&&(L.font=C),y.styleRuns.push({length:E,style:L})}for(let O=m;y.styleRuns.length&&O>0;O--)--y.styleRuns[y.styleRuns.length-1].length===0&&y.styleRuns.pop();return ms(y.style,y.styleRuns,vo),y.styleRuns.length||delete y.styleRuns,y}var wi=e=>e/65536;function Ug(e){var n,t,i,o;let r=[],s="";for(let c of e.lines)for(let{code:f,style:u}of c.chars){s+=String.fromCharCode(f);let d=r[r.length-1];d&&d.mark===u?d.length++:r.push({length:1,mark:u})}s.endsWith("\r")&&(s=s.slice(0,-1),--r[r.length-1].length===0&&r.pop());let a=r.map(({length:c,mark:f})=>{var u,d;let p=(u=e.styles.find(y=>y.mark===f))!==null&&u!==void 0?u:e.styles[0],h=p&&((d=e.faces.find(y=>y.mark===p.faceMark))!==null&&d!==void 0?d:e.faces[0]),m={};return h&&(m.font={name:h.name,script:h.script}),p&&(m.fontSize=wi(p.size),m.autoLeading=p.leading===0,p.leading&&(m.leading=wi(p.leading)),m.tracking=Math.round(wi(p.tracking)*1e3),m.autoKerning=p.autoKerning,m.kerning=Math.round(wi(p.kerning)*1e3),m.baselineShift=wi(p.baselineShift)),m.fillColor=e.color,{length:c,style:m}}),l={text:s.replace(/\r/g,`
10
+ `),transform:e.transform,antiAlias:e.antiAlias?"smooth":"none",orientation:((n=e.lines[0])===null||n===void 0?void 0:n.orientation)===1?"vertical":"horizontal",paragraphStyle:{justification:(o=bs[((i=(t=e.lines[0])===null||t===void 0?void 0:t.alignment)!==null&&i!==void 0?i:0)|0])!==null&&o!==void 0?o:"left"},style:{},styleRuns:a};return ms(l.style,l.styleRuns,vo),l.styleRuns.length||delete l.styleRuns,l}function Af(e,n){if(!e||!n.length)return e;let t=0,i=0;return e.map(o=>{let r=Math.max(0,o.length||0),s=t+r,a=0;for(;i<n.length&&n[i]<s;)n[i]>=t&&a++,i++;return t=s,Object.assign(Object.assign({},o),{length:r-a})})}function Bg(e){var n,t,i,o,r,s,a,l,c,f,u,d,p;let h=e.text||"",m=[];for(let W=0;W<h.length-1;W++)h.charCodeAt(W)===13&&h.charCodeAt(W+1)===10&&m.push(W);let y=`${h.replace(/\r?\n/g,"\r")}\r`,g=[{name:"AdobeInvisFont",script:0,type:0,synthetic:0}],k=((n=e.style)===null||n===void 0?void 0:n.font)||((i=(t=e.styleRuns)===null||t===void 0?void 0:t.find(W=>W.style.font))===null||i===void 0?void 0:i.style.font)||If,x=[],S=[],A=Af(e.paragraphStyleRuns,m);if(A&&A.length){let W=y.length;for(let B of A){let $=Math.min(B.length,W);W-=$,W===1&&B===A[A.length-1]&&($++,W--),$&&(S.push($),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:wo(Object.assign(Object.assign(Object.assign({},bo),e.paragraphStyle),B.style),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}W&&(S.push(W),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:wo(Object.assign(Object.assign({},bo),e.paragraphStyle),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}else for(let W=0,B=0;W<y.length;W++)y.charCodeAt(W)===13&&(S.push(W-B+1),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:wo(Object.assign(Object.assign({},bo),e.paragraphStyle),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}),B=W+1);let D=ps(Object.assign(Object.assign({},Pg),{font:k}),g),C=!((o=e.styleRuns)===null||o===void 0)&&o.length?Af(e.styleRuns,m):[{length:y.length,style:e.style||{}}],O=[],E=[],L=y.length;for(let W of C){let B=Math.min(W.length,L);L-=B,B&&(L===1&&W===C[C.length-1]&&(B++,L--),E.push(B),O.push({StyleSheet:{StyleSheetData:ps(Object.assign(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),W.style),g)}}))}L&&(E.push(L),O.push({StyleSheet:{StyleSheetData:ps(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),g)}}));let M=Object.assign(Object.assign({},fn),e.gridInfo),J=hs.indexOf((r=e.antiAlias)!==null&&r!==void 0?r:"sharp"),pe=e.orientation==="vertical"?2:0,R=e.orientation==="vertical"?1:0,ie=e.shapeType==="box"?1:0,he={ShapeType:ie};ie===0?he.PointBase=e.pointBase||[0,0]:he.BoxBounds=e.boxBounds||[0,0,0,0],he.Base={ShapeType:ie,TransformPoint0:[1,0],TransformPoint1:[0,1],TransformPoint2:[0,0]};let ce={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:wo(Object.assign(Object.assign({},bo),e.paragraphStyle),g)}],StyleSheetSet:[{Name:"Normal RGB",StyleSheetData:D}],FontSet:g.map(W=>({Name:W.name,Script:W.script||0,FontType:W.type||0,Synthetic:W.synthetic||0})),SuperscriptSize:(s=e.superscriptSize)!==null&&s!==void 0?s:.583,SuperscriptPosition:(a=e.superscriptPosition)!==null&&a!==void 0?a:.333,SubscriptSize:(l=e.subscriptSize)!==null&&l!==void 0?l:.583,SubscriptPosition:(c=e.subscriptPosition)!==null&&c!==void 0?c:.333,SmallCapSize:(f=e.smallCapSize)!==null&&f!==void 0?f:.7};return{EngineDict:{Editor:{Text:y},ParagraphRun:{DefaultRunData:{ParagraphSheet:{DefaultStyleSheet:0,Properties:{}},Adjustments:{Axis:[1,0,1],XY:[0,0]}},RunArray:x,RunLengthArray:S,IsJoinable:1},StyleRun:{DefaultRunData:{StyleSheet:{StyleSheetData:{}}},RunArray:O,RunLengthArray:E,IsJoinable:2},GridInfo:{GridIsOn:!!M.isOn,ShowGrid:!!M.show,GridSize:(u=M.size)!==null&&u!==void 0?u:18,GridLeading:(d=M.leading)!==null&&d!==void 0?d:22,GridColor:gs(M.color),GridLeadingFillColor:gs(M.leadingFillColor),AlignLineHeightToGridFlags:!!M.alignLineHeightToGridFlags},AntiAlias:J===-1?hs.indexOf("sharp"):J,UseFractionalGlyphWidths:(p=e.useFractionalGlyphWidths)!==null&&p!==void 0?p:!0,Rendered:{Version:1,Shapes:{WritingDirection:pe,Children:[{ShapeType:ie,Procession:R,Lines:{WritingDirection:pe,Children:[]},Cookie:{Photoshop:he}}]}}},ResourceDict:Object.assign({},ce),DocumentResources:Object.assign({},ce)}}});var Uf=ae(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.decodeEngineData2=jg;var Rg=us(),ws={0:{uproot:!0,children:{0:{name:"Type"},1:{name:"Values"}}}},xs={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:ws},54:{name:"StrokeColor",children:ws},55:{children:{99:{uproot:!0}}},79:{children:ws}},vs={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:xs}},Ff={name:"StyleSheetData",children:xs},Tg={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:Ff}}}}}},6:{name:"ParagraphSheetSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},5:{name:"Properties",children:vs},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:vs},6:{name:"6"}}}}},1:{name:"RunLength"}}}}},6:{name:"StyleRun",children:{0:{name:"RunArray",children:{0:{name:"StyleSheet",children:{0:{uproot:!0,children:{6:Ff}}}},1:{name:"RunLength"}}}}}}},1:{name:"FontVectorData ???"}}},2:{name:"StyleSheet",children:xs},3:{name:"ParagraphSheet",children:vs}}}},Lf=256;function Ss(e,n){return Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0}function So(e,n,t){var i,o;if(t>Lf)throw new Error(`Engine data is nested too deeply (more than ${Lf} levels)`);if(e==null)return e;if(Array.isArray(e))return e.map(l=>So(l,n,t+1));if(typeof e!="object")return e;let r=Object.keys(e),s=r.find(l=>{var c;return l!=="99"&&((c=Ss(n,l))===null||c===void 0?void 0:c.uproot)}),a;if(s!==void 0){if(a=So(e[s],(i=Ss(n,s).children)!==null&&i!==void 0?i:{},t+1),a===null||typeof a!="object"||(e[99]&&(a._type=e[99]),Array.isArray(a)))return a}else a={};for(let l of r){if(l===s)continue;let c=Ss(n,l);if(l==="99")s===void 0&&(a._type=e[l]);else{let f=c?.name||l;(s===void 0||!(f in a))&&(0,Rg.setProperty)(a,f,So(e[l],(o=c?.children)!==null&&o!==void 0?o:{},t+1))}}return a}function Mf(){return{FontSet:[],StyleSheetSet:[],ParagraphSheetSet:[]}}function jg(e){let n=So(e,Tg,0);return!n||typeof n!="object"||Array.isArray(n)?{ResourceDict:Mf(),EngineDict:{}}:((!n.ResourceDict||typeof n.ResourceDict!="object")&&(n.ResourceDict=Mf()),n)}});var di=ae(Ae=>{"use strict";var zg=Ae&&Ae.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.booleanOperations=Ae.infoHandlersMap=Ae.infoHandlers=void 0;Ae.readBezierKnot=ed;Ae.readVectorMask=td;Ae.writeVectorMask=nd;Ae.parseKeyDescriptorList=id;Ae.serializeKeyDescriptorList=od;Ae.hasMultiEffects=Co;var Bf=to(),Rf=mf(),De=Ot(),b=st(),w=En(),v=ro(),Es=us(),Fs=Ef(),$g=Uf(),Ze="abcdefghijklmnopqrstuvwxyz";Ae.infoHandlers=[];Ae.infoHandlersMap={};function U(e,n,t,i){let o={key:e,has:n,read:t,write:i};Ae.infoHandlers.push(o),Ae.infoHandlersMap[o.key]=o}function lt(e,n){Ae.infoHandlersMap[e]=Ae.infoHandlersMap[n]}function le(e){return n=>n[e]!==void 0}function _o(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)}U("TySh",le("text"),(e,n,t)=>{var i;if((0,b.readInt16)(e)!==1)throw new Error("Invalid TySh version");let o=[];for(let a=0;a<6;a++)o.push((0,b.readFloat64)(e));if((0,b.readInt16)(e)!==50)throw new Error("Invalid TySh text version");let r=(0,v.readVersionAndDescriptor)(e);if((0,b.readInt16)(e)!==1)throw new Error("Invalid TySh warp version");let s=(0,v.readVersionAndDescriptor)(e);if(n.text={transform:o,left:(0,b.readFloat32)(e),top:(0,b.readFloat32)(e),right:(0,b.readFloat32)(e),bottom:(0,b.readFloat32)(e),text:r["Txt "].replace(/\r/g,`
11
+ `),index:r.TextIndex||0,gridding:v.textGridding.decode(r.textGridding),antiAlias:v.Annt.decode(r.AntA),orientation:v.Ornt.decode(r.Ornt),warp:{style:v.warpStyle.decode(s.warpStyle),value:s.warpValue||0,perspective:s.warpPerspective||0,perspectiveOther:s.warpPerspectiveOther||0,rotate:v.Ornt.decode(s.warpRotate)}},r.bounds&&(n.text.bounds=(0,v.descBoundsToBounds)(r.bounds)),r.boundingBox&&(n.text.boundingBox=(0,v.descBoundsToBounds)(r.boundingBox)),r.substitutesUsed!==void 0&&(n.text.substitutesUsed=r.substitutesUsed),r.TxtC&&(n.text.clickPoint=(0,v.horzVrtcToXY)(r.TxtC)),(r.TxPT!==void 0||r.TxPR!==void 0||r.TxMP!==void 0)&&(n.text.textOnPath={},r.TxPT!==void 0&&(n.text.textOnPath.type=r.TxPT.split(".")[1]),r.TxPR!==void 0&&(n.text.textOnPath.direction=r.TxPR.split(".")[1]),r.TxMP!==void 0&&(n.text.textOnPath.mirror=r.TxMP)),r.VAlign!==void 0&&(n.text.verticalAlignment=r.VAlign),r.EngineData){let a=(0,Es.parseEngineData)(r.EngineData,e),l=(0,Fs.decodeEngineData)(a);n.text=Object.assign(Object.assign(Object.assign({},n.text),l),{antiAlias:(i=n.text.antiAlias)!==null&&i!==void 0?i:l.antiAlias})}(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s,a,l;let c=n.text,f=c.warp||{},u=c.transform||[1,0,0,1,0,0],d=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({"Txt ":(c.text||"").replace(/\r?\n/g,"\r")},c.clickPoint?{TxtC:(0,v.xyToHorzVrtc)(c.clickPoint)}:{}),c.substitutesUsed!==void 0?{substitutesUsed:!!c.substitutesUsed}:{}),{textGridding:v.textGridding.encode(c.gridding),Ornt:v.Ornt.encode(c.orientation),AntA:v.Annt.encode(c.antiAlias)}),((t=c.textOnPath)===null||t===void 0?void 0:t.type)!==void 0?{TxPT:`TxPT.${c.textOnPath.type}`}:{}),((i=c.textOnPath)===null||i===void 0?void 0:i.direction)!==void 0?{TxPR:`TxPR.${c.textOnPath.direction}`}:{}),((o=c.textOnPath)===null||o===void 0?void 0:o.mirror)!==void 0?{TxMP:!!c.textOnPath.mirror}:{}),c.bounds?{bounds:(0,v.boundsToDescBounds)(c.bounds)}:{}),c.boundingBox?{boundingBox:(0,v.boundsToDescBounds)(c.boundingBox)}:{}),{TextIndex:c.index||0}),c.verticalAlignment!==void 0?{VAlign:c.verticalAlignment}:{}),{EngineData:(0,Es.serializeEngineData)((0,Fs.encodeEngineData)(c))});(0,w.writeInt16)(e,1);for(let p=0;p<6;p++)(0,w.writeFloat64)(e,u[p]);(0,w.writeInt16)(e,50),(0,v.writeVersionAndDescriptor)(e,"","TxLr",d,"text"),(0,w.writeInt16)(e,1),(0,v.writeVersionAndDescriptor)(e,"","warp",Io(f)),(0,w.writeFloat32)(e,(r=c.left)!==null&&r!==void 0?r:0),(0,w.writeFloat32)(e,(s=c.top)!==null&&s!==void 0?s:0),(0,w.writeFloat32)(e,(a=c.right)!==null&&a!==void 0?a:0),(0,w.writeFloat32)(e,(l=c.bottom)!==null&&l!==void 0?l:0)});U("tySh",()=>!1,(e,n,t)=>{if((0,b.readInt16)(e)!==1)throw new Error("Invalid tySh version");let i=[];for(let l=0;l<6;l++)i.push((0,b.readFloat64)(e));if((0,b.readInt16)(e)!==6)throw new Error("Invalid tySh font version");let o={transform:i,faces:[],styles:[],lines:[],color:{r:0,g:0,b:0},antiAlias:!1},r=(0,b.readInt16)(e);for(let l=0;l<r;l++){let c=(0,b.readInt16)(e);(0,b.readInt32)(e);let f=(0,b.readPascalString)(e,1),u=(0,b.readPascalString)(e,1),d=(0,b.readPascalString)(e,1),p=(0,b.readInt16)(e),h=(0,b.readInt32)(e);if(h<0||h*4>t())throw new Error("Invalid tySh design axes count");(0,b.skipBytes)(e,h*4),o.faces.push({mark:c,name:f,familyName:u,styleName:d,script:p})}let s=(0,b.readInt16)(e);for(let l=0;l<s;l++){let c=(0,b.readInt16)(e),f=(0,b.readInt16)(e),u=(0,b.readInt32)(e),d=(0,b.readInt32)(e),p=(0,b.readInt32)(e),h=(0,b.readInt32)(e),m=(0,b.readInt32)(e),y=!!(0,b.readUint8)(e);(0,b.readUint8)(e),o.styles.push({mark:c,faceMark:f,size:u,tracking:d,kerning:p,leading:h,baselineShift:m,autoKerning:y})}(0,b.readInt16)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e);let a=(0,b.readInt16)(e);for(let l=0;l<a;l++){let c=(0,b.readInt32)(e),f=(0,b.readInt16)(e),u=(0,b.readInt16)(e);if(c<0||c*4>t())throw new Error("Invalid tySh character count");let d=[];for(let p=0;p<c;p++){let h=(0,b.readUint16)(e),m=(0,b.readInt16)(e);d.push({code:h,style:m})}o.lines.push({orientation:f,alignment:u,chars:d})}o.color=(0,b.readColor)(e),o.antiAlias=!!(0,b.readUint8)(e),n.text||(n.text=(0,Fs.decodeLegacyTextData)(o)),(0,b.skipBytes)(e,t())},()=>{});U("SoCo",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="color",(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("GdFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&(e.vectorFill.type==="solid"||e.vectorFill.type==="noise"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("PtFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="pattern",(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("vscg",e=>e.vectorFill!==void 0&&e.vectorStroke!==void 0,(e,n,t)=>{(0,b.readSignature)(e);let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t,key:i}=(0,v.serializeVectorContent)(n.vectorFill);(0,w.writeSignature)(e,i),(0,v.writeVersionAndDescriptor)(e,"","null",t)});function ed(e,n,t){let i=(0,b.readFixedPointPath32)(e)*t,o=(0,b.readFixedPointPath32)(e)*n,r=(0,b.readFixedPointPath32)(e)*t,s=(0,b.readFixedPointPath32)(e)*n,a=(0,b.readFixedPointPath32)(e)*t,l=(0,b.readFixedPointPath32)(e)*n;return[o,i,s,r,l,a]}function Vg(e,n,t,i){(0,w.writeFixedPointPath32)(e,n[1]/i),(0,w.writeFixedPointPath32)(e,n[0]/t),(0,w.writeFixedPointPath32)(e,n[3]/i),(0,w.writeFixedPointPath32)(e,n[2]/t),(0,w.writeFixedPointPath32)(e,n[5]/i),(0,w.writeFixedPointPath32)(e,n[4]/t)}Ae.booleanOperations=["exclude","combine","subtract","intersect"];function td(e,n,t,i,o){let r=e.offset+o,s=n.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),f=(0,b.readUint16)(e);(0,b.skipBytes)(e,18),a={open:l===3,knots:[],fillRule:f===2?"non-zero":"even-odd"},c!==-1&&(a.operation=Ae.booleanOperations[c]),s.push(a);break}case 1:case 2:case 4:case 5:if(!a)throw new Error("Bezier knot record without subpath length record");a.knots.push({linked:l===1||l===4,points:ed(e,t,i)});break;case 6:(0,b.skipBytes)(e,24);break;case 7:{let c=(0,b.readFixedPointPath32)(e),f=(0,b.readFixedPointPath32)(e),u=(0,b.readFixedPointPath32)(e),d=(0,b.readFixedPointPath32)(e),p=(0,b.readFixedPointPath32)(e);(0,b.skipBytes)(e,4),n.clipboard={top:c,left:f,bottom:u,right:d,resolution:p};break}case 8:n.fillStartsWithAllPixels=!!(0,b.readUint16)(e),(0,b.skipBytes)(e,22);break;default:throw new Error("Invalid vmsk section")}}return s}function nd(e,n,t,i,o=!1){(0,w.writeUint16)(e,6),(0,w.writeZeros)(e,24);let r=n.clipboard;r&&((0,w.writeUint16)(e,7),(0,w.writeFixedPointPath32)(e,r.top),(0,w.writeFixedPointPath32)(e,r.left),(0,w.writeFixedPointPath32)(e,r.bottom),(0,w.writeFixedPointPath32)(e,r.right),(0,w.writeFixedPointPath32)(e,r.resolution),(0,w.writeZeros)(e,4)),(0,w.writeUint16)(e,8),(0,w.writeUint16)(e,n.fillStartsWithAllPixels?1:0),(0,w.writeZeros)(e,22);let s=-1;for(let a of n.paths){(a.operation||s<0)&&s++,(0,w.writeUint16)(e,a.open?3:0),(0,w.writeUint16)(e,a.knots.length),(0,w.writeUint16)(e,a.operation?Ae.booleanOperations.indexOf(a.operation):-1),(0,w.writeUint16)(e,a.fillRule==="non-zero"?2:1),(0,w.writeZeros)(e,4),(0,w.writeUint32)(e,o?s:0),(0,w.writeZeros)(e,10);let l=a.open?4:1,c=a.open?5:2;for(let{linked:f,points:u}of a.knots)(0,w.writeUint16)(e,f?l:c),Vg(e,u,t,i)}}U("vmsk",le("vectorMask"),(e,n,t,{width:i,height:o})=>{if((0,b.readUint32)(e)!==3)throw new Error("Invalid vmsk version");n.vectorMask={paths:[]};let r=n.vectorMask,s=(0,b.readUint32)(e);r.invert=(s&1)!==0,r.notLink=(s&2)!==0,r.disable=(s&4)!==0,td(e,r,i,o,t()),(0,b.skipBytes)(e,t())},(e,n,{width:t,height:i})=>{let o=n.vectorMask,r=(o.invert?1:0)|(o.notLink?2:0)|(o.disable?4:0);(0,w.writeUint32)(e,3),(0,w.writeUint32)(e,r),nd(e,o,t,i,!0)});lt("vsms","vmsk");U("vowv",le("vowv"),(e,n)=>{n.vowv=(0,b.readUint32)(e)},(e,n)=>{(0,w.writeUint32)(e,n.vowv)});function _s(e){return[(0,v.horzVrtcToXY)(e.rectangleCornerA),(0,v.horzVrtcToXY)(e.rectangleCornerB),(0,v.horzVrtcToXY)(e.rectangleCornerC),(0,v.horzVrtcToXY)(e.rectangleCornerD)]}function As(e){return{rectangleCornerA:(0,v.xyToHorzVrtc)(e[0]),rectangleCornerB:(0,v.xyToHorzVrtc)(e[1]),rectangleCornerC:(0,v.xyToHorzVrtc)(e[2]),rectangleCornerD:(0,v.xyToHorzVrtc)(e[3])}}function id(e){let n=[];for(let t of e.keyDescriptorList){let i={};t.keyShapeInvalidated!=null&&(i.keyShapeInvalidated=t.keyShapeInvalidated),t.keyOriginType!=null&&(i.keyOriginType=t.keyOriginType),t.keyOriginResolution!=null&&(i.keyOriginResolution=t.keyOriginResolution),t.keyOriginShapeBBox&&(i.keyOriginShapeBoundingBox={top:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox["Top "]),left:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Left),bottom:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Btom),right:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Rght)});let o=t.keyOriginRRectRadii;o&&(i.keyOriginRRectRadii={topRight:(0,v.parseUnits)(o.topRight),topLeft:(0,v.parseUnits)(o.topLeft),bottomLeft:(0,v.parseUnits)(o.bottomLeft),bottomRight:(0,v.parseUnits)(o.bottomRight)}),t.keyOriginBoxCorners&&(i.keyOriginBoxCorners=_s(t.keyOriginBoxCorners)),t.keyOriginPolySides!=null&&(i.keyOriginPolySides=t.keyOriginPolySides),t.keyOriginPolyCornerRadius!=null&&(i.keyOriginPolyCornerRadius=t.keyOriginPolyCornerRadius),t.keyOriginPolyStarRatio&&(i.keyOriginPolyStarRatio=(0,v.parsePercent)(t.keyOriginPolyStarRatio)),t.keyOriginPolyPreviousTightBoxCorners&&(i.keyOriginPolyPreviousTightBoxCorners=_s(t.keyOriginPolyPreviousTightBoxCorners)),t.keyOriginPolyTrueRectCorners&&(i.keyOriginPolyTrueRectCorners=_s(t.keyOriginPolyTrueRectCorners)),t.keyOriginPolyPixelHSF!=null&&(i.keyOriginPolyPixelHSF=t.keyOriginPolyPixelHSF),t.keyOriginLineStart&&(i.keyOriginLineStart=(0,v.horzVrtcToXY)(t.keyOriginLineStart)),t.keyOriginLineEnd&&(i.keyOriginLineEnd=(0,v.horzVrtcToXY)(t.keyOriginLineEnd)),t.keyOriginLineWeight!=null&&(i.keyOriginLineWeight=t.keyOriginLineWeight),t.keyOriginLineArrowSt!=null&&(i.keyOriginLineArrowStart=t.keyOriginLineArrowSt),t.keyOriginLineArrowEnd!=null&&(i.keyOriginLineArrowEnd=t.keyOriginLineArrowEnd),t.keyOriginLineArrWdth!=null&&(i.keyOriginLineArrowWidth=t.keyOriginLineArrWdth),t.keyOriginLineArrLngth!=null&&(i.keyOriginLineArrowLength=t.keyOriginLineArrLngth),t.keyOriginLineArrConc!=null&&(i.keyOriginLineArrowConcavity=t.keyOriginLineArrConc);let r=t.Trnf;r&&(i.transform=[r.xx,r.xy,r.yx,r.yy,r.tx,r.ty]),n.push(i)}return n}function od(e){let n={keyDescriptorList:[]};for(let t=0;t<e.length;t++){let i=e[t];n.keyDescriptorList.push({});let o=n.keyDescriptorList[n.keyDescriptorList.length-1];i.keyOriginType!=null&&(o.keyOriginType=i.keyOriginType),i.keyOriginResolution!=null&&(o.keyOriginResolution=i.keyOriginResolution);let r=i.keyOriginRRectRadii;r&&(o.keyOriginRRectRadii={unitValueQuadVersion:1,topRight:(0,v.unitsValue)(r.topRight,"topRight"),topLeft:(0,v.unitsValue)(r.topLeft,"topLeft"),bottomLeft:(0,v.unitsValue)(r.bottomLeft,"bottomLeft"),bottomRight:(0,v.unitsValue)(r.bottomRight,"bottomRight")});let s=i.keyOriginShapeBoundingBox;s&&(o.keyOriginShapeBBox={unitValueQuadVersion:1,"Top ":(0,v.unitsValue)(s.top,"top"),Left:(0,v.unitsValue)(s.left,"left"),Btom:(0,v.unitsValue)(s.bottom,"bottom"),Rght:(0,v.unitsValue)(s.right,"right")});let a=i.keyOriginBoxCorners;a&&a.length===4&&(o.keyOriginBoxCorners=As(a)),i.keyOriginPolySides!=null&&(o.keyOriginPolySides=i.keyOriginPolySides),i.keyOriginPolyCornerRadius!=null&&(o.keyOriginPolyCornerRadius=i.keyOriginPolyCornerRadius),i.keyOriginPolyStarRatio!=null&&(o.keyOriginPolyStarRatio=(0,v.unitsPercentF)(i.keyOriginPolyStarRatio));let l=i.keyOriginPolyPreviousTightBoxCorners;l&&l.length===4&&(o.keyOriginPolyPreviousTightBoxCorners=As(l));let c=i.keyOriginPolyTrueRectCorners;c&&c.length===4&&(o.keyOriginPolyTrueRectCorners=As(c)),i.keyOriginPolyPixelHSF!=null&&(o.keyOriginPolyPixelHSF=i.keyOriginPolyPixelHSF),i.keyOriginLineEnd&&(o.keyOriginLineEnd=(0,v.xyToHorzVrtc)(i.keyOriginLineEnd)),i.keyOriginLineStart&&(o.keyOriginLineStart=(0,v.xyToHorzVrtc)(i.keyOriginLineStart)),i.keyOriginLineWeight!=null&&(o.keyOriginLineWeight=i.keyOriginLineWeight),i.keyOriginLineArrowStart!=null&&(o.keyOriginLineArrowSt=!!i.keyOriginLineArrowStart),i.keyOriginLineArrowEnd!=null&&(o.keyOriginLineArrowEnd=!!i.keyOriginLineArrowEnd),i.keyOriginLineArrowWidth!=null&&(o.keyOriginLineArrWdth=i.keyOriginLineArrowWidth),i.keyOriginLineArrowLength!=null&&(o.keyOriginLineArrLngth=i.keyOriginLineArrowLength),i.keyOriginLineArrowConcavity!=null&&(o.keyOriginLineArrConc=i.keyOriginLineArrowConcavity);let f=i.transform;f&&f.length===6&&(o.Trnf={xx:f[0],xy:f[1],yx:f[2],yy:f[3],tx:f[4],ty:f[5]}),i.keyShapeInvalidated!=null&&(o.keyShapeInvalidated=i.keyShapeInvalidated),o.keyOriginIndex=t}return n}U("vogk",le("vectorOrigination"),(e,n,t)=>{if((0,b.readInt32)(e)!==1)throw new Error("Invalid vogk version");let i=(0,v.readVersionAndDescriptor)(e);n.vectorOrigination={keyDescriptorList:id(i)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=od(n.vectorOrigination.keyDescriptorList);(0,w.writeInt32)(e,1),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("lmfx",e=>e.effects!==void 0&&!Ts(e)&&Co(e.effects),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lmfx version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("lrFX",le("effects"),(e,n,t)=>{n.effects||(n.effects=(0,Rf.readEffects)(e)),(0,b.skipBytes)(e,t())},(e,n)=>{(0,Rf.writeEffects)(e,n.effects)});U("luni",le("name"),(e,n,t)=>{if(t()>4){let i=(0,b.readUint32)(e);t()>=i*2?n.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,t())},(e,n)=>{(0,w.writeUnicodeString)(e,n.name)});U("lnsr",le("nameSource"),(e,n)=>n.nameSource=(0,b.readSignature)(e),(e,n)=>(0,w.writeSignature)(e,n.nameSource));function Ng(e){return!!(e.animationFrames||e.timeline||e.comps)}function Tf(e,n){if(!n.explicitLayerIds){let t=new Set,i=o=>{for(let r of o??[])r.id!==void 0&&t.add(r.id),i(r.children)};i(e.children),n.explicitLayerIds=t}return n.explicitLayerIds}function Is(e,n){var t;let i=(t=n.layerToId.get(e))!==null&&t!==void 0?t:e.id;if(i===void 0)throw new Error("Missing layer id");return i}U("lyid",e=>e.id!==void 0||Ng(e),(e,n)=>{n.id=(0,b.readUint32)(e)},(e,n,t,i)=>{var o;let r;if(n.id!==void 0){if(r=n.id,i.layerIds.has(r)){let s=Tf(t,i);for(;i.layerIds.has(r)||s.has(r);)r+=100}}else{let s=Tf(t,i);for(r=(o=i.nextGeneratedLayerId)!==null&&o!==void 0?o:1;i.layerIds.has(r)||s.has(r);)r++;i.nextGeneratedLayerId=r+1}(0,w.writeUint32)(e,r),i.layerIds.add(r),i.layerToId.set(n,r)});U("lsct",le("sectionDivider"),(e,n,t)=>{n.sectionDivider={type:(0,b.readUint32)(e)},t()&&((0,b.checkSignature)(e,"8BIM"),n.sectionDivider.key=(0,b.readSignature)(e)),t()&&(n.sectionDivider.subType=(0,b.readUint32)(e))},(e,n)=>{(0,w.writeUint32)(e,n.sectionDivider.type),n.sectionDivider.key&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,n.sectionDivider.key),n.sectionDivider.subType!==void 0&&(0,w.writeUint32)(e,n.sectionDivider.subType))});lt("lsdk","lsct");U("clbl",le("blendClippendElements"),(e,n)=>{n.blendClippendElements=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.blendClippendElements?1:0),(0,w.writeZeros)(e,3)});U("infx",le("blendInteriorElements"),(e,n)=>{n.blendInteriorElements=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.blendInteriorElements?1:0),(0,w.writeZeros)(e,3)});U("knko",le("knockout"),(e,n)=>{n.knockout=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.knockout?1:0),(0,w.writeZeros)(e,3)});U("lmgm",le("layerMaskAsGlobalMask"),(e,n)=>{n.layerMaskAsGlobalMask=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.layerMaskAsGlobalMask?1:0),(0,w.writeZeros)(e,3)});U("vmgm",le("vectorMaskAsGlobalMask"),(e,n)=>{n.vectorMaskAsGlobalMask=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.vectorMaskAsGlobalMask?1:0),(0,w.writeZeros)(e,3)});U("ffxi",le("foreignEffectId"),(e,n)=>{n.foreignEffectId=(0,b.readInt32)(e)},(e,n)=>{(0,w.writeInt32)(e,n.foreignEffectId)});U("shpa",le("patternData"),(e,n,t)=>{if((0,b.readInt32)(e)!==0)throw new Error("Invalid shpa version");let i=(0,b.readInt32)(e);n.patternData=[];for(let o=0;o<i&&t()>0;o++){let r=(0,b.readSignature)(e),s=(0,b.readSignature)(e),a=(0,b.readInt32)(e),l=!!(0,b.readUint8)(e);(0,b.skipBytes)(e,3);let c=[];for(let f=0;f<a&&t()>0;f++){let u=v.patternColorHandling.decode("."+(0,b.readSignature)(e));(0,b.readPascalString)(e,1);let d=(0,b.readUnicodeString)(e),p=(0,b.readPascalString)(e,1);c.push({colorHandling:u,name:d,id:p})}n.patternData.push({signature:r,key:s,copyOnSheetDuplication:l,patterns:c})}(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.patternData;(0,w.writeInt32)(e,0),(0,w.writeInt32)(e,t.length);for(let i of t){(0,w.writeSignature)(e,i.signature),(0,w.writeSignature)(e,i.key),(0,w.writeInt32)(e,i.patterns.length),(0,w.writeUint8)(e,i.copyOnSheetDuplication?1:0),(0,w.writeZeros)(e,3);for(let o of i.patterns)(0,w.writeSignature)(e,v.patternColorHandling.encode(o.colorHandling).split(".")[1]),(0,w.writePascalString)(e,o.name.replace(/[^\x20-\x7e]/g,"?"),1),(0,w.writeUnicodeString)(e,o.name),(0,w.writePascalString)(e,o.id,1)}});U("lspf",le("protected"),(e,n)=>{let t=(0,b.readUint32)(e);n.protected={transparency:(t&1)!==0,composite:(t&2)!==0,position:(t&4)!==0},t&8&&(n.protected.artboards=!0),t&2147483648&&(n.protected.all=!0)},(e,n)=>{let t=(n.protected.transparency?1:0)|(n.protected.composite?2:0)|(n.protected.position?4:0)|(n.protected.artboards?8:0)|(n.protected.all?2147483648:0);(0,w.writeUint32)(e,t>>>0)});U("lclr",le("layerColor"),(e,n)=>{let t=(0,b.readUint16)(e);(0,b.skipBytes)(e,6),n.layerColor=De.layerColors[t]},(e,n)=>{let t=De.layerColors.indexOf(n.layerColor);(0,w.writeUint16)(e,t===-1?0:t),(0,w.writeZeros)(e,6)});function Us(e){let n={};return e.exportAs&&(n.exportAs={},e.exportAs.exportOption!==void 0&&(n.exportAs.exportOption=e.exportAs.exportOption),e.exportAs.scaleSettings!==void 0&&(n.exportAs.scaleSettings=e.exportAs.scaleSettings)),e.generator_45_assets&&(n.assets=e.generator_45_assets.json),e.layerTime!==void 0&&(n.layerTime=e.layerTime),e.crema&&(n.crema=e.crema.json),n}function rd(e){let n={_name:"",_classID:e.assets!==void 0?"generatorSettings":"null"};return e.exportAs&&(n.exportAs={_name:"",_classID:"null"},e.exportAs.exportOption!==void 0&&(n.exportAs.exportOption=e.exportAs.exportOption),e.exportAs.scaleSettings!==void 0&&(n.exportAs.scaleSettings=e.exportAs.scaleSettings)),e.assets!==void 0&&(n.generator_45_assets={_name:"",_classID:"generatorSettings",json:e.assets}),e.layerTime!==void 0&&(n.layerTime=e.layerTime),e.crema!==void 0&&(n.crema={_name:"",_classID:"null",json:e.crema}),{generatorSettings:n}}function Ls(e){return e.width!==void 0}var sd=(0,De.createEnum)("knockout","none",{none:"none",shallow:"shallow",deep:"deep"});function jf(e,n){e["Md "]!==void 0&&(n.blendMode=v.BlnM.decode(e["Md "])),e.Opct!==void 0&&(n.opacity=(0,v.parsePercent)(e.Opct)),e.fillOpacity!==void 0&&(n.fillOpacity=(0,v.parsePercent)(e.fillOpacity)),e.blendInterior!==void 0&&(n.blendInteriorElements=e.blendInterior),e.blendClipped!==void 0&&(n.blendClippedElements=e.blendClipped),e.knockout!==void 0&&(n.knockout=sd.decode(e.knockout))}function zf(e){let n={};return e.blendMode!==void 0&&(n["Md "]=v.BlnM.encode(e.blendMode)),e.opacity!==void 0&&(n.Opct=(0,v.unitsPercentF)(e.opacity)),e.fillOpacity!==void 0&&(n.fillOpacity=(0,v.unitsPercentF)(e.fillOpacity)),e.blendInteriorElements!==void 0&&(n.blendInterior=!!e.blendInteriorElements),e.blendClippedElements!==void 0&&(n.blendClipped=!!e.blendClippedElements),e.knockout!==void 0&&(n.knockout=sd.encode(e.knockout)),Object.keys(n).length?n:void 0}function $f(e,n){let t=e.textLayerSettings;t&&(n.text={warp:{style:v.warpStyle.decode(t.warpStyle),value:t.warpValue||0,perspective:t.warpPerspective||0,perspectiveOther:t.warpPerspectiveOther||0,rotate:v.Ornt.decode(t.warpRotate)},warpRect:t.textLayerSettingsWarpRect||[0,0,0,0]}),e.placedLayerSettings&&(n.placedLayerCompId=e.placedLayerSettings.placedLayerCompID)}function Vf(e){let n={},t=e.text;return t&&(n.textLayerSettings={warpStyle:v.warpStyle.encode(t.warp.style),warpValue:t.warp.value||0,warpPerspective:t.warp.perspective||0,warpPerspectiveOther:t.warp.perspectiveOther||0,warpRotate:v.Ornt.encode(t.warp.rotate),textLayerSettingsWarpRect:t.warpRect||[0,0,0,0]}),e.placedLayerCompId!==void 0&&(n.placedLayerSettings={placedLayerCompID:e.placedLayerCompId}),Object.keys(n).length?n:void 0}U("shmd",e=>e.timestamp!==void 0||e.animationFrames!==void 0||e.animationFrameFlags!==void 0||e.timeline!==void 0||e.comps!==void 0||e.generatorSettings!==void 0&&!Ls(e),(e,n,t)=>{let i=(0,b.readUint32)(e);for(let o=0;o<i;o++){let r=(0,b.readSignature)(e);if(r!=="8BIM"&&r!=="8ELE")throw new Error(`Invalid shmd signature: '${r}'`);let s=(0,b.readSignature)(e);(0,b.readUint8)(e),(0,b.skipBytes)(e,3);let a=e.offset+4+e.view.getUint32(e.offset);try{(0,b.readSection)(e,1,l=>{var c,f,u;if(s==="cust"){let d=(0,v.readVersionAndDescriptor)(e);d.layerTime!==void 0&&(n.timestamp=d.layerTime)}else if(s==="mlst"){let d=(0,v.readVersionAndDescriptor)(e);n.animationFrames=[];for(let p=0;p<d.LaSt.length;p++){let h=d.LaSt[p],m={frames:h.FrLs};h.enab!==void 0&&(m.enable=h.enab),h.Ofst&&(m.offset=(0,v.horzVrtcToXY)(h.Ofst)),!((c=h.IMsk)===null||c===void 0)&&c.Ofst&&(m.maskOffset=(0,v.horzVrtcToXY)(h.IMsk.Ofst)),!((f=h.VMsk)===null||f===void 0)&&f.Ofst&&(m.vectorMaskOffset=(0,v.horzVrtcToXY)(h.VMsk.Ofst)),h.FXRf&&(m.referencePoint=(0,v.horzVrtcToXY)(h.FXRf)),h.Lefx&&(m.effects=(0,v.parseEffects)(h.Lefx,e)),h.blendOptions&&jf(h.blendOptions,m),h.LSpc&&$f(h.LSpc,m),n.animationFrames.push(m)}}else if(s==="mdyn"){(0,b.readUint16)(e);let d=(0,b.readUint8)(e),p=(0,b.readUint8)(e);n.animationFrameFlags={propagateFrameOne:!d,unifyLayerPosition:(p&1)!==0,unifyLayerStyle:(p&2)!==0,unifyLayerVisibility:(p&4)!==0}}else if(s==="tmln"){let d=(0,v.readVersionAndDescriptor)(e),p=d.timeScope,h={start:(0,v.frac)(p.Strt),duration:(0,v.frac)(p.duration),inTime:(0,v.frac)(p.inTime),outTime:(0,v.frac)(p.outTime),autoScope:d.autoScope,audioLevel:d.audioLevel};d.trackList&&(h.tracks=(0,v.parseTrackList)(d.trackList,e)),n.timeline=h}else if(s==="cmls"){let d=(0,v.readVersionAndDescriptor)(e);n.comps={settings:[]},d.origFXRefPoint&&(n.comps.originalEffectsReferencePoint={x:d.origFXRefPoint.Hrzn,y:d.origFXRefPoint.Vrtc});for(let p of d.layerSettings){n.comps.settings.push({compList:p.compList});let h=n.comps.settings[n.comps.settings.length-1];"enab"in p&&(h.enabled=p.enab),p.Ofst&&(h.offset={x:p.Ofst.Hrzn,y:p.Ofst.Vrtc}),!((u=p.vectorMask)===null||u===void 0)&&u.Ofst&&(h.vectorMaskOffset=(0,v.horzVrtcToXY)(p.vectorMask.Ofst)),p.Lefx&&(h.effects=(0,v.parseEffects)(p.Lefx,e)),p.blendOptions&&jf(p.blendOptions,h),p.FXRefPoint&&(h.effectsReferencePoint={x:p.FXRefPoint.Hrzn,y:p.FXRefPoint.Vrtc}),p.layerSpecific&&$f(p.layerSpecific,h)}}else if(s==="extn"){let d=(0,v.readVersionAndDescriptor)(e);d.generatorSettings&&(n.generatorSettings=Us(d.generatorSettings))}else e.logMissingFeatures&&e.log('Unhandled "shmd" section key',s);(0,b.skipBytes)(e,l())})}catch(l){if(e.throwForMissingFeatures)throw l;e.logMissingFeatures&&e.log(`Failed to read "shmd" section key ${s}: ${l.message}`),e.offset=a}}(0,b.skipBytes)(e,t())},(e,n,t,i)=>{let{animationFrames:o,animationFrameFlags:r,timestamp:s,timeline:a,comps:l}=n,c=Ls(n)?void 0:n.generatorSettings,f=0;o&&f++,r&&f++,a&&f++,s!==void 0&&f++,l&&f++,c&&f++,(0,w.writeUint32)(e,f),o&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"mlst"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={LaID:Is(n,i),LaSt:[]};for(let d=0;d<o.length;d++){let p=o[d],h={};p.enable!==void 0&&(h.enab=p.enable),h.FrLs=p.frames,p.offset&&(h.Ofst=(0,v.xyToHorzVrtc)(p.offset)),p.maskOffset&&(h.IMsk={Ofst:(0,v.xyToHorzVrtc)(p.maskOffset)}),p.vectorMaskOffset&&(h.VMsk={Ofst:(0,v.xyToHorzVrtc)(p.vectorMaskOffset)}),p.referencePoint&&(h.FXRf=(0,v.xyToHorzVrtc)(p.referencePoint));let m=Vf(p);m&&(h.LSpc=m),p.effects&&(h.Lefx=(0,v.serializeEffects)(p.effects,e,Co(p.effects)));let y=zf(p);y&&(h.blendOptions=y),u.LaSt.push(h)}(0,v.writeVersionAndDescriptor)(e,"","null",u,v.layerStateRoot)},!0)),r&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"mdyn"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{(0,w.writeUint16)(e,0),(0,w.writeUint8)(e,r.propagateFrameOne?0:15),(0,w.writeUint8)(e,(r.unifyLayerPosition?1:0)|(r.unifyLayerStyle?2:0)|(r.unifyLayerVisibility?4:0))})),a&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"tmln"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={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&&(u.trackList=(0,v.serializeTrackList)(a.tracks,e)),u.LyrI=Is(n,i),(0,v.writeVersionAndDescriptor)(e,"","null",u,"anim")},!0)),s!==void 0&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"cust"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={layerTime:s};(0,v.writeVersionAndDescriptor)(e,"","metadata",u)},!0)),l&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"cmls"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={};l.originalEffectsReferencePoint&&(u.origFXRefPoint={Hrzn:l.originalEffectsReferencePoint.x,Vrtc:l.originalEffectsReferencePoint.y}),u.LyrI=Is(n,i),u.layerSettings=[];for(let d of l.settings){let p={};if(d.enabled!==void 0&&(p.enab=d.enabled),d.offset&&(p.Ofst=(0,v.xyToHorzVrtc)(d.offset)),d.vectorMaskOffset&&(p.vectorMask={Ofst:(0,v.xyToHorzVrtc)(d.vectorMaskOffset)}),d.effects){let y=(0,v.serializeEffects)(d.effects,e,!0),{numModifyingFX:g}=y,k=zg(y,["numModifyingFX"]);p.Lefx=k}let h=zf(d);h&&(p.blendOptions=h),d.effectsReferencePoint&&(p.FXRefPoint={Hrzn:d.effectsReferencePoint.x,Vrtc:d.effectsReferencePoint.y});let m=Vf(d);m&&(p.layerSpecific=m),p.compList=d.compList,u.layerSettings.push(p)}(0,v.writeVersionAndDescriptor)(e,"","null",u,v.layerStateRoot)},!0)),c&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"extn"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{(0,v.writeVersionAndDescriptor)(e,"","null",rd(c))},!0))});U("PxSc",le("pixelSource"),(e,n)=>{let t=(0,v.readVersionAndDescriptor)(e,!0);t.pixelSourceType===1986285651?n.pixelSource={type:"vdPS",origin:{x:t.origin.Hrzn,y:t.origin.Vrtc},interpretation:{interpretAlpha:t.interpretation.interpretAlpha.split(".")[1],profile:t.interpretation.profile},frameReader:{type:"QTFR",link:{name:t.frameReader["Lnk "]["Nm "],fullPath:t.frameReader["Lnk "].fullPath,originalPath:t.frameReader["Lnk "].originalPath,relativePath:t.frameReader["Lnk "].relPath,alias:t.frameReader["Lnk "].alis},mediaDescriptor:t.frameReader.mediaDescriptor},showAlteredVideo:t.showAlteredVideo}:e.log("Unknown pixelSourceType")},(e,n)=>{let t=n.pixelSource,i={_name:"",_classID:"PixelSource",pixelSourceType:1986285651,descVersion:1,origin:{Hrzn:t.origin.x,Vrtc:t.origin.y},interpretation:{_name:"",_classID:"footageInterpretation",Vrsn:1,interpretAlpha:`alphaInterpretation.${t.interpretation.interpretAlpha}`,profile:t.interpretation.profile},frameReader:{_name:"",_classID:"FrameReader",frameReaderType:1364477522,descVersion:1,"Lnk ":{_name:"",_classID:"ExternalFileLink",descVersion:2,"Nm ":t.frameReader.link.name,fullPath:t.frameReader.link.fullPath,originalPath:t.frameReader.link.originalPath,alis:t.frameReader.link.alias,relPath:t.frameReader.link.relativePath},mediaDescriptor:t.frameReader.mediaDescriptor},showAlteredVideo:t.showAlteredVideo};(0,v.writeVersionAndDescriptor)(e,"","PixelSource",i)});U("vstk",le("vectorStroke"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorStroke={strokeEnabled:i.strokeEnabled,fillEnabled:i.fillEnabled,lineWidth:(0,v.parseUnits)(i.strokeStyleLineWidth),lineDashOffset:(0,v.parseUnits)(i.strokeStyleLineDashOffset),miterLimit:i.strokeStyleMiterLimit,lineCapType:v.strokeStyleLineCapType.decode(i.strokeStyleLineCapType),lineJoinType:v.strokeStyleLineJoinType.decode(i.strokeStyleLineJoinType),lineAlignment:v.strokeStyleLineAlignment.decode(i.strokeStyleLineAlignment),scaleLock:i.strokeStyleScaleLock,strokeAdjust:i.strokeStyleStrokeAdjust,lineDashSet:(i.strokeStyleLineDashSet||[]).map(v.parseUnits),blendMode:v.BlnM.decode(i.strokeStyleBlendMode),opacity:(0,v.parsePercent)(i.strokeStyleOpacity),content:(0,v.parseVectorContent)(i.strokeStyleContent),resolution:i.strokeStyleResolution},(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o;let r=n.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:(t=r.miterLimit)!==null&&t!==void 0?t:100,strokeStyleLineCapType:v.strokeStyleLineCapType.encode(r.lineCapType),strokeStyleLineJoinType:v.strokeStyleLineJoinType.encode(r.lineJoinType),strokeStyleLineAlignment:v.strokeStyleLineAlignment.encode(r.lineAlignment),strokeStyleScaleLock:!!r.scaleLock,strokeStyleStrokeAdjust:!!r.strokeAdjust,strokeStyleLineDashSet:r.lineDashSet||[],strokeStyleBlendMode:v.BlnM.encode(r.blendMode),strokeStyleOpacity:(0,v.unitsPercent)((i=r.opacity)!==null&&i!==void 0?i:1),strokeStyleContent:(0,v.serializeVectorContent)(r.content||{type:"color",color:{r:0,g:0,b:0}}).descriptor,strokeStyleResolution:(o=r.resolution)!==null&&o!==void 0?o:72};(0,v.writeVersionAndDescriptor)(e,"","strokeStyle",s)});U("artb",le("artboard"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=i.artboardRect;n.artboard={rect:{top:o["Top "],left:o.Left,bottom:o.Btom,right:o.Rght},guideIndices:i.guideIndeces,presetName:i.artboardPresetName},i["Clr "]&&(n.artboard.color=(0,v.parseColor)(i["Clr "])),i.artboardBackgroundType!==void 0&&(n.artboard.backgroundType=i.artboardBackgroundType),(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.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,v.serializeColor)(i.color),artboardBackgroundType:(t=i.backgroundType)!==null&&t!==void 0?t:1};(0,v.writeVersionAndDescriptor)(e,"","artboard",r)});U("sn2P",le("usingAlignedRendering"),(e,n)=>n.usingAlignedRendering=!!(0,b.readUint32)(e),(e,n)=>(0,w.writeUint32)(e,n.usingAlignedRendering?1:0));var Nn=["unknown","vector","raster","image stack"];function ad(e){var n,t,i,o,r,s;let a=Object.assign(Object.assign({style:v.warpStyle.decode(e.warpStyle)},e.warpValues?{values:e.warpValues}:{value:e.warpValue||0}),{perspective:e.warpPerspective||0,perspectiveOther:e.warpPerspectiveOther||0,rotate:v.Ornt.decode(e.warpRotate),bounds:e.bounds&&{top:(0,v.parseUnitsOrNumber)(e.bounds["Top "]),left:(0,v.parseUnitsOrNumber)(e.bounds.Left),bottom:(0,v.parseUnitsOrNumber)(e.bounds.Btom),right:(0,v.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=((n=l.meshPoints.find(u=>u.type==="Hrzn"))===null||n===void 0?void 0:n.values)||[],f=((t=l.meshPoints.find(u=>u.type==="Vrtc"))===null||t===void 0?void 0:t.values)||[];for(let u=0;u<c.length;u++)a.customEnvelopeWarp.meshPoints.push({x:c[u],y:f[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 Bs(e){var n,t;return e.deformNumCols!=null||e.deformNumRows!=null||((n=e.customEnvelopeWarp)===null||n===void 0?void 0:n.quiltSliceX)||((t=e.customEnvelopeWarp)===null||t===void 0?void 0:t.quiltSliceY)}function Io(e){let n=e.bounds,t=Object.assign(Object.assign({warpStyle:v.warpStyle.encode(e.style)},e.values?{warpValues:e.values}:{warpValue:e.value||0}),{warpPerspective:e.perspective||0,warpPerspectiveOther:e.perspectiveOther||0,warpRotate:v.Ornt.encode(e.rotate),bounds:{"Top ":(0,v.unitsValue)(n&&n.top||{units:"Pixels",value:0},"bounds.top"),Left:(0,v.unitsValue)(n&&n.left||{units:"Pixels",value:0},"bounds.left"),Btom:(0,v.unitsValue)(n&&n.bottom||{units:"Pixels",value:0},"bounds.bottom"),Rght:(0,v.unitsValue)(n&&n.right||{units:"Pixels",value:0},"bounds.right")},uOrder:e.uOrder||0,vOrder:e.vOrder||0}),i=Bs(e);if(i){let r=t;r.deformNumRows=e.deformNumRows||0,r.deformNumCols=e.deformNumCols||0}let o=e.customEnvelopeWarp;if(o){let r=o.meshPoints||[];if(i){let s=t;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 t.customEnvelopeWarp={_name:"",_classID:"customEnvelopeWarp",meshPoints:[{type:"Hrzn",values:r.map(s=>s.x)},{type:"Vrtc",values:r.map(s=>s.y)}]}}return t}U("PlLd",e=>!!e.placedLayer&&!e.placedLayer.external,(e,n,t)=>{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(!Nn[s])throw new Error("Invalid PlLd type");let a=[];for(let f=0;f<8;f++)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,v.readVersionAndDescriptor)(e);n.placedLayer=n.placedLayer||{id:i,type:Nn[s],pageNumber:o,totalPages:r,transform:a,warp:ad(c)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.placedLayer;if((0,w.writeSignature)(e,"plcL"),(0,w.writeInt32)(e,3),!t.id||typeof t.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(t.id))throw new Error("Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,w.writePascalString)(e,t.id,1),(0,w.writeInt32)(e,t.pageNumber||1),(0,w.writeInt32)(e,t.totalPages||1),(0,w.writeInt32)(e,16),Nn.indexOf(t.type)===-1)throw new Error("Invalid placedLayer type");(0,w.writeInt32)(e,Nn.indexOf(t.type));for(let s=0;s<8;s++)(0,w.writeFloat64)(e,t.transform[s]);(0,w.writeInt32)(e,0);let i=cd(t),r=Bs(i)?"quiltWarp":"warp";(0,v.writeVersionAndDescriptor)(e,"",r,Io(i),r)});var Gg=["_name","_classID","presetKind","Adjs"],Hg=["_name","_classID","Chnl","Inpt","Otpt","Gmm "];function Wg(e){let n=Math.floor(e.byteLength/4);return new Float32Array(e.buffer.slice(e.byteOffset,e.byteOffset+n*4),0,n)}function Xg(e){let n=Math.floor(e.byteLength/4);return new Uint32Array(e.buffer.slice(e.byteOffset,e.byteOffset+n*4),0,n)}function Cs(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ao(e){let n=[];for(let t=0;t<e.length;t+=2)n.push({x:e[t],y:e[t+1]});return n}function Si(e){let n=[];for(let t=0;t<e.length;t++)n.push(e[t].x,e[t].y);return n}function Nf(e){return Ao(Wg(e))}function xi(e){return{x:(0,v.parseUnits)(e.Hrzn),y:(0,v.parseUnits)(e.Vrtc)}}function ki(e){return{_name:"",_classID:"Pnt ",Hrzn:(0,v.unitsValue)(e.x,"x"),Vrtc:(0,v.unitsValue)(e.y,"y")}}var Ps=[["red","R"],["orange","O"],["yellow","Y"],["green","G"],["aqua","A"],["blue","B"],["purple","P"],["magenta","M"]],Ms=[["version","CrVe"],["processVersion","PrVN"],["processVersionCode","PrVe"],["whiteBalance","WBal"],["temperature","Temp"],["tint","Tint"],["exposure","Ex12"],["contrast","Cr12"],["highlights","Hi12"],["shadows","Sh12"],["whites","Wh12"],["blacks","Bk12"],["texture","CrTx"],["clarity","Cl12"],["dehaze","Dhze"],["vibrance","Vibr"],["saturation","Strt"],["parametricCurve.shadows","PC_S"],["parametricCurve.darks","PC_D"],["parametricCurve.lights","PC_L"],["parametricCurve.highlights","PC_H"],["parametricCurve.shadowSplit","PC_1"],["parametricCurve.midtoneSplit","PC_2"],["parametricCurve.highlightSplit","PC_3"],["pointCurve.composite","Crv "],["pointCurve.red","CrvR"],["pointCurve.green","CrvG"],["pointCurve.blue","CrvB"],...Ps.map(([e,n])=>[`hsl.hue.${e}`,`HA_${n}`]),...Ps.map(([e,n])=>[`hsl.saturation.${e}`,`SA_${n}`]),...Ps.map(([e,n])=>[`hsl.luminance.${e}`,`LA_${n}`]),["colorGrading.shadows.hue","STSH"],["colorGrading.shadows.saturation","STSS"],["colorGrading.shadows.luminance","CgSL"],["colorGrading.midtones.hue","CgMH"],["colorGrading.midtones.saturation","CgMS"],["colorGrading.midtones.luminance","CgML"],["colorGrading.highlights.hue","STHH"],["colorGrading.highlights.saturation","STHS"],["colorGrading.highlights.luminance","CgHL"],["colorGrading.global.hue","CgGH"],["colorGrading.global.saturation","CgGS"],["colorGrading.global.luminance","CgGL"],["colorGrading.blending","CgBl"],["colorGrading.balance","STB "],["sharpening.amount","Shrp"],["sharpening.radius","ShpR"],["sharpening.detail","ShpD"],["sharpening.masking","ShpM"],["noiseReduction.luminance","LNR "],["noiseReduction.luminanceDetail","LNRD"],["noiseReduction.luminanceContrast","LNRC"],["noiseReduction.color","CNR "],["noiseReduction.colorDetail","CNRD"],["noiseReduction.colorSmoothness","CNRS"],["grain.amount","GRNA"],["grain.size","GRNS"],["grain.roughness","GRNF"],["postCropVignette.amount","PCVA"],["postCropVignette.midpoint","PCVM"],["postCropVignette.feather","PCVF"],["postCropVignette.roundness","PCVR"]],ld=["Crv ","CrvR","CrvG","CrvB"],qg=2783;function Zg(e,n){var t;let i={};for(let[o,r]of Ms){let s=e[r];if(s===void 0)continue;if(r==="WBal")s=s.split(".")[1];else if(ld.includes(r)){let c=s;s=[];for(let f=0;f+1<c.length;f+=2)s.push({input:c[f],output:c[f+1]})}let a=o.split("."),l=i;for(let c=0;c<a.length-1;c++)l=l[a[c]]=(t=l[a[c]])!==null&&t!==void 0?t:{};l[a[a.length-1]]=s}for(let o of Object.keys(e))o!=="_name"&&o!=="_classID"&&!Ms.some(r=>r[1]===o)&&n.logMissingFeatures&&n.log(`Unhandled Camera Raw Filter setting: ${o}`);return i}function Kg(e){let n={_name:"",_classID:v.cameraRawFilterClassID};for(let[t,i]of Ms){let o=e;for(let r of t.split("."))o=o?.[r];o!==void 0&&(i==="WBal"?o=`WBal.${o}`:ld.includes(i)?o=o.flatMap(r=>[Math.round(r.input),Math.round(r.output)]):typeof o=="number"&&i!=="Ex12"&&i!=="ShpR"&&(o=Math.round(o)),n[i]=o)}return n}function Yg(e,n){let t={name:e["Nm "],opacity:(0,v.parsePercent)(e.blendOptions.Opct),blendMode:v.BlnM.decode(e.blendOptions["Md "]),enabled:e.enab,hasOptions:e.hasoptions,foregroundColor:(0,v.parseColor)(e.FrgC),backgroundColor:(0,v.parseColor)(e.BckC)};if("Fltr"in e&&e.Fltr._classID===v.cameraRawFilterClassID)return Object.assign(Object.assign({},t),{type:"camera raw",filter:Zg(e.Fltr,n)});if("Fltr"in e)switch(e.Fltr._classID){case"boxblur":return Object.assign(Object.assign({},t),{type:"box blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"GsnB":return Object.assign(Object.assign({},t),{type:"gaussian blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"MtnB":return Object.assign(Object.assign({},t),{type:"motion blur",filter:{angle:e.Fltr.Angl,distance:(0,v.parseUnits)(e.Fltr.Dstn)}});case"RdlB":return Object.assign(Object.assign({},t),{type:"radial blur",filter:{amount:e.Fltr.Amnt,method:v.BlrM.decode(e.Fltr.BlrM),quality:v.BlrQ.decode(e.Fltr.BlrQ)}});case"shapeBlur":return Object.assign(Object.assign({},t),{type:"shape blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "]),customShape:{name:e.Fltr.customShape["Nm "],id:e.Fltr.customShape.Idnt}}});case"SmrB":return Object.assign(Object.assign({},t),{type:"smart blur",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh,quality:v.SmBQ.decode(e.Fltr.SmBQ),mode:v.SmBM.decode(e.Fltr.SmBM)}});case"surfaceBlur":return Object.assign(Object.assign({},t),{type:"surface blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dspl":return Object.assign(Object.assign({},t),{type:"displace",filter:{horizontalScale:e.Fltr.HrzS,verticalScale:e.Fltr.VrtS,displacementMap:v.DspM.decode(e.Fltr.DspM),undefinedAreas:v.UndA.decode(e.Fltr.UndA),displacementFile:{signature:e.Fltr.DspF.sig,path:e.Fltr.DspF.path}}});case"Pnch":return Object.assign(Object.assign({},t),{type:"pinch",filter:{amount:e.Fltr.Amnt}});case"Plr ":return Object.assign(Object.assign({},t),{type:"polar coordinates",filter:{conversion:v.Cnvr.decode(e.Fltr.Cnvr)}});case"Rple":return Object.assign(Object.assign({},t),{type:"ripple",filter:{amount:e.Fltr.Amnt,size:v.RplS.decode(e.Fltr.RplS)}});case"Shr ":return Object.assign(Object.assign({},t),{type:"shear",filter:{shearPoints:e.Fltr.ShrP.map(i=>({x:i.Hrzn,y:i.Vrtc})),shearStart:e.Fltr.ShrS,shearEnd:e.Fltr.ShrE,undefinedAreas:v.UndA.decode(e.Fltr.UndA)}});case"Sphr":return Object.assign(Object.assign({},t),{type:"spherize",filter:{amount:e.Fltr.Amnt,mode:v.SphM.decode(e.Fltr.SphM)}});case"Twrl":return Object.assign(Object.assign({},t),{type:"twirl",filter:{angle:e.Fltr.Angl}});case"Wave":return Object.assign(Object.assign({},t),{type:"wave",filter:{numberOfGenerators:e.Fltr.NmbG,type:v.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:v.UndA.decode(e.Fltr.UndA)}});case"ZgZg":return Object.assign(Object.assign({},t),{type:"zigzag",filter:{amount:e.Fltr.Amnt,ridges:e.Fltr.NmbR,style:v.ZZTy.decode(e.Fltr.ZZTy)}});case"AdNs":return Object.assign(Object.assign({},t),{type:"add noise",filter:{amount:(0,v.parsePercent)(e.Fltr.Nose),distribution:v.Dstr.decode(e.Fltr.Dstr),monochromatic:e.Fltr.Mnch,randomSeed:e.Fltr.FlRs}});case"DstS":return Object.assign(Object.assign({},t),{type:"dust and scratches",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh}});case"Mdn ":return Object.assign(Object.assign({},t),{type:"median",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"denoise":return Object.assign(Object.assign({},t),{type:"reduce noise",filter:{preset:e.Fltr.preset,removeJpegArtifact:e.Fltr.removeJPEGArtifact,reduceColorNoise:(0,v.parsePercent)(e.Fltr.ClNs),sharpenDetails:(0,v.parsePercent)(e.Fltr.Shrp),channelDenoise:e.Fltr.channelDenoise.map(i=>Object.assign({channels:i.Chnl.map(v.Chnl.decode),amount:i.Amnt},i.EdgF?{preserveDetails:i.EdgF}:{}))}});case"ClrH":return Object.assign(Object.assign({},t),{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({},t),{type:"crystallize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Mztn":return Object.assign(Object.assign({},t),{type:"mezzotint",filter:{type:v.MztT.decode(e.Fltr.MztT),randomSeed:e.Fltr.FlRs}});case"Msc ":return Object.assign(Object.assign({},t),{type:"mosaic",filter:{cellSize:(0,v.parseUnits)(e.Fltr.ClSz)}});case"Pntl":return Object.assign(Object.assign({},t),{type:"pointillize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Clds":return Object.assign(Object.assign({},t),{type:"clouds",filter:{randomSeed:e.Fltr.FlRs}});case"DfrC":return Object.assign(Object.assign({},t),{type:"difference clouds",filter:{randomSeed:e.Fltr.FlRs}});case"Fbrs":return Object.assign(Object.assign({},t),{type:"fibers",filter:{variance:e.Fltr.Vrnc,strength:e.Fltr.Strg,randomSeed:e.Fltr.RndS}});case"LnsF":return Object.assign(Object.assign({},t),{type:"lens flare",filter:{brightness:e.Fltr.Brgh,position:{x:e.Fltr.FlrC.Hrzn,y:e.Fltr.FlrC.Vrtc},lensType:v.Lns.decode(e.Fltr["Lns "])}});case"smartSharpen":return Object.assign(Object.assign({},t),{type:"smart sharpen",filter:{amount:(0,v.parsePercent)(e.Fltr.Amnt),radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh,angle:e.Fltr.Angl,moreAccurate:e.Fltr.moreAccurate,blur:v.blurType.decode(e.Fltr.blur),preset:e.Fltr.preset,shadow:{fadeAmount:(0,v.parsePercent)(e.Fltr.sdwM.Amnt),tonalWidth:(0,v.parsePercent)(e.Fltr.sdwM.Wdth),radius:e.Fltr.sdwM["Rds "]},highlight:{fadeAmount:(0,v.parsePercent)(e.Fltr.hglM.Amnt),tonalWidth:(0,v.parsePercent)(e.Fltr.hglM.Wdth),radius:e.Fltr.hglM["Rds "]}}});case"UnsM":return Object.assign(Object.assign({},t),{type:"unsharp mask",filter:{amount:(0,v.parsePercent)(e.Fltr.Amnt),radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dfs ":return Object.assign(Object.assign({},t),{type:"diffuse",filter:{mode:v.DfsM.decode(e.Fltr["Md "]),randomSeed:e.Fltr.FlRs}});case"Embs":return Object.assign(Object.assign({},t),{type:"emboss",filter:{angle:e.Fltr.Angl,height:e.Fltr.Hght,amount:e.Fltr.Amnt}});case"Extr":return Object.assign(Object.assign({},t),{type:"extrude",filter:{type:v.ExtT.decode(e.Fltr.ExtT),size:e.Fltr.ExtS,depth:e.Fltr.ExtD,depthMode:v.ExtR.decode(e.Fltr.ExtR),randomSeed:e.Fltr.FlRs,solidFrontFaces:e.Fltr.ExtF,maskIncompleteBlocks:e.Fltr.ExtM}});case"Tls ":return Object.assign(Object.assign({},t),{type:"tiles",filter:{numberOfTiles:e.Fltr.TlNm,maximumOffset:e.Fltr.TlOf,fillEmptyAreaWith:v.FlCl.decode(e.Fltr.FlCl),randomSeed:e.Fltr.FlRs}});case"TrcC":return Object.assign(Object.assign({},t),{type:"trace contour",filter:{level:e.Fltr["Lvl "],edge:v.CntE.decode(e.Fltr["Edg "])}});case"Wnd ":return Object.assign(Object.assign({},t),{type:"wind",filter:{method:v.WndM.decode(e.Fltr.WndM),direction:v.Drct.decode(e.Fltr.Drct)}});case"Dntr":return Object.assign(Object.assign({},t),{type:"de-interlace",filter:{eliminate:v.IntE.decode(e.Fltr.IntE),newFieldsBy:v.IntC.decode(e.Fltr.IntC)}});case"Cstm":return Object.assign(Object.assign({},t),{type:"custom",filter:{scale:e.Fltr["Scl "],offset:e.Fltr.Ofst,matrix:e.Fltr.Mtrx}});case"HghP":return Object.assign(Object.assign({},t),{type:"high pass",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Mxm ":return Object.assign(Object.assign({},t),{type:"maximum",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Mnm ":return Object.assign(Object.assign({},t),{type:"minimum",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Ofst":return Object.assign(Object.assign({},t),{type:"offset",filter:{horizontal:e.Fltr.Hrzn,vertical:e.Fltr.Vrtc,undefinedAreas:v.FlMd.decode(e.Fltr["Fl "])}});case"rigidTransform":return Object.assign(Object.assign({},t),{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:Nf(i.originalVertexArray),deformedVertexArray:Nf(i.deformedVertexArray),indexArray:Array.from(Xg(i.indexArray)),pinOffsets:Ao(i.pinOffsets),posFinalPins:Ao(i.posFinalPins),pinVertexIndices:i.pinVertexIndices,selectedPin:i.selectedPin,pinPosition:Ao(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:xi(s.Anch),forward:xi(s["Fwd "]),backward:xi(s["Bwd "]),smooth:s.Smoo}))}))}))}}))}});case"PbPl":{let i=[],o=e.Fltr;for(let r=0;r<Ze.length&&o[`PN${Ze[r]}a`];r++)for(let s=0;s<Ze.length&&o[`PN${Ze[r]}${Ze[s]}`];s++)i.push({name:o[`PN${Ze[r]}${Ze[s]}`],value:o[`PF${Ze[r]}${Ze[s]}`]});return Object.assign(Object.assign({},t),{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({},t),{type:"hsb/hsl",filter:{inputMode:v.ClrS.decode(e.Fltr.Inpt),rowOrder:v.ClrS.decode(e.Fltr.Otpt)}});case"oilPaint":return Object.assign(Object.assign({},t),{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({},t),{type:"liquify",filter:{liquifyMesh:e.Fltr.LqMe}});case"perspectiveWarpTransform":return Object.assign(Object.assign({},t),{type:"perspective warp",filter:{vertices:e.Fltr.vertices.map(xi),warpedVertices:e.Fltr.warpedVertices.map(xi),quads:e.Fltr.quads.map(i=>i.indices)}});case"Crvs":return Object.assign(Object.assign({},t),{type:"curves",filter:Object.assign(Object.assign({},e.Fltr.presetKind!==void 0?{presetKind:v.presetKindType.decode(e.Fltr.presetKind)}:{}),e.Fltr.Adjs?{adjustments:e.Fltr.Adjs.map(i=>{let o=i.Chnl.map(v.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"Lvls":{let i=e.Fltr.Adjs,o=(r,s)=>Object.keys(r).every(a=>s.indexOf(a)!==-1);if(!o(e.Fltr,Gg)||i&&!i.every(r=>o(r,Hg))){if(n.throwForMissingFeatures)throw new Error("Unknown levels filter settings");n.logMissingFeatures&&n.log("Skipped levels smart filter with unknown settings");return}return Object.assign(Object.assign({},t),{type:"levels",filter:Object.assign(Object.assign({},e.Fltr.presetKind!==void 0?{presetKind:v.presetKindType.decode(e.Fltr.presetKind)}:{}),i?{adjustments:i.map(r=>{let s={channels:r.Chnl.map(v.Chnl.decode)};return r.Inpt&&(s.shadowInput=r.Inpt[0],s.highlightInput=r.Inpt[1]),r.Otpt&&(s.shadowOutput=r.Otpt[0],s.highlightOutput=r.Otpt[1]),r["Gmm "]!==void 0&&(s.midtoneInput=r["Gmm "]),s})}:{})})}case"BrgC":return Object.assign(Object.assign({},t),{type:"brightness/contrast",filter:{brightness:e.Fltr.Brgh,contrast:e.Fltr.Cntr,useLegacy:!!e.Fltr.useLegacy}});default:if(n.throwForMissingFeatures)throw new Error(`Unknown filter classId: ${e.Fltr._classID}`);n.logMissingFeatures&&n.log(`Unhandled smart filter: ${e.Fltr._classID} (${e["Nm "]})`);return}else switch(e.filterID){case 1098281575:return Object.assign(Object.assign({},t),{type:"average"});case 1114403360:return Object.assign(Object.assign({},t),{type:"blur"});case 1114403405:return Object.assign(Object.assign({},t),{type:"blur more"});case 1148416099:return Object.assign(Object.assign({},t),{type:"despeckle"});case 1180922912:return Object.assign(Object.assign({},t),{type:"facet"});case 1181902701:return Object.assign(Object.assign({},t),{type:"fragment"});case 1399353968:return Object.assign(Object.assign({},t),{type:"sharpen"});case 1399353925:return Object.assign(Object.assign({},t),{type:"sharpen edges"});case 1399353933:return Object.assign(Object.assign({},t),{type:"sharpen more"});case 1181639749:return Object.assign(Object.assign({},t),{type:"find edges"});case 1399616122:return Object.assign(Object.assign({},t),{type:"solarize"});case 1314149187:return Object.assign(Object.assign({},t),{type:"ntsc colors"});case 1231976050:return Object.assign(Object.assign({},t),{type:"invert"});default:if(n.throwForMissingFeatures)throw new Error(`Unknown filterID: ${e.filterID}`);n.logMissingFeatures&&n.log(`Unhandled smart filter: ${e.filterID} (${e["Nm "]})`);return}}function Jg(e,n){return{enabled:e.enab,validAtPosition:e.validAtPosition,maskEnabled:e.filterMaskEnable,maskLinked:e.filterMaskLinked,maskExtendWithWhite:e.filterMaskExtendWithWhite,list:e.filterFXList.map(t=>Yg(t,n)).filter(t=>!!t)}}function kt(e){return(0,v.unitsValue)(e.radius,"radius")}function Qg(e){let n={_name:"",_classID:"filterFX","Nm ":e.name,blendOptions:{_name:"",_classID:"blendOptions",Opct:(0,v.unitsPercentF)(e.opacity),"Md ":v.BlnM.encode(e.blendMode)},enab:e.enabled,hasoptions:e.hasOptions,FrgC:(0,v.serializeColor)(e.foregroundColor),BckC:(0,v.serializeColor)(e.backgroundColor)};switch(e.type){case"average":return Object.assign(Object.assign({},n),{filterID:1098281575});case"blur":return Object.assign(Object.assign({},n),{filterID:1114403360});case"blur more":return Object.assign(Object.assign({},n),{filterID:1114403405});case"box blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Box Blur",_classID:"boxblur","Rds ":kt(e.filter)},filterID:697});case"gaussian blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Gaussian Blur",_classID:"GsnB","Rds ":kt(e.filter)},filterID:1198747202});case"motion blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Motion Blur",_classID:"MtnB",Angl:e.filter.angle,Dstn:(0,v.unitsValue)(e.filter.distance,"distance")},filterID:1299476034});case"radial blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Radial Blur",_classID:"RdlB",Amnt:e.filter.amount,BlrM:v.BlrM.encode(e.filter.method),BlrQ:v.BlrQ.encode(e.filter.quality)},filterID:1382313026});case"shape blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Shape Blur",_classID:"shapeBlur","Rds ":kt(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({},n),{Fltr:{_name:"Smart Blur",_classID:"SmrB","Rds ":e.filter.radius,Thsh:e.filter.threshold,SmBQ:v.SmBQ.encode(e.filter.quality),SmBM:v.SmBM.encode(e.filter.mode)},filterID:1399681602});case"surface blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Surface Blur",_classID:"surfaceBlur","Rds ":kt(e.filter),Thsh:e.filter.threshold},filterID:701});case"displace":return Object.assign(Object.assign({},n),{Fltr:{_name:"Displace",_classID:"Dspl",HrzS:e.filter.horizontalScale,VrtS:e.filter.verticalScale,DspM:v.DspM.encode(e.filter.displacementMap),UndA:v.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({},n),{Fltr:{_name:"Pinch",_classID:"Pnch",Amnt:e.filter.amount},filterID:1349411688});case"polar coordinates":return Object.assign(Object.assign({},n),{Fltr:{_name:"Polar Coordinates",_classID:"Plr ",Cnvr:v.Cnvr.encode(e.filter.conversion)},filterID:1349284384});case"ripple":return Object.assign(Object.assign({},n),{Fltr:{_name:"Ripple",_classID:"Rple",Amnt:e.filter.amount,RplS:v.RplS.encode(e.filter.size)},filterID:1383099493});case"shear":return Object.assign(Object.assign({},n),{Fltr:{_name:"Shear",_classID:"Shr ",ShrP:e.filter.shearPoints.map(t=>({_name:"",_classID:"Pnt ",Hrzn:t.x,Vrtc:t.y})),UndA:v.UndA.encode(e.filter.undefinedAreas),ShrS:e.filter.shearStart,ShrE:e.filter.shearEnd},filterID:1399353888});case"spherize":return Object.assign(Object.assign({},n),{Fltr:{_name:"Spherize",_classID:"Sphr",Amnt:e.filter.amount,SphM:v.SphM.encode(e.filter.mode)},filterID:1399875698});case"twirl":return Object.assign(Object.assign({},n),{Fltr:{_name:"Twirl",_classID:"Twrl",Angl:e.filter.angle},filterID:1417114220});case"wave":return Object.assign(Object.assign({},n),{Fltr:{_name:"Wave",_classID:"Wave",Wvtp:v.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:v.UndA.encode(e.filter.undefinedAreas),RndS:e.filter.randomSeed},filterID:1466005093});case"zigzag":return Object.assign(Object.assign({},n),{Fltr:{_name:"ZigZag",_classID:"ZgZg",Amnt:e.filter.amount,NmbR:e.filter.ridges,ZZTy:v.ZZTy.encode(e.filter.style)},filterID:1516722791});case"add noise":return Object.assign(Object.assign({},n),{Fltr:{_name:"Add Noise",_classID:"AdNs",Dstr:v.Dstr.encode(e.filter.distribution),Nose:(0,v.unitsPercentF)(e.filter.amount),Mnch:e.filter.monochromatic,FlRs:e.filter.randomSeed},filterID:1097092723});case"despeckle":return Object.assign(Object.assign({},n),{filterID:1148416099});case"dust and scratches":return Object.assign(Object.assign({},n),{Fltr:{_name:"Dust & Scratches",_classID:"DstS","Rds ":e.filter.radius,Thsh:e.filter.threshold},filterID:1148417107});case"median":return Object.assign(Object.assign({},n),{Fltr:{_name:"Median",_classID:"Mdn ","Rds ":kt(e.filter)},filterID:1298427424});case"reduce noise":return Object.assign(Object.assign({},n),{Fltr:{_name:"Reduce Noise",_classID:"denoise",ClNs:(0,v.unitsPercentF)(e.filter.reduceColorNoise),Shrp:(0,v.unitsPercentF)(e.filter.sharpenDetails),removeJPEGArtifact:e.filter.removeJpegArtifact,channelDenoise:e.filter.channelDenoise.map(t=>Object.assign({_name:"",_classID:"channelDenoiseParams",Chnl:t.channels.map(i=>v.Chnl.encode(i)),Amnt:t.amount},t.preserveDetails?{EdgF:t.preserveDetails}:{})),preset:e.filter.preset},filterID:633});case"color halftone":return Object.assign(Object.assign({},n),{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({},n),{Fltr:{_name:"Crystallize",_classID:"Crst",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1131574132});case"facet":return Object.assign(Object.assign({},n),{filterID:1180922912});case"fragment":return Object.assign(Object.assign({},n),{filterID:1181902701});case"mezzotint":return Object.assign(Object.assign({},n),{Fltr:{_name:"Mezzotint",_classID:"Mztn",MztT:v.MztT.encode(e.filter.type),FlRs:e.filter.randomSeed},filterID:1299870830});case"mosaic":return Object.assign(Object.assign({},n),{Fltr:{_name:"Mosaic",_classID:"Msc ",ClSz:(0,v.unitsValue)(e.filter.cellSize,"cellSize")},filterID:1299407648});case"pointillize":return Object.assign(Object.assign({},n),{Fltr:{_name:"Pointillize",_classID:"Pntl",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1349416044});case"clouds":return Object.assign(Object.assign({},n),{Fltr:{_name:"Clouds",_classID:"Clds",FlRs:e.filter.randomSeed},filterID:1131177075});case"difference clouds":return Object.assign(Object.assign({},n),{Fltr:{_name:"Difference Clouds",_classID:"DfrC",FlRs:e.filter.randomSeed},filterID:1147564611});case"fibers":return Object.assign(Object.assign({},n),{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({},n),{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 ":v.Lns.encode(e.filter.lensType)},filterID:1282306886});case"sharpen":return Object.assign(Object.assign({},n),{filterID:1399353968});case"sharpen edges":return Object.assign(Object.assign({},n),{filterID:1399353925});case"sharpen more":return Object.assign(Object.assign({},n),{filterID:1399353933});case"smart sharpen":return Object.assign(Object.assign({},n),{Fltr:{_name:"Smart Sharpen",_classID:"smartSharpen",Amnt:(0,v.unitsPercentF)(e.filter.amount),"Rds ":kt(e.filter),Thsh:e.filter.threshold,Angl:e.filter.angle,moreAccurate:e.filter.moreAccurate,blur:v.blurType.encode(e.filter.blur),preset:e.filter.preset,sdwM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,v.unitsPercentF)(e.filter.shadow.fadeAmount),Wdth:(0,v.unitsPercentF)(e.filter.shadow.tonalWidth),"Rds ":e.filter.shadow.radius},hglM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,v.unitsPercentF)(e.filter.highlight.fadeAmount),Wdth:(0,v.unitsPercentF)(e.filter.highlight.tonalWidth),"Rds ":e.filter.highlight.radius}},filterID:698});case"unsharp mask":return Object.assign(Object.assign({},n),{Fltr:{_name:"Unsharp Mask",_classID:"UnsM",Amnt:(0,v.unitsPercentF)(e.filter.amount),"Rds ":kt(e.filter),Thsh:e.filter.threshold},filterID:1433301837});case"diffuse":return Object.assign(Object.assign({},n),{Fltr:{_name:"Diffuse",_classID:"Dfs ","Md ":v.DfsM.encode(e.filter.mode),FlRs:e.filter.randomSeed},filterID:1147564832});case"emboss":return Object.assign(Object.assign({},n),{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({},n),{Fltr:{_name:"Extrude",_classID:"Extr",ExtS:e.filter.size,ExtD:e.filter.depth,ExtF:e.filter.solidFrontFaces,ExtM:e.filter.maskIncompleteBlocks,ExtT:v.ExtT.encode(e.filter.type),ExtR:v.ExtR.encode(e.filter.depthMode),FlRs:e.filter.randomSeed},filterID:1165522034});case"find edges":return Object.assign(Object.assign({},n),{filterID:1181639749});case"solarize":return Object.assign(Object.assign({},n),{filterID:1399616122});case"tiles":return Object.assign(Object.assign({},n),{Fltr:{_name:"Tiles",_classID:"Tls ",TlNm:e.filter.numberOfTiles,TlOf:e.filter.maximumOffset,FlCl:v.FlCl.encode(e.filter.fillEmptyAreaWith),FlRs:e.filter.randomSeed},filterID:1416393504});case"trace contour":return Object.assign(Object.assign({},n),{Fltr:{_name:"Trace Contour",_classID:"TrcC","Lvl ":e.filter.level,"Edg ":v.CntE.encode(e.filter.edge)},filterID:1416782659});case"wind":return Object.assign(Object.assign({},n),{Fltr:{_name:"Wind",_classID:"Wnd ",WndM:v.WndM.encode(e.filter.method),Drct:v.Drct.encode(e.filter.direction)},filterID:1466852384});case"de-interlace":return Object.assign(Object.assign({},n),{Fltr:{_name:"De-Interlace",_classID:"Dntr",IntE:v.IntE.encode(e.filter.eliminate),IntC:v.IntC.encode(e.filter.newFieldsBy)},filterID:1148089458});case"ntsc colors":return Object.assign(Object.assign({},n),{filterID:1314149187});case"invert":return Object.assign(Object.assign({},n),{filterID:1231976050});case"custom":return Object.assign(Object.assign({},n),{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({},n),{Fltr:{_name:"High Pass",_classID:"HghP","Rds ":kt(e.filter)},filterID:1214736464});case"maximum":return Object.assign(Object.assign({},n),{Fltr:{_name:"Maximum",_classID:"Mxm ","Rds ":kt(e.filter)},filterID:1299737888});case"minimum":return Object.assign(Object.assign({},n),{Fltr:{_name:"Minimum",_classID:"Mnm ","Rds ":kt(e.filter)},filterID:1299082528});case"offset":return Object.assign(Object.assign({},n),{Fltr:{_name:"Offset",_classID:"Ofst",Hrzn:e.filter.horizontal,Vrtc:e.filter.vertical,"Fl ":v.FlMd.encode(e.filter.undefinedAreas)},filterID:1332114292});case"puppet":return Object.assign(Object.assign({},n),{Fltr:{_name:"Rigid Transform",_classID:"rigidTransform",null:["Ordn.Trgt"],rigidType:e.filter.rigidType,puppetShapeList:(e.filter.puppetShapeList||[]).map(t=>({_name:"",_classID:"puppetShape",rigidType:t.rigidType,VrsM:1,VrsN:0,originalVertexArray:Cs(new Float32Array(Si(t.originalVertexArray))),deformedVertexArray:Cs(new Float32Array(Si(t.deformedVertexArray))),indexArray:Cs(new Uint32Array(t.indexArray)),pinOffsets:Si(t.pinOffsets),posFinalPins:Si(t.posFinalPins),pinVertexIndices:t.pinVertexIndices,PinP:Si(t.pinPosition),PnRt:t.pinRotation,PnOv:t.pinOverlay,PnDp:t.pinDepth,meshQuality:t.meshQuality,meshExpansion:t.meshExpansion,meshRigidity:t.meshRigidity,imageResolution:t.imageResolution,meshBoundaryPath:{_name:"",_classID:"pathClass",pathComponents:t.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:ki(r.anchor),"Fwd ":ki(r.forward),"Bwd ":ki(r.backward),Smoo:r.smooth}))}))}))},selectedPin:t.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 t={};for(let i=0;i<e.filter.parameters.length;i++){let{name:o,value:r}=e.filter.parameters[i],s=`${Ze[Math.floor(i/Ze.length)]}${Ze[i%Ze.length]}`;t[`PN${s}`]=o,t[`PT${s}`]=0,t[`PF${s}`]=r}return Object.assign(Object.assign({},n),{Fltr:Object.assign({_name:"Oil Paint Plugin",_classID:"PbPl",KnNm:e.filter.name,GpuY:e.filter.gpu,LIWy:e.filter.lighting,FPth:"1"},t),filterID:1348620396})}case"oil paint":return Object.assign(Object.assign({},n),{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({},n),{Fltr:{_name:"Liquify",_classID:"LqFy",LqMe:e.filter.liquifyMesh},filterID:1282492025});case"perspective warp":return Object.assign(Object.assign({},n),{Fltr:{_name:"Perspective Warp",_classID:"perspectiveWarpTransform",vertices:e.filter.vertices.map(ki),warpedVertices:e.filter.warpedVertices.map(ki),quads:e.filter.quads.map(t=>({_name:"",_classID:"quadIndices",indices:t}))},filterID:442});case"curves":return Object.assign(Object.assign({},n),{Fltr:Object.assign(Object.assign({_name:"Curves",_classID:"Crvs"},e.filter.presetKind!==void 0?{presetKind:v.presetKindType.encode(e.filter.presetKind)}:{}),e.filter.adjustments?{Adjs:e.filter.adjustments.map(t=>"curve"in t?{_name:"",_classID:"CrvA",Chnl:t.channels.map(v.Chnl.encode),"Crv ":t.curve.map(i=>Object.assign({_name:"",_classID:"Pnt ",Hrzn:i.x,Vrtc:i.y},i.curved?{Cnty:!0}:{}))}:{_name:"",_classID:"CrvA",Chnl:t.channels.map(v.Chnl.encode),Mpng:t.values})}:{}),filterID:1131574899});case"levels":return Object.assign(Object.assign({},n),{Fltr:Object.assign(Object.assign({_name:"Levels",_classID:"Lvls"},e.filter.presetKind!==void 0?{presetKind:v.presetKindType.encode(e.filter.presetKind)}:{}),e.filter.adjustments?{Adjs:e.filter.adjustments.map(t=>{var i,o,r,s;let a={_name:"",_classID:"LvlA",Chnl:t.channels.map(v.Chnl.encode)};return(t.shadowInput!==void 0||t.highlightInput!==void 0)&&(a.Inpt=[Math.round((i=t.shadowInput)!==null&&i!==void 0?i:0),Math.round((o=t.highlightInput)!==null&&o!==void 0?o:255)]),(t.shadowOutput!==void 0||t.highlightOutput!==void 0)&&(a.Otpt=[Math.round((r=t.shadowOutput)!==null&&r!==void 0?r:0),Math.round((s=t.highlightOutput)!==null&&s!==void 0?s:255)]),t.midtoneInput!==void 0&&(a["Gmm "]=t.midtoneInput),a})}:{}),filterID:1282829427});case"camera raw":return Object.assign(Object.assign({},n),{Fltr:Kg(e.filter),filterID:qg});case"brightness/contrast":return Object.assign(Object.assign({},n),{Fltr:{_name:"Brightness/Contrast",_classID:"BrgC",Brgh:e.filter.brightness,Cntr:e.filter.contrast,useLegacy:!!e.filter.useLegacy},filterID:1114793795});case"hsb/hsl":return Object.assign(Object.assign({},n),{Fltr:{_name:"HSB/HSL",_classID:"HsbP",Inpt:v.ClrS.encode(e.filter.inputMode),Otpt:v.ClrS.encode(e.filter.rowOrder)},filterID:1215521360});default:throw new Error(`Unknown filter type: ${e.type}`)}}function cd(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 n=e.width,t=e.height,i=0,o=n/3,r=n*2/3,s=n,a=0,l=t/3,c=t*2/3,f=t;return{style:"custom",value:0,perspective:0,perspectiveOther:0,rotate:"horizontal",bounds:{top:{value:0,units:"Pixels"},left:{value:0,units:"Pixels"},bottom:{value:t,units:"Pixels"},right:{value:n,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:f},{x:o,y:f},{x:r,y:f},{x:s,y:f}]}}}U("SoLd",e=>!!e.placedLayer&&!e.placedLayer.external,(e,n,t)=>{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,v.readVersionAndDescriptor)(e,!0);n.placedLayer={id:o.Idnt,placed:o.placed,type:Nn[o.Type],pageNumber:o.PgNm,totalPages:o.totalPages,frameStep:(0,v.frac)(o.frameStep),duration:(0,v.frac)(o.duration),frameCount:o.frameCount,transform:o.Trnf,width:o["Sz "].Wdth,height:o["Sz "].Hght,resolution:(0,v.parseUnits)(o.Rslt),warp:ad(o.quiltWarp||o.warp)},o.nonAffineTransform&&o.nonAffineTransform.some((r,s)=>r!==o.Trnf[s])&&(n.placedLayer.nonAffineTransform=o.nonAffineTransform),o.Crop&&(n.placedLayer.crop=o.Crop),o.comp&&(n.placedLayer.comp=o.comp),o.compInfo&&(n.placedLayer.compInfo={compID:o.compInfo.compID,originalCompID:o.compInfo.originalCompID}),o.filterFX&&(n.placedLayer.filter=Jg(o.filterFX,e)),o.Impr&&(n.placedLayer.imported=!0),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i;(0,w.writeSignature)(e,"soLD"),(0,w.writeInt32)(e,4);let o=n.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=Nn.indexOf(o.type);if(r===-1)throw new Error("Invalid placedLayer type");let s=cd(o),a=s.bounds,l=o.width||(a?a.right.value-a.left.value:0),c=o.height||(a?a.bottom.value-a.top.value:0),f=Object.assign(Object.assign({Idnt:o.id,placed:(t=o.placed)!==null&&t!==void 0?t: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:r,Trnf:o.transform,nonAffineTransform:(i=o.nonAffineTransform)!==null&&i!==void 0?i:o.transform,warp:Io(s),"Sz ":{_name:"",_classID:"Pnt ",Wdth:l,Hght:c},Rslt:o.resolution?(0,v.unitsValue)(o.resolution,"resolution"):{units:"Density",value:72}});if(o.filter&&(f.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(u=>Qg(u))}),o.warp&&Bs(o.warp)){let u=Io(o.warp);f.quiltWarp=u,f.warp={warpStyle:"warpStyle.warpNone",warpValue:u.warpValue,warpPerspective:u.warpPerspective,warpPerspectiveOther:u.warpPerspectiveOther,warpRotate:u.warpRotate,bounds:u.bounds,uOrder:u.uOrder,vOrder:u.vOrder}}else delete f.quiltWarp;o.comp&&(f.comp=o.comp),o.compInfo&&(f.compInfo=o.compInfo),o.imported&&(f.Impr={}),(0,v.writeVersionAndDescriptor)(e,"","null",f,f.quiltWarp?"quiltWarp":"warp")});var Gf=Ae.infoHandlersMap.SoLd;U("SoLE",e=>{var n;return!!(!((n=e.placedLayer)===null||n===void 0)&&n.external)},(e,n,t,i,o)=>{Gf.read(e,n,t,i,o),n.placedLayer.external=!0},Gf.write);U("fxrp",le("referencePoint"),(e,n)=>{n.referencePoint={x:(0,b.readFloat64)(e),y:(0,b.readFloat64)(e)}},(e,n)=>{(0,w.writeFloat64)(e,n.referencePoint.x),(0,w.writeFloat64)(e,n.referencePoint.y)});function Rs(e,n){U(e,()=>!1,(t,i,o,r,s)=>{var a;if(!t.layersInGlobalInfo&&(r.bitsPerChannel===n||!(!((a=r.children)===null||a===void 0)&&a.length))){let l=r.children;r.children=[];try{(0,b.readLayerInfo)(t,r,s)}catch(c){throw r.children=l,c}t.layersInGlobalInfo=!0}(0,b.skipBytes)(t,o())},()=>{})}Rs("Lr16",16);Rs("Lr32",32);Rs("Layr",void 0);for(let e of["Mtrn","Mt16","Mt32"])U(e,()=>!1,(n,t,i)=>{n.globalAlpha=!0,(0,b.skipBytes)(n,i())},()=>{});U("LMsk",le("userMask"),(e,n)=>{if(n.userMask={colorSpace:(0,b.readColor)(e),opacity:(0,b.readUint16)(e)/100},(0,b.readUint8)(e)!==128)throw new Error("Invalid flag value");(0,b.skipBytes)(e,1)},(e,n)=>{let t=n.userMask;(0,w.writeColor)(e,t.colorSpace),(0,w.writeUint16)(e,Math.round((0,De.clamp)(t.opacity,0,1)*100)),(0,w.writeUint8)(e,128),(0,w.writeZeros)(e,1)});U("Patt",e=>!!(e.patterns&&e.patterns.length>0),(e,n,t)=>{for(;t()>0;){let i=(0,b.readPatternSafe)(e);i&&(n.patterns===void 0&&(n.patterns=[]),n.patterns.push(i))}},(e,n,t,i)=>{let o=n.patterns||[];for(let r of o)(0,w.writePattern)(e,r)});lt("Pat2","Patt");lt("Pat3","Patt");De.MOCK_HANDLERS&&U("CAI ",e=>e._CAI_!==void 0,(e,n,t)=>{n._CAI_=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._CAI_)});De.MOCK_HANDLERS&&U("OCIO",e=>e._OCIO!==void 0,(e,n,t)=>{n._OCIO=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._OCIO)});De.MOCK_HANDLERS&&U("GenI",e=>e._GenI!==void 0,(e,n,t)=>{n._GenI=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._GenI)});function Hf(e){let n=(0,b.readInt32)(e),t=(0,b.readInt32)(e),i=(0,b.readInt32)(e),o=(0,b.readInt32)(e);return{top:n,left:t,bottom:i,right:o}}function Wf(e,n){(0,w.writeInt32)(e,n.top),(0,w.writeInt32)(e,n.left),(0,w.writeInt32)(e,n.bottom),(0,w.writeInt32)(e,n.right)}U("Anno",e=>e.annotations!==void 0,(e,n,t)=>{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++){let l=e.offset,c=(0,b.readUint32)(e),f=(0,b.readSignature)(e),u=!!(0,b.readUint8)(e);(0,b.readUint8)(e),(0,b.readUint16)(e);let d=Hf(e),p=Hf(e),h=(0,b.readColor)(e),m=(0,b.readPascalString)(e,2),y=(0,b.readPascalString)(e,2),g=(0,b.readPascalString)(e,2);(0,b.readUint32)(e),(0,b.readSignature)(e);let k=(0,b.readUint32)(e),x;if(f==="txtA"){let S=e.offset;k>=2&&(0,b.readUint16)(e)===65279?x=(0,b.readUnicodeStringWithLength)(e,Math.floor((k-2)/2)):(e.offset=S,x=(0,b.readAsciiString)(e,k)),x=x.replace(/\r/g,`
12
+ `)}else if(f==="sndA")x=(0,b.readBytes)(e,k);else throw new Error("Unknown annotation type");s.push({type:f==="txtA"?"text":"sound",open:u,iconLocation:d,popupLocation:p,color:h,author:m,name:y,date:g,data:x}),c>=e.offset-l&&(e.offset=l+c)}n.annotations=s,(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.annotations;(0,w.writeUint16)(e,2),(0,w.writeUint16)(e,1),(0,w.writeUint32)(e,t.length);for(let i of t){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,w.writeUint32)(e,0),(0,w.writeSignature)(e,o?"sndA":"txtA"),(0,w.writeUint8)(e,i.open?1:0),(0,w.writeUint8)(e,28),(0,w.writeUint16)(e,1),Wf(e,i.iconLocation),Wf(e,i.popupLocation),(0,w.writeColor)(e,i.color),(0,w.writePascalString)(e,i.author||"",2),(0,w.writePascalString)(e,i.name||"",2),(0,w.writePascalString)(e,i.date||"",2);let s=e.offset;(0,w.writeUint32)(e,0),(0,w.writeSignature)(e,o?"sndM":"txtC"),(0,w.writeUint32)(e,0);let a=e.offset;if(o)(0,w.writeBytes)(e,i.data);else{(0,w.writeUint16)(e,65279);let l=i.data.replace(/\n/g,"\r");for(let c=0;c<l.length;c++)(0,w.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 Xf(e){let n=(0,b.readSignature)(e);return/^[\0 ]*$/.test(n)?"":n.trim()}function fd(e){U(e,n=>{let t=n;return!(!t.linkedFiles||!t.linkedFiles.length||e==="lnkE"&&!t.linkedFiles.some(i=>i.linkedFile))},(n,t,i,o)=>{let r=t;for(r.linkedFiles=r.linkedFiles||[];i()>8;){let s=_o(n),a=n.offset,l=(0,b.readSignature)(n),c=(0,b.readInt32)(n),f=(0,b.readPascalString)(n,1),u=(0,b.readUnicodeString)(n),d=Xf(n),p=Xf(n),h=_o(n),y=(0,b.readUint8)(n)?(0,v.readVersionAndDescriptor)(n):void 0,g=l==="liFE"?(0,v.readVersionAndDescriptor)(n):void 0,k={id:f,name:u};if(d&&(k.type=d),p&&(k.creator=p),y&&(k.descriptor={compInfo:{compID:y.compInfo.compID,originalCompID:y.compInfo.originalCompID}}),l==="liFE"&&c>3){let S=(0,b.readInt32)(n),A=(0,b.readUint8)(n),D=(0,b.readUint8)(n),C=(0,b.readUint8)(n),O=(0,b.readUint8)(n),E=(0,b.readFloat64)(n),L=Math.floor(E),M=(E-L)*1e3;try{k.time=new Date(Date.UTC(S,A,D,C,O,L,M)).toISOString()}catch{k.time=new Date(0).toISOString()}}let x=l==="liFE"?_o(n):0;if(l==="liFD"&&h>i())throw new Error("Invalid linked file data size");if(l==="liFA"&&(0,b.skipBytes)(n,8),l==="liFD"&&(k.data=(0,b.readBytes)(n,h)),c>=5&&(k.childDocumentID=(0,b.readUnicodeString)(n)),c>=6&&(k.assetModTime=(0,b.readFloat64)(n)),c>=7&&(k.assetLockedState=(0,b.readUint8)(n)),l==="liFE"&&c===2){if(x>i())throw new Error("Invalid linked file size");k.data=(0,b.readBytes)(n,x)}for(n.skipLinkedFilesData&&(k.data=void 0),e==="lnkE"&&(k.linkedFile={fileSize:x,name:g?.["Nm "]||"",fullPath:g?.fullPath||"",originalPath:g?.originalPath||"",relativePath:g?.relPath||""},g?.alis!==void 0&&(k.linkedFile.alias=g.alis)),r.linkedFiles.push(k);s%4;)s++;n.offset=a+s}(0,b.skipBytes)(n,i())},(n,t)=>{var i,o,r,s,a,l,c,f,u,d,p;let h=t;for(let m of h.linkedFiles){if(e==="lnkE"!=!!m.linkedFile)continue;let y=e==="lnkE",g=2;m.assetLockedState!=null?g=7:m.assetModTime!=null?g=6:m.childDocumentID!=null?g=5:y&&!m.data&&(g=4),(0,w.writeUint64)(n,0);let k=n.offset;if((0,w.writeSignature)(n,y?"liFE":m.data?"liFD":"liFA"),(0,w.writeInt32)(n,g),!m.id||typeof m.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(m.id))throw new Error("Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,w.writePascalString)(n,m.id,1),(0,w.writeUnicodeStringWithPadding)(n,m.name||""),(0,w.writeSignature)(n,m.type?`${m.type} `.substring(0,4):" "),(0,w.writeSignature)(n,m.creator?`${m.creator} `.substring(0,4):"\0\0\0\0"),(0,w.writeUint64)(n,!y&&m.data?m.data.byteLength:0),m.descriptor&&m.descriptor.compInfo){let S={compInfo:{compID:m.descriptor.compInfo.compID,originalCompID:m.descriptor.compInfo.originalCompID}};(0,w.writeUint8)(n,1),(0,v.writeVersionAndDescriptor)(n,"","null",S)}else(0,w.writeUint8)(n,0);if(y){let S=Object.assign(Object.assign({descVersion:2,"Nm ":(o=(i=m.linkedFile)===null||i===void 0?void 0:i.name)!==null&&o!==void 0?o:"",fullPath:(s=(r=m.linkedFile)===null||r===void 0?void 0:r.fullPath)!==null&&s!==void 0?s:""},((a=m.linkedFile)===null||a===void 0?void 0:a.alias)!==void 0?{alis:m.linkedFile.alias}:{}),{originalPath:(c=(l=m.linkedFile)===null||l===void 0?void 0:l.originalPath)!==null&&c!==void 0?c:"",relPath:(u=(f=m.linkedFile)===null||f===void 0?void 0:f.relativePath)!==null&&u!==void 0?u:""});(0,v.writeVersionAndDescriptor)(n,"","ExternalFileLink",S)}if(y&&g>3){let S=m.time?new Date(m.time):new Date;(0,w.writeInt32)(n,S.getUTCFullYear()),(0,w.writeUint8)(n,S.getUTCMonth()),(0,w.writeUint8)(n,S.getUTCDate()),(0,w.writeUint8)(n,S.getUTCHours()),(0,w.writeUint8)(n,S.getUTCMinutes()),(0,w.writeFloat64)(n,S.getUTCSeconds()+S.getUTCMilliseconds()/1e3)}y?(0,w.writeUint64)(n,(g===2?(d=m.data)===null||d===void 0?void 0:d.byteLength:(p=m.linkedFile)===null||p===void 0?void 0:p.fileSize)||0):m.data?(0,w.writeBytes)(n,m.data):(0,w.writeZeros)(n,8),g>=5&&(0,w.writeUnicodeStringWithPadding)(n,m.childDocumentID||""),g>=6&&(0,w.writeFloat64)(n,m.assetModTime||0),g>=7&&(0,w.writeUint8)(n,m.assetLockedState||0),y&&g===2&&m.data&&(0,w.writeBytes)(n,m.data);let x=n.offset-k;for(n.view.setUint32(k-4,x,!1);x%4;)x++,(0,w.writeUint8)(n,0)}})}fd("lnk2");fd("lnkE");lt("lnkD","lnk2");lt("lnk3","lnk2");U("pths",e=>{var n;return((n=e.imageResources)===null||n===void 0?void 0:n.savedPaths)!==void 0},(e,n,t,i)=>{var o,r;if(!t())return;if(e.imageResourcesWhitelistSet&&!e.imageResourcesWhitelistSet.has("savedPaths")){(0,b.skipBytes)(e,t());return}let s=(0,v.readVersionAndDescriptor)(e,!0),a=(o=i.imageResources)!==null&&o!==void 0?o:i.imageResources={},l=(r=a.savedPaths)!==null&&r!==void 0?r:a.savedPaths=[];for(let c=0;c<s.pathList.length&&c<l.length;c++){let{pathUnicodeName:f,pathSymmetryClass:u}=s.pathList[c],d=l[c];a.clippingPath&&a.clippingPath.name===d.name&&(a.clippingPath.name=f),d.name=f,u&&(d.symmetryMode=u.pathSymmetryMode.split(".")[1])}(0,b.skipBytes)(e,t())},(e,n,t)=>{let i={pathList:t.imageResources.savedPaths.map(o=>Object.assign({_name:"",_classID:"pathInfoClass",pathUnicodeName:o.name},o.symmetryMode?{pathSymmetryClass:{_name:"",_classID:"pathSymmetryClass",pathSymmetryMode:`pathSymmetryModeEnum.${o.symmetryMode}`}}:{}))};(0,v.writeVersionAndDescriptor)(e,"","pathsDataClass",i)});U("lyvr",le("version"),(e,n)=>n.version=(0,b.readUint32)(e),(e,n)=>(0,w.writeUint32)(e,n.version));U("lfxs",e=>e.effects!==void 0&&Ts(e),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lfxs version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});function Ee(e){return n=>!!n.adjustment&&n.adjustment.type===e}U("brit",Ee("brightness/contrast"),(e,n,t)=>{n.adjustment||(n.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,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeInt16)(e,i.brightness||0),(0,w.writeInt16)(e,i.contrast||0),(0,w.writeInt16)(e,(t=i.meanValue)!==null&&t!==void 0?t:127),(0,w.writeUint8)(e,i.labColorOnly?1:0),(0,w.writeZeros)(e,1)});function qf(e){let n=(0,b.readInt16)(e),t=(0,b.readInt16)(e),i=(0,b.readInt16)(e),o=(0,b.readInt16)(e),r=(0,b.readInt16)(e)/100;return{shadowInput:n,highlightInput:t,shadowOutput:i,highlightOutput:o,midtoneInput:r}}var Zf={shadowInput:0,highlightInput:255,shadowOutput:0,highlightOutput:255,midtoneInput:1};function em(e){return e.shadowInput===0&&e.highlightInput===255&&e.shadowOutput===0&&e.highlightOutput===255&&e.midtoneInput===1}function Kf(e,n){(0,w.writeInt16)(e,n.shadowInput),(0,w.writeInt16)(e,n.highlightInput),(0,w.writeInt16)(e,n.shadowOutput),(0,w.writeInt16)(e,n.highlightOutput),(0,w.writeInt16)(e,Math.round(n.midtoneInput*100))}U("levl",Ee("levels"),(e,n,t)=>{if((0,b.readUint16)(e)!==2)throw new Error("Invalid levl version");let i=[];for(let o=0;o<29&&t()>=10;o++)i.push(qf(e));if(t()>=8){let o=(0,b.readSignature)(e),r;if(o==="ls\0")r=(0,b.readUint16)(e);else{if(o!=="Lvls")throw new Error("Invalid levl signature");if((0,b.readUint16)(e)!==3)throw new Error("Invalid levl version");r=(0,b.readUint16)(e)}for(;i.length<r&&t()>=10;)i.push(qf(e))}for(;i.length&&em(i[i.length-1]);)i.pop();n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"levels",channels:i}),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment.channels||[];(0,w.writeUint16)(e,2);for(let i=0;i<29;i++)Kf(e,t[i]||Zf);(0,w.writeSignature)(e,"Lvls"),(0,w.writeUint16)(e,3),(0,w.writeUint16)(e,62);for(let i=29;i<62;i++)Kf(e,t[i]||Zf)});function tm(e){let n=(0,b.readUint16)(e),t=[];for(let i=0;i<n;i++){let o=(0,b.readInt16)(e),r=(0,b.readInt16)(e);t.push({input:r,output:o})}return t}function nm(e,n){(0,w.writeUint16)(e,n.length);for(let t of n)(0,w.writeUint16)(e,t.output),(0,w.writeUint16)(e,t.input)}U("curv",Ee("curves"),(e,n,t)=>{let i=!!(0,b.readUint8)(e),o=(0,b.readUint16)(e);if(o!==1&&o!==4)throw new Error("Invalid curv version");let r=(0,b.readUint32)(e),s=[],a=()=>i?Array.from((0,b.readBytes)(e,256)):tm(e);if(o===1){for(let l=0;l<32;l++)if(r&1<<l){for(;s.length<l;)s.push([]);s.push(a())}}else{if(r>64)throw new Error("Invalid curv channel count");for(let l=0;l<r;l++)s.push(a())}if(o===1&&t()>=10&&(0,b.readSignature)(e)==="Crv "){(0,b.readUint16)(e);let l=(0,b.readUint32)(e);for(let c=0;c<l&&t()>=2;c++){let f=(0,b.readUint16)(e),u=a();for(;s.length<f;)s.push([]);s[f]=u}}n.adjustment=Object.assign(Object.assign(Object.assign({},n.adjustment),{type:"curves"}),i?{values:s}:{channels:s}),(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment,o=!!i.values,r=(o?i.values:i.channels)||[],s=[],a=0;for(let c=0;c<r.length;c++)!((t=r[c])===null||t===void 0)&&t.length&&(c<32&&(a|=1<<c),s.push(c));let l=c=>{var f;if(o)for(let u=0;u<256;u++)(0,w.writeUint8)(e,(0,De.clamp)(Math.round((f=c[u])!==null&&f!==void 0?f:u),0,255));else nm(e,c)};(0,w.writeUint8)(e,o?1:0),(0,w.writeUint16)(e,1),(0,w.writeUint32)(e,a>>>0);for(let c of s)c<32&&l(r[c]);(0,w.writeSignature)(e,"Crv "),(0,w.writeUint16)(e,4),(0,w.writeUint32)(e,s.length);for(let c of s)(0,w.writeUint16)(e,c),l(r[c])});U("expA",Ee("exposure"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid expA version");n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"exposure",exposure:(0,b.readFloat32)(e),offset:(0,b.readFloat32)(e),gamma:(0,b.readFloat32)(e)}),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeFloat32)(e,t.exposure),(0,w.writeFloat32)(e,t.offset),(0,w.writeFloat32)(e,t.gamma),(0,w.writeZeros)(e,2)});U("vibA",Ee("vibrance"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.adjustment={type:"vibrance"},i.vibrance!==void 0&&(n.adjustment.vibrance=i.vibrance),i.Strt!==void 0&&(n.adjustment.saturation=i.Strt),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={};t.vibrance!==void 0&&(i.vibrance=t.vibrance),t.saturation!==void 0&&(i.Strt=t.saturation),(0,v.writeVersionAndDescriptor)(e,"","null",i)});function $n(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 Vn(e,n){let t=n||{};(0,w.writeInt16)(e,t.a||0),(0,w.writeInt16)(e,t.b||0),(0,w.writeInt16)(e,t.c||0),(0,w.writeInt16)(e,t.d||0),(0,w.writeInt16)(e,t.hue||0),(0,w.writeInt16)(e,t.saturation||0),(0,w.writeInt16)(e,t.lightness||0)}U("hue2",Ee("hue/saturation"),(e,n,t)=>{if((0,b.readUint16)(e)!==2)throw new Error("Invalid hue2 version");let i=!!(0,b.readUint8)(e);(0,b.skipBytes)(e,1);let o=(0,b.readInt16)(e),r=(0,b.readInt16)(e),s=(0,b.readInt16)(e);n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"hue/saturation",colorize:i,colorization:{hue:o<0?o+360:o,saturation:r,lightness:s},master:{hue:(0,b.readInt16)(e),saturation:(0,b.readInt16)(e),lightness:(0,b.readInt16)(e)},reds:$n(e),yellows:$n(e),greens:$n(e),cyans:$n(e),blues:$n(e),magentas:$n(e)}),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s,a,l,c,f,u,d,p;let h=n.adjustment;(0,w.writeUint16)(e,2),(0,w.writeUint8)(e,h.colorize?1:0),(0,w.writeUint8)(e,0);let m=Math.round((i=(t=h.colorization)===null||t===void 0?void 0:t.hue)!==null&&i!==void 0?i:0);(0,w.writeInt16)(e,m>180?m-360:m),(0,w.writeInt16)(e,Math.round((r=(o=h.colorization)===null||o===void 0?void 0:o.saturation)!==null&&r!==void 0?r:0)),(0,w.writeInt16)(e,Math.round((a=(s=h.colorization)===null||s===void 0?void 0:s.lightness)!==null&&a!==void 0?a:0)),(0,w.writeInt16)(e,Math.round((c=(l=h.master)===null||l===void 0?void 0:l.hue)!==null&&c!==void 0?c:0)),(0,w.writeInt16)(e,Math.round((u=(f=h.master)===null||f===void 0?void 0:f.saturation)!==null&&u!==void 0?u:0)),(0,w.writeInt16)(e,Math.round((p=(d=h.master)===null||d===void 0?void 0:d.lightness)!==null&&p!==void 0?p:0)),Vn(e,h.reds),Vn(e,h.yellows),Vn(e,h.greens),Vn(e,h.cyans),Vn(e,h.blues),Vn(e,h.magentas)});function Ds(e){return{cyanRed:(0,b.readInt16)(e),magentaGreen:(0,b.readInt16)(e),yellowBlue:(0,b.readInt16)(e)}}function Os(e,n){(0,w.writeInt16)(e,n.cyanRed||0),(0,w.writeInt16)(e,n.magentaGreen||0),(0,w.writeInt16)(e,n.yellowBlue||0)}U("blnc",Ee("color balance"),(e,n,t)=>{n.adjustment={type:"color balance",shadows:Ds(e),midtones:Ds(e),highlights:Ds(e),preserveLuminosity:!!(0,b.readUint8)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;Os(e,t.shadows||{}),Os(e,t.midtones||{}),Os(e,t.highlights||{}),(0,w.writeUint8)(e,t.preserveLuminosity?1:0),(0,w.writeZeros)(e,1)});U("blwh",Ee("black & white"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.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&&(n.adjustment.tintColor=(0,v.parseColor)(i.tintColor)),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={"Rd ":t.reds||0,Yllw:t.yellows||0,"Grn ":t.greens||0,"Cyn ":t.cyans||0,"Bl ":t.blues||0,Mgnt:t.magentas||0,useTint:!!t.useTint,tintColor:(0,v.serializeColor)(t.tintColor),bwPresetKind:t.presetKind||0,blackAndWhitePresetFileName:t.presetFileName||""};(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("phfl",Ee("photo filter"),(e,n,t)=>{let i=(0,b.readUint16)(e);if(i!==2&&i!==3)throw new Error("Invalid phfl version");let o;if(i===2)o=(0,b.readColor)(e);else{let r=(0,b.readInt32)(e)/32768,s=(0,b.readInt32)(e)/32768,a=(0,b.readInt32)(e)/32768;if(!(r>=0&&s>=0&&a>=0&&r<=2&&s<=2&&a<=2))throw new Error("Invalid phfl XYZ color");let l=c=>c>216/24389?Math.cbrt(c):(24389/27*c+16)/116;o={l:Math.max(0,116*l(s)-16)/100,a:(0,De.normalizeLabAB)(500*(l(r)-l(s))),b:(0,De.normalizeLabAB)(200*(l(s)-l(a)))}}n.adjustment={type:"photo filter",color:o,density:(0,b.readUint32)(e)/100,preserveLuminosity:!!(0,b.readUint8)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,2),(0,w.writeColor)(e,t.color||{l:0,a:0,b:0}),(0,w.writeUint32)(e,Math.round(Math.max(0,t.density||0)*100)),(0,w.writeUint8)(e,t.preserveLuminosity?1:0),(0,w.writeZeros)(e,3)});function xo(e){let n=(0,b.readInt16)(e),t=(0,b.readInt16)(e),i=(0,b.readInt16)(e);(0,b.skipBytes)(e,2);let o=(0,b.readInt16)(e);return{red:n,green:t,blue:i,constant:o}}function _i(e,n){let t=n||{};(0,w.writeInt16)(e,t.red),(0,w.writeInt16)(e,t.green),(0,w.writeInt16)(e,t.blue),(0,w.writeZeros)(e,2),(0,w.writeInt16)(e,t.constant)}U("mixr",Ee("channel mixer"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid mixr version");let i=n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"channel mixer",monochrome:!!(0,b.readUint16)(e)});i.monochrome||(i.red=xo(e),i.green=xo(e),i.blue=xo(e)),i.gray=xo(e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeUint16)(e,t.monochrome?1:0),t.monochrome?(_i(e,t.gray),(0,w.writeZeros)(e,30)):(_i(e,t.red),_i(e,t.green),_i(e,t.blue),_i(e,t.gray))});var Yf=(0,De.createEnum)("colorLookupType","3dlut",{"3dlut":"3DLUT",abstractProfile:"abstractProfile",deviceLinkProfile:"deviceLinkProfile"}),Jf=(0,De.createEnum)("LUTFormatType","look",{look:"LUTFormatLOOK",cube:"LUTFormatCUBE","3dl":"LUTFormat3DL"}),ko=(0,De.createEnum)("colorLookupOrder","rgb",{rgb:"rgbOrder",bgr:"bgrOrder"});U("clrL",Ee("color lookup"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid clrL version");let i=(0,v.readVersionAndDescriptor)(e);n.adjustment={type:"color lookup"};let o=n.adjustment;i.lookupType!==void 0&&(o.lookupType=Yf.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=Jf.decode(i.LUTFormat)),i.dataOrder!==void 0&&(o.dataOrder=ko.decode(i.dataOrder)),i.tableOrder!==void 0&&(o.tableOrder=ko.decode(i.tableOrder)),i.LUT3DFileData!==void 0&&(o.lut3DFileData=i.LUT3DFileData),i.LUT3DFileName!==void 0&&(o.lut3DFileName=i.LUT3DFileName),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={};t.lookupType!==void 0&&(i.lookupType=Yf.encode(t.lookupType)),t.name!==void 0&&(i["Nm "]=t.name),t.dither!==void 0&&(i.Dthr=t.dither),t.profile!==void 0&&(i.profile=t.profile),t.lutFormat!==void 0&&(i.LUTFormat=Jf.encode(t.lutFormat)),t.dataOrder!==void 0&&(i.dataOrder=ko.encode(t.dataOrder)),t.tableOrder!==void 0&&(i.tableOrder=ko.encode(t.tableOrder)),t.lut3DFileData!==void 0&&(i.LUT3DFileData=t.lut3DFileData),t.lut3DFileName!==void 0&&(i.LUT3DFileName=t.lut3DFileName),(0,w.writeUint16)(e,1),(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("nvrt",Ee("invert"),(e,n,t)=>{n.adjustment={type:"invert"},(0,b.skipBytes)(e,t())},()=>{});U("post",Ee("posterize"),(e,n,t)=>{n.adjustment={type:"posterize",levels:(0,b.readUint16)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeUint16)(e,(t=i.levels)!==null&&t!==void 0?t:4),(0,w.writeZeros)(e,2)});U("thrs",Ee("threshold"),(e,n,t)=>{n.adjustment={type:"threshold",level:(0,b.readUint16)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeUint16)(e,(t=i.level)!==null&&t!==void 0?t:128),(0,w.writeZeros)(e,2)});var Qf=["","","","rgb","hsb","","lab"];U("grdm",Ee("gradient map"),(e,n,t)=>{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=v.gradientInterpolationMethodType.decode(`gradientInterpolationMethodType.${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=Qf[(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,t());for(let u of o.colorStops)u.location/=4096;for(let u of o.opacityStops)u.location/=4096;n.adjustment=o},(e,n)=>{var t,i,o;let r=n.adjustment;(0,w.writeUint16)(e,r.method!==void 0?3:1),(0,w.writeUint8)(e,r.reverse?1:0),(0,w.writeUint8)(e,r.dither?1:0),r.method!==void 0&&(0,w.writeSignature)(e,v.gradientInterpolationMethodType.encode(r.method).split(".")[1]),(0,w.writeUnicodeStringWithPadding)(e,r.name||""),(0,w.writeUint16)(e,r.colorStops&&r.colorStops.length||0);let s=Math.round((0,De.clamp)((t=r.smoothness)!==null&&t!==void 0?t:1,0,1)*4096);for(let l of r.colorStops||[])(0,w.writeUint32)(e,Math.round((0,De.clamp)(l.location,0,1)*4096)),(0,w.writeUint32)(e,Math.round(l.midpoint*100)),(0,w.writeColor)(e,l.color),(0,w.writeZeros)(e,2);(0,w.writeUint16)(e,r.opacityStops&&r.opacityStops.length||0);for(let l of r.opacityStops||[])(0,w.writeUint32)(e,Math.round((0,De.clamp)(l.location,0,1)*4096)),(0,w.writeUint32)(e,Math.round(l.midpoint*100)),(0,w.writeUint16)(e,Math.round((0,De.clamp)(l.opacity,0,1)*255));(0,w.writeUint16)(e,2),(0,w.writeUint16)(e,s),(0,w.writeUint16)(e,32),(0,w.writeUint16)(e,r.gradientType==="noise"?1:0),(0,w.writeUint32)(e,r.randomSeed||0),(0,w.writeUint16)(e,r.addTransparency?1:0),(0,w.writeUint16)(e,r.restrictColors?1:0),(0,w.writeUint32)(e,Math.round(((i=r.roughness)!==null&&i!==void 0?i:1)*4096));let a=Qf.indexOf((o=r.colorModel)!==null&&o!==void 0?o:"rgb");(0,w.writeUint16)(e,a===-1?3:a);for(let l=0;l<4;l++)(0,w.writeUint16)(e,Math.round((r.min&&r.min[l]||0)*32768));for(let l=0;l<4;l++)(0,w.writeUint16)(e,Math.round((r.max&&r.max[l]||0)*32768));(0,w.writeZeros)(e,4)});function Lt(e){return{c:(0,b.readInt16)(e),m:(0,b.readInt16)(e),y:(0,b.readInt16)(e),k:(0,b.readInt16)(e)}}function Mt(e,n){let t=n||{};(0,w.writeInt16)(e,t.c),(0,w.writeInt16)(e,t.m),(0,w.writeInt16)(e,t.y),(0,w.writeInt16)(e,t.k)}U("selc",Ee("selective color"),(e,n)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid selc version");let t=(0,b.readUint16)(e)?"absolute":"relative";(0,b.skipBytes)(e,8),n.adjustment={type:"selective color",mode:t,reds:Lt(e),yellows:Lt(e),greens:Lt(e),cyans:Lt(e),blues:Lt(e),magentas:Lt(e),whites:Lt(e),neutrals:Lt(e),blacks:Lt(e)}},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeUint16)(e,t.mode==="absolute"?1:0),(0,w.writeZeros)(e,8),Mt(e,t.reds),Mt(e,t.yellows),Mt(e,t.greens),Mt(e,t.cyans),Mt(e,t.blues),Mt(e,t.magentas),Mt(e,t.whites),Mt(e,t.neutrals),Mt(e,t.blacks)});U("CgEd",e=>{let n=e.adjustment;return n?n.type==="brightness/contrast"&&!n.useLegacy||(n.type==="levels"||n.type==="curves"||n.type==="exposure"||n.type==="channel mixer"||n.type==="hue/saturation")&&n.presetFileName!==void 0:!1},(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);if(i.Vrsn!==1)throw new Error("Invalid CgEd version");"presetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.presetKind,presetFileName:i.presetFileName}):"curvesPresetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.curvesPresetKind,presetFileName:i.curvesPresetFileName}):"mixerPresetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.mixerPresetKind,presetFileName:i.mixerPresetFileName}):n.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,t())},(e,n)=>{var t,i,o,r;let s=n.adjustment;if(s.type==="levels"||s.type==="exposure"||s.type==="hue/saturation"){let a={Vrsn:1,presetKind:(t=s.presetKind)!==null&&t!==void 0?t:1,presetFileName:s.presetFileName||""};(0,v.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,v.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,v.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,v.writeVersionAndDescriptor)(e,"","null",a)}else throw new Error("Unhandled CgEd case")});function im(e){let n=[];function t(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&&(n[r.text.index]=r),t(r)}return t(e),n}U("Txt2",le("engineData"),(e,n,t,i)=>{let o=(0,b.readBytes)(e,t());n.engineData=(0,Bf.fromByteArray)(o);let r=im(i),s=(0,Es.parseEngineData)(o,e),l=(0,$g.decodeEngineData2)(s).ResourceDict.TextFrameSet;if(l)for(let c=0;c<l.length;c++){let f=r[c];l[c].path&&f?.text&&(f.text.textPath=l[c].path)}},(e,n)=>{let t=(0,Bf.toByteArray)(n.engineData);(0,w.writeBytes)(e,t)});U("FEid",le("filterEffectsMasks"),(e,n,t,i)=>{let o=(0,b.readInt32)(e);if(o<1||o>3)throw new Error(`Invalid filterEffects version ${o}`);for(n.filterEffectsMasks=[];t()>8;){if((0,b.readUint32)(e))throw new Error("filterEffects: 64 bit length is not supported");let r=(0,b.readUint32)(e),s=e.offset+r,a=(0,b.readPascalString)(e,1),l=(0,b.readInt32)(e);if(l!==1)throw new Error(`Invalid filterEffect version ${l}`);if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");(0,b.readUint32)(e);let c=(0,b.readInt32)(e),f=(0,b.readInt32)(e),u=(0,b.readInt32)(e),d=(0,b.readInt32)(e),p=(0,b.readInt32)(e),h=(0,b.readInt32)(e),m=[];for(let g=0;g<h+2;g++)if((0,b.readInt32)(e)){if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let x=(0,b.readUint32)(e);if(!x)throw new Error("filterEffect: Empty channel");let S=(0,b.readUint16)(e);if(x-2>t())throw new Error("filterEffect: Invalid channel length");let A=(0,b.readBytes)(e,x-2);m.push({compressionMode:S,data:A})}else m.push(void 0);if(n.filterEffectsMasks.push({id:a,top:c,left:f,bottom:u,right:d,depth:p,colorMode:i.colorMode,channels:m}),e.offset<s&&(0,b.readUint8)(e)){let g=(0,b.readInt32)(e),k=(0,b.readInt32)(e),x=(0,b.readInt32)(e),S=(0,b.readInt32)(e);if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let A=(0,b.readUint32)(e),D=(0,b.readUint16)(e);if(A-2>t())throw new Error("filterEffect: Invalid extra channel length");let C=(0,b.readBytes)(e,A-2);n.filterEffectsMasks[n.filterEffectsMasks.length-1].extra={top:g,left:k,bottom:x,right:S,compressionMode:D,data:C}}e.offset=s;let y=r;for(;y%4;)e.offset++,y++}},(e,n)=>{(0,w.writeInt32)(e,3);for(let t of n.filterEffectsMasks){(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,0);let i=e.offset;(0,w.writePascalString)(e,t.id,1),(0,w.writeInt32)(e,1),(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,0);let o=e.offset;(0,w.writeInt32)(e,t.top),(0,w.writeInt32)(e,t.left),(0,w.writeInt32)(e,t.bottom),(0,w.writeInt32)(e,t.right),(0,w.writeInt32)(e,t.depth);let r=Math.max(0,t.channels.length-2);(0,w.writeInt32)(e,r);for(let l=0;l<r+2;l++){let c=t.channels[l];(0,w.writeInt32)(e,c?1:0),c&&((0,w.writeUint32)(e,0),(0,w.writeUint32)(e,c.data.length+2),(0,w.writeUint16)(e,c.compressionMode),(0,w.writeBytes)(e,c.data))}e.view.setUint32(o-4,e.offset-o,!1);let s=t.extra;s&&((0,w.writeUint8)(e,1),(0,w.writeInt32)(e,s.top),(0,w.writeInt32)(e,s.left),(0,w.writeInt32)(e,s.bottom),(0,w.writeInt32)(e,s.right),(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,s.data.byteLength+2),(0,w.writeUint16)(e,s.compressionMode),(0,w.writeBytes)(e,s.data));let a=e.offset-i;for(e.view.setUint32(i-4,a,!1);a%4;)(0,w.writeZeros)(e,1),a++}});lt("FXid","FEid");lt("FELS","FEid");lt("hue ","hue2");lt("plLd","PlLd");lt("abdd","artb");U("FMsk",le("filterMask"),(e,n)=>{n.filterMask={colorSpace:(0,b.readColor)(e),opacity:(0,b.readUint16)(e)/100}},(e,n)=>{var t;(0,w.writeColor)(e,n.filterMask.colorSpace),(0,w.writeUint16)(e,Math.round((0,De.clamp)((t=n.filterMask.opacity)!==null&&t!==void 0?t:1,0,1)*100))});U("artd",e=>e.artboards!==void 0,(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=n.artboards={count:i["Cnt "]};i.autoExpandOffset&&(o.autoExpandOffset={horizontal:i.autoExpandOffset.Hrzn,vertical:i.autoExpandOffset.Vrtc}),i.origin&&(o.origin={horizontal:i.origin.Hrzn,vertical:i.origin.Vrtc}),i.autoExpandEnabled!==void 0&&(o.autoExpandEnabled=i.autoExpandEnabled),i.autoNestEnabled!==void 0&&(o.autoNestEnabled=i.autoNestEnabled),i.autoPositionEnabled!==void 0&&(o.autoPositionEnabled=i.autoPositionEnabled),o.shrinkwrapOnSaveEnabled=!!i.shrinkwrapOnSaveEnabled,i.docDefaultNewArtboardBackgroundColor&&(o.docDefaultNewArtboardBackgroundColor=(0,v.parseColor)(i.docDefaultNewArtboardBackgroundColor)),i.docDefaultNewArtboardBackgroundType!==void 0&&(o.docDefaultNewArtboardBackgroundType=i.docDefaultNewArtboardBackgroundType),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s;let a=n.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:(t=a.autoExpandEnabled)!==null&&t!==void 0?t:!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,v.serializeColor)(a.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:(s=a.docDefaultNewArtboardBackgroundType)!==null&&s!==void 0?s:1};(0,v.writeVersionAndDescriptor)(e,"","null",l,"artd")});function Ts(e){return!!e.children}function Co(e){return Object.keys(e).map(n=>e[n]).some(n=>Array.isArray(n)&&n.length>1)}U("lfx2",e=>e.effects!==void 0&&!Ts(e)&&!Co(e.effects),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lfx2 version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("cinf",le("compositorUsed"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);function o(r){return r.split(".")[1]}n.compositorUsed={description:i.description,reason:i.reason,engine:o(i.Engn)},i.Vrsn&&(n.compositorUsed.version=i.Vrsn),i.psVersion&&(n.compositorUsed.photoshopVersion=i.psVersion),i.enableCompCore&&(n.compositorUsed.enableCompCore=o(i.enableCompCore)),i.enableCompCoreGPU&&(n.compositorUsed.enableCompCoreGPU=o(i.enableCompCoreGPU)),i.enableCompCoreThreads&&(n.compositorUsed.enableCompCoreThreads=o(i.enableCompCoreThreads)),i.compCoreSupport&&(n.compositorUsed.compCoreSupport=o(i.compCoreSupport)),i.compCoreGPUSupport&&(n.compositorUsed.compCoreGPUSupport=o(i.compCoreGPUSupport)),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.compositorUsed,i={Vrsn:t.version||{major:1,minor:0,fix:0}};t.photoshopVersion&&(i.psVersion=t.photoshopVersion),i.description=t.description,i.reason=t.reason,i.Engn=`Engn.${t.engine}`,t.enableCompCore&&(i.enableCompCore=`enable.${t.enableCompCore}`),t.enableCompCoreGPU&&(i.enableCompCoreGPU=`enable.${t.enableCompCoreGPU}`),t.enableCompCoreThreads&&(i.enableCompCoreThreads=`enable.${t.enableCompCoreThreads}`),t.compCoreSupport&&(i.compCoreSupport=`reason.${t.compCoreSupport}`),t.compCoreGPUSupport&&(i.compCoreGPUSupport=`reason.${t.compCoreGPUSupport}`),(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("extn",e=>e.generatorSettings!==void 0&&Ls(e),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);i.generatorSettings&&(n.generatorSettings=Us(i.generatorSettings)),(0,b.skipBytes)(e,t())},(e,n)=>{(0,v.writeVersionAndDescriptor)(e,"","null",rd(n.generatorSettings))});U("extd",()=>!1,(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);i.generatorSettings&&n.generatorSettings===void 0&&(n.generatorSettings=Us(i.generatorSettings)),(0,b.skipBytes)(e,t())},()=>{});U("frgb",le("framedGroup"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=i.framedGroupRect;n.framedGroup={rect:{top:o["Top "],left:o.Left,bottom:o.Btom,right:o.Rght},type:i.framedGroupType},i.LockPPI!==void 0&&(n.framedGroup.lockPPI=i.LockPPI),i.PreferredResolution!==void 0&&(n.framedGroup.preferredResolution=i.PreferredResolution),i.SavedIteratedName!==void 0&&(n.framedGroup.savedIteratedName=i.SavedIteratedName),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.framedGroup,i=t.rect,o={framedGroupRect:{_name:"",_classID:"classFloatRect","Top ":i.top,Left:i.left,Btom:i.bottom,Rght:i.right},framedGroupType:t.type};t.lockPPI!==void 0&&(o.LockPPI=t.lockPPI),t.preferredResolution!==void 0&&(o.PreferredResolution=t.preferredResolution),t.savedIteratedName!==void 0&&(o.SavedIteratedName=t.savedIteratedName),(0,v.writeVersionAndDescriptor)(e,"","framedGroup",o)});U("anFX",le("animationEffects"),(e,n,t)=>{n.animationEffects=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n.animationEffects)});U("PxSD",le("pixelSourceData"),(e,n,t)=>{for(n.pixelSourceData=[];t()>=8;){let i=_o(e);if(i>t())throw new Error("Invalid PxSD data length");n.pixelSourceData.push((0,b.readBytes)(e,i))}(0,b.skipBytes)(e,t())},(e,n)=>{for(let t of n.pixelSourceData)(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,t.byteLength),(0,w.writeBytes)(e,t)});U("iOpa",le("fillOpacity"),(e,n)=>{n.fillOpacity=(0,b.readUint8)(e)/255,(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,Math.round((0,De.clamp)(n.fillOpacity,0,1)*255)),(0,w.writeZeros)(e,3)});U("brst",le("channelBlendingRestrictions"),(e,n,t)=>{for(n.channelBlendingRestrictions=[];t()>=4;)n.channelBlendingRestrictions.push((0,b.readInt32)(e))},(e,n)=>{for(let t of n.channelBlendingRestrictions)(0,w.writeInt32)(e,t)});U("tsly",le("transparencyShapesLayer"),(e,n)=>{n.transparencyShapesLayer=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.transparencyShapesLayer?1:0),(0,w.writeZeros)(e,3)})});var En=ae(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.createWriter=sm;ue.getWriterBuffer=am;ue.getWriterBufferNoCopy=lm;ue.writeUint8=ye;ue.writeInt16=Zt;ue.writeUint16=q;ue.writeUint16LE=md;ue.writeInt32=je;ue.writeInt32LE=cm;ue.writeUint32=me;ue.writeFloat32=fm;ue.writeFloat64=Vs;ue.writeFixedPoint32=dm;ue.writeFixedPointPath32=um;ue.writeBytes=Ai;ue.writeZeros=Gn;ue.writeSignature=Ut;ue.writeAsciiString=pm;ue.writePascalString=Oo;ue.writeUnicodeStringWithoutLength=yd;ue.writeUnicodeStringWithoutLengthLE=hm;ue.writeUnicodeString=bd;ue.writeUnicodeStringWithPadding=gm;ue.getRLEChannelBound=Eo;ue.writeUint64=wd;ue.writeSection=Ke;ue.writePsd=bm;ue.writeColor=Lm;ue.writePattern=Mm;var re=Ot(),om=Gi(),dd=di(),rm=qr(),Do=st();function sm(e=4096){let n=new ArrayBuffer(e),t=new DataView(n);return{buffer:n,view:t,offset:0,tempBuffer:void 0,log:console.log}}function am(e){return e.buffer.slice(0,e.offset)}function lm(e){return new Uint8Array(e.buffer,0,e.offset)}function ye(e,n){let t=Bt(e,1);e.view.setUint8(t,n)}function Zt(e,n){let t=Bt(e,2);e.view.setInt16(t,n,!1)}function q(e,n){let t=Bt(e,2);e.view.setUint16(t,n,!1)}function md(e,n){let t=Bt(e,2);e.view.setUint16(t,n,!0)}function je(e,n){let t=Bt(e,4);e.view.setInt32(t,n,!1)}function cm(e,n){let t=Bt(e,4);e.view.setInt32(t,n,!0)}function me(e,n){let t=Bt(e,4);e.view.setUint32(t,n,!1)}function fm(e,n){let t=Bt(e,4);e.view.setFloat32(t,n,!1)}function Vs(e,n){let t=Bt(e,8);e.view.setFloat64(t,n,!1)}function dm(e,n){je(e,n*65536)}function um(e,n){je(e,n*(1<<24))}function Ai(e,n){n&&(Ws(e,e.offset+n.length),new Uint8Array(e.buffer).set(n,e.offset),e.offset+=n.length)}function Gn(e,n){for(let t=0;t<n;t++)ye(e,0)}function Ut(e,n){if(n.length!==4)throw new Error(`Invalid signature: '${n}'`);for(let t=0;t<4;t++)ye(e,n.charCodeAt(t))}function pm(e,n){for(let t=0;t<n.length;t++)ye(e,n.charCodeAt(t))}function Oo(e,n,t){let i=n.length;if(i>255)throw new Error("String too long");ye(e,i);for(let o=0;o<i;o++){let r=n.charCodeAt(o);ye(e,r<128?r:63)}for(;++i%t;)ye(e,0)}function yd(e,n){for(let t=0;t<n.length;t++)q(e,n.charCodeAt(t))}function hm(e,n){for(let t=0;t<n.length;t++)md(e,n.charCodeAt(t))}function bd(e,n){me(e,n.length),yd(e,n)}function gm(e,n){me(e,n.length+1);for(let t=0;t<n.length;t++)q(e,n.charCodeAt(t));q(e,0)}function Eo(e,n,t){return n*((t?4:2)+e+Math.ceil(e/128))}function Gs(e=[],n){let t=0;for(let i of e){for(let o of[i,i.mask,i.realMask])if(o){let{width:r,height:s}=Xs(o);t=Math.max(t,Eo(r,s,n))}i.children&&(t=Math.max(t,Gs(i.children,n)))}return t}function wd(e,n){me(e,Math.floor(n/4294967296)),me(e,n>>>0)}function Ke(e,n,t,i=!1,o=!1){let r=e.offset;o&&me(e,0),me(e,0);let s=e.offset;t();let a=e.offset-s,l=a;for(;l%n;)ye(e,0),l++;if(i&&(a=l),o)e.view.setUint32(r,Math.floor(a/4294967296),!1),e.view.setUint32(r+4,a>>>0,!1);else{if(a>4294967295)throw new Error("Section too large, use PSB format instead");e.view.setUint32(r,a,!1)}}function js(e,n){let t=e&&e.data.BYTES_PER_ELEMENT;if(t!==void 0&&t!==1&&t!==2&&!(e.data instanceof Float32Array))throw new Error(`${n} has incorrect bitDepth (only Uint8Array, Uint8ClampedArray, Uint16Array and Float32Array data is supported for writing)`)}var mm={0:[1],1:[8,16,32],2:[8],3:[8,16,32],4:[8,16]},zs={0:"Bitmap",1:"Grayscale",2:"Indexed",3:"RGB",4:"CMYK",7:"Multichannel",8:"Duotone",9:"Lab"};function vd(e){return e===3?3:e===4?4:1}var ym=[104,100,114,116,0,0,0,3,62,107,133,31,0,0,0,2,0,0,0,7,0,76,0,105,0,110,0,101,0,97,0,114,0,0,0,2,0,2,0,0,0,0,0,255,0,255,1,1,0,0,0,0,0,0,0,0,65,128,0,0,0,0,0,1,0,0,0,0,63,128,0,0,104,100,114,97,0,0,0,6,0,0,0,0,65,160,0,0,65,240,0,0,0,0,0,0,0,0,0,0,63,128,0,0,0,0,0,0,0,0];function Sd(e){var n,t,i;(n=e.children)===null||n===void 0||n.forEach(Sd),js(e.imageData,"imageData"),"mask"in e&&js((t=e.mask)===null||t===void 0?void 0:t.imageData,"mask imageData"),"realMask"in e&&js((i=e.realMask)===null||i===void 0?void 0:i.imageData,"realMask imageData")}function bm(e,n,t={}){var i,o,r,s;if(!(+n.width>0&&+n.height>0))throw new Error("Invalid document size");if((n.width>3e4||n.height>3e4)&&!t.psb)throw new Error("Document size is too large (max is 30000x30000, use PSB format instead)");let a=(i=n.colorMode)!==null&&i!==void 0?i:3,l=(o=n.bitsPerChannel)!==null&&o!==void 0?o:a===0?1:8,c=mm[a];if(!c)throw new Error(`${(r=zs[a])!==null&&r!==void 0?r:a} color mode is not supported for writing`);if(c.indexOf(l)===-1)throw new Error(`bitsPerChannel ${l} is not supported for writing in ${zs[a]} color mode`);let f=a!==0&&a!==2;if(!f&&(!((s=n.children)===null||s===void 0)&&s.length))throw new Error(`Layers are not supported in ${zs[a]} color mode`);if(a===2&&!n.palette)throw new Error("Missing color palette for Indexed color mode");t.log&&(e.log=t.log),t.logMissingFeatures&&(e.logMissingFeatures=!0);let u=[];Ad(u,n.children),!u.length&&f&&u.push({}),Sd(n);let d=Object.assign({},n.imageResources),p=Object.assign(Object.assign({},t),{layerIds:new Set,layerToId:new Map,colorMode:a,bitsPerChannel:l}),h=l===16||l===32;p.generateThumbnail&&(d.thumbnail=Pm(n));let m=n.imageData;if(!m&&n.canvas&&(m=n.canvas.getContext("2d").getImageData(0,0,n.canvas.width,n.canvas.height)),!m&&n.rawCompositeData&&(m=(0,Do.getCompositeImageData)(n)),m&&(n.width!==m.width||n.height!==m.height))throw new Error("Document canvas must have the same size as document");let y=!!m&&f&&(0,re.hasAlpha)(m);if(e.tempBuffer=new Uint8Array(Gs(n.children,!!t.psb)),Ut(e,"8BPS"),q(e,t.psb?2:1),Gn(e,6),q(e,vd(a)+(y?1:0)),me(e,n.height),me(e,n.width),q(e,l),q(e,a),Ke(e,1,()=>{var g,k,x,S,A,D;if(a===2){let C=n.palette;for(let O=0;O<256;O++)ye(e,(k=(g=C[O])===null||g===void 0?void 0:g.r)!==null&&k!==void 0?k:0);for(let O=0;O<256;O++)ye(e,(S=(x=C[O])===null||x===void 0?void 0:x.g)!==null&&S!==void 0?S:0);for(let O=0;O<256;O++)ye(e,(D=(A=C[O])===null||A===void 0?void 0:A.b)!==null&&D!==void 0?D:0)}else l===32&&Ai(e,new Uint8Array(ym))}),d.layersGroup=u.map(g=>g.linkGroup||0),d.layerGroupsEnabledId=u.map(g=>g.linkGroupEnabled==!1?0:1),Ke(e,1,()=>{for(let g of rm.resourceHandlers){let k=g.has(d),x=k===!1?0:k===!0?1:k;for(let S=0;S<x;S++){let A=g.keyCount>1?g.key+S:g.key,D=g.name?g.name(d,S):"";Ut(e,"8BIM"),q(e,A),Oo(e,D,2),Ke(e,2,()=>g.write(e,d,S,n))}}}),Ke(e,2,()=>{h||!f?Ke(e,4,()=>{},!0,p.psb):km(e,u,n,y,p),Im(e,n.globalLayerMaskInfo),h&&(y&&ud(e,l===16?"Mt16":"Mt32",!!p.psb,()=>{}),ud(e,l===16?"Lr16":"Lr32",!!p.psb,()=>{kd(e,u,n,y,p)})),_d(e,n,n,p)},void 0,!!p.psb),e.tempBuffer=void 0,a===3&&l===8&&(!m||Fo(m))){q(e,1);let g=y?[0,1,2,3]:[0,1,2],k=xm(m,n.width,n.height,y),x=g.length*Eo(k.width,k.height,!!t.psb);Ws(e,e.offset+x);let S=new Uint8Array(e.buffer,e.offset,x);e.offset+=(0,re.writeDataRLE)(S,k,g,!!t.psb).length}else wm(e,n,m,a,l,y,!!t.psb)}function ud(e,n,t,i){Ut(e,t?"8B64":"8BIM"),Ut(e,n),Ke(e,4,i,!1,t)}function Fo(e){return e.data.BYTES_PER_ELEMENT===1}function Hs(e,n,t,i){let{data:o,width:r,height:s}=e,a=r*s,l=o instanceof Float32Array,c=l?1:o instanceof Uint16Array?65535:255,f=t===32,u=f?1:t===16?65535:255,d=vd(n),p=()=>f?new Float32Array(a):t===16?new Uint16Array(a):new Uint8Array(a),h=[];for(let D=0;D<d;D++)h.push(p());let m=p(),y=D=>l?Math.pow((0,re.clamp)(D,0,1),1/2.2):D/c,g=D=>f?Math.pow(D,2.2):Math.round((0,re.clamp)(D,0,1)*u),k=l===f&&c===u,x=D=>k?f?D:Math.round(D):g(y(D)),S=D=>k?D:f?D/c:Math.round((0,re.clamp)(D/c,0,1)*u),A=[0,0,0,0];for(let D=0,C=0;D<a;D++,C+=4){let O=o[C+3],E=S(O);m[D]=E;let L=i&&O!==c&&O>0?(0,re.clamp)(O/c,0,1):1;if(n===4){(0,re.rgbToCmykValues)(y(o[C]),y(o[C+1]),y(o[C+2]),A);for(let M=0;M<4;M++)h[M][D]=Math.round((1-(0,re.clamp)(A[M]*L,0,1))*u)}else for(let M=0;M<d;M++){let J;if(n===3)J=x(o[C+M]);else{let pe=o[C],R=o[C+1],ie=o[C+2];J=x(pe===R&&R===ie?pe:.299*pe+.587*R+.114*ie)}L!==1&&(J=f?J*L+1-L:Math.round(J*L+u*(1-L))),h[M][D]=J}}return{colors:h,alpha:m}}function xd(e,n,t,i){return e instanceof Uint8Array?i.compress?{data:(0,om.deflate)(e),compression:2}:{data:(0,re.writeDataRLEBytes)(e,n,t,!!i.psb),compression:1}:{data:(0,re.writeDataZipWithPrediction)(e,n,t),compression:3}}function wm(e,n,t,i,o,r,s){var a;let{width:l,height:c}=n,f=t??{data:new Uint8Array(l*c*4),width:l,height:c},u=[];if(i===0||i===2){let d=i===0?vm(f):Sm(f,n.palette,(a=n.imageResources)===null||a===void 0?void 0:a.transparencyIndex),p=i===0?Math.ceil(l/8):l;i===0?(q(e,0),u.push(d)):(q(e,1),u.push((0,re.writeDataRLEBytes)(d,p,c,s)))}else{let{colors:d,alpha:p}=Hs(f,i,o,r),h=r?[...d,p]:d;if(o===8){let m=h.map(g=>(0,re.writeDataRLEBytes)(g,l,c,s)),y=c*(s?4:2);q(e,1);for(let g of m)u.push(g.subarray(0,y));for(let g of m)u.push(g.subarray(y))}else{q(e,0);for(let m of h)u.push((0,re.planarToBytes)(m))}}for(let d of u)Ai(e,d)}function vm({data:e,width:n,height:t}){let i=Math.ceil(n/8),o=new Uint8Array(i*t),r=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let s=0,a=0;s<t;s++)for(let l=0;l<n;l++,a+=4){let c=e[a+3]/r;(.299*e[a]+.587*e[a+1]+.114*e[a+2])/r*c+(1-c)<.5&&(o[s*i+(l>>3)]|=128>>(l&7))}return o}function Sm({data:e,width:n,height:t},i,o){let r=n*t,s=new Uint8Array(r),a=e instanceof Uint16Array?8:0,l=new Map;for(let c=0;c<i.length&&c<256;c++){let f=i[c].r<<16|i[c].g<<8|i[c].b;c!==o&&!l.has(f)&&l.set(f,c)}for(let c=0,f=0;c<r;c++,f+=4){let u=k=>e instanceof Float32Array?Math.round(Math.pow((0,re.clamp)(k,0,1),.45454545454545453)*255):k>>>a,d=e instanceof Float32Array?e[f+3]*255:e[f+3]>>>a;if(o!==void 0&&o>=0&&d<128){s[c]=o;continue}let p=u(e[f]),h=u(e[f+1]),m=u(e[f+2]),y=p<<16|h<<8|m,g=l.get(y);if(g===void 0){let k=1/0;g=0;for(let x=0;x<i.length&&x<256;x++){if(x===o)continue;let S=i[x].r-p,A=i[x].g-h,D=i[x].b-m,C=S*S+A*A+D*D;C<k&&(k=C,g=x)}l.set(y,g)}s[c]=g}return s}function xm(e,n,t,i){if(!e)return{data:new Uint8Array(n*t*4),width:n,height:t};let o=n*t*4,r=e.data,s;if(i)for(let a=0;a<o;a+=4){let l=r[a+3];if(l!=0&&l!=255){s||(s=new Uint8Array(r.buffer,r.byteOffset,o).slice());let c=l/255,f=255*(1-c);s[a+0]=r[a+0]*c+f,s[a+1]=r[a+1]*c+f,s[a+2]=r[a+2]*c+f}}return s?{data:s,width:n,height:t}:e}function km(e,n,t,i,o){Ke(e,4,()=>kd(e,n,t,i,o),!0,o.psb)}function kd(e,n,t,i,o){var r;Zt(e,i?-n.length:n.length);let s=n.map((a,l)=>Dm(e,a,l===0,o));for(let a of s){let{layer:l,top:c,left:f,bottom:u,right:d,channels:p}=a;je(e,c),je(e,f),je(e,u),je(e,d),q(e,p.length);for(let m of p)Zt(e,m.id),o.psb?wd(e,m.length):me(e,m.length);Ut(e,"8BIM"),Ut(e,re.fromBlendMode[l.blendMode]||"norm"),ye(e,Math.round((0,re.clamp)((r=l.opacity)!==null&&r!==void 0?r:1,0,1)*255)),ye(e,l.clipping?1:0);let h=8;l.transparencyProtected&&(h|=1),l.hidden&&(h|=2),(l.vectorMask||l.sectionDivider&&l.sectionDivider.type!==0||l.adjustment)&&(h|=16),l.effectsOpen&&(h|=32),ye(e,h),ye(e,0),Ke(e,1,()=>{_m(e,l,a),Am(e,l),Oo(e,(l.name||"").substring(0,255),4),_d(e,l,t,o)})}for(let a of s)for(let l of a.channels)q(e,l.compression),l.data&&Ai(e,l.data)}function Ns(e){return e.mask?{mask:e.mask,realMask:e.realMask}:{mask:e.realMask,realMask:void 0}}function _m(e,n,t){let{mask:i,realMask:o}=Ns(n);Ke(e,4,()=>{if(!i&&!o)return;let r=0,s=0,a=0;i&&(i.userMaskDensity!==void 0&&(r|=1),i.userMaskFeather!==void 0&&(r|=2),i.vectorMaskDensity!==void 0&&(r|=4),i.vectorMaskFeather!==void 0&&(r|=8),i.disabled&&(s|=2),i.positionRelativeToLayer&&(s|=1),i.fromVectorData&&(s|=8),r&&(s|=16));let l=t.mask||{};if(je(e,l.top||0),je(e,l.left||0),je(e,l.bottom||0),je(e,l.right||0),ye(e,i&&i.defaultColor||0),ye(e,s),o){o.disabled&&(a|=2),o.positionRelativeToLayer&&(a|=1),o.fromVectorData&&(a|=8);let c=t.realMask||{};ye(e,a),ye(e,o.defaultColor||0),je(e,c.top||0),je(e,c.left||0),je(e,c.bottom||0),je(e,c.right||0)}r&&i&&(ye(e,r),i.userMaskDensity!==void 0&&ye(e,Math.round(i.userMaskDensity*255)),i.userMaskFeather!==void 0&&Vs(e,i.userMaskFeather),i.vectorMaskDensity!==void 0&&ye(e,Math.round(i.vectorMaskDensity*255)),i.vectorMaskFeather!==void 0&&Vs(e,i.vectorMaskFeather))},!0)}function Po(e,n){ye(e,n[0]),ye(e,n[1]),ye(e,n[2]),ye(e,n[3])}function Am(e,n){Ke(e,1,()=>{let t=n.blendingRanges;if(t){Po(e,t.compositeGrayBlendSource),Po(e,t.compositeGraphBlendDestinationRange);for(let i of t.ranges)Po(e,i.sourceRange),Po(e,i.destRange)}})}function Im(e,n){Ke(e,1,()=>{n&&(q(e,n.overlayColorSpace),q(e,n.colorSpace1),q(e,n.colorSpace2),q(e,n.colorSpace3),q(e,n.colorSpace4),q(e,Math.round((0,re.clamp)(n.opacity,0,1)*100)),ye(e,n.kind),Gn(e,3))})}function _d(e,n,t,i){for(let o of dd.infoHandlers){let r=o.key;if(!(r==="Txt2"&&i.invalidateTextLayers)&&(r==="vmsk"&&dd.infoHandlersMap.vscg.has(n)&&(r="vsms"),o.has(n))){let s=i.psb&&re.largeAdditionalInfoKeys.indexOf(r)!==-1,a=r!=="Txt2"&&r!=="cinf"&&r!=="extn"&&r!=="CAI "&&r!=="OCIO",l=r==="levl"||r==="Txt2"||r==="luni"||r==="vmsk"||r==="artb"||r==="artd"||r==="vogk"||r==="SoLd"||r==="SoLE"||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";Ut(e,s?"8B64":"8BIM"),Ut(e,r),Ke(e,l?4:2,()=>{o.write(e,n,t,i)},a,s)}}}function Ad(e,n){if(n)for(let t of n){if(t.children&&t.canvas)throw new Error("Invalid layer, cannot have both 'canvas' and 'children' properties");if(t.children&&t.imageData)throw new Error("Invalid layer, cannot have both 'imageData' and 'children' properties");t.children?(e.push({name:"</Layer group>",sectionDivider:{type:3}}),Ad(e,t.children),e.push(Object.assign(Object.assign({},t),{blendMode:t.blendMode==="pass through"?"normal":t.blendMode,sectionDivider:{type:t.opened===!1?2:1,key:re.fromBlendMode[t.blendMode]||"pass",subType:0}}))):e.push(Object.assign({},t))}}function Cm(e,n){let t=Math.max(e.buffer.byteLength*2,n),i=new ArrayBuffer(t),o=new Uint8Array(i),r=new Uint8Array(e.buffer);o.set(r),e.buffer=i,e.view=new DataView(e.buffer)}function Ws(e,n){n>e.buffer.byteLength&&Cm(e,n)}function Bt(e,n){let t=e.offset;return Ws(e,e.offset+=n),t}function Pm(e){let n=(0,re.createCanvas)(10,10),t=1;e.width>e.height?(n.width=160,n.height=Math.max(1,Math.floor(e.height*(n.width/e.width))),t=n.width/e.width):(n.height=160,n.width=Math.max(1,Math.floor(e.width*(n.height/e.height))),t=n.height/e.height);let i=n.getContext("2d");return i.scale(t,t),e.imageData?i.drawImage((0,re.imageDataToCanvas)(e.imageData),0,0):e.canvas&&i.drawImage(e.canvas,0,0),n}function pd(e,n,t,i,o){var r;let s=t.top|0,a=t.left|0,l=t.right|0,c=t.bottom|0,{width:f,height:u}=Xs(t),d=t.imageData;if(!d&&t.canvas&&f&&u&&(d=t.canvas.getContext("2d").getImageData(0,0,f,u)),d&&(d.width!==f||d.height!==u))throw new Error("Invalid imageData dimentions");l=a+f,c=s+u;let p,h,m=(r=i.bitsPerChannel)!==null&&r!==void 0?r:8;if(!d)p=new Uint8Array(0),h=1;else if(m!==8||!Fo(d)){let{colors:y}=Hs(d,3,m,!1);({data:p,compression:h}=xd(y[0],f,u,i))}else i.compress?(p=(0,re.writeDataZipWithoutPrediction)(d,[0]),h=2):(p=(0,re.writeDataRLE)(e,d,[0],!!i.psb).slice(),h=1);n.channels.push({id:o?-3:-2,compression:h,data:p,length:2+p.length}),n[o?"realMask":"mask"]={top:s,left:a,right:l,bottom:c}}function $s(e){return e?{top:e.top||0,left:e.left||0,right:e.right||0,bottom:e.bottom||0}:void 0}function Dm(e,n,t,i){var o,r;let s=n;if(n.rawData){let{colorMode:u,bitsPerChannel:d,large:p}=n.rawData,h=i;if(p===!!i.psb&&u===((o=h.colorMode)!==null&&o!==void 0?o:3)&&d===((r=h.bitsPerChannel)!==null&&r!==void 0?r:8)){let{mask:y,realMask:g}=Ns(n);return Object.assign(Object.assign({layer:n,channels:n.rawData.channels.map(k=>{var x,S;return Object.assign(Object.assign({},k),{length:2+((S=(x=k.data)===null||x===void 0?void 0:x.byteLength)!==null&&S!==void 0?S:0)})})},$s(n)),{mask:$s(y),realMask:$s(g)})}s=Object.assign(Object.assign({},n),{rawData:void 0,canvas:void 0,imageData:(0,Do.getLayerImageData)(n),mask:n.mask&&Object.assign(Object.assign({},n.mask),{canvas:void 0,imageData:(0,Do.getLayerMaskImageData)(n)}),realMask:n.realMask&&Object.assign(Object.assign({},n.realMask),{canvas:void 0,imageData:(0,Do.getLayerRealMaskImageData)(n)})});let m=Gs([Object.assign(Object.assign({},s),{children:void 0})],!!i.psb);e.tempBuffer.byteLength<m&&(e.tempBuffer=new Uint8Array(m))}let a=e.tempBuffer,{mask:l,realMask:c}=Ns(s),f=Em(a,s,t,i);return l&&pd(a,f,l,i,!1),c&&pd(a,f,c,i,!0),f.layer=n,f}function Xs({canvas:e,imageData:n}){var t,i,o,r;let s=(i=(t=n?.width)!==null&&t!==void 0?t:e?.width)!==null&&i!==void 0?i:0,a=(r=(o=n?.height)!==null&&o!==void 0?o:e?.height)!==null&&r!==void 0?r:0;return{width:s,height:a}}function Om(e,n,t,i,o){let r=Fo(e)?(0,re.createImageData)(i,o):{width:i,height:o,data:new e.data.constructor(i*o*4)},s=e.data,a=r.data;for(let l=0;l<o;l++)for(let c=0;c<i;c++){let f=(c+n+(l+t)*e.width)*4,u=(c+l*i)*4;a[u]=s[f],a[u+1]=s[f+1],a[u+2]=s[f+2],a[u+3]=s[f+3]}return r}function Em(e,n,t,i){var o,r;let s=n.top|0,a=n.left|0,l=n.right|0,c=n.bottom|0,f=[{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:u,height:d}=Xs(n);if(!(n.canvas||n.imageData)||!u||!d)return(n.right===void 0||l>a)&&(l=a),(n.bottom===void 0||c>s)&&(c=s),{layer:n,top:s,left:a,right:l,bottom:c,channels:f};l=a+u,c=s+d;let p=n.imageData||n.canvas.getContext("2d").getImageData(0,0,u,d);if(i.trimImageData){let g=Fm(p);if(g.left!==0||g.top!==0||g.right!==p.width||g.bottom!==p.height){if(a+=g.left,s+=g.top,l-=p.width-g.right,c-=p.height-g.bottom,u=l-a,d=c-s,!u||!d)return{layer:n,top:s,left:a,right:l,bottom:c,channels:f};p=Om(p,g.left,g.top,u,d)}}let h=[0,1,2];(!t||i.noBackground||n.mask||(0,re.hasAlpha)(p))&&h.unshift(-1);let m=(o=i.colorMode)!==null&&o!==void 0?o:3,y=(r=i.bitsPerChannel)!==null&&r!==void 0?r:8;if(m!==3||y!==8||!Fo(p)){let{colors:g,alpha:k}=Hs(p,m,y,!1),x=h[0]===-1?[-1]:[];for(let S=0;S<g.length;S++)x.push(S);return f=x.map(S=>{let{data:A,compression:D}=xd(S===-1?k:g[S],u,d,i);return{id:S,compression:D,data:A,length:2+A.length}}),{layer:n,top:s,left:a,right:l,bottom:c,channels:f}}return f=h.map(g=>{let k=(0,re.offsetForChannel)(g,!1),x,S;return i.compress?(x=(0,re.writeDataZipWithoutPrediction)(p,[k]),S=2):(x=(0,re.writeDataRLE)(e,p,[k],!!i.psb).slice(),S=1),{id:g,compression:S,data:x,length:2+x.length}}),{layer:n,top:s,left:a,right:l,bottom:c,channels:f}}function hd({data:e,width:n},t,i,o){let r=(t*n+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 gd({data:e,width:n},t,i,o){let r=n*4|0,s=i*r+t*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 Fm(e){let n=0,t=0,i=e.width,o=e.height;for(;n<o&&hd(e,n,t,i);)n++;for(;o>n&&hd(e,o-1,t,i);)o--;for(;t<i&&gd(e,t,n,o);)t++;for(;i>t&&gd(e,i-1,n,o);)i--;return{top:n,left:t,right:i,bottom:o}}function Lm(e,n){n?"r"in n?(q(e,0),q(e,Math.round(n.r*257)),q(e,Math.round(n.g*257)),q(e,Math.round(n.b*257)),q(e,0)):"fr"in n?(q(e,0),q(e,Math.round(n.fr*255*257)),q(e,Math.round(n.fg*255*257)),q(e,Math.round(n.fb*255*257)),q(e,0)):"l"in n?(q(e,7),Zt(e,Math.round(n.l*1e4)),Zt(e,Math.round((0,re.denormalizeLabAB)(n.a,100))),Zt(e,Math.round((0,re.denormalizeLabAB)(n.b,100))),q(e,0)):"h"in n?(q(e,1),q(e,Math.round(n.h*65535)),q(e,Math.round(n.s*65535)),q(e,Math.round(n.b*65535)),q(e,0)):"c"in n?(q(e,2),q(e,65535-Math.round((0,re.clamp)(n.c,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.m,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.y,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.k,0,255)*257))):(q(e,8),q(e,Math.round(n.k*1e4/255)),Gn(e,6)):(q(e,0),Gn(e,8))}function Mm(e,n){let t=n.bounds.w,i=n.bounds.h,o={width:t,height:i,data:n.data};me(e,0);let r=e.offset;me(e,1),me(e,3),Zt(e,n.x),Zt(e,n.y),bd(e,n.name+"\0"),Oo(e,n.id,1),me(e,3),me(e,0);let s=e.offset,a=n.bounds.y,l=n.bounds.x,c=a+i,f=l+t;me(e,a),me(e,l),me(e,c),me(e,f),me(e,24);let u=new Uint8Array(Eo(t,i,!1));for(let h=0;h<26;h++){let m=h<3?h:h===25?3:-1;if(m<0){me(e,0);continue}let y=(0,re.writeDataRLE)(u,o,[m],!1);me(e,1),me(e,y.length+4+16+2+1),me(e,8),me(e,a),me(e,l),me(e,c),me(e,f),q(e,8),ye(e,1),Ai(e,y)}let d=e.offset-s,p=e.offset-r;for(;p%4;)Gn(e,1),p++;e.view.setUint32(s-4,d,!1),e.view.setUint32(r-4,p,!1)}});var Fd=ae(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.readAbr=jm;var K=ro(),se=st(),Um=["off","fade","pen pressure","pen tilt","stylus wheel","initial direction","direction","initial rotation","rotation"],Id=["round point","round blunt","round curve","round angle","round fan","flat point","flat blunt","flat curve","flat angle","flat fan"],Bm=["erodible point","erodible flat","erodible round","erodible square","erodible triangle","custom"],Cd=1e4,Rm=new Map([["_","brush"],["MixB","mixer brush"],["SmTl","smudge brush"]]);function Fe(e){return{control:Um[e.bVTy],steps:e.fStp,jitter:(0,K.parsePercent)(e.jitter),minimum:(0,K.parsePercent)(e["Mnm "])}}function Pd(e){switch(e._classID){case"computedBrush":return{type:"computed",size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,K.parseAngle)(e.Angl),roundness:(0,K.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,K.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,hardness:(0,K.parsePercent)(e.Hrdn)};case"sampledBrush":return{type:"sampled",size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,K.parseAngle)(e.Angl),roundness:(0,K.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,K.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,name:e["Nm "],sampledData:e.sampledData};case"dBrush":return{type:"dynamic",shape:Id[e["Shp "]],angle:(0,K.parseAngle)(e.Angl),size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),density:(0,K.parsePercent)(e.Dnst),length:(0,K.parsePercent)(e.Lngt),clumping:(0,K.parsePercent)(e.clumping),thickness:(0,K.parsePercent)(e.thickness),stiffness:(0,K.parsePercent)(e.stiffness),physics:e.physics,spacing:(0,K.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY};case"dTips":return Object.assign(Object.assign({type:"tips",angle:(0,K.parseAngle)(e.Angl),size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),shape:Id[e["Shp "]],physics:e.physics,spacing:(0,K.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY,tipsType:Bm[e.dtipsType],tipsLengthRatio:(0,K.parsePercent)(e.dtipsLengthRatio),tipsHardness:(0,K.parsePercent)(e.dtipsHardness)},e.dtipsGridSize&&e.dtipsErodibleTipHeightMap?{tipsGridSize:e.dtipsGridSize,tipsErodibleTipHeightMap:Tm(e.dtipsErodibleTipHeightMap)}:{}),{tipsAirbrushCutoffAngle:e.dtipsAirbrushCutoffAngle,tipsAirbrushGranularity:(0,K.parsePercent)(e.dtipsAirbrushGranularity),tipsAirbrushStreakiness:(0,K.parsePercent)(e.dtipsAirbrushStreakiness),tipsAirbrushSplatSize:(0,K.parsePercent)(e.dtipsAirbrushSplatSize),tipsAirbrushSplatCount:e.dtipsAirbrushSplatCount});default:throw new Error(`Unknown brush classId: ${e._classID}`)}}function Tm(e){let n=[];for(let t=0;t<e.byteLength;t++)n.push(e[t]);return n}function Dd(e,n){let t=(0,se.createReader)(e.view.buffer,e.view.byteOffset+e.offset,n-e.offset);return(0,K.readVersionAndDescriptor)(t,!0)}function jm(e,n={}){let t=(0,se.createReader)(e.buffer,e.byteOffset,e.byteLength);t.logMissingFeatures=n.logMissingFeatures,t.throwForMissingFeatures=n.throwForMissingFeatures,t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024;let i=(f,u)=>{if(n.throwForMissingFeatures)throw f;n.logMissingFeatures&&t.log(`Skipped ${u}: ${f.message}`)};if(t.view.byteLength<4)throw new Error("Invalid ABR file");let o=(0,se.readInt16)(t),r=[],s=[],a=[],l=[],c;if(o===1||o===2)$m(t,o,r,s,i);else if(o===6||o===7||o===9||o===10){let f=(0,se.readInt16)(t);if(f!==1&&f!==2)throw new Error("Unsupported ABR minor version");for(;t.offset+12<=t.view.byteLength;){(0,se.checkSignature)(t,"8BIM");let u=(0,se.readSignature)(t),d=(0,se.readUint32)(t),p=Math.min(t.offset+d,t.view.byteLength);try{switch(u){case"samp":{for(;t.offset+4<=p;){let h=(0,se.readUint32)(t);for(;h&3;)h++;let m=Math.min(t.offset+h,p);try{let y=zm(t,m,f);r.push(y)}catch(y){i(y,"brush sample")}t.offset=m}break}case"desc":{let h=Dd(t,p);for(let[m,y]of(h.Brsh||[]).entries())try{let g=Vm(y);s.push(g),l[m]=g}catch(g){i(g,`brush "${y["Nm "]}"`)}break}case"patt":{for(;t.offset+4<=p;){let h=(0,se.readPatternSafe)(t);h&&a.push(h)}break}case"phry":{c=Dd(t,p).hierarchy;break}default:n.logMissingFeatures&&t.log(`Unhandled brush section: ${u}`);break}}catch(h){i(h,`brush section ${u}`)}for(t.offset=p;t.offset%4;)t.offset++}}else throw new Error(`Unsupported ABR version (${o})`);if(c){let f=[],u=0;for(let d of c)if(d._classID==="Grup")f.push(d["Nm "]);else if(d._classID==="groupEnd")f.pop();else if(d._classID==="preset"){let p=l[u];p&&f.length&&(p.group=f.slice()),u++}}return{samples:r,patterns:a,brushes:s}}function zm(e,n,t){let i=(0,se.readPascalString)(e,1);return(0,se.skipBytes)(e,t===1?10:264),Ed(e,n,i)}function Ed(e,n,t){let i=(0,se.readInt32)(e),o=(0,se.readInt32)(e),r=(0,se.readInt32)(e)-i,s=(0,se.readInt32)(e)-o;if(s<=0||r<=0)throw new Error("Invalid bounds");if(s>Cd||r>Cd)throw new Error(`Brush sample too large (${s}x${r})`);let a=(0,se.readInt16)(e),l=(0,se.readUint8)(e);if(a!==8&&a!==16)throw new Error("Invalid depth");if(l!==0&&l!==1)throw new Error("Invalid compression");let c=s*(a===16?2:1);if((l===0?r*c:r*(2+Math.ceil(c/128)*2))>n-e.offset)throw new Error("Brush sample data out of bounds");(0,se.consumeMemory)(e,s*r*(a===16?3:1));let u=new Uint8Array(s*r);if(a===8)if(l===0)u.set((0,se.readBytes)(e,u.byteLength));else if(l===1)(0,se.readDataRLE)(e,{width:s,height:r,data:u},s,r,a,1,[0],!1);else throw new Error("Invalid compression");else if(a===16){let d=new Uint16Array(s*r);if(l===0)for(let m=0;m<d.length;m++)d[m]=(0,se.readUint16)(e);else if(l===1)(0,se.readDataRLE)(e,{width:s,height:r,data:d},s,r,a,1,[0],!1);else throw new Error("Invalid compression");let p=0;for(let m=0;m<d.length;m++)p=Math.max(p,d[m]);let h=p>32768?255/65535:255/32768;for(let m=0;m<u.byteLength;m++)u[m]=Math.round(d[m]*h)}else throw new Error("Invalid depth");return{id:t,bounds:{x:o,y:i,w:s,h:r},alpha:u}}function $m(e,n,t,i,o){let r=(0,se.readUint16)(e);for(let s=0;s<r;s++){let a=(0,se.readUint16)(e),l=(0,se.readUint32)(e),c=e.offset+l;if(c>e.view.byteLength){o(new Error("Brush data out of bounds"),`brush ${s+1}`);break}try{if(a===1){(0,se.skipBytes)(e,4);let f=(0,se.readUint16)(e),u=(0,se.readUint16)(e),d=(0,se.readUint16)(e),p=(0,se.readInt16)(e),h=(0,se.readUint16)(e);if(e.offset>c)throw new Error("Brush data out of bounds");i.push(Od("",{type:"computed",size:u,angle:p,roundness:d/100,spacingOn:f!==0,spacing:f/100,flipX:!1,flipY:!1,hardness:h/100}))}else if(a===2){(0,se.skipBytes)(e,4);let f=(0,se.readUint16)(e),u=n===2?(0,se.readUnicodeString)(e):"";(0,se.skipBytes)(e,9);let d=Ed(e,c,`brush-${s+1}`);t.push(d),i.push(Od(u,{type:"sampled",size:Math.max(d.bounds.w,d.bounds.h),angle:0,roundness:1,spacingOn:f!==0,spacing:f/100,flipX:!1,flipY:!1,name:u,sampledData:d.id}))}else throw new Error(`Unknown brush type: ${a}`)}catch(f){o(f,`brush ${s+1}`)}e.offset=c}}function Od(e,n){return{name:e,shape:n,spacing:1,wetEdges:!1,noise:!1,buildUp:!1,useBrushSize:!0}}function Vm(e){var n,t,i;let o={name:e["Nm "],shape:Pd(e.Brsh),spacing:(0,K.parsePercent)(e.Spcn),wetEdges:e.Wtdg,noise:e.Nose,buildUp:!!e["Rpt "],useBrushSize:e.useBrushSize};e.interpretation!=null&&(o.interpretation=e.interpretation),e.protectTexture!=null&&(o.protectTexture=e.protectTexture),e.useTipDynamics&&(o.shapeDynamics={tiltScale:(0,K.parsePercent)(e.tiltScale),sizeDynamics:Fe(e.szVr),angleDynamics:Fe(e.angleDynamics),roundnessDynamics:Fe(e.roundnessDynamics),flipX:e.flipX,flipY:e.flipY,brushProjection:e.brushProjection,minimumDiameter:(0,K.parsePercent)(e.minimumDiameter),minimumRoundness:(0,K.parsePercent)(e.minimumRoundness)}),e.useScatter&&(o.scatter={count:e["Cnt "],bothAxes:e.bothAxes,countDynamics:Fe(e.countDynamics),scatterDynamics:Fe(e.scatterDynamics)}),e.useTexture&&e.Txtr&&(o.texture={id:e.Txtr.Idnt,name:e.Txtr["Nm "],blendMode:K.BlnM.decode(e.textureBlendMode),depth:(0,K.parsePercent)(e.textureDepth),depthMinimum:(0,K.parsePercent)(e.minimumDepth),depthDynamics:Fe(e.textureDepthDynamics),scale:(0,K.parsePercent)(e.textureScale),invert:e.InvT,brightness:e.textureBrightness,contrast:e.textureContrast,textureEachTip:!!e.TxtC});let r=e.dualBrush;r&&r.useDualBrush&&(o.dualBrush={flip:r.Flip,shape:Pd(r.Brsh),blendMode:K.BlnM.decode(r.BlnM),useScatter:r.useScatter,spacing:(0,K.parsePercent)(r.Spcn),count:r["Cnt "],bothAxes:r.bothAxes,countDynamics:Fe(r.countDynamics),scatterDynamics:Fe(r.scatterDynamics)}),e.useColorDynamics&&(o.colorDynamics={foregroundBackground:Fe(e.clVr),hue:(0,K.parsePercent)(e["H "]),saturation:(0,K.parsePercent)(e.Strt),brightness:(0,K.parsePercent)(e.Brgh),purity:(0,K.parsePercent)(e.purity),perTip:e.colorDynamicsPerTip}),e.usePaintDynamics&&(o.transfer={flowDynamics:Fe(e.prVr),opacityDynamics:Fe(e.opVr)},e.wtVr&&(o.transfer.wetnessDynamics=Fe(e.wtVr)),e.mxVr&&(o.transfer.mixDynamics=Fe(e.mxVr))),e.useBrushPose&&(o.brushPose={overrideAngle:e.overridePoseAngle,overrideTiltX:e.overridePoseTiltX,overrideTiltY:e.overridePoseTiltY,overridePressure:e.overridePosePressure,pressure:(0,K.parsePercent)(e.brushPosePressure),tiltX:e.brushPoseTiltX,tiltY:e.brushPoseTiltY,angle:e.brushPoseAngle});let s=e.toolOptions;return s&&(o.toolOptions={type:Rm.get(s._classID)||"brush",brushPreset:s.brushPreset,flow:(n=s.flow)!==null&&n!==void 0?n:100,smooth:(t=s.Smoo)!==null&&t!==void 0?t:0,mode:K.BlnM.decode(s["Md "]||"BlnM.Nrml"),opacity:(i=s.Opct)!==null&&i!==void 0?i:100,smoothing:!!s.smoothing,smoothingValue:s.smoothingValue||0,smoothingRadiusMode:!!s.smoothingRadiusMode,smoothingCatchup:!!s.smoothingCatchup,smoothingCatchupAtEnd:!!s.smoothingCatchupAtEnd,smoothingZoomCompensation:!!s.smoothingZoomCompensation,pressureSmoothing:!!s.pressureSmoothing,usePressureOverridesSize:!!s.usePressureOverridesSize,usePressureOverridesOpacity:!!s.usePressureOverridesOpacity,useLegacy:!!s.useLegacy},s.prVr&&(o.toolOptions.flowDynamics=Fe(s.prVr)),s.opVr&&(o.toolOptions.opacityDynamics=Fe(s.opVr)),s.szVr&&(o.toolOptions.sizeDynamics=Fe(s.szVr)),"wetness"in s&&(o.toolOptions.wetness=s.wetness),"dryness"in s&&(o.toolOptions.dryness=s.dryness),"mix"in s&&(o.toolOptions.mix=s.mix),"autoFill"in s&&(o.toolOptions.autoFill=s.autoFill),"autoClean"in s&&(o.toolOptions.autoClean=s.autoClean),"loadSolidColorOnly"in s&&(o.toolOptions.loadSolidColorOnly=s.loadSolidColorOnly),"sampleAllLayers"in s&&(o.toolOptions.sampleAllLayers=s.sampleAllLayers),"SmdF"in s&&(o.toolOptions.smudgeFingerPainting=s.SmdF),"SmdS"in s&&(o.toolOptions.smudgeSampleAllLayers=s.SmdS),"Prs "in s&&(o.toolOptions.strength=s["Prs "])),o}});var Ld=ae(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.readCsh=Gm;var Nm=di(),tt=st();function Gm(e,n={}){let t=(0,tt.createReader)(e.buffer,e.byteOffset,e.byteLength);t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024;let i={shapes:[]};if((0,tt.checkSignature)(t,"cush"),(0,tt.readUint32)(t)!==2)throw new Error("Invalid version");let o=(0,tt.readUint32)(t);for(let r=0;r<o;r++){let s=(0,tt.readUnicodeString)(t);for(;t.offset%4;)t.offset++;if((0,tt.readUint32)(t)!==1)throw new Error("Invalid shape version");let a=(0,tt.readUint32)(t),l=t.offset+a,c=(0,tt.readPascalString)(t,1),f=(0,tt.readUint32)(t),u=(0,tt.readUint32)(t),d=(0,tt.readUint32)(t),h=(0,tt.readUint32)(t)-u,m=d-f,y={paths:[]};(0,Nm.readVectorMask)(t,y,h,m,l-t.offset),i.shapes.push(Object.assign({name:s,id:c,width:h,height:m},y)),t.offset=l}return i}});var Md=ae(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.readAse=Hm;var ze=st();function Hm(e,n={}){let t=(0,ze.createReader)(e.buffer,e.byteOffset,e.byteLength);if(t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024,(0,ze.readSignature)(t)!=="ASEF")throw new Error("Invalid signature");let o=(0,ze.readUint16)(t);if((0,ze.readUint16)(t),o!==1)throw new Error("Invalid version");let r=(0,ze.readUint32)(t),s={colors:[]},a=s;for(let l=0;l<r&&t.offset+6<=t.view.byteLength;l++){let c=(0,ze.readUint16)(t),f=(0,ze.readUint32)(t),u=Math.min(t.offset+f,t.view.byteLength),d=(0,ze.createReader)(t.view.buffer,t.view.byteOffset+t.offset,u-t.offset);d.totalMemoryLimit=t.totalMemoryLimit;try{switch(c){case 1:{let p=Wm(d);if(p)a.colors.push(p);else{if(n.throwForMissingFeatures)throw new Error("Unsupported color mode");n.logMissingFeatures&&t.log("Skipped color with unsupported color mode")}break}case 49153:{let p=(0,ze.readUint16)(d),h=(0,ze.readUnicodeStringWithLength)(d,p);s.colors.push(a={name:h,colors:[]});break}case 49154:a=s;break;default:if(n.throwForMissingFeatures)throw new Error(`Invalid block type: ${c}`);n.logMissingFeatures&&t.log(`Skipped unknown block type: ${c}`)}}catch(p){if(n.throwForMissingFeatures)throw p;n.logMissingFeatures&&t.log(`Skipped invalid block: ${p.message}`)}t.totalMemoryLimit=d.totalMemoryLimit,t.offset=u}return s}function Wm(e){let n=(0,ze.readUint16)(e),t=(0,ze.readUnicodeStringWithLength)(e,n),i=(0,ze.readSignature)(e),o=()=>{let s=(0,ze.readFloat32)(e);return isFinite(s)?s:0},r=()=>{let s=e.offset+2<=e.view.byteLength?(0,ze.readUint16)(e):2;return Xm[s]||"normal"};switch(i){case"RGB ":return{name:t,color:{r:o(),g:o(),b:o(),type:r()}};case"CMYK":return{name:t,color:{c:o(),m:o(),y:o(),k:o(),type:r()}};case"Gray":return{name:t,color:{k:o(),type:r()}};case"LAB ":return{name:t,color:{l:o(),a:o(),b:o(),type:r()}};default:return}}var Xm=["global","spot","normal"]});var zd=ae(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.Compression=nt.ChannelID=nt.LayerCompCapturedInfo=nt.SectionDividerType=nt.ColorMode=void 0;var Ud;(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"})(Ud||(nt.ColorMode=Ud={}));var Bd;(function(e){e[e.Other=0]="Other",e[e.OpenFolder=1]="OpenFolder",e[e.ClosedFolder=2]="ClosedFolder",e[e.BoundingSectionDivider=3]="BoundingSectionDivider"})(Bd||(nt.SectionDividerType=Bd={}));var Rd;(function(e){e[e.None=0]="None",e[e.Visibility=1]="Visibility",e[e.Position=2]="Position",e[e.Appearance=4]="Appearance"})(Rd||(nt.LayerCompCapturedInfo=Rd={}));var Td;(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"})(Td||(nt.ChannelID=Td={}));var jd;(function(e){e[e.RawData=0]="RawData",e[e.RleCompressed=1]="RleCompressed",e[e.ZipWithoutPrediction=2]="ZipWithoutPrediction",e[e.ZipWithPrediction=3]="ZipWithPrediction"})(jd||(nt.Compression=jd={}))});var Vd=ae(Y=>{"use strict";var qm=Y&&Y.__createBinding||(Object.create?(function(e,n,t,i){i===void 0&&(i=t);var o=Object.getOwnPropertyDescriptor(n,t);(!o||("get"in o?!n.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,o)}):(function(e,n,t,i){i===void 0&&(i=t),e[i]=n[t]})),Lo=Y&&Y.__exportStar||function(e,n){for(var t in e)t!=="default"&&!Object.prototype.hasOwnProperty.call(n,t)&&qm(n,e,t)};Object.defineProperty(Y,"__esModule",{value:!0});Y.getFilterEffectsMaskExtraCanvas=Y.getFilterEffectsMaskCanvas=Y.getFilterEffectsMaskExtraImageData=Y.getFilterEffectsMaskImageData=Y.getCompositeCanvas=Y.getCompositeImageData=Y.getLayerRealMaskCanvas=Y.getLayerMaskCanvas=Y.getLayerCanvas=Y.getLayerRealMaskImageData=Y.getLayerMaskImageData=Y.getLayerImageData=Y.decodeLayerPixels=Y.byteArrayToBase64=Y.initializeCanvas=void 0;Y.readPsd=Ym;Y.writePsd=Jm;Y.writePsdUint8Array=$d;Y.writePsdBuffer=Qm;var Hn=En(),Le=st();Object.defineProperty(Y,"decodeLayerPixels",{enumerable:!0,get:function(){return Le.decodeLayerPixels}});Object.defineProperty(Y,"getLayerImageData",{enumerable:!0,get:function(){return Le.getLayerImageData}});Object.defineProperty(Y,"getLayerMaskImageData",{enumerable:!0,get:function(){return Le.getLayerMaskImageData}});Object.defineProperty(Y,"getLayerRealMaskImageData",{enumerable:!0,get:function(){return Le.getLayerRealMaskImageData}});Object.defineProperty(Y,"getLayerCanvas",{enumerable:!0,get:function(){return Le.getLayerCanvas}});Object.defineProperty(Y,"getLayerMaskCanvas",{enumerable:!0,get:function(){return Le.getLayerMaskCanvas}});Object.defineProperty(Y,"getLayerRealMaskCanvas",{enumerable:!0,get:function(){return Le.getLayerRealMaskCanvas}});Object.defineProperty(Y,"getCompositeImageData",{enumerable:!0,get:function(){return Le.getCompositeImageData}});Object.defineProperty(Y,"getCompositeCanvas",{enumerable:!0,get:function(){return Le.getCompositeCanvas}});Object.defineProperty(Y,"getFilterEffectsMaskImageData",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskImageData}});Object.defineProperty(Y,"getFilterEffectsMaskExtraImageData",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskExtraImageData}});Object.defineProperty(Y,"getFilterEffectsMaskCanvas",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskCanvas}});Object.defineProperty(Y,"getFilterEffectsMaskExtraCanvas",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskExtraCanvas}});var Zm=to();Lo(Fd(),Y);Lo(Ld(),Y);Lo(Md(),Y);var Km=Ot();Object.defineProperty(Y,"initializeCanvas",{enumerable:!0,get:function(){return Km.initializeCanvas}});Lo(zd(),Y);Y.byteArrayToBase64=Zm.fromByteArray;function Ym(e,n){let t="buffer"in e?(0,Le.createReader)(e.buffer,e.byteOffset,e.byteLength):(0,Le.createReader)(e);return(0,Le.readPsd)(t,n)}function Jm(e,n){let t=(0,Hn.createWriter)();return(0,Hn.writePsd)(t,e,n),(0,Hn.getWriterBuffer)(t)}function $d(e,n){let t=(0,Hn.createWriter)();return(0,Hn.writePsd)(t,e,n),(0,Hn.getWriterBufferNoCopy)(t)}function Qm(e,n){if(typeof Buffer>"u")throw new Error("Buffer not supported on this platform");return Buffer.from($d(e,n))}});var Bo=gu(Vd(),1);var Uo=class{view;offset=0;constructor(n){this.view=new DataView(n)}get length(){return this.view.byteLength}ensure(n,t=this.length,i="Adobe resource"){if(!Number.isSafeInteger(n)||n<0||this.offset+n>t||t>this.length)throw new Error(`${i} is truncated or has an invalid length.`)}u8(n,t){return this.ensure(1,n,t),this.view.getUint8(this.offset++)}i16(n,t){this.ensure(2,n,t);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u16(n,t){this.ensure(2,n,t);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i32(n,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}u32(n,t){this.ensure(4,n,t);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32le(n,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!0);return this.offset+=4,i}ascii(n,t,i){this.ensure(n,t,i);let o="";for(let r=0;r<n;r+=1)o+=String.fromCharCode(this.view.getUint8(this.offset++));return o}skip(n,t,i){this.ensure(n,t,i),this.offset+=n}},Ys=e=>{let n=e+3&-4;if(!Number.isSafeInteger(n)||n<e)throw new Error("Adobe resource alignment overflowed.");return n},_t=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} overflows the safe integer range.`);return i},Nd=(e,n,t)=>{if(e.byteLength>n.maxFileBytes)throw new Error(`${t.toUpperCase()} source exceeds the ${n.maxFileBytes}-byte safety limit.`)},un=(e,n,t)=>{if(!Number.isSafeInteger(e)||e<0||e>n.maxResourceItems)throw new Error(`${t} exceeds the ${n.maxResourceItems}-item safety limit.`)},Gd=(e,n,t,i)=>{un(n,t,i),e.descriptorItems+=n;let o=Math.min(1e6,t.maxResourceItems*64);if(e.descriptorItems>o)throw new Error(`Adobe descriptor complexity exceeds the ${o}-record safety limit.`)},Hd=(e,n,t,i,o)=>{if(n<=0||n>i.maxResourcePreviewPixels)throw new Error(`${o} exceeds the ${i.maxResourcePreviewPixels}-pixel preview limit.`);if(e.previewPixels+=n,e.decodedBytes+=t,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.`)},Wn=(e,n,t,i)=>{let o=e.u32(n,i);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(_t(o,2,`${i} length`),n,i)},Js=(e,n,t,i)=>{let o=e.u8(n,i);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(o,n,i)},Rt=(e,n,t,i)=>{let o=e.i32(n,i);if(o<0)throw new Error(`${i} has a negative string length.`);let r=o||4;if(r>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-character identifier limit.`);e.skip(r,n,i)},dn=(e,n,t,i)=>{Wn(e,n,t,`${i} name`),Rt(e,n,t,`${i} class id`)},Mo=(e,n,t,i,o)=>{let r=e.i32(n,o);if(r<0)throw new Error(`${o} has a negative item count.`);return Gd(t,r,i,o),r},Wd=(e,n,t,i,o,r)=>{if(i>r.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${r.maxNestingDepth}-level safety limit.`);switch(t){case"obj ":{let s=Mo(e,n,o,r,"Adobe descriptor reference");for(let a=0;a<s;a+=1){let l=e.ascii(4,n,"Adobe descriptor reference type");if(l==="prop")dn(e,n,r,"Adobe property reference"),Rt(e,n,r,"Adobe property key");else if(l==="Clss")dn(e,n,r,"Adobe class reference");else if(l==="Enmr")dn(e,n,r,"Adobe enum reference"),Rt(e,n,r,"Adobe enum type"),Rt(e,n,r,"Adobe enum value");else if(l==="rele")dn(e,n,r,"Adobe offset reference"),e.skip(4,n,"Adobe offset reference");else if(l==="Idnt"||l==="indx")e.skip(4,n,"Adobe integer reference");else if(l==="name")dn(e,n,r,"Adobe name reference"),Wn(e,n,r,"Adobe reference name");else throw new Error(`Unsupported Adobe descriptor reference type ${JSON.stringify(l)}.`)}return}case"Objc":case"GlbO":Xd(e,n,i+1,o,r);return;case"VlLs":{let s=Mo(e,n,o,r,"Adobe descriptor list");for(let a=0;a<s;a+=1){let l=e.ascii(4,n,"Adobe descriptor list type");Wd(e,n,l,i+1,o,r)}return}case"doub":e.skip(8,n,"Adobe double");return;case"UntF":e.skip(12,n,"Adobe unit double");return;case"UnFl":e.skip(8,n,"Adobe unit float");return;case"TEXT":Wn(e,n,r,"Adobe descriptor text");return;case"enum":Rt(e,n,r,"Adobe enum type"),Rt(e,n,r,"Adobe enum value");return;case"long":e.skip(4,n,"Adobe integer");return;case"comp":e.skip(8,n,"Adobe large integer");return;case"bool":e.skip(1,n,"Adobe boolean");return;case"type":case"GlbC":dn(e,n,r,"Adobe descriptor class");return;case"alis":case"tdta":{let s=e.i32(n,"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,n,"Adobe descriptor data");return}case"ObAr":{e.skip(4,n,"Adobe object-array version"),Wn(e,n,r,"Adobe object-array name"),Rt(e,n,r,"Adobe object-array class");let s=Mo(e,n,o,r,"Adobe object array");for(let a=0;a<s;a+=1){Rt(e,n,r,"Adobe object-array item type");let l=e.ascii(4,n,"Adobe object-array value type");if(l!=="UnFl")throw new Error(`Unsupported Adobe object-array value type ${JSON.stringify(l)}.`);e.skip(4,n,"Adobe object-array units");let c=Mo(e,n,o,r,"Adobe object-array values");e.skip(_t(c,8,"Adobe object-array values"),n,"Adobe object-array values")}return}case"Pth ":{let s=e.i32(n,"Adobe path length");if(s<0||s>r.maxDecodedBytes)throw new Error("Adobe descriptor path length is invalid.");e.skip(4,n,"Adobe path signature");let a=e.i32le(n,"Adobe path size"),l=e.i32le(n,"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(_t(l,2,"Adobe path characters"),n,"Adobe descriptor path");return}default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(t)}.`)}},Xd=(e,n,t,i,o)=>{if(t>o.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${o.maxNestingDepth}-level safety limit.`);dn(e,n,o,"Adobe descriptor");let r=e.u32(n,"Adobe descriptor item count");Gd(i,r,o,"Adobe descriptor item count");for(let s=0;s<r;s+=1){Rt(e,n,o,"Adobe descriptor key");let a=e.ascii(4,n,"Adobe descriptor value type");Wd(e,n,a,t+1,i,o)}},ey=(e,n,t,i)=>{let o=e.u32(n,"Adobe descriptor version");if(o!==16)throw new Error(`Unsupported Adobe descriptor version ${o}.`);Xd(e,n,0,t,i)},qd=(e,n,t,i,o)=>{let r=_t(i,2,`${o} row table`);e.ensure(r,n,o);let s=Array.from({length:i},()=>e.u16(n,`${o} row length`));for(let a=0;a<i;a+=1){let l=e.offset+s[a];if(l>n)throw new Error(`${o} compressed row ${a} is truncated.`);let c=0;for(;e.offset<l;){let f=e.u8(l,`${o} PackBits header`);if(f<=127){let u=f+1;e.skip(u,l,`${o} PackBits literal`),c+=u}else f>=129&&(e.skip(1,l,`${o} PackBits repeat value`),c+=257-f);if(c>t)throw new Error(`${o} PackBits row ${a} expands beyond its declared width.`)}if(c!==t)throw new Error(`${o} PackBits row ${a} does not expand to its declared width.`)}},ty=(e,n,t,i,o)=>{let r=0;for(;e.offset<n;){un(++r,o,"ABR sample count");let s=e.u32(n,"ABR sample length"),a=e.offset,l=a+s,c=a+Ys(s);if(l>n||c>n)throw new Error("ABR sample record is truncated.");Js(e,l,o,"ABR sample id"),e.skip(t===1?10:264,l,"ABR sample header");let f=e.i32(l,"ABR sample top"),u=e.i32(l,"ABR sample left"),d=e.i32(l,"ABR sample bottom"),h=e.i32(l,"ABR sample right")-u,m=d-f;if(h<=0||m<=0||h>o.maxCanvasDimension||m>o.maxCanvasDimension)throw new Error(`ABR sample dimensions exceed the ${o.maxCanvasDimension}-pixel side limit.`);let y=_t(h,m,"ABR sample pixels"),g=e.i16(l,"ABR sample depth"),k=e.u8(l,"ABR sample compression");if(g!==8&&g!==16)throw new Error(`Unsupported ABR sample depth ${g}.`);if(k!==0&&k!==1)throw new Error(`Unsupported ABR sample compression ${k}.`);if(g===16&&k===1)throw new Error("ABR 16-bit RLE samples are not supported by the decoding engine.");if(Hd(i,y,y,o,"ABR sample"),k===0?e.skip(_t(y,g/8,"ABR raw sample bytes"),l,"ABR raw sample"):qd(e,l,h,m,"ABR sample"),e.offset>l)throw new Error("ABR sample payload exceeded its declared record boundary.");e.offset=l,e.offset=c}return r},ny=(e,n,t,i)=>{let o=e.u32(n,"ABR pattern length"),s=e.offset+Ys(o);if(s>n)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"),Wn(e,s,i,"ABR pattern name"),Js(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"),f=e.u32(s,"ABR pattern bottom"),u=e.u32(s,"ABR pattern right"),d=e.u32(s,"ABR pattern channel count");if(f<=l||u<=c||d>16)throw new Error("ABR pattern bounds or channel count is invalid.");let p=u-c,h=f-l;if(p>i.maxCanvasDimension||h>i.maxCanvasDimension)throw new Error(`ABR pattern dimensions exceed the ${i.maxCanvasDimension}-pixel side limit.`);let m=_t(p,h,"ABR pattern pixels");Hd(t,m,_t(m,4,"ABR pattern RGBA bytes"),i,"ABR pattern");for(let y=0;y<d+2;y+=1){if(!e.u32(s,"ABR pattern channel presence"))continue;let k=e.u32(s,"ABR pattern channel length");if(k<23)throw new Error("ABR pattern channel length is invalid.");let x=e.offset+k;if(x>s)throw new Error("ABR pattern channel is truncated.");let S=e.u32(x,"ABR pattern channel depth"),A=e.u32(x,"ABR pattern channel top"),D=e.u32(x,"ABR pattern channel left"),C=e.u32(x,"ABR pattern channel bottom"),O=e.u32(x,"ABR pattern channel right"),E=e.u16(x,"ABR pattern channel depth duplicate"),L=e.u8(x,"ABR pattern channel compression");if(S!==8||E!==8||L!==0&&L!==1)throw new Error("ABR pattern channel uses an unsupported depth or compression mode.");if(C<A||O<D||A<l||D<c||C>f||O>u)throw new Error("ABR pattern channel bounds are invalid.");let M=O-D,J=C-A,pe=_t(M,J,"ABR pattern channel pixels");if(L===0){if(x-e.offset!==pe)throw new Error("ABR raw pattern channel length does not match its dimensions.");e.skip(pe,x,"ABR raw pattern channel")}else if(qd(e,x,M,J,"ABR pattern channel"),e.offset!==x)throw new Error("ABR RLE pattern channel has trailing bytes.")}e.offset=s},Zd=(e,n)=>{Nd(e,n,"ABR");let t=new Uo(e),i=t.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=t.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(;t.offset<t.length;){if(un(++s,n,"ABR section count"),t.ascii(4,void 0,"ABR section signature")!=="8BIM")throw new Error("Invalid ABR section signature.");let c=t.ascii(4,void 0,"ABR section type"),f=t.u32(void 0,"ABR section length"),u=t.offset,d=u+f,p=u+Ys(f);if(d>t.length||p>t.length)throw new Error("ABR section is truncated.");if(c==="samp")a+=ty(t,d,o,r,n);else if(c==="desc"||c==="phry"){if(ey(t,d,r,n),t.offset!==d)throw new Error(`ABR ${c} descriptor does not consume its declared section.`)}else if(c==="patt")for(;t.offset<d;)un(++l,n,"ABR pattern count"),ny(t,d,r,n);else throw new Error(`Unsupported ABR section type ${JSON.stringify(c)}.`);if(t.offset>d)throw new Error(`ABR ${c} section exceeded its declared boundary.`);t.offset=p}return un(a+l,n,"ABR decoded resource count"),{format:"abr",majorVersion:i,minorVersion:o,sections:s,samples:a,patterns:l,previewPixels:r.previewPixels,decodedBytes:r.decodedBytes}},Kd=(e,n)=>{Nd(e,n,"CSH");let t=new Uo(e);if(t.ascii(4,void 0,"CSH signature")!=="cush")throw new Error("Invalid CSH signature.");let i=t.u32(void 0,"CSH version");if(i!==2)throw new Error(`Unsupported CSH version ${i}; version 2 is required.`);let o=t.u32(void 0,"CSH shape count");un(o,n,"CSH shape count");let r=0,s=0,a=Math.min(1e6,n.maxResourceItems*64);for(let l=0;l<o;l+=1){for(Wn(t,t.length,n,`CSH shape ${l} name`);t.offset%4;)t.skip(1,t.length,"CSH name padding");if(t.u32(void 0,"CSH shape version")!==1)throw new Error("Unsupported CSH shape record version.");let c=t.u32(void 0,"CSH shape record length"),f=t.offset+c;if(f>t.length)throw new Error("CSH shape record is truncated.");Js(t,f,n,`CSH shape ${l} id`);let u=t.u32(f,"CSH shape top"),d=t.u32(f,"CSH shape left"),p=t.u32(f,"CSH shape bottom"),h=t.u32(f,"CSH shape right");if(p<=u||h<=d)throw new Error("CSH shape bounds are invalid.");let m=h-d,y=p-u;if(m>n.maxCanvasDimension||y>n.maxCanvasDimension)throw new Error(`CSH shape dimensions exceed the ${n.maxCanvasDimension}-pixel side limit.`);let g=_t(m,y,"CSH shape preview pixels");if(s+=g,s>n.maxResourcePreviewPixels)throw new Error(`CSH previews exceed the ${n.maxResourcePreviewPixels}-pixel collection limit.`);if((f-t.offset)%26!==0)throw new Error("CSH vector record section is not aligned to 26-byte path records.");let k=0,x=0,S=!1;for(;t.offset<f;){if(r+=1,r>a)throw new Error(`CSH path complexity exceeds the ${a}-record safety limit.`);let A=t.u16(f,"CSH vector selector");if(A===0||A===3){if(S&&x!==k)throw new Error("CSH path knot count does not match its declared count.");k=t.u16(f,"CSH path knot count"),un(k,n,"CSH path knot count");let D=t.i16(f,"CSH path boolean operation");if(D<-1||D>3)throw new Error("CSH path boolean operation is invalid.");t.skip(20,f,"CSH path header"),x=0,S=!0}else if(A===1||A===2||A===4||A===5){if(!S)throw new Error("CSH knot appears before a path header.");if(t.skip(24,f,"CSH Bezier knot"),x+=1,x>k)throw new Error("CSH path contains more knots than declared.")}else if(A===6||A===7||A===8)t.skip(24,f,"CSH vector metadata record");else throw new Error(`Unsupported CSH vector selector ${A}.`)}if(S&&x!==k)throw new Error("CSH path knot count does not match its declared count.")}if(t.offset!==t.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 Tt=(e,n)=>{if(!Number.isFinite(e))throw new Error(`${n} is not finite.`);return e},pn=(e,n,t)=>{if(e.length>n.maxResourceNameCodeUnits)throw new Error(`${t} exceeds the ${n.maxResourceNameCodeUnits}-code-unit name limit.`);return e},iy=(e,n,t)=>{let i=Tt(e.size,`${t} size`),o=Tt(e.angle,`${t} angle`);if(i<0||i>n.maxCanvasDimension)throw new Error(`${t} size exceeds the ${n.maxCanvasDimension}-pixel side limit.`);let r={type:e.type,size:i,angle:o};return"roundness"in e&&(r.roundness=Tt(e.roundness,`${t} roundness`)),"hardness"in e&&(r.hardness=Tt(e.hardness,`${t} hardness`)),"spacing"in e&&(r.spacing=Tt(e.spacing,`${t} spacing`)),e.type==="sampled"&&(r.sampledDataId=pn(e.sampledData,n,`${t} sampled-data id`)),r},oy=(e,n)=>({name:pn(e.name,n,"ABR brush name"),shape:iy(e.shape,n,`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}:{}}),ry=(e,n)=>{let t=Zd(e,n),i=(0,Bo.readAbr)(new Uint8Array(e),{logMissingFeatures:!1,totalMemoryLimit:n.maxDecodedBytes});if(i.brushes.length+i.samples.length+i.patterns.length>n.maxResourceItems)throw new Error(`ABR decoded resources exceed the ${n.maxResourceItems}-item safety limit.`);let r=0,s=0,a=i.samples.map((c,f)=>{let{w:u,h:d,x:p,y:h}=c.bounds,m=u*d;if(!Number.isSafeInteger(m)||m<=0||c.alpha.byteLength!==m)throw new Error(`ABR sample ${f} returned inconsistent decoded pixels.`);return s+=m,r+=c.alpha.byteLength,{id:pn(c.id,n,`ABR sample ${f} id`),x:Tt(p,`ABR sample ${f} x`),y:Tt(h,`ABR sample ${f} y`),width:u,height:d,alpha:c.alpha}}),l=i.patterns.map((c,f)=>{let{w:u,h:d,x:p,y:h}=c.bounds,m=u*d;if(!Number.isSafeInteger(m)||m<=0||c.data.byteLength!==m*4)throw new Error(`ABR pattern ${f} returned inconsistent decoded pixels.`);return s+=m,r+=c.data.byteLength,{id:pn(c.id,n,`ABR pattern ${f} id`),name:pn(c.name,n,`ABR pattern ${f} name`),x:Tt(p,`ABR pattern ${f} x`),y:Tt(h,`ABR pattern ${f} y`),width:u,height:d,rgba:c.data}});if(s!==t.previewPixels||s>n.maxResourcePreviewPixels)throw new Error("ABR decoded preview pixels do not match the bounded preflight result.");if(r!==t.decodedBytes||r>n.maxDecodedBytes)throw new Error("ABR decoded byte count does not match the bounded preflight result.");return{format:"abr",version:`${t.majorVersion}.${t.minorVersion}`,engine:"ag-psd",fidelity:"decoded-tip-and-metadata-preview",brushes:i.brushes.map(c=>oy(c,n)),samples:a,patterns:l,limitations:["The preview shows decoded tip alpha, embedded pattern pixels, and preset metadata; it does not simulate a painted stroke.","The bounded decoder rejects legacy ABR versions 1 and 2 and 16-bit RLE brush samples."]}},Ne=e=>{let n=Math.abs(e)<1e-9?0:e;return Number(n.toFixed(4)).toString()},sy=(e,n)=>{if(!e.knots.length)return{d:"",fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}};let t=e.knots.map((r,s)=>{if(r.points.length!==6||r.points.some(a=>!Number.isFinite(a)))throw new Error(`${n} knot ${s} has invalid Bezier coordinates.`);return r.points}),i=t[0],o=`M ${Ne(i[2])} ${Ne(i[3])}`;for(let r=1;r<t.length;r+=1){let s=t[r-1],a=t[r];o+=` C ${Ne(s[4])} ${Ne(s[5])} ${Ne(a[0])} ${Ne(a[1])} ${Ne(a[2])} ${Ne(a[3])}`}if(!e.open){let r=t.at(-1);o+=` C ${Ne(r[4])} ${Ne(r[5])} ${Ne(i[0])} ${Ne(i[1])} ${Ne(i[2])} ${Ne(i[3])} Z`}return{d:o,fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}}},ay=(e,n)=>{let t=Kd(e,n),i=(0,Bo.readCsh)(new Uint8Array(e),{totalMemoryLimit:n.maxDecodedBytes});if(i.shapes.length!==t.shapes)throw new Error("CSH decoded shape count does not match its bounded preflight result.");let o=0,r=0,s=Math.min(1e6,n.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 f=l.paths.map((u,d)=>(r+=u.knots.length,sy(u,`CSH shape ${c} path ${d}`)));if(o+r>s)throw new Error(`CSH decoded path complexity exceeds the ${s}-record safety limit.`);return{id:pn(l.id,n,`CSH shape ${c} id`),name:pn(l.name,n,`CSH shape ${c} name`),width:l.width,height:l.height,paths:f,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."]}},Yd=(e,n,t)=>n==="abr"?ry(e,t):ay(e,t);var ly=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},cy=(e,n)=>{if(!Number.isFinite(e))throw new Error(`${n} is not finite.`);return e},Xn=class{bytes;view;offset=0;constructor(n){this.bytes=n instanceof Uint8Array?n:new Uint8Array(n),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(n,t=this.length,i="Adobe binary data"){if(!Number.isSafeInteger(n)||n<0||this.offset>t||n>t-this.offset)throw new Error(`${i} is truncated.`)}u8(n=this.length,t){return this.ensure(1,n,t),this.view.getUint8(this.offset++)}u16(n=this.length,t){this.ensure(2,n,t);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i16(n=this.length,t){this.ensure(2,n,t);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u32(n=this.length,t){this.ensure(4,n,t);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32(n=this.length,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}i64(n=this.length,t){this.ensure(8,n,t);let i=this.view.getBigInt64(this.offset,!1);return this.offset+=8,i}f64(n=this.length,t){this.ensure(8,n,t);let i=this.view.getFloat64(this.offset,!1);return this.offset+=8,cy(i,t||"Adobe double")}ascii(n,t=this.length,i="Adobe ASCII data"){this.ensure(n,t,i);let o="";for(let r=0;r<n;r+=1)o+=String.fromCharCode(this.bytes[this.offset+r]);return this.offset+=n,o}slice(n,t=this.length,i="Adobe binary data"){this.ensure(n,t,i);let o=this.bytes.subarray(this.offset,this.offset+n);return this.offset+=n,o}skip(n,t=this.length,i="Adobe binary data"){this.ensure(n,t,i),this.offset+=n}},Ci=(e,n,t,i)=>{let o=e.u32(n,`${i} length`);if(o>t.maxResourceNameCodeUnits+1)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit safety limit.`);let r=e.slice(ly(o,2,`${i} bytes`),n,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>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit safety limit.`);return s},Kt=(e,n,t,i)=>{let o=e.u32(n,`${i} length`),r=o===0?4:o;if(r===0||r>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-byte safety limit.`);return e.ascii(r,n,i)},Ii=(e,n,t)=>{if(!Number.isSafeInteger(n)||n<0||n>e.maximum-e.values)throw new Error(`${t} exceeds the ${e.maximum}-value descriptor safety limit.`);e.values+=n},Jd=(e,n,t,i)=>({name:Ci(e,n,t,`${i} name`),classId:Kt(e,n,t,`${i} id`)}),fy=(e,n,t,i)=>{let o=e.u32(n,"Adobe reference count");Ii(i,o,"Adobe reference count");let r=[];for(let s=0;s<o;s+=1){let a=e.ascii(4,n,"Adobe reference form"),{name:l,classId:c}=Jd(e,n,t,"Adobe reference class"),f={form:a,className:l,classId:c};if(a==="prop")f.property=Kt(e,n,t,"Adobe reference property");else if(a==="Enmr")f.enumType=Kt(e,n,t,"Adobe reference enum type"),f.enumValue=Kt(e,n,t,"Adobe reference enum value");else if(a==="rele"||a==="Idnt"||a==="indx")f.index=e.i32(n,"Adobe reference index");else if(a==="name")f.name=Ci(e,n,t,"Adobe reference name");else if(a!=="Clss")throw new Error(`Unsupported Adobe reference form ${JSON.stringify(a)}.`);r.push(f)}return r},dy=(e,n,t)=>{let i=e.u32(n,"Adobe descriptor path length");if(i>t.maxDecodedBytes)throw new Error(`Adobe descriptor path exceeds the ${t.maxDecodedBytes}-byte safety limit.`);return e.skip(i,n,"Adobe descriptor path"),{type:"path",length:i}},Qd=(e,n,t,i,o,r)=>{if(r>i.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${i.maxNestingDepth}-level safety limit.`);switch(t){case"bool":return{type:"boolean",value:e.u8(n,"Adobe boolean")!==0};case"long":return{type:"integer",value:e.i32(n,"Adobe integer")};case"comp":return{type:"large-integer",value:e.i64(n,"Adobe large integer")};case"doub":return{type:"double",value:e.f64(n,"Adobe double")};case"UntF":return{type:"unit-double",unit:e.ascii(4,n,"Adobe unit"),value:e.f64(n,"Adobe unit double")};case"TEXT":return{type:"text",value:Ci(e,n,i,"Adobe descriptor text")};case"enum":return{type:"enum",enumType:Kt(e,n,i,"Adobe enum type"),value:Kt(e,n,i,"Adobe enum value")};case"Objc":case"GlbO":return{type:"object",value:hn(e,n,i,o,r+1)};case"VlLs":{let s=e.u32(n,"Adobe list count");Ii(o,s,"Adobe list count");let a=[];for(let l=0;l<s;l+=1)a.push(Qd(e,n,e.ascii(4,n,"Adobe list value type"),i,o,r+1));return{type:"list",value:a}}case"alis":case"tdta":{let s=e.u32(n,"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,n,"Adobe raw data"),{type:"raw",length:s,alias:t==="alis"}}case"type":case"GlbC":{let s=Jd(e,n,i,"Adobe class reference");return{type:"class",name:s.name,classId:s.classId}}case"UnFl":{let s=e.ascii(4,n,"Adobe unit-float-array unit"),a=e.u32(n,"Adobe unit-float-array count");Ii(o,a,"Adobe unit-float-array count");let l=Array.from({length:a},()=>e.f64(n,"Adobe unit-float-array value"));return{type:"unit-double-array",unit:s,value:l}}case"ObAr":{let s=e.u32(n,"Adobe object-array count");return Ii(o,s,"Adobe object-array count"),{type:"object-array",count:s,value:hn(e,n,i,o,r+1)}}case"obj ":return{type:"reference",value:fy(e,n,i,o)};case"Pth ":return dy(e,n,i);default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(t)}.`)}},Pi=e=>{let n=Number.isSafeInteger(e.maxResourceItems)&&e.maxResourceItems>0?Math.min(1e6,e.maxResourceItems):1;return{values:0,maximum:n>3906?1e6:n*256}},hn=(e,n,t,i=Pi(t),o=0)=>{if(o>t.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${t.maxNestingDepth}-level safety limit.`);let r=Ci(e,n,t,"Adobe descriptor name"),s=Kt(e,n,t,"Adobe descriptor class"),a=e.u32(n,"Adobe descriptor item count");Ii(i,a,"Adobe descriptor item count");let l=new Map,c=[];for(let f=0;f<a;f+=1){let u=Kt(e,n,t,"Adobe descriptor key");if(l.has(u))throw new Error(`Adobe descriptor contains duplicate key ${JSON.stringify(u)}.`);let d=e.ascii(4,n,"Adobe descriptor value type");l.set(u,Qd(e,n,d,t,i,o+1)),c.push(u)}return{name:r,classId:s,entries:l,keys:c}},Me=(e,n)=>e?.entries.get(n),Di=(e,n)=>{let t=Me(e,n);return t?.type==="object"?t.value:void 0},gn=(e,n)=>{let t=Me(e,n);return t?.type==="text"?t.value:void 0},Oi=(e,n)=>{let t=Me(e,n);return t?.type==="enum"?t.value:void 0},Ei=(e,n,t=!1)=>{let i=Me(e,n);return i?.type==="boolean"?i.value:t},Ie=(e,n,t=0)=>{let i=Me(e,n);return i?i.type==="integer"||i.type==="double"||i.type==="unit-double"?i.value:i.type==="large-integer"?Number(i.value):t:t},eu=Ci;var uy=["maxFileBytes","maxCanvasPixels","maxCanvasDimension","maxLayers","maxNestingDepth","maxLayerPixels","maxDecodedBytes","maxLayerCacheBytes","maxResourceItems","maxResourceNameCodeUnits","maxResourcePreviewPixels"],py=e=>{for(let n of uy){let t=e[n];if(!Number.isSafeInteger(t)||t<=0)throw new Error(`Invalid Adobe preset safety limit ${n}.`)}},ou=e=>e+3&-4,ct=(e,n,t)=>{let i=e+n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},To=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},ea=(e,n,t)=>{if(e.byteLength>n.maxFileBytes)throw new Error(`${t} source exceeds the ${n.maxFileBytes}-byte safety limit.`);if(!e.byteLength)throw new Error(`${t} source is empty.`)},ru=(e,n,t,i,o)=>{if(e.previewPixels=ct(e.previewPixels,n,`${o} preview pixels`),e.decodedBytes=ct(e.decodedBytes,t,`${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.`)},hy=(e,n,t,i)=>{let o=e.u8(n,`${i} length`);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-byte safety limit.`);let r=e.ascii(o,n,i),s=r.length;for(;s>0&&r.charCodeAt(s-1)===0;)s-=1;return r.slice(0,s)},gy=(e,n,t,i,o,r)=>{let s=Array.from({length:i},(l,c)=>e.u16(n,`${r} row ${c} length`)),a=o?new Uint8Array(To(t,i,`${r} pixels`)):void 0;for(let l=0;l<i;l+=1){let c=ct(e.offset,s[l],`${r} row ${l} end`);if(c>n)throw new Error(`${r} compressed row ${l} is truncated.`);let f=0;for(;e.offset<c;){let u=e.u8(c,`${r} PackBits header`);if(u<=127){let d=u+1,p=e.slice(d,c,`${r} PackBits literal`);if(f+d>t)throw new Error(`${r} row ${l} expands beyond its declared width.`);a&&a.set(p,l*t+f),f+=d}else if(u>=129){let d=257-u,p=e.u8(c,`${r} PackBits repeat value`);if(f+d>t)throw new Error(`${r} row ${l} expands beyond its declared width.`);a?.fill(p,l*t+f,l*t+f+d),f+=d}}if(f!==t)throw new Error(`${r} row ${l} expands to ${f} instead of ${t} pixels.`)}if(e.offset!==n)throw new Error(`${r} has trailing compressed bytes.`);return a},my=(e,n,t,i,o,r,s)=>{let a=To(t,i,`${s} pixels`);if(o===0){if(e.offset+a!==n)throw new Error(`${s} raw byte length does not match its dimensions.`);return r?Uint8Array.from(e.slice(a,n,s)):(e.skip(a,n,s),void 0)}if(o===1)return gy(e,n,t,i,r,s);throw new Error(`${s} uses unsupported compression mode ${o}.`)},tu=(e,n,t,i,o,r,s,a)=>{for(let l=0;l<i.height;l+=1)for(let c=0;c<i.width;c+=1){let f=l*i.width+c,u=((i.top-n.top+l)*n.width+i.left-n.left+c)*4,d=t[f];r===1&&o===0?(e[u]=d,e[u+1]=d,e[u+2]=d):r===2&&o===0&&s?(e[u]=s[d*3],e[u+1]=s[d*3+1],e[u+2]=s[d*3+2],a&&(a[(i.top-n.top+l)*n.width+i.left-n.left+c]=d)):e[u+o]=d}},su=(e,n,t,i,o,r)=>{if(e.u32(n,`PAT pattern ${r} version`)!==1)throw new Error(`PAT pattern ${r} uses an unsupported record version.`);let s=e.u32(n,`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(n,`PAT pattern ${r} vertical value`),l=e.i16(n,`PAT pattern ${r} horizontal value`),c=eu(e,n,t,`PAT pattern ${r} name`),f=hy(e,n,t,`PAT pattern ${r} id`);if(!f)throw new Error(`PAT pattern ${r} has an empty unique id.`);let u,d=65535;if(s===2&&(u=Uint8Array.from(e.slice(768,n,`PAT pattern ${r} indexed palette`)),o?(e.u16(n,`PAT pattern ${r} indexed color count`),d=e.u16(n,`PAT pattern ${r} transparent palette index`)):e.skip(4,n,`PAT pattern ${r} indexed footer`)),e.u32(n,`PAT pattern ${r} VMAL version`)!==3)throw new Error(`PAT pattern ${r} uses an unsupported VMAL version.`);let p=e.u32(n,`PAT pattern ${r} VMAL length`),h=ct(e.offset,p,`PAT pattern ${r} VMAL end`);if(h>n)throw new Error(`PAT pattern ${r} VMAL is truncated.`);let m=e.i32(h,`PAT pattern ${r} top`),y=e.i32(h,`PAT pattern ${r} left`),g=e.i32(h,`PAT pattern ${r} bottom`),k=e.i32(h,`PAT pattern ${r} right`),x=k-y,S=g-m,A=e.u32(h,`PAT pattern ${r} channel count`);if(x<=0||S<=0||x>t.maxCanvasDimension||S>t.maxCanvasDimension)throw new Error(`PAT pattern ${r} dimensions exceed the ${t.maxCanvasDimension}-pixel side safety limit.`);if(o&&(l!==x||a!==S))throw new Error(`PAT pattern ${r} header dimensions disagree with its decoded VMAL bounds.`);if(A>64)throw new Error(`PAT pattern ${r} channel count exceeds the 64-channel safety limit.`);let D=To(x,S,`PAT pattern ${r} pixels`);ru(i,D,To(D,4,`PAT pattern ${r} RGBA bytes`),t,`PAT pattern ${r}`);let C=new Uint8Array(D*4);for(let R=3;R<C.length;R+=4)C[R]=255;let O=s===2?new Uint8Array(D):void 0,E=s===3?3:1,L=new Set,M=!1,J={top:m,left:y,width:x,height:S};for(let R=0;R<A+2;R+=1){let ie=e.u32(h,`PAT pattern ${r} channel ${R} presence`);if(!ie)continue;if(ie!==1)throw new Error(`PAT pattern ${r} channel ${R} has an invalid presence marker.`);let he=e.u32(h,`PAT pattern ${r} channel ${R} length`);if(he<23)throw new Error(`PAT pattern ${r} channel ${R} is shorter than its header.`);let ce=ct(e.offset,he,`PAT pattern ${r} channel ${R} end`);if(ce>h)throw new Error(`PAT pattern ${r} channel ${R} is truncated.`);let Ce=e.u32(ce,`PAT pattern ${r} channel ${R} depth`),W=e.i32(ce,`PAT pattern ${r} channel ${R} top`),B=e.i32(ce,`PAT pattern ${r} channel ${R} left`),$=e.i32(ce,`PAT pattern ${r} channel ${R} bottom`),ne=e.i32(ce,`PAT pattern ${r} channel ${R} right`),ge=e.u16(ce,`PAT pattern ${r} channel ${R} depth copy`),Q=e.u8(ce,`PAT pattern ${r} channel ${R} compression`);if(Ce!==8||ge!==8)throw new Error(`PAT pattern ${r} channel ${R} is not 8-bit.`);if(W<m||B<y||$>g||ne>k||$<=W||ne<=B)throw new Error(`PAT pattern ${r} channel ${R} bounds are outside the tile.`);let ee=ne-B,be=$-W,Se=R<E,xe=R===A+1,jt=my(e,ce,ee,be,Q,Se||xe,`PAT pattern ${r} channel ${R}`);jt&&Se?(L.add(R),tu(C,J,jt,{top:W,left:B,width:ee,height:be},R,s,u,O)):jt&&xe&&(M=!0,tu(C,J,jt,{top:W,left:B,width:ee,height:be},3,s))}if(e.offset!==h)throw new Error(`PAT pattern ${r} VMAL has trailing or unparsed bytes.`);if(L.size!==E)throw new Error(`PAT pattern ${r} is missing one or more required color planes.`);if(s===2&&!M&&d<256&&O)for(let R=0;R<O.length;R+=1)O[R]===d&&(C[R*4+3]=0);let pe=!1;for(let R=0;R<D;R+=1)if(C[R*4+3]!==255){pe=!0;break}return{name:c||`Pattern ${r}`,id:f,width:x,height:S,colorMode:s===1?"grayscale":s===2?"indexed":"rgb",rgba:C,hasTransparency:pe}},yy=(e,n,t,i)=>{let o=[];for(;e.offset<n;){if(o.length>=t.maxResourceItems)throw new Error(`Embedded pattern count exceeds the ${t.maxResourceItems}-item safety limit.`);let r=e.u32(n,"Embedded PAT record length"),s=ct(e.offset,r,"Embedded PAT record end"),a=ct(e.offset,ou(r),"Embedded PAT padded end");if(!r||s>n||a>n)throw new Error("Embedded PAT record is truncated.");if(o.push(su(e,s,t,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!==n)throw new Error("Embedded PAT block length is invalid.");return o},by=(e,n)=>{ea(e,n,"PAT");let t=new Xn(e);if(t.ascii(4,t.length,"PAT signature")!=="8BPT")throw new Error("Invalid Photoshop PAT signature.");if(t.u16(t.length,"PAT version")!==1)throw new Error("Unsupported Photoshop PAT version; expected version 1.");let i=t.u32(t.length,"PAT pattern count");if(!i||i>n.maxResourceItems)throw new Error(`PAT pattern count must be between 1 and ${n.maxResourceItems}.`);let o={previewPixels:0,decodedBytes:0},r=Array.from({length:i},(s,a)=>su(t,t.length,n,o,!0,a+1));return na(t,n,Pi(n),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."]}},Ue=(e,n,t,i)=>{if(!Number.isFinite(e)||e<n||e>t)throw new Error(`${i} is outside ${n}\u2026${t}.`);return e},$e=e=>Math.max(0,Math.min(255,Math.round(e))),wy=(e,n,t)=>{let i=(e%360+360)%360/60,o=Math.max(0,Math.min(1,n/100)),r=Math.max(0,Math.min(1,t/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(f=>$e((f+l)*255))},vy=(e,n,t)=>{let i=.20689655172413793,o=p=>p>i?p**3:3*i*i*(p-4/29),r=(e+16)/116,s=.96422*o(r+n/500),a=o(r),l=.82521*o(r-t/200),c=.9555766*s-.0230393*a+.0631636*l,f=-.0282895*s+1.0099416*a+.0210077*l,u=.0122982*s-.020483*a+1.3299098*l;return[3.2404542*c-1.5371385*f-.4985314*u,-.969266*c+1.8760108*f+.041556*u,.0556434*c-.2040259*f+1.0572252*u].map(p=>$e((p<=.0031308?12.92*p:1.055*Math.max(0,p)**(1/2.4)-.055)*255))},Sy=e=>{if(!e)return{rgb:[0,0,0],colorSpace:"unknown"};if(e.classId==="RGBC")return{rgb:[$e(Ie(e,"Rd ")),$e(Ie(e,"Grn ")),$e(Ie(e,"Bl "))],colorSpace:"rgb"};if(e.classId==="Grsc"){let n=$e(Ue(Ie(e,"Gry "),0,100,"GRD gray")*2.55);return{rgb:[n,n,n],colorSpace:"gray"}}if(e.classId==="HSBC"||e.classId==="HSBl")return{rgb:wy(Ie(e,"H "),Ie(e,"Strt"),Ie(e,"Brgh")),colorSpace:"hsb"};if(e.classId==="LbCl")return{rgb:vy(Ie(e,"Lmnc"),Ie(e,"A "),Ie(e,"B ")),colorSpace:"lab"};if(e.classId==="CMYC"){let n=Ue(Ie(e,"Cyn "),0,100,"GRD cyan")/100,t=Ue(Ie(e,"Mgnt"),0,100,"GRD magenta")/100,i=Ue(Ie(e,"Ylw "),0,100,"GRD yellow")/100,o=Ue(Ie(e,"Blck"),0,100,"GRD black")/100;return{rgb:[$e((1-n)*(1-o)*255),$e((1-t)*(1-o)*255),$e((1-i)*(1-o)*255)],colorSpace:"cmyk"}}return{rgb:[0,0,0],colorSpace:"unknown"}},Qs=(e,n,t)=>{if(!e||e.type!=="list")throw new Error(`${n} list is missing.`);if(e.value.length>t)throw new Error(`${n} exceeds the ${t}-item safety limit.`);return e.value.map((i,o)=>{if(i.type!=="object")throw new Error(`${n} item ${o+1} is not an object.`);return i.value})},xy=(e,n)=>e<=n?n<=0?.5:.5*e/n:n>=1?.5:.5+.5*(e-n)/(1-n),nu=(e,n,t)=>{if(n<=e[0].location)return e[0].value;if(n>=e.at(-1).location)return e.at(-1).value;let i=e.findIndex(l=>l.location>=n),o=e[i-1],r=e[i],s=Math.max(1e-9,r.location-o.location),a=xy((n-o.location)/s,Math.max(.001,Math.min(.999,o.midpoint)));return Array.from({length:t},(l,c)=>o.value[c]+(r.value[c]-o.value[c])*a)},ky=(e,n)=>{let t=new Uint8Array(1024),i=e.map(r=>({location:r.location,midpoint:r.midpoint,value:r.rgb})),o=n.map(r=>({location:r.location,midpoint:r.midpoint,value:[r.opacity]}));for(let r=0;r<256;r+=1){let s=r/255,a=nu(i,s,3),l=nu(o,s,1)[0];t.set([$e(a[0]),$e(a[1]),$e(a[2]),$e(l*255)],r*4)}return t},iu=(e,n,t)=>{let i=Me(e,n),o=i?.type==="list"?i.value:[];return[0,1,2,3].map(r=>{let s=o[r];return s?.type==="integer"?Ue(s.value,0,100,`GRD ${n} range`):t})},_y=(e,n,t,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]=$e((n[l]+s()*(t[l]-n[l]))*2.55);o[a*4+3]=i?$e((n[3]+s()*(t[3]-n[3]))*2.55):255}return o},ta=e=>{if(!e.startsWith("$$$/"))return e;let n=e.lastIndexOf("=");if(n>=0&&n+1<e.length)return e.slice(n+1);let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e},Ay=(e,n,t,i)=>{ru(i,256,1024,t,`GRD gradient ${n}`);let o=Di(e,"Grad")||e,r=ta(gn(o,"Nm ")||`Gradient ${n}`),s=Oi(o,"GrdF")||"CstS";if(s==="ClNs"){let u=iu(o,"Mnm ",0),d=iu(o,"Mxm ",100);d.forEach((k,x)=>{if(k<u[x])throw new Error(`${r}: noise maximum is below its minimum.`)});let p=Ue(Ie(o,"RndS",0),0,4294967295,`${r} random seed`),h=Ue(Ie(o,"Smth",2048),0,4096,`${r} roughness`),m=Oi(o,"ClrS")||"RGBC",y=m==="HSBl"||m==="HSBC"?"hsb":m==="LbCl"||m==="LABC"?"lab":"rgb",g=Ei(o,"ShTr",!1);return{name:r,definition:{form:"noise",seed:p,roughness:h,colorModel:y,restrictColors:Ei(o,"VctC",!0),addTransparency:g,minimum:u,maximum:d},previewRgba:_y(p,u,d,g)}}if(s!=="CstS")throw new Error(`${r}: unsupported GRD gradient form ${JSON.stringify(s)}.`);let l=Qs(Me(o,"Clrs"),`${r} color stops`,Math.min(256,t.maxResourceItems)).map((u,d)=>{let p=Ue(Ie(u,"Lctn")/4096,0,1,`${r} color stop ${d+1} location`),h=Ue(Ie(u,"Mdpn",50)/100,0,1,`${r} color stop ${d+1} midpoint`),m=Oi(u,"Type")||"UsrS",y=m==="FrgC"?"foreground":m==="BckC"?"background":"user",g=y==="foreground"?{rgb:[0,0,0],colorSpace:"unknown"}:y==="background"?{rgb:[255,255,255],colorSpace:"unknown"}:Sy(Di(u,"Clr "));if(y==="user"&&g.colorSpace==="unknown")throw new Error(`${r} color stop ${d+1} uses an unsupported color object.`);return{location:p,midpoint:h,kind:y,...g}}).sort((u,d)=>u.location-d.location);if(l.length<2)throw new Error(`${r} has fewer than two usable color stops.`);let c=Me(o,"Trns"),f=c?Qs(c,`${r} transparency stops`,Math.min(256,t.maxResourceItems)).map((u,d)=>({location:Ue(Ie(u,"Lctn")/4096,0,1,`${r} alpha stop ${d+1} location`),midpoint:Ue(Ie(u,"Mdpn",50)/100,0,1,`${r} alpha stop ${d+1} midpoint`),opacity:Ue(Ie(u,"Opct",100)/100,0,1,`${r} alpha stop ${d+1} opacity`)})).sort((u,d)=>u.location-d.location):[{location:0,midpoint:.5,opacity:1},{location:1,midpoint:.5,opacity:1}];if(!f.length)throw new Error(`${r} declares an empty transparency-stop list.`);return{name:r,definition:{form:"solid",smoothness:Ue(Ie(o,"Intr",4096),0,4096,`${r} smoothness`),colorStops:l,alphaStops:f},previewRgba:ky(l,f)}},Iy=(e,n)=>{let t=Me(e,"hierarchy");if(!t||t.type!=="list")return Array.from({length:n},()=>"");let i=Array.from({length:n},()=>""),o=[],r=0;for(let s of t.value)s.type==="object"&&(s.value.classId==="Grup"?o.push(ta(gn(s.value,"Nm ")||"")):s.value.classId==="groupEnd"?o.pop():s.value.classId==="preset"&&r<i.length&&(i[r++]=o.filter(Boolean).join(" / ")));return i},na=(e,n,t,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=ct(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=hn(e,r,n,t);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 Iy(s,i)},Cy=(e,n)=>{ea(e,n,"GRD");let t=new Xn(e);if(t.ascii(4,t.length,"GRD signature")!=="8BGR")throw new Error("Invalid Photoshop GRD signature.");if(t.u16(t.length,"GRD version")!==5)throw new Error("Unsupported Photoshop GRD version; only descriptor-based version 5 is decoded.");if(t.u32(t.length,"GRD descriptor version")!==16)throw new Error("Unsupported GRD Action Descriptor version.");let i=Pi(n),o=hn(t,t.length,n,i),r={previewPixels:0,decodedBytes:0},s=Qs(Me(o,"GrdL"),"GRD gradients",n.maxResourceItems).map((l,c)=>Ay(l,c+1,n,r));if(!s.length)throw new Error("GRD file contains no gradients.");let a=na(t,n,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."]}},Py=[{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"}],Dy=e=>{if(!e)return[];let n=[];for(let t of Py){let i=Me(e,t.single),o=Me(e,t.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&&n.push({kind:t.kind,enabled:r.some(s=>Ei(s,"enab",!0)),instances:r.length})}return n},Ro=(e,n)=>{if(e.type==="object"){n(e.value);for(let t of e.value.entries.values())Ro(t,n)}else if(e.type==="list")e.value.forEach(t=>Ro(t,n));else if(e.type==="object-array"){n(e.value);for(let t of e.value.entries.values())Ro(t,n)}},Oy=e=>{let n=new Map;if(!e)return[];let t=i=>{if(i.classId!=="Ptrn"&&!i.entries.has("Idnt"))return;let o=gn(i,"Idnt")||"",r=gn(i,"Nm ")||"";o&&n.set(o,{name:r,id:o})};t(e);for(let i of e.entries.values())Ro(i,t);return[...n.values()]},Ey=(e,n,t,i,o)=>{if(e.u32(n,`ASL style ${o} identity descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported identity descriptor version.`);let r=hn(e,n,t,i),s=ta(gn(r,"Nm ")||""),a=gn(r,"Idnt")||"";if(!s||!a)throw new Error(`ASL style ${o} is missing its name or unique id.`);if(e.u32(n,`ASL style ${o} effect descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported effect descriptor version.`);let l=hn(e,n,t,i),c=Di(l,"Lefx"),f=Di(l,"blendOptions"),u=Me(f,"Blnd"),d={name:s,id:a,effectsVisible:Ei(c,"masterFXSwitch",!0),effects:Dy(c),blendIfChannels:u?.type==="list"?u.value.length:0,referencedPatterns:Oy(c)},p=Oi(f,"Md ");p&&(d.blendMode=p);let h=Me(f,"Opct");(h?.type==="unit-double"||h?.type==="double"||h?.type==="integer")&&(d.opacity=Ue(h.value,0,100,`${s} opacity`));let m=Me(f,"fillOpacity");if((m?.type==="unit-double"||m?.type==="double"||m?.type==="integer")&&(d.fillOpacity=Ue(m.value,0,100,`${s} fill opacity`)),!d.effects.length&&!f)throw new Error(`${s} contains no supported effect graph or blending options.`);return d},Fy=(e,n)=>{ea(e,n,"ASL");let t=new Xn(e);if(t.u16(t.length,"ASL version")!==2)throw new Error("Unsupported Photoshop ASL version; expected version 2.");if(t.ascii(4,t.length,"ASL signature")!=="8BSL")throw new Error("Invalid Photoshop ASL signature.");if(t.u16(t.length,"ASL pattern section version")!==3)throw new Error("Unsupported ASL embedded-pattern section version.");let i=t.u32(t.length,"ASL embedded-pattern section length"),o=ct(t.offset,i,"ASL embedded-pattern section end");if(o>t.length)throw new Error("ASL embedded-pattern section is truncated.");let s=i?yy(t,o,n,{previewPixels:0,decodedBytes:0}):[],a=t.u32(t.length,"ASL style count");if(!a||a>n.maxResourceItems)throw new Error(`ASL style count must be between 1 and ${n.maxResourceItems}.`);let l=Pi(n),c=[];for(let f=0;f<a;f+=1){let u=t.u32(t.length,`ASL style ${f+1} length`),d=ct(t.offset,u,`ASL style ${f+1} end`),p=ct(t.offset,ou(u),`ASL style ${f+1} padded end`);if(!u||d>t.length||p>t.length)throw new Error(`ASL style ${f+1} record is truncated.`);c.push(Ey(t,d,n,l,f+1));for(let h of t.slice(d-t.offset,d,`ASL style ${f+1} padding`))if(h!==0)throw new Error(`ASL style ${f+1} has unparsed non-zero bytes.`);for(let h of t.slice(p-d,p,`ASL style ${f+1} alignment`))if(h!==0)throw new Error(`ASL style ${f+1} has non-zero alignment bytes.`)}return na(t,n,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."]}},au=(e,n,t)=>{if(py(t),n==="pat")return by(e,t);if(n==="grd")return Cy(e,t);if(n==="asl")return Fy(e,t);throw new Error(`Unsupported Adobe preset format ${JSON.stringify(n)}.`)};var jo=self,lu=e=>e.format==="abr"?[...e.samples.map(n=>n.alpha.buffer),...e.patterns.map(n=>n.rgba.buffer)].filter(n=>n instanceof ArrayBuffer):e.format==="pat"?e.patterns.map(n=>n.rgba.buffer).filter(n=>n instanceof ArrayBuffer):e.format==="grd"?e.gradients.map(n=>n.previewRgba.buffer).filter(n=>n instanceof ArrayBuffer):e.format==="asl"?e.patterns.map(n=>n.rgba.buffer).filter(n=>n instanceof ArrayBuffer):[];jo.addEventListener("message",e=>{let n=e.data;try{if(!n||n.type!=="parse"&&n.type!=="parse-preset")throw new Error("Invalid Adobe resource Worker request.");if(n.type==="parse-preset"){let t=au(n.buffer,n.format,n.limits),i={id:n.id,ok:!0,result:t};jo.postMessage(i,lu(t))}else{let t=Yd(n.buffer,n.format,n.limits),i={id:n.id,ok:!0,result:t};jo.postMessage(i,lu(t))}}catch(t){let i={id:n?.id??0,ok:!1,error:{name:t instanceof Error?t.name:"Error",message:t instanceof Error?t.message:String(t)}};jo.postMessage(i)}});