import{b as t,d as e,p as r,s as i,x as n,f as s,U as a,u as o,r as h,n as l,y as c}from"./index-BBP3z-Qn.js";class f extends i{constructor(){super(...arguments),this.indeterminate=!1,this.progress=0,this.density=0,this.closed=!1}open(){this.closed=!1}close(){this.closed=!0}render(){const t={"mdc-circular-progress--closed":this.closed,"mdc-circular-progress--indeterminate":this.indeterminate},e=48+4*this.density,r={width:`${e}px`,height:`${e}px`};return n`
      <div
        class="mdc-circular-progress ${s(t)}"
        style="${a(r)}"
        role="progressbar"
        aria-label="${o(this.ariaLabel)}"
        aria-valuemin="0"
        aria-valuemax="1"
        aria-valuenow="${o(this.indeterminate?void 0:this.progress)}">
        ${this.renderDeterminateContainer()}
        ${this.renderIndeterminateContainer()}
      </div>`}renderDeterminateContainer(){const t=48+4*this.density,e=t/2,r=this.density>=-3?18+11*this.density/6:12.5+5*(this.density+3)/4,i=6.2831852*r,s=(1-this.progress)*i,a=this.density>=-3?4+this.density*(1/3):3+(this.density+3)*(1/6);return n`
      <div class="mdc-circular-progress__determinate-container">
        <svg class="mdc-circular-progress__determinate-circle-graphic"
             viewBox="0 0 ${t} ${t}">
          <circle class="mdc-circular-progress__determinate-track"
                  cx="${e}" cy="${e}" r="${r}"
                  stroke-width="${a}"></circle>
          <circle class="mdc-circular-progress__determinate-circle"
                  cx="${e}" cy="${e}" r="${r}"
                  stroke-dasharray="${6.2831852*r}"
                  stroke-dashoffset="${s}"
                  stroke-width="${a}"></circle>
        </svg>
      </div>`}renderIndeterminateContainer(){return n`
      <div class="mdc-circular-progress__indeterminate-container">
        <div class="mdc-circular-progress__spinner-layer">
          ${this.renderIndeterminateSpinnerLayer()}
        </div>
      </div>`}renderIndeterminateSpinnerLayer(){const t=48+4*this.density,e=t/2,r=this.density>=-3?18+11*this.density/6:12.5+5*(this.density+3)/4,i=6.2831852*r,s=.5*i,a=this.density>=-3?4+this.density*(1/3):3+(this.density+3)*(1/6);return n`
        <div class="mdc-circular-progress__circle-clipper mdc-circular-progress__circle-left">
          <svg class="mdc-circular-progress__indeterminate-circle-graphic"
               viewBox="0 0 ${t} ${t}">
            <circle cx="${e}" cy="${e}" r="${r}"
                    stroke-dasharray="${i}"
                    stroke-dashoffset="${s}"
                    stroke-width="${a}"></circle>
          </svg>
        </div>
        <div class="mdc-circular-progress__gap-patch">
          <svg class="mdc-circular-progress__indeterminate-circle-graphic"
               viewBox="0 0 ${t} ${t}">
            <circle cx="${e}" cy="${e}" r="${r}"
                    stroke-dasharray="${i}"
                    stroke-dashoffset="${s}"
                    stroke-width="${.8*a}"></circle>
          </svg>
        </div>
        <div class="mdc-circular-progress__circle-clipper mdc-circular-progress__circle-right">
          <svg class="mdc-circular-progress__indeterminate-circle-graphic"
               viewBox="0 0 ${t} ${t}">
            <circle cx="${e}" cy="${e}" r="${r}"
                    stroke-dasharray="${i}"
                    stroke-dashoffset="${s}"
                    stroke-width="${a}"></circle>
          </svg>
        </div>`}update(t){super.update(t),t.has("progress")&&(this.progress>1&&(this.progress=1),this.progress<0&&(this.progress=0))}}t([e({type:Boolean,reflect:!0})],f.prototype,"indeterminate",void 0),t([e({type:Number,reflect:!0})],f.prototype,"progress",void 0),t([e({type:Number,reflect:!0})],f.prototype,"density",void 0),t([e({type:Boolean,reflect:!0})],f.prototype,"closed",void 0),t([r,e({type:String,attribute:"aria-label"})],f.prototype,"ariaLabel",void 0);const d=h`.mdc-circular-progress__determinate-circle,.mdc-circular-progress__indeterminate-circle-graphic{stroke:#6200ee;stroke:var(--mdc-theme-primary, #6200ee)}.mdc-circular-progress__determinate-track{stroke:transparent}@keyframes mdc-circular-progress-container-rotate{to{transform:rotate(360deg)}}@keyframes mdc-circular-progress-spinner-layer-rotate{12.5%{transform:rotate(135deg)}25%{transform:rotate(270deg)}37.5%{transform:rotate(405deg)}50%{transform:rotate(540deg)}62.5%{transform:rotate(675deg)}75%{transform:rotate(810deg)}87.5%{transform:rotate(945deg)}100%{transform:rotate(1080deg)}}@keyframes mdc-circular-progress-color-1-fade-in-out{from{opacity:.99}25%{opacity:.99}26%{opacity:0}89%{opacity:0}90%{opacity:.99}to{opacity:.99}}@keyframes mdc-circular-progress-color-2-fade-in-out{from{opacity:0}15%{opacity:0}25%{opacity:.99}50%{opacity:.99}51%{opacity:0}to{opacity:0}}@keyframes mdc-circular-progress-color-3-fade-in-out{from{opacity:0}40%{opacity:0}50%{opacity:.99}75%{opacity:.99}76%{opacity:0}to{opacity:0}}@keyframes mdc-circular-progress-color-4-fade-in-out{from{opacity:0}65%{opacity:0}75%{opacity:.99}90%{opacity:.99}to{opacity:0}}@keyframes mdc-circular-progress-left-spin{from{transform:rotate(265deg)}50%{transform:rotate(130deg)}to{transform:rotate(265deg)}}@keyframes mdc-circular-progress-right-spin{from{transform:rotate(-265deg)}50%{transform:rotate(-130deg)}to{transform:rotate(-265deg)}}.mdc-circular-progress{display:inline-flex;position:relative;direction:ltr;line-height:0;transition:opacity 250ms 0ms cubic-bezier(0.4, 0, 0.6, 1)}.mdc-circular-progress__determinate-container,.mdc-circular-progress__indeterminate-circle-graphic,.mdc-circular-progress__indeterminate-container,.mdc-circular-progress__spinner-layer{position:absolute;width:100%;height:100%}.mdc-circular-progress__determinate-container{transform:rotate(-90deg)}.mdc-circular-progress__indeterminate-container{font-size:0;letter-spacing:0;white-space:nowrap;opacity:0}.mdc-circular-progress__determinate-circle-graphic,.mdc-circular-progress__indeterminate-circle-graphic{fill:transparent}.mdc-circular-progress__determinate-circle{transition:stroke-dashoffset 500ms 0ms cubic-bezier(0, 0, 0.2, 1)}.mdc-circular-progress__gap-patch{position:absolute;top:0;left:47.5%;box-sizing:border-box;width:5%;height:100%;overflow:hidden}.mdc-circular-progress__gap-patch .mdc-circular-progress__indeterminate-circle-graphic{left:-900%;width:2000%;transform:rotate(180deg)}.mdc-circular-progress__circle-clipper{display:inline-flex;position:relative;width:50%;height:100%;overflow:hidden}.mdc-circular-progress__circle-clipper .mdc-circular-progress__indeterminate-circle-graphic{width:200%}.mdc-circular-progress__circle-right .mdc-circular-progress__indeterminate-circle-graphic{left:-100%}.mdc-circular-progress--indeterminate .mdc-circular-progress__determinate-container{opacity:0}.mdc-circular-progress--indeterminate .mdc-circular-progress__indeterminate-container{opacity:1}.mdc-circular-progress--indeterminate .mdc-circular-progress__indeterminate-container{animation:mdc-circular-progress-container-rotate 1568.2352941176ms linear infinite}.mdc-circular-progress--indeterminate .mdc-circular-progress__spinner-layer{animation:mdc-circular-progress-spinner-layer-rotate 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--indeterminate .mdc-circular-progress__color-1{animation:mdc-circular-progress-spinner-layer-rotate 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both,mdc-circular-progress-color-1-fade-in-out 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--indeterminate .mdc-circular-progress__color-2{animation:mdc-circular-progress-spinner-layer-rotate 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both,mdc-circular-progress-color-2-fade-in-out 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--indeterminate .mdc-circular-progress__color-3{animation:mdc-circular-progress-spinner-layer-rotate 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both,mdc-circular-progress-color-3-fade-in-out 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--indeterminate .mdc-circular-progress__color-4{animation:mdc-circular-progress-spinner-layer-rotate 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both,mdc-circular-progress-color-4-fade-in-out 5332ms cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--indeterminate .mdc-circular-progress__circle-left .mdc-circular-progress__indeterminate-circle-graphic{animation:mdc-circular-progress-left-spin 1333ms cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--indeterminate .mdc-circular-progress__circle-right .mdc-circular-progress__indeterminate-circle-graphic{animation:mdc-circular-progress-right-spin 1333ms cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--closed{opacity:0}:host{display:inline-flex}.mdc-circular-progress__determinate-track{stroke:transparent;stroke:var(--mdc-circular-progress-track-color, transparent)}`;let u=class extends f{};u.styles=[d],u=t([l("mwc-circular-progress")],u);const _=t=>c(`./downloads?configuration=${encodeURIComponent(t)}`),p=(t,e)=>`./download.bin?configuration=${encodeURIComponent(t)}&file=${encodeURIComponent(e.file)}&download=${encodeURIComponent(e.download)}`,g=t=>`./download.bin?configuration=${encodeURIComponent(t)}&file=firmware-factory.bin`,m=async t=>{import("./c.CyVU7PUN.js");const e=document.createElement("esphome-no-port-picked-dialog");return e.doTryAgain=t,document.body.append(e),!0};class y extends Error{}function w(t){let e=t.length;for(;--e>=0;)t[e]=0}const b=256,E=286,A=30,v=15,S=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]),k=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]),B=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),T=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),R=new Array(576);w(R);const I=new Array(60);w(I);const x=new Array(512);w(x);const U=new Array(256);w(U);const z=new Array(29);w(z);const L=new Array(A);function O(t,e,r,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let C,D,M;function F(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}w(L);const P=t=>t<256?x[t]:x[256+(t>>>7)],N=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},$=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,N(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},Z=(t,e,r)=>{$(t,r[2*e],r[2*e+1])},H=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},W=(t,e,r)=>{const i=new Array(16);let n,s,a=0;for(n=1;n<=v;n++)a=a+r[n-1]<<1,i[n]=a;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=H(i[e]++,e))}},j=t=>{let e;for(e=0;e<E;e++)t.dyn_ltree[2*e]=0;for(e=0;e<A;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},G=t=>{t.bi_valid>8?N(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},K=(t,e,r,i)=>{const n=2*e,s=2*r;return t[n]<t[s]||t[n]===t[s]&&i[e]<=i[r]},Y=(t,e,r)=>{const i=t.heap[r];let n=r<<1;for(;n<=t.heap_len&&(n<t.heap_len&&K(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!K(e,i,t.heap[n],t.depth));)t.heap[r]=t.heap[n],r=n,n<<=1;t.heap[r]=i},q=(t,e,r)=>{let i,n,s,a,o=0;if(0!==t.sym_next)do{i=255&t.pending_buf[t.sym_buf+o++],i+=(255&t.pending_buf[t.sym_buf+o++])<<8,n=t.pending_buf[t.sym_buf+o++],0===i?Z(t,n,e):(s=U[n],Z(t,s+b+1,e),a=S[s],0!==a&&(n-=z[s],$(t,n,a)),i--,s=P(i),Z(t,s,r),a=k[s],0!==a&&(i-=L[s],$(t,i,a)))}while(o<t.sym_next);Z(t,256,e)},V=(t,e)=>{const r=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,s=e.stat_desc.elems;let a,o,h,l=-1;for(t.heap_len=0,t.heap_max=573,a=0;a<s;a++)0!==r[2*a]?(t.heap[++t.heap_len]=l=a,t.depth[a]=0):r[2*a+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=l<2?++l:0,r[2*h]=1,t.depth[h]=0,t.opt_len--,n&&(t.static_len-=i[2*h+1]);for(e.max_code=l,a=t.heap_len>>1;a>=1;a--)Y(t,r,a);h=s;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Y(t,r,1),o=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=o,r[2*h]=r[2*a]+r[2*o],t.depth[h]=(t.depth[a]>=t.depth[o]?t.depth[a]:t.depth[o])+1,r[2*a+1]=r[2*o+1]=h,t.heap[1]=h++,Y(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,s=e.stat_desc.has_stree,a=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let l,c,f,d,u,_,p=0;for(d=0;d<=v;d++)t.bl_count[d]=0;for(r[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)c=t.heap[l],d=r[2*r[2*c+1]+1]+1,d>h&&(d=h,p++),r[2*c+1]=d,c>i||(t.bl_count[d]++,u=0,c>=o&&(u=a[c-o]),_=r[2*c],t.opt_len+=_*(d+u),s&&(t.static_len+=_*(n[2*c+1]+u)));if(0!==p){do{for(d=h-1;0===t.bl_count[d];)d--;t.bl_count[d]--,t.bl_count[d+1]+=2,t.bl_count[h]--,p-=2}while(p>0);for(d=h;0!==d;d--)for(c=t.bl_count[d];0!==c;)f=t.heap[--l],f>i||(r[2*f+1]!==d&&(t.opt_len+=(d-r[2*f+1])*r[2*f],r[2*f+1]=d),c--)}})(t,e),W(r,l,t.bl_count)},X=(t,e,r)=>{let i,n,s=-1,a=e[1],o=0,h=7,l=4;for(0===a&&(h=138,l=3),e[2*(r+1)+1]=65535,i=0;i<=r;i++)n=a,a=e[2*(i+1)+1],++o<h&&n===a||(o<l?t.bl_tree[2*n]+=o:0!==n?(n!==s&&t.bl_tree[2*n]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,s=n,0===a?(h=138,l=3):n===a?(h=6,l=3):(h=7,l=4))},J=(t,e,r)=>{let i,n,s=-1,a=e[1],o=0,h=7,l=4;for(0===a&&(h=138,l=3),i=0;i<=r;i++)if(n=a,a=e[2*(i+1)+1],!(++o<h&&n===a)){if(o<l)do{Z(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(Z(t,n,t.bl_tree),o--),Z(t,16,t.bl_tree),$(t,o-3,2)):o<=10?(Z(t,17,t.bl_tree),$(t,o-3,3)):(Z(t,18,t.bl_tree),$(t,o-11,7));o=0,s=n,0===a?(h=138,l=3):n===a?(h=6,l=3):(h=7,l=4)}};let Q=!1;const tt=(t,e,r,i)=>{$(t,0+(i?1:0),3),G(t),N(t,r),N(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r};var et=t=>{Q||((()=>{let t,e,r,i,n;const s=new Array(16);for(r=0,i=0;i<28;i++)for(z[i]=r,t=0;t<1<<S[i];t++)U[r++]=i;for(U[r-1]=i,n=0,i=0;i<16;i++)for(L[i]=n,t=0;t<1<<k[i];t++)x[n++]=i;for(n>>=7;i<A;i++)for(L[i]=n<<7,t=0;t<1<<k[i]-7;t++)x[256+n++]=i;for(e=0;e<=v;e++)s[e]=0;for(t=0;t<=143;)R[2*t+1]=8,t++,s[8]++;for(;t<=255;)R[2*t+1]=9,t++,s[9]++;for(;t<=279;)R[2*t+1]=7,t++,s[7]++;for(;t<=287;)R[2*t+1]=8,t++,s[8]++;for(W(R,287,s),t=0;t<A;t++)I[2*t+1]=5,I[2*t]=H(t,5);C=new O(R,S,257,E,v),D=new O(I,k,0,A,v),M=new O(new Array(0),B,0,19,7)})(),Q=!0),t.l_desc=new F(t.dyn_ltree,C),t.d_desc=new F(t.dyn_dtree,D),t.bl_desc=new F(t.bl_tree,M),t.bi_buf=0,t.bi_valid=0,j(t)},rt=(t,e,r,i)=>{let n,s,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<b;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),V(t,t.l_desc),V(t,t.d_desc),a=(t=>{let e;for(X(t,t.dyn_ltree,t.l_desc.max_code),X(t,t.dyn_dtree,t.d_desc.max_code),V(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*T[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),n=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=n&&(n=s)):n=s=r+5,r+4<=n&&-1!==e?tt(t,e,r,i):4===t.strategy||s===n?($(t,2+(i?1:0),3),q(t,R,I)):($(t,4+(i?1:0),3),((t,e,r,i)=>{let n;for($(t,e-257,5),$(t,r-1,5),$(t,i-4,4),n=0;n<i;n++)$(t,t.bl_tree[2*T[n]+1],3);J(t,t.dyn_ltree,e-1),J(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),q(t,t.dyn_ltree,t.dyn_dtree)),j(t),i&&G(t)},it=(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(U[r]+b+1)]++,t.dyn_dtree[2*P(e)]++),t.sym_next===t.sym_end),nt=t=>{$(t,2,3),Z(t,256,R),(t=>{16===t.bi_valid?(N(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)},st={_tr_init:et,_tr_stored_block:tt,_tr_flush_block:rt,_tr_tally:it,_tr_align:nt};var at=(t,e,r,i)=>{let n=65535&t|0,s=t>>>16&65535|0,a=0;for(;0!==r;){a=r>2e3?2e3:r,r-=a;do{n=n+e[i++]|0,s=s+n|0}while(--a);n%=65521,s%=65521}return n|s<<16|0};const ot=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var ht=(t,e,r,i)=>{const n=ot,s=i+r;t^=-1;for(let r=i;r<s;r++)t=t>>>8^n[255&(t^e[r])];return-1^t},lt={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"},ct={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ft,_tr_stored_block:dt,_tr_flush_block:ut,_tr_tally:_t,_tr_align:pt}=st,{Z_NO_FLUSH:gt,Z_PARTIAL_FLUSH:mt,Z_FULL_FLUSH:yt,Z_FINISH:wt,Z_BLOCK:bt,Z_OK:Et,Z_STREAM_END:At,Z_STREAM_ERROR:vt,Z_DATA_ERROR:St,Z_BUF_ERROR:kt,Z_DEFAULT_COMPRESSION:Bt,Z_FILTERED:Tt,Z_HUFFMAN_ONLY:Rt,Z_RLE:It,Z_FIXED:xt,Z_DEFAULT_STRATEGY:Ut,Z_UNKNOWN:zt,Z_DEFLATED:Lt}=ct,Ot=258,Ct=262,Dt=42,Mt=113,Ft=666,Pt=(t,e)=>(t.msg=lt[e],e),Nt=t=>2*t-(t>4?9:0),$t=t=>{let e=t.length;for(;--e>=0;)t[e]=0},Zt=t=>{let e,r,i,n=t.w_size;e=t.hash_size,i=e;do{r=t.head[--i],t.head[i]=r>=n?r-n:0}while(--e);e=n,i=e;do{r=t.prev[--i],t.prev[i]=r>=n?r-n:0}while(--e)};let Ht=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const Wt=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},jt=(t,e)=>{ut(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Wt(t.strm)},Gt=(t,e)=>{t.pending_buf[t.pending++]=e},Kt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Yt=(t,e,r,i)=>{let n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),r),1===t.state.wrap?t.adler=at(t.adler,e,n,r):2===t.state.wrap&&(t.adler=ht(t.adler,e,n,r)),t.next_in+=n,t.total_in+=n,n)},qt=(t,e)=>{let r,i,n=t.max_chain_length,s=t.strstart,a=t.prev_length,o=t.nice_match;const h=t.strstart>t.w_size-Ct?t.strstart-(t.w_size-Ct):0,l=t.window,c=t.w_mask,f=t.prev,d=t.strstart+Ot;let u=l[s+a-1],_=l[s+a];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(r=e,l[r+a]===_&&l[r+a-1]===u&&l[r]===l[s]&&l[++r]===l[s+1]){s+=2,r++;do{}while(l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&s<d);if(i=Ot-(d-s),s=d-Ot,i>a){if(t.match_start=e,a=i,i>=o)break;u=l[s+a-1],_=l[s+a]}}}while((e=f[e&c])>h&&0!=--n);return a<=t.lookahead?a:t.lookahead},Vt=t=>{const e=t.w_size;let r,i,n;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Ct)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),Zt(t),i+=e),0===t.strm.avail_in)break;if(r=Yt(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=r,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=Ht(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=Ht(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<Ct&&0!==t.strm.avail_in)},Xt=(t,e)=>{let r,i,n,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,a=0,o=t.strm.avail_in;do{if(r=65535,n=t.bi_valid+42>>3,t.strm.avail_out<n)break;if(n=t.strm.avail_out-n,i=t.strstart-t.block_start,r>i+t.strm.avail_in&&(r=i+t.strm.avail_in),r>n&&(r=n),r<s&&(0===r&&e!==wt||e===gt||r!==i+t.strm.avail_in))break;a=e===wt&&r===i+t.strm.avail_in?1:0,dt(t,0,0,a),t.pending_buf[t.pending-4]=r,t.pending_buf[t.pending-3]=r>>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,Wt(t.strm),i&&(i>r&&(i=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,r-=i),r&&(Yt(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===a);return o-=t.strm.avail_in,o&&(o>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=o&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-o,t.strm.next_in),t.strstart),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),a?4:e!==gt&&e!==wt&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(n=t.window_size-t.strstart,t.strm.avail_in>n&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,n+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),n>t.strm.avail_in&&(n=t.strm.avail_in),n&&(Yt(t.strm,t.window,t.strstart,n),t.strstart+=n,t.insert+=n>t.w_size-t.insert?t.w_size-t.insert:n),t.high_water<t.strstart&&(t.high_water=t.strstart),n=t.bi_valid+42>>3,n=t.pending_buf_size-n>65535?65535:t.pending_buf_size-n,s=n>t.w_size?t.w_size:n,i=t.strstart-t.block_start,(i>=s||(i||e===wt)&&e!==gt&&0===t.strm.avail_in&&i<=n)&&(r=i>n?n:i,a=e===wt&&0===t.strm.avail_in&&r===i?1:0,dt(t,t.block_start,r,a),t.block_start+=r,Wt(t.strm)),a?3:1)},Jt=(t,e)=>{let r,i;for(;;){if(t.lookahead<Ct){if(Vt(t),t.lookahead<Ct&&e===gt)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Ht(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-Ct&&(t.match_length=qt(t,r)),t.match_length>=3)if(i=_t(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=Ht(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=Ht(t,t.ins_h,t.window[t.strstart+1]);else i=_t(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(jt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===wt?(jt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(jt(t,!1),0===t.strm.avail_out)?1:2},Qt=(t,e)=>{let r,i,n;for(;;){if(t.lookahead<Ct){if(Vt(t),t.lookahead<Ct&&e===gt)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Ht(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-Ct&&(t.match_length=qt(t,r),t.match_length<=5&&(t.strategy===Tt||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=_t(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=Ht(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(jt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=_t(t,0,t.window[t.strstart-1]),i&&jt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=_t(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===wt?(jt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(jt(t,!1),0===t.strm.avail_out)?1:2};function te(t,e,r,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=i,this.func=n}const ee=[new te(0,0,0,0,Xt),new te(4,4,8,4,Jt),new te(4,5,16,8,Jt),new te(4,6,32,32,Jt),new te(4,4,16,16,Qt),new te(8,16,32,32,Qt),new te(8,16,128,128,Qt),new te(8,32,128,256,Qt),new te(32,128,258,1024,Qt),new te(32,258,258,4096,Qt)];function re(){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=Lt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),$t(this.dyn_ltree),$t(this.dyn_dtree),$t(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),$t(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),$t(this.depth),this.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}const ie=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Dt&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==Mt&&e.status!==Ft?1:0},ne=t=>{if(ie(t))return Pt(t,vt);t.total_in=t.total_out=0,t.data_type=zt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?Dt:Mt,t.adler=2===e.wrap?0:1,e.last_flush=-2,ft(e),Et},se=t=>{const e=ne(t);return e===Et&&(t=>{t.window_size=2*t.w_size,$t(t.head),t.max_lazy_match=ee[t.level].max_lazy,t.good_match=ee[t.level].good_length,t.nice_match=ee[t.level].nice_length,t.max_chain_length=ee[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0})(t.state),e},ae=(t,e,r,i,n,s)=>{if(!t)return vt;let a=1;if(e===Bt&&(e=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),n<1||n>9||r!==Lt||i<8||i>15||e<0||e>9||s<0||s>xt||8===i&&1!==a)return Pt(t,vt);8===i&&(i=9);const o=new re;return t.state=o,o.strm=t,o.status=Dt,o.wrap=a,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=e,o.strategy=s,o.method=r,se(t)};var oe=(t,e)=>{if(ie(t)||e>bt||e<0)return t?Pt(t,vt):vt;const r=t.state;if(!t.output||0!==t.avail_in&&!t.input||r.status===Ft&&e!==wt)return Pt(t,0===t.avail_out?kt:vt);const i=r.last_flush;if(r.last_flush=e,0!==r.pending){if(Wt(t),0===t.avail_out)return r.last_flush=-1,Et}else if(0===t.avail_in&&Nt(e)<=Nt(i)&&e!==wt)return Pt(t,kt);if(r.status===Ft&&0!==t.avail_in)return Pt(t,kt);if(r.status===Dt&&0===r.wrap&&(r.status=Mt),r.status===Dt){let e=Lt+(r.w_bits-8<<4)<<8,i=-1;if(i=r.strategy>=Rt||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=i<<6,0!==r.strstart&&(e|=32),e+=31-e%31,Kt(r,e),0!==r.strstart&&(Kt(r,t.adler>>>16),Kt(r,65535&t.adler)),t.adler=1,r.status=Mt,Wt(t),0!==r.pending)return r.last_flush=-1,Et}if(57===r.status)if(t.adler=0,Gt(r,31),Gt(r,139),Gt(r,8),r.gzhead)Gt(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Gt(r,255&r.gzhead.time),Gt(r,r.gzhead.time>>8&255),Gt(r,r.gzhead.time>>16&255),Gt(r,r.gzhead.time>>24&255),Gt(r,9===r.level?2:r.strategy>=Rt||r.level<2?4:0),Gt(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Gt(r,255&r.gzhead.extra.length),Gt(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=ht(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(Gt(r,0),Gt(r,0),Gt(r,0),Gt(r,0),Gt(r,0),Gt(r,9===r.level?2:r.strategy>=Rt||r.level<2?4:0),Gt(r,3),r.status=Mt,Wt(t),0!==r.pending)return r.last_flush=-1,Et;if(69===r.status){if(r.gzhead.extra){let e=r.pending,i=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+i>r.pending_buf_size;){let n=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>e&&(t.adler=ht(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex+=n,Wt(t),0!==r.pending)return r.last_flush=-1,Et;e=0,i-=n}let n=new Uint8Array(r.gzhead.extra);r.pending_buf.set(n.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending+=i,r.gzhead.hcrc&&r.pending>e&&(t.adler=ht(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let e,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(t.adler=ht(t.adler,r.pending_buf,r.pending-i,i)),Wt(t),0!==r.pending)return r.last_flush=-1,Et;i=0}e=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Gt(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>i&&(t.adler=ht(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let e,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(t.adler=ht(t.adler,r.pending_buf,r.pending-i,i)),Wt(t),0!==r.pending)return r.last_flush=-1,Et;i=0}e=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Gt(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>i&&(t.adler=ht(t.adler,r.pending_buf,r.pending-i,i))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Wt(t),0!==r.pending))return r.last_flush=-1,Et;Gt(r,255&t.adler),Gt(r,t.adler>>8&255),t.adler=0}if(r.status=Mt,Wt(t),0!==r.pending)return r.last_flush=-1,Et}if(0!==t.avail_in||0!==r.lookahead||e!==gt&&r.status!==Ft){let i=0===r.level?Xt(r,e):r.strategy===Rt?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(Vt(t),0===t.lookahead)){if(e===gt)return 1;break}if(t.match_length=0,r=_t(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(jt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===wt?(jt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(jt(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===It?((t,e)=>{let r,i,n,s;const a=t.window;for(;;){if(t.lookahead<=Ot){if(Vt(t),t.lookahead<=Ot&&e===gt)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,i=a[n],i===a[++n]&&i===a[++n]&&i===a[++n])){s=t.strstart+Ot;do{}while(i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&n<s);t.match_length=Ot-(s-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=_t(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=_t(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(jt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===wt?(jt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(jt(t,!1),0===t.strm.avail_out)?1:2})(r,e):ee[r.level].func(r,e);if(3!==i&&4!==i||(r.status=Ft),1===i||3===i)return 0===t.avail_out&&(r.last_flush=-1),Et;if(2===i&&(e===mt?pt(r):e!==bt&&(dt(r,0,0,!1),e===yt&&($t(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),Wt(t),0===t.avail_out))return r.last_flush=-1,Et}return e!==wt?Et:r.wrap<=0?At:(2===r.wrap?(Gt(r,255&t.adler),Gt(r,t.adler>>8&255),Gt(r,t.adler>>16&255),Gt(r,t.adler>>24&255),Gt(r,255&t.total_in),Gt(r,t.total_in>>8&255),Gt(r,t.total_in>>16&255),Gt(r,t.total_in>>24&255)):(Kt(r,t.adler>>>16),Kt(r,65535&t.adler)),Wt(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Et:At)},he=(t,e)=>{let r=e.length;if(ie(t))return vt;const i=t.state,n=i.wrap;if(2===n||1===n&&i.status!==Dt||i.lookahead)return vt;if(1===n&&(t.adler=at(t.adler,e,r,0)),i.wrap=0,r>=i.w_size){0===n&&($t(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(r-i.w_size,r),0),e=t,r=i.w_size}const s=t.avail_in,a=t.next_in,o=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,Vt(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=Ht(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,Vt(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=a,t.input=o,t.avail_in=s,i.wrap=n,Et},le={deflateInit:(t,e)=>ae(t,e,Lt,15,8,Ut),deflateInit2:ae,deflateReset:se,deflateResetKeep:ne,deflateSetHeader:(t,e)=>ie(t)||2!==t.state.wrap?vt:(t.state.gzhead=e,Et),deflate:oe,deflateEnd:t=>{if(ie(t))return vt;const e=t.state.status;return t.state=null,e===Mt?Pt(t,St):Et},deflateSetDictionary:he,deflateInfo:"pako deflate (from Nodeca project)"};const ce=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var fe={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)ce(r,e)&&(t[e]=r[e])}}return t},flattenChunks:t=>{let e=0;for(let r=0,i=t.length;r<i;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,i=0,n=t.length;e<n;e++){let n=t[e];r.set(n,i),i+=n.length}return r}};let de=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){de=!1}const ue=new Uint8Array(256);for(let t=0;t<256;t++)ue[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;ue[254]=ue[254]=1;var _e={string2buf:t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,i,n,s,a=t.length,o=0;for(n=0;n<a;n++)r=t.charCodeAt(n),55296==(64512&r)&&n+1<a&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),o+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(o),s=0,n=0;s<o;n++)r=t.charCodeAt(n),55296==(64512&r)&&n+1<a&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?e[s++]=r:r<2048?(e[s++]=192|r>>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},buf2string:(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,n;const s=new Array(2*r);for(n=0,i=0;i<r;){let e=t[i++];if(e<128){s[n++]=e;continue}let a=ue[e];if(a>4)s[n++]=65533,i+=a-1;else{for(e&=2===a?31:3===a?15:7;a>1&&i<r;)e=e<<6|63&t[i++],a--;a>1?s[n++]=65533:e<65536?s[n++]=e:(e-=65536,s[n++]=55296|e>>10&1023,s[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&de)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let i=0;i<e;i++)r+=String.fromCharCode(t[i]);return r})(s,n)},utf8border:(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+ue[t[r]]>e?r:e}};var pe=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const ge=Object.prototype.toString,{Z_NO_FLUSH:me,Z_SYNC_FLUSH:ye,Z_FULL_FLUSH:we,Z_FINISH:be,Z_OK:Ee,Z_STREAM_END:Ae,Z_DEFAULT_COMPRESSION:ve,Z_DEFAULT_STRATEGY:Se,Z_DEFLATED:ke}=ct;function Be(t){this.options=fe.assign({level:ve,method:ke,chunkSize:16384,windowBits:15,memLevel:8,strategy:Se},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new pe,this.strm.avail_out=0;let r=le.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Ee)throw new Error(lt[r]);if(e.header&&le.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?_e.string2buf(e.dictionary):"[object ArrayBuffer]"===ge.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=le.deflateSetDictionary(this.strm,t),r!==Ee)throw new Error(lt[r]);this._dict_set=!0}}function Te(t,e){const r=new Be(e);if(r.push(t,!0),r.err)throw r.msg||lt[r.err];return r.result}Be.prototype.push=function(t,e){const r=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?be:me,"string"==typeof t?r.input=_e.string2buf(t):"[object ArrayBuffer]"===ge.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(s===ye||s===we)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=le.deflate(r,s),n===Ae)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=le.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Ee;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Be.prototype.onData=function(t){this.chunks.push(t)},Be.prototype.onEnd=function(t){t===Ee&&(this.result=fe.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Re={Deflate:Be,deflate:Te,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Te(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Te(t,e)},constants:ct};const Ie=16209;var xe=function(t,e){let r,i,n,s,a,o,h,l,c,f,d,u,_,p,g,m,y,w,b,E,A,v,S,k;const B=t.state;r=t.next_in,S=t.input,i=r+(t.avail_in-5),n=t.next_out,k=t.output,s=n-(e-t.avail_out),a=n+(t.avail_out-257),o=B.dmax,h=B.wsize,l=B.whave,c=B.wnext,f=B.window,d=B.hold,u=B.bits,_=B.lencode,p=B.distcode,g=(1<<B.lenbits)-1,m=(1<<B.distbits)-1;t:do{u<15&&(d+=S[r++]<<u,u+=8,d+=S[r++]<<u,u+=8),y=_[d&g];e:for(;;){if(w=y>>>24,d>>>=w,u-=w,w=y>>>16&255,0===w)k[n++]=65535&y;else{if(!(16&w)){if(0==(64&w)){y=_[(65535&y)+(d&(1<<w)-1)];continue e}if(32&w){B.mode=16191;break t}t.msg="invalid literal/length code",B.mode=Ie;break t}b=65535&y,w&=15,w&&(u<w&&(d+=S[r++]<<u,u+=8),b+=d&(1<<w)-1,d>>>=w,u-=w),u<15&&(d+=S[r++]<<u,u+=8,d+=S[r++]<<u,u+=8),y=p[d&m];r:for(;;){if(w=y>>>24,d>>>=w,u-=w,w=y>>>16&255,!(16&w)){if(0==(64&w)){y=p[(65535&y)+(d&(1<<w)-1)];continue r}t.msg="invalid distance code",B.mode=Ie;break t}if(E=65535&y,w&=15,u<w&&(d+=S[r++]<<u,u+=8,u<w&&(d+=S[r++]<<u,u+=8)),E+=d&(1<<w)-1,E>o){t.msg="invalid distance too far back",B.mode=Ie;break t}if(d>>>=w,u-=w,w=n-s,E>w){if(w=E-w,w>l&&B.sane){t.msg="invalid distance too far back",B.mode=Ie;break t}if(A=0,v=f,0===c){if(A+=h-w,w<b){b-=w;do{k[n++]=f[A++]}while(--w);A=n-E,v=k}}else if(c<w){if(A+=h+c-w,w-=c,w<b){b-=w;do{k[n++]=f[A++]}while(--w);if(A=0,c<b){w=c,b-=w;do{k[n++]=f[A++]}while(--w);A=n-E,v=k}}}else if(A+=c-w,w<b){b-=w;do{k[n++]=f[A++]}while(--w);A=n-E,v=k}for(;b>2;)k[n++]=v[A++],k[n++]=v[A++],k[n++]=v[A++],b-=3;b&&(k[n++]=v[A++],b>1&&(k[n++]=v[A++]))}else{A=n-E;do{k[n++]=k[A++],k[n++]=k[A++],k[n++]=k[A++],b-=3}while(b>2);b&&(k[n++]=k[A++],b>1&&(k[n++]=k[A++]))}break}}break}}while(r<i&&n<a);b=u>>3,r-=b,u-=b<<3,d&=(1<<u)-1,t.next_in=r,t.next_out=n,t.avail_in=r<i?i-r+5:5-(r-i),t.avail_out=n<a?a-n+257:257-(n-a),B.hold=d,B.bits=u};const Ue=15,ze=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]),Le=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]),Oe=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]),Ce=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var De=(t,e,r,i,n,s,a,o)=>{const h=o.bits;let l,c,f,d,u,_,p=0,g=0,m=0,y=0,w=0,b=0,E=0,A=0,v=0,S=0,k=null;const B=new Uint16Array(16),T=new Uint16Array(16);let R,I,x,U=null;for(p=0;p<=Ue;p++)B[p]=0;for(g=0;g<i;g++)B[e[r+g]]++;for(w=h,y=Ue;y>=1&&0===B[y];y--);if(w>y&&(w=y),0===y)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(m=1;m<y&&0===B[m];m++);for(w<m&&(w=m),A=1,p=1;p<=Ue;p++)if(A<<=1,A-=B[p],A<0)return-1;if(A>0&&(0===t||1!==y))return-1;for(T[1]=0,p=1;p<Ue;p++)T[p+1]=T[p]+B[p];for(g=0;g<i;g++)0!==e[r+g]&&(a[T[e[r+g]]++]=g);if(0===t?(k=U=a,_=20):1===t?(k=ze,U=Le,_=257):(k=Oe,U=Ce,_=0),S=0,g=0,p=m,u=s,b=w,E=0,f=-1,v=1<<w,d=v-1,1===t&&v>852||2===t&&v>592)return 1;for(;;){R=p-E,a[g]+1<_?(I=0,x=a[g]):a[g]>=_?(I=U[a[g]-_],x=k[a[g]-_]):(I=96,x=0),l=1<<p-E,c=1<<b,m=c;do{c-=l,n[u+(S>>E)+c]=R<<24|I<<16|x|0}while(0!==c);for(l=1<<p-1;S&l;)l>>=1;if(0!==l?(S&=l-1,S+=l):S=0,g++,0==--B[p]){if(p===y)break;p=e[r+a[g]]}if(p>w&&(S&d)!==f){for(0===E&&(E=w),u+=m,b=p-E,A=1<<b;b+E<y&&(A-=B[b+E],!(A<=0));)b++,A<<=1;if(v+=1<<b,1===t&&v>852||2===t&&v>592)return 1;f=S&d,n[f]=w<<24|b<<16|u-s|0}}return 0!==S&&(n[u+S]=p-E<<24|64<<16|0),o.bits=w,0};const{Z_FINISH:Me,Z_BLOCK:Fe,Z_TREES:Pe,Z_OK:Ne,Z_STREAM_END:$e,Z_NEED_DICT:Ze,Z_STREAM_ERROR:He,Z_DATA_ERROR:We,Z_MEM_ERROR:je,Z_BUF_ERROR:Ge,Z_DEFLATED:Ke}=ct,Ye=16180,qe=16190,Ve=16191,Xe=16192,Je=16194,Qe=16199,tr=16200,er=16206,rr=16209,ir=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function nr(){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}const sr=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<Ye||e.mode>16211?1:0},ar=t=>{if(sr(t))return He;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=Ye,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,Ne},or=t=>{if(sr(t))return He;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ar(t)},hr=(t,e)=>{let r;if(sr(t))return He;const i=t.state;return e<0?(r=0,e=-e):(r=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?He:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,or(t))},lr=(t,e)=>{if(!t)return He;const r=new nr;t.state=r,r.strm=t,r.window=null,r.mode=Ye;const i=hr(t,e);return i!==Ne&&(t.state=null),i};let cr,fr,dr=!0;const ur=t=>{if(dr){cr=new Int32Array(512),fr=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(De(1,t.lens,0,288,cr,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;De(2,t.lens,0,32,fr,0,t.work,{bits:5}),dr=!1}t.lencode=cr,t.lenbits=9,t.distcode=fr,t.distbits=5},_r=(t,e,r,i)=>{let n;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(e.subarray(r-i,r-i+n),s.wnext),(i-=n)?(s.window.set(e.subarray(r-i,r),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var pr=(t,e)=>{let r,i,n,s,a,o,h,l,c,f,d,u,_,p,g,m,y,w,b,E,A,v,S=0;const k=new Uint8Array(4);let B,T;const R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(sr(t)||!t.output||!t.input&&0!==t.avail_in)return He;r=t.state,r.mode===Ve&&(r.mode=Xe),a=t.next_out,n=t.output,h=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,l=r.hold,c=r.bits,f=o,d=h,v=Ne;t:for(;;)switch(r.mode){case Ye:if(0===r.wrap){r.mode=Xe;break}for(;c<16;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(2&r.wrap&&35615===l){0===r.wbits&&(r.wbits=15),r.check=0,k[0]=255&l,k[1]=l>>>8&255,r.check=ht(r.check,k,2,0),l=0,c=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",r.mode=rr;break}if((15&l)!==Ke){t.msg="unknown compression method",r.mode=rr;break}if(l>>>=4,c-=4,A=8+(15&l),0===r.wbits&&(r.wbits=A),A>15||A>r.wbits){t.msg="invalid window size",r.mode=rr;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=512&l?16189:Ve,l=0,c=0;break;case 16181:for(;c<16;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(r.flags=l,(255&r.flags)!==Ke){t.msg="unknown compression method",r.mode=rr;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=rr;break}r.head&&(r.head.text=l>>8&1),512&r.flags&&4&r.wrap&&(k[0]=255&l,k[1]=l>>>8&255,r.check=ht(r.check,k,2,0)),l=0,c=0,r.mode=16182;case 16182:for(;c<32;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}r.head&&(r.head.time=l),512&r.flags&&4&r.wrap&&(k[0]=255&l,k[1]=l>>>8&255,k[2]=l>>>16&255,k[3]=l>>>24&255,r.check=ht(r.check,k,4,0)),l=0,c=0,r.mode=16183;case 16183:for(;c<16;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}r.head&&(r.head.xflags=255&l,r.head.os=l>>8),512&r.flags&&4&r.wrap&&(k[0]=255&l,k[1]=l>>>8&255,r.check=ht(r.check,k,2,0)),l=0,c=0,r.mode=16184;case 16184:if(1024&r.flags){for(;c<16;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}r.length=l,r.head&&(r.head.extra_len=l),512&r.flags&&4&r.wrap&&(k[0]=255&l,k[1]=l>>>8&255,r.check=ht(r.check,k,2,0)),l=0,c=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(u=r.length,u>o&&(u=o),u&&(r.head&&(A=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(s,s+u),A)),512&r.flags&&4&r.wrap&&(r.check=ht(r.check,i,u,s)),o-=u,s+=u,r.length-=u),r.length))break t;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===o)break t;u=0;do{A=i[s+u++],r.head&&A&&r.length<65536&&(r.head.name+=String.fromCharCode(A))}while(A&&u<o);if(512&r.flags&&4&r.wrap&&(r.check=ht(r.check,i,u,s)),o-=u,s+=u,A)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===o)break t;u=0;do{A=i[s+u++],r.head&&A&&r.length<65536&&(r.head.comment+=String.fromCharCode(A))}while(A&&u<o);if(512&r.flags&&4&r.wrap&&(r.check=ht(r.check,i,u,s)),o-=u,s+=u,A)break t}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;c<16;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(4&r.wrap&&l!==(65535&r.check)){t.msg="header crc mismatch",r.mode=rr;break}l=0,c=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Ve;break;case 16189:for(;c<32;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}t.adler=r.check=ir(l),l=0,c=0,r.mode=qe;case qe:if(0===r.havedict)return t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,r.hold=l,r.bits=c,Ze;t.adler=r.check=1,r.mode=Ve;case Ve:if(e===Fe||e===Pe)break t;case Xe:if(r.last){l>>>=7&c,c-=7&c,r.mode=er;break}for(;c<3;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}switch(r.last=1&l,l>>>=1,c-=1,3&l){case 0:r.mode=16193;break;case 1:if(ur(r),r.mode=Qe,e===Pe){l>>>=2,c-=2;break t}break;case 2:r.mode=16196;break;case 3:t.msg="invalid block type",r.mode=rr}l>>>=2,c-=2;break;case 16193:for(l>>>=7&c,c-=7&c;c<32;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",r.mode=rr;break}if(r.length=65535&l,l=0,c=0,r.mode=Je,e===Pe)break t;case Je:r.mode=16195;case 16195:if(u=r.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;n.set(i.subarray(s,s+u),a),o-=u,s+=u,h-=u,a+=u,r.length-=u;break}r.mode=Ve;break;case 16196:for(;c<14;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(r.nlen=257+(31&l),l>>>=5,c-=5,r.ndist=1+(31&l),l>>>=5,c-=5,r.ncode=4+(15&l),l>>>=4,c-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=rr;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;c<3;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}r.lens[R[r.have++]]=7&l,l>>>=3,c-=3}for(;r.have<19;)r.lens[R[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,B={bits:r.lenbits},v=De(0,r.lens,0,19,r.lencode,0,r.work,B),r.lenbits=B.bits,v){t.msg="invalid code lengths set",r.mode=rr;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;S=r.lencode[l&(1<<r.lenbits)-1],g=S>>>24,m=S>>>16&255,y=65535&S,!(g<=c);){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(y<16)l>>>=g,c-=g,r.lens[r.have++]=y;else{if(16===y){for(T=g+2;c<T;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(l>>>=g,c-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=rr;break}A=r.lens[r.have-1],u=3+(3&l),l>>>=2,c-=2}else if(17===y){for(T=g+3;c<T;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}l>>>=g,c-=g,A=0,u=3+(7&l),l>>>=3,c-=3}else{for(T=g+7;c<T;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}l>>>=g,c-=g,A=0,u=11+(127&l),l>>>=7,c-=7}if(r.have+u>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=rr;break}for(;u--;)r.lens[r.have++]=A}}if(r.mode===rr)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=rr;break}if(r.lenbits=9,B={bits:r.lenbits},v=De(1,r.lens,0,r.nlen,r.lencode,0,r.work,B),r.lenbits=B.bits,v){t.msg="invalid literal/lengths set",r.mode=rr;break}if(r.distbits=6,r.distcode=r.distdyn,B={bits:r.distbits},v=De(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,B),r.distbits=B.bits,v){t.msg="invalid distances set",r.mode=rr;break}if(r.mode=Qe,e===Pe)break t;case Qe:r.mode=tr;case tr:if(o>=6&&h>=258){t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,r.hold=l,r.bits=c,xe(t,d),a=t.next_out,n=t.output,h=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,l=r.hold,c=r.bits,r.mode===Ve&&(r.back=-1);break}for(r.back=0;S=r.lencode[l&(1<<r.lenbits)-1],g=S>>>24,m=S>>>16&255,y=65535&S,!(g<=c);){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(m&&0==(240&m)){for(w=g,b=m,E=y;S=r.lencode[E+((l&(1<<w+b)-1)>>w)],g=S>>>24,m=S>>>16&255,y=65535&S,!(w+g<=c);){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}l>>>=w,c-=w,r.back+=w}if(l>>>=g,c-=g,r.back+=g,r.length=y,0===m){r.mode=16205;break}if(32&m){r.back=-1,r.mode=Ve;break}if(64&m){t.msg="invalid literal/length code",r.mode=rr;break}r.extra=15&m,r.mode=16201;case 16201:if(r.extra){for(T=r.extra;c<T;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;S=r.distcode[l&(1<<r.distbits)-1],g=S>>>24,m=S>>>16&255,y=65535&S,!(g<=c);){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(0==(240&m)){for(w=g,b=m,E=y;S=r.distcode[E+((l&(1<<w+b)-1)>>w)],g=S>>>24,m=S>>>16&255,y=65535&S,!(w+g<=c);){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}l>>>=w,c-=w,r.back+=w}if(l>>>=g,c-=g,r.back+=g,64&m){t.msg="invalid distance code",r.mode=rr;break}r.offset=y,r.extra=15&m,r.mode=16203;case 16203:if(r.extra){for(T=r.extra;c<T;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=rr;break}r.mode=16204;case 16204:if(0===h)break t;if(u=d-h,r.offset>u){if(u=r.offset-u,u>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=rr;break}u>r.wnext?(u-=r.wnext,_=r.wsize-u):_=r.wnext-u,u>r.length&&(u=r.length),p=r.window}else p=n,_=a-r.offset,u=r.length;u>h&&(u=h),h-=u,r.length-=u;do{n[a++]=p[_++]}while(--u);0===r.length&&(r.mode=tr);break;case 16205:if(0===h)break t;n[a++]=r.length,h--,r.mode=tr;break;case er:if(r.wrap){for(;c<32;){if(0===o)break t;o--,l|=i[s++]<<c,c+=8}if(d-=h,t.total_out+=d,r.total+=d,4&r.wrap&&d&&(t.adler=r.check=r.flags?ht(r.check,n,d,a-d):at(r.check,n,d,a-d)),d=h,4&r.wrap&&(r.flags?l:ir(l))!==r.check){t.msg="incorrect data check",r.mode=rr;break}l=0,c=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;c<32;){if(0===o)break t;o--,l+=i[s++]<<c,c+=8}if(4&r.wrap&&l!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=rr;break}l=0,c=0}r.mode=16208;case 16208:v=$e;break t;case rr:v=We;break t;case 16210:return je;default:return He}return t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,r.hold=l,r.bits=c,(r.wsize||d!==t.avail_out&&r.mode<rr&&(r.mode<er||e!==Me))&&_r(t,t.output,t.next_out,d-t.avail_out),f-=t.avail_in,d-=t.avail_out,t.total_in+=f,t.total_out+=d,r.total+=d,4&r.wrap&&d&&(t.adler=r.check=r.flags?ht(r.check,n,d,t.next_out-d):at(r.check,n,d,t.next_out-d)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Ve?128:0)+(r.mode===Qe||r.mode===Je?256:0),(0===f&&0===d||e===Me)&&v===Ne&&(v=Ge),v},gr={inflateReset:or,inflateReset2:hr,inflateResetKeep:ar,inflateInit:t=>lr(t,15),inflateInit2:lr,inflate:pr,inflateEnd:t=>{if(sr(t))return He;let e=t.state;return e.window&&(e.window=null),t.state=null,Ne},inflateGetHeader:(t,e)=>{if(sr(t))return He;const r=t.state;return 0==(2&r.wrap)?He:(r.head=e,e.done=!1,Ne)},inflateSetDictionary:(t,e)=>{const r=e.length;let i,n,s;return sr(t)?He:(i=t.state,0!==i.wrap&&i.mode!==qe?He:i.mode===qe&&(n=1,n=at(n,e,r,0),n!==i.check)?We:(s=_r(t,e,r,r),s?(i.mode=16210,je):(i.havedict=1,Ne)))},inflateInfo:"pako inflate (from Nodeca project)"};var mr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const yr=Object.prototype.toString,{Z_NO_FLUSH:wr,Z_FINISH:br,Z_OK:Er,Z_STREAM_END:Ar,Z_NEED_DICT:vr,Z_STREAM_ERROR:Sr,Z_DATA_ERROR:kr,Z_MEM_ERROR:Br}=ct;function Tr(t){this.options=fe.assign({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new pe,this.strm.avail_out=0;let r=gr.inflateInit2(this.strm,e.windowBits);if(r!==Er)throw new Error(lt[r]);if(this.header=new mr,gr.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=_e.string2buf(e.dictionary):"[object ArrayBuffer]"===yr.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=gr.inflateSetDictionary(this.strm,e.dictionary),r!==Er)))throw new Error(lt[r])}function Rr(t,e){const r=new Tr(e);if(r.push(t),r.err)throw r.msg||lt[r.err];return r.result}Tr.prototype.push=function(t,e){const r=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=e===~~e?e:!0===e?br:wr,"[object ArrayBuffer]"===yr.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),s=gr.inflate(r,a),s===vr&&n&&(s=gr.inflateSetDictionary(r,n),s===Er?s=gr.inflate(r,a):s===kr&&(s=vr));r.avail_in>0&&s===Ar&&r.state.wrap>0&&0!==t[r.next_in];)gr.inflateReset(r),s=gr.inflate(r,a);switch(s){case Sr:case kr:case vr:case Br:return this.onEnd(s),this.ended=!0,!1}if(o=r.avail_out,r.next_out&&(0===r.avail_out||s===Ar))if("string"===this.options.to){let t=_e.utf8border(r.output,r.next_out),e=r.next_out-t,n=_e.buf2string(r.output,t);r.next_out=e,r.avail_out=i-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(n)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Er||0!==o){if(s===Ar)return s=gr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},Tr.prototype.onData=function(t){this.chunks.push(t)},Tr.prototype.onEnd=function(t){t===Er&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=fe.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ir={Inflate:Tr,inflate:Rr,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Rr(t,e)},ungzip:Rr,constants:ct};const{Deflate:xr,deflate:Ur,deflateRaw:zr,gzip:Lr}=Re,{Inflate:Or,inflate:Cr,inflateRaw:Dr,ungzip:Mr}=Ir;var Fr=Ur,Pr=Or;class Nr{constructor(t,e=!1,r=!0){this.device=t,this.tracing=e,this.slipReaderEnabled=!1,this.leftOver=new Uint8Array(0),this.baudrate=0,this.traceLog="",this.lastTraceTime=Date.now(),this._DTR_state=!1,this.slipReaderEnabled=r}getInfo(){const t=this.device.getInfo();return t.usbVendorId&&t.usbProductId?`WebSerial VendorID 0x${t.usbVendorId.toString(16)} ProductID 0x${t.usbProductId.toString(16)}`:""}getPid(){return this.device.getInfo().usbProductId}trace(t){const e=`${`TRACE ${(Date.now()-this.lastTraceTime).toFixed(3)}`} ${t}`;console.log(e),this.traceLog+=e+"\n"}async returnTrace(){try{await navigator.clipboard.writeText(this.traceLog),console.log("Text copied to clipboard!")}catch(t){console.error("Failed to copy text:",t)}}hexify(t){return Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("").padEnd(16," ")}hexConvert(t,e=!0){if(e&&t.length>16){let e="",r=t;for(;r.length>0;){const t=r.slice(0,16),i=String.fromCharCode(...t).split("").map((t=>" "===t||t>=" "&&t<="~"&&"  "!==t?t:".")).join("");r=r.slice(16),e+=`\n    ${this.hexify(t.slice(0,8))} ${this.hexify(t.slice(8))} | ${i}`}return e}return this.hexify(t)}slipWriter(t){const e=[];e.push(192);for(let r=0;r<t.length;r++)219===t[r]?e.push(219,221):192===t[r]?e.push(219,220):e.push(t[r]);return e.push(192),new Uint8Array(e)}async write(t){const e=this.slipWriter(t);if(this.device.writable){const t=this.device.writable.getWriter();this.tracing&&(console.log("Write bytes"),this.trace(`Write ${e.length} bytes: ${this.hexConvert(e)}`)),await t.write(e),t.releaseLock()}}_appendBuffer(t,e){const r=new Uint8Array(t.byteLength+e.byteLength);return r.set(new Uint8Array(t),0),r.set(new Uint8Array(e),t.byteLength),r.buffer}slipReader(t){let e=0,r=0,i=0,n="init";for(;e<t.length;)if("init"!==n||192!=t[e]){if("valid_data"===n&&192==t[e]){i=e-1,n="packet_complete";break}e++}else r=e+1,n="valid_data",e++;if("packet_complete"!==n)return this.leftOver=t,new Uint8Array(0);this.leftOver=t.slice(i+2);const s=new Uint8Array(i-r+1);let a=0;for(e=r;e<=i;e++,a++)219!==t[e]||220!==t[e+1]?219!==t[e]||221!==t[e+1]?s[a]=t[e]:(s[a]=219,e++):(s[a]=192,e++);return s.slice(0,a)}async read(t=0,e=12){let r,i=this.leftOver;if(this.leftOver=new Uint8Array(0),this.slipReaderEnabled){const t=this.slipReader(i);if(t.length>0)return t;i=this.leftOver,this.leftOver=new Uint8Array(0)}if(null==this.device.readable)return this.leftOver;const n=this.device.readable.getReader();try{t>0&&(r=setTimeout((function(){n.cancel()}),t));do{const{value:t,done:e}=await n.read();if(e)throw this.leftOver=i,new Error("Timeout");i=new Uint8Array(this._appendBuffer(i.buffer,t.buffer))}while(i.length<e)}finally{t>0&&clearTimeout(r),n.releaseLock()}if(this.tracing&&(console.log("Read bytes"),this.trace(`Read ${i.length} bytes: ${this.hexConvert(i)}`)),this.slipReaderEnabled){const t=this.slipReader(i);return this.tracing&&(console.log("Slip reader results"),this.trace(`Read ${t.length} bytes: ${this.hexConvert(t)}`)),t}return i}async rawRead(t=0){if(0!=this.leftOver.length){const t=this.leftOver;return this.leftOver=new Uint8Array(0),t}if(!this.device.readable)return this.leftOver;const e=this.device.readable.getReader();let r;try{t>0&&(r=setTimeout((function(){e.cancel()}),t));const{value:i,done:n}=await e.read();if(n)throw new Error("Timeout");return this.tracing&&(console.log("Raw Read bytes"),this.trace(`Read ${i.length} bytes: ${this.hexConvert(i)}`)),i}finally{t>0&&clearTimeout(r),e.releaseLock()}}async setRTS(t){await this.device.setSignals({requestToSend:t}),await this.setDTR(this._DTR_state)}async setDTR(t){this._DTR_state=t,await this.device.setSignals({dataTerminalReady:t})}async connect(t=115200,e={}){await this.device.open({baudRate:t,dataBits:null==e?void 0:e.dataBits,stopBits:null==e?void 0:e.stopBits,bufferSize:null==e?void 0:e.bufferSize,parity:null==e?void 0:e.parity,flowControl:null==e?void 0:e.flowControl}),this.baudrate=t,this.leftOver=new Uint8Array(0)}async sleep(t){return new Promise((e=>setTimeout(e,t)))}async waitForUnlock(t){for(;this.device.readable&&this.device.readable.locked||this.device.writable&&this.device.writable.locked;)await this.sleep(t)}async disconnect(){await this.waitForUnlock(400),await this.device.close()}}function $r(t){return new Promise((e=>setTimeout(e,t)))}async function Zr(t,e){const r={D:async e=>await t.setDTR(e),R:async e=>await t.setRTS(e),W:async t=>await $r(t)};try{const t=function(t){const e=["D","R","W"],r=t.split("|");for(const t of r){const r=t[0],i=t.slice(1);if(!e.includes(r))return!1;if("D"===r||"R"===r){if("0"!==i&&"1"!==i)return!1}else if("W"===r){const t=parseInt(i);if(isNaN(t)||t<=0)return!1}}return!0}(e);if(!t)return;const i=e.split("|");for(const t of i){const e=t[0],i=t.slice(1);"W"===e?await r.W(Number(i)):"D"!==e&&"R"!==e||await r[e]("1"===i)}}catch(t){throw new Error("Invalid custom reset sequence")}}for(var Hr={},Wr={byteLength:function(t){var e=Vr(t),r=e[0],i=e[1];return 3*(r+i)/4-i},toByteArray:function(t){var e,r,i=Vr(t),n=i[0],s=i[1],a=new Kr(function(t,e,r){return 3*(e+r)/4-r}(0,n,s)),o=0,h=s>0?n-4:n;for(r=0;r<h;r+=4)e=Gr[t.charCodeAt(r)]<<18|Gr[t.charCodeAt(r+1)]<<12|Gr[t.charCodeAt(r+2)]<<6|Gr[t.charCodeAt(r+3)],a[o++]=e>>16&255,a[o++]=e>>8&255,a[o++]=255&e;2===s&&(e=Gr[t.charCodeAt(r)]<<2|Gr[t.charCodeAt(r+1)]>>4,a[o++]=255&e);1===s&&(e=Gr[t.charCodeAt(r)]<<10|Gr[t.charCodeAt(r+1)]<<4|Gr[t.charCodeAt(r+2)]>>2,a[o++]=e>>8&255,a[o++]=255&e);return a},fromByteArray:function(t){for(var e,r=t.length,i=r%3,n=[],s=16383,a=0,o=r-i;a<o;a+=s)n.push(Xr(t,a,a+s>o?o:a+s));1===i?(e=t[r-1],n.push(jr[e>>2]+jr[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],n.push(jr[e>>10]+jr[e>>4&63]+jr[e<<2&63]+"="));return n.join("")}},jr=[],Gr=[],Kr="undefined"!=typeof Uint8Array?Uint8Array:Array,Yr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qr=0;qr<64;++qr)jr[qr]=Yr[qr],Gr[Yr.charCodeAt(qr)]=qr;function Vr(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function Xr(t,e,r){for(var i,n,s=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(jr[(n=i)>>18&63]+jr[n>>12&63]+jr[n>>6&63]+jr[63&n]);return s.join("")}Gr["-".charCodeAt(0)]=62,Gr["_".charCodeAt(0)]=63;var Jr={};Jr.read=function(t,e,r,i,n){var s,a,o=8*n-i-1,h=(1<<o)-1,l=h>>1,c=-7,f=r?n-1:0,d=r?-1:1,u=t[e+f];for(f+=d,s=u&(1<<-c)-1,u>>=-c,c+=o;c>0;s=256*s+t[e+f],f+=d,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=i;c>0;a=256*a+t[e+f],f+=d,c-=8);if(0===s)s=1-l;else{if(s===h)return a?NaN:1/0*(u?-1:1);a+=Math.pow(2,i),s-=l}return(u?-1:1)*a*Math.pow(2,s-i)},Jr.write=function(t,e,r,i,n,s){var a,o,h,l=8*s-n-1,c=(1<<l)-1,f=c>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,u=i?0:s-1,_=i?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-a))<1&&(a--,h*=2),(e+=a+f>=1?d/h:d*Math.pow(2,1-f))*h>=2&&(a++,h/=2),a+f>=c?(o=0,a=c):a+f>=1?(o=(e*h-1)*Math.pow(2,n),a+=f):(o=e*Math.pow(2,f-1)*Math.pow(2,n),a=0));n>=8;t[r+u]=255&o,u+=_,o/=256,n-=8);for(a=a<<n|o,l+=n;l>0;t[r+u]=255&a,u+=_,a/=256,l-=8);t[r+u-_]|=128*p},function(t){const e=Wr,r=Jr,i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},t.INSPECT_MAX_BYTES=50;const n=2147483647;function s(t){if(t>n)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return o(t,e,r)}function o(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|u(t,e);let i=s(r);const n=i.write(t,e);n!==r&&(i=i.slice(0,n));return i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(K(t,ArrayBuffer)||t&&K(t.buffer,ArrayBuffer))return f(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return f(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return a.from(i,e,r);const n=function(t){if(a.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||Y(t.length)?s(0):c(t);if("Buffer"===t.type&&Array.isArray(t.data))return c(t.data)}(t);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return h(t),s(t<0?0:0|d(t))}function c(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let i=0;i<e;i+=1)r[i]=255&t[i];return r}function f(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let i;return i=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(i,a.prototype),i}function d(t){if(t>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|t}function u(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||K(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(n)return i?-1:W(t).length;e=(""+e).toLowerCase(),n=!0}}function _(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return v(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function p(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function g(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=a.from(e,i)),a.isBuffer(e))return 0===e.length?-1:m(t,e,r,i,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,i,n){let s,a=1,o=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;a=2,o/=2,h/=2,r/=2}function l(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(n){let i=-1;for(s=r;s<o;s++)if(l(t,s)===l(e,-1===i?0:s-i)){if(-1===i&&(i=s),s-i+1===h)return i*a}else-1!==i&&(s-=s-i),i=-1}else for(r+h>o&&(r=o-h),s=r;s>=0;s--){let r=!0;for(let i=0;i<h;i++)if(l(t,s+i)!==l(e,i)){r=!1;break}if(r)return s}return-1}function y(t,e,r,i){r=Number(r)||0;const n=t.length-r;i?(i=Number(i))>n&&(i=n):i=n;const s=e.length;let a;for(i>s/2&&(i=s/2),a=0;a<i;++a){const i=parseInt(e.substr(2*a,2),16);if(Y(i))return a;t[r+a]=i}return a}function w(t,e,r,i){return G(W(e,t.length-r),t,r,i)}function b(t,e,r,i){return G(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function E(t,e,r,i){return G(j(e),t,r,i)}function A(t,e,r,i){return G(function(t,e){let r,i,n;const s=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),i=r>>8,n=r%256,s.push(n),s.push(i);return s}(e,t.length-r),t,r,i)}function v(t,r,i){return 0===r&&i===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,i))}function S(t,e,r){r=Math.min(t.length,r);const i=[];let n=e;for(;n<r;){const e=t[n];let s=null,a=e>239?4:e>223?3:e>191?2:1;if(n+a<=r){let r,i,o,h;switch(a){case 1:e<128&&(s=e);break;case 2:r=t[n+1],128==(192&r)&&(h=(31&e)<<6|63&r,h>127&&(s=h));break;case 3:r=t[n+1],i=t[n+2],128==(192&r)&&128==(192&i)&&(h=(15&e)<<12|(63&r)<<6|63&i,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:r=t[n+1],i=t[n+2],o=t[n+3],128==(192&r)&&128==(192&i)&&128==(192&o)&&(h=(15&e)<<18|(63&r)<<12|(63&i)<<6|63&o,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),n+=a}return function(t){const e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);let r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=k));return r}(i)}t.kMaxLength=n,a.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return o(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return h(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},a.allocUnsafe=function(t){return l(t)},a.allocUnsafeSlow=function(t){return l(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(K(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),K(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,i=e.length;for(let n=0,s=Math.min(r,i);n<s;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const i=a.allocUnsafe(e);let n=0;for(r=0;r<t.length;++r){let e=t[r];if(K(e,Uint8Array))n+e.length>i.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(i,n)):Uint8Array.prototype.set.call(i,e,n);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,n)}n+=e.length}return i},a.byteLength=u,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)p(this,e,e+1);return this},a.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)p(this,e,e+3),p(this,e+1,e+2);return this},a.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)p(this,e,e+7),p(this,e+1,e+6),p(this,e+2,e+5),p(this,e+3,e+4);return this},a.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?S(this,0,t):_.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(t,e,r,i,n){if(K(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let s=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(e>>>=0);const h=Math.min(s,o),l=this.slice(i,n),c=t.slice(e,r);for(let t=0;t<h;++t)if(l[t]!==c[t]){s=l[t],o=c[t];break}return s<o?-1:o<s?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},a.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}const n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return y(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":case"latin1":case"binary":return b(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function B(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function T(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function R(t,e,r){const i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);let n="";for(let i=e;i<r;++i)n+=q[t[i]];return n}function I(t,e,r){const i=t.slice(e,r);let n="";for(let t=0;t<i.length-1;t+=2)n+=String.fromCharCode(i[t]+256*i[t+1]);return n}function x(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,i,n,s){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<s)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function z(t,e,r,i,n){N(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function L(t,e,r,i,n){N(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s>>=8,t[r+6]=s,s>>=8,t[r+5]=s,s>>=8,t[r+4]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function O(t,e,r,i,n,s){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,i,n,s){return e=+e,i>>>=0,s||O(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function D(t,e,i,n,s){return e=+e,i>>>=0,s||O(t,0,i,8),r.write(t,e,i,n,52,8),i+8}a.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const i=this.subarray(t,e);return Object.setPrototypeOf(i,a.prototype),i},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);let i=this[t],n=1,s=0;for(;++s<e&&(n*=256);)i+=this[t+s]*n;return i},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);let i=this[t+--e],n=1;for(;e>0&&(n*=256);)i+=this[t+--e]*n;return i},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=V((function(t){$(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Z(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(i)+(BigInt(n)<<BigInt(32))})),a.prototype.readBigUInt64BE=V((function(t){$(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Z(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(i)<<BigInt(32))+BigInt(n)})),a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);let i=this[t],n=1,s=0;for(;++s<e&&(n*=256);)i+=this[t+s]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);let i=e,n=1,s=this[t+--i];for(;i>0&&(n*=256);)s+=this[t+--i]*n;return n*=128,s>=n&&(s-=Math.pow(2,8*e)),s},a.prototype.readInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||x(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||x(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=V((function(t){$(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Z(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),a.prototype.readBigInt64BE=V((function(t){$(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Z(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||x(t,4,this.length),r.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||x(t,4,this.length),r.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||x(t,8,this.length),r.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||x(t,8,this.length),r.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e>>>=0,r>>>=0,!i){U(this,t,e,r,Math.pow(2,8*r)-1,0)}let n=1,s=0;for(this[e]=255&t;++s<r&&(n*=256);)this[e+s]=t/n&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e>>>=0,r>>>=0,!i){U(this,t,e,r,Math.pow(2,8*r)-1,0)}let n=r-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=V((function(t,e=0){return z(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeBigUInt64BE=V((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}let n=0,s=1,a=0;for(this[e]=255&t;++n<r&&(s*=256);)t<0&&0===a&&0!==this[e+n-1]&&(a=1),this[e+n]=(t/s>>0)-a&255;return e+r},a.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}let n=r-1,s=1,a=0;for(this[e+n]=255&t;--n>=0&&(s*=256);)t<0&&0===a&&0!==this[e+n+1]&&(a=1),this[e+n]=(t/s>>0)-a&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=V((function(t,e=0){return z(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeBigInt64BE=V((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,i){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);const n=i-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(t,this.subarray(r,i),e),n},a.prototype.fill=function(t,e,r,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){const e=t.charCodeAt(0);("utf8"===i&&e<128||"latin1"===i)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let n;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(n=e;n<r;++n)this[n]=t;else{const s=a.isBuffer(t)?t:a.from(t,i),o=s.length;if(0===o)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(n=0;n<r-e;++n)this[n+e]=s[n%o]}return this};const M={};function F(t,e,r){M[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function P(t){let e="",r=t.length;const i="-"===t[0]?1:0;for(;r>=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function N(t,e,r,i,n,s){if(t>r||t<e){const i="bigint"==typeof e?"n":"";let n;throw n=s>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new M.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){$(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||Z(e,t.length-(r+1))}(i,n,s)}function $(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function Z(t,e,r){if(Math.floor(t)!==t)throw $(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),F("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),F("ERR_OUT_OF_RANGE",(function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=P(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=P(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i}),RangeError);const H=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const i=t.length;let n=null;const s=[];for(let a=0;a<i;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(a+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,i){let n;for(n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const q=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const i=16*r;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function V(t){return"undefined"==typeof BigInt?X:t}function X(){throw new Error("BigInt not supported")}}(Hr);class Qr{constructor(t){this.ESP_RAM_BLOCK=6144,this.ESP_FLASH_BEGIN=2,this.ESP_FLASH_DATA=3,this.ESP_FLASH_END=4,this.ESP_MEM_BEGIN=5,this.ESP_MEM_END=6,this.ESP_MEM_DATA=7,this.ESP_WRITE_REG=9,this.ESP_READ_REG=10,this.ESP_SPI_ATTACH=13,this.ESP_CHANGE_BAUDRATE=15,this.ESP_FLASH_DEFL_BEGIN=16,this.ESP_FLASH_DEFL_DATA=17,this.ESP_FLASH_DEFL_END=18,this.ESP_SPI_FLASH_MD5=19,this.ESP_ERASE_FLASH=208,this.ESP_ERASE_REGION=209,this.ESP_READ_FLASH=210,this.ESP_RUN_USER_CODE=211,this.ESP_IMAGE_MAGIC=233,this.ESP_CHECKSUM_MAGIC=239,this.ROM_INVALID_RECV_MSG=5,this.ERASE_REGION_TIMEOUT_PER_MB=3e4,this.ERASE_WRITE_TIMEOUT_PER_MB=4e4,this.MD5_TIMEOUT_PER_MB=8e3,this.CHIP_ERASE_TIMEOUT=12e4,this.FLASH_READ_TIMEOUT=1e5,this.MAX_TIMEOUT=2*this.CHIP_ERASE_TIMEOUT,this.CHIP_DETECT_MAGIC_REG_ADDR=1073745920,this.DETECTED_FLASH_SIZES={18:"256KB",19:"512KB",20:"1MB",21:"2MB",22:"4MB",23:"8MB",24:"16MB"},this.DETECTED_FLASH_SIZES_NUM={18:256,19:512,20:1024,21:2048,22:4096,23:8192,24:16384},this.USB_JTAG_SERIAL_PID=4097,this.romBaudrate=115200,this.debugLogging=!1,this.checksum=function(t){let e,r=239;for(e=0;e<t.length;e++)r^=t[e];return r},this.timeoutPerMb=function(t,e){const r=t*(e/1e6);return r<3e3?3e3:r},this.flashSizeBytes=function(t){let e=-1;return-1!==t.indexOf("KB")?e=1024*parseInt(t.slice(0,t.indexOf("KB"))):-1!==t.indexOf("MB")&&(e=1024*parseInt(t.slice(0,t.indexOf("MB")))*1024),e},this.IS_STUB=!1,this.FLASH_WRITE_SIZE=16384,this.transport=t.transport,this.baudrate=t.baudrate,t.serialOptions&&(this.serialOptions=t.serialOptions),t.romBaudrate&&(this.romBaudrate=t.romBaudrate),t.terminal&&(this.terminal=t.terminal,this.terminal.clean()),void 0!==t.debugLogging&&(this.debugLogging=t.debugLogging),t.port&&(this.transport=new Nr(t.port)),void 0!==t.enableTracing&&(this.transport.tracing=t.enableTracing),this.info("esptool.js"),this.info("Serial port "+this.transport.getInfo())}_sleep(t){return new Promise((e=>setTimeout(e,t)))}write(t,e=!0){this.terminal?e?this.terminal.writeLine(t):this.terminal.write(t):console.log(t)}error(t,e=!0){this.write(`Error: ${t}`,e)}info(t,e=!0){this.write(t,e)}debug(t,e=!0){this.debugLogging&&this.write(`Debug: ${t}`,e)}_shortToBytearray(t){return new Uint8Array([255&t,t>>8&255])}_intToByteArray(t){return new Uint8Array([255&t,t>>8&255,t>>16&255,t>>24&255])}_byteArrayToShort(t,e){return t|e>>8}_byteArrayToInt(t,e,r,i){return t|e<<8|r<<16|i<<24}_appendBuffer(t,e){const r=new Uint8Array(t.byteLength+e.byteLength);return r.set(new Uint8Array(t),0),r.set(new Uint8Array(e),t.byteLength),r.buffer}_appendArray(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r}ui8ToBstr(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}bstrToUi8(t){const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}async flushInput(){try{await this.transport.rawRead(200)}catch(t){this.error(t.message)}}async readPacket(t=null,e=3e3){for(let r=0;r<100;r++){const r=await this.transport.read(e),i=r[0],n=r[1],s=this._byteArrayToInt(r[4],r[5],r[6],r[7]),a=r.slice(8);if(1==i){if(null==t||n==t)return[s,a];if(0!=a[0]&&a[1]==this.ROM_INVALID_RECV_MSG)throw await this.flushInput(),new y("unsupported command error")}}throw new y("invalid response")}async command(t=null,e=new Uint8Array(0),r=0,i=!0,n=3e3){if(null!=t){this.transport.tracing&&this.transport.trace(`command op:0x${t.toString(16).padStart(2,"0")} data len=${e.length} wait_response=${i?1:0} timeout=${(n/1e3).toFixed(3)} data=${this.transport.hexConvert(e)}`);const s=new Uint8Array(8+e.length);let a;for(s[0]=0,s[1]=t,s[2]=this._shortToBytearray(e.length)[0],s[3]=this._shortToBytearray(e.length)[1],s[4]=this._intToByteArray(r)[0],s[5]=this._intToByteArray(r)[1],s[6]=this._intToByteArray(r)[2],s[7]=this._intToByteArray(r)[3],a=0;a<e.length;a++)s[8+a]=e[a];await this.transport.write(s)}return i?this.readPacket(t,n):[0,new Uint8Array(0)]}async readReg(t,e=3e3){const r=this._intToByteArray(t);return(await this.command(this.ESP_READ_REG,r,void 0,void 0,e))[0]}async writeReg(t,e,r=4294967295,i=0,n=0){let s=this._appendArray(this._intToByteArray(t),this._intToByteArray(e));s=this._appendArray(s,this._intToByteArray(r)),s=this._appendArray(s,this._intToByteArray(i)),n>0&&(s=this._appendArray(s,this._intToByteArray(this.chip.UART_DATE_REG_ADDR)),s=this._appendArray(s,this._intToByteArray(0)),s=this._appendArray(s,this._intToByteArray(0)),s=this._appendArray(s,this._intToByteArray(n))),await this.checkCommand("write target memory",this.ESP_WRITE_REG,s)}async sync(){this.debug("Sync");const t=new Uint8Array(36);let e;for(t[0]=7,t[1]=7,t[2]=18,t[3]=32,e=0;e<32;e++)t[4+e]=85;try{return await this.command(8,t,void 0,void 0,100)}catch(t){throw this.debug("Sync err "+t),t}}async _connectAttempt(t="default_reset",e=!1){if(this.debug("_connect_attempt "+t+" "+e),"no_reset"!==t)if(this.transport.getPid()===this.USB_JTAG_SERIAL_PID)await async function(t){await t.setRTS(!1),await t.setDTR(!1),await $r(100),await t.setDTR(!0),await t.setRTS(!1),await $r(100),await t.setRTS(!0),await t.setDTR(!1),await t.setRTS(!0),await $r(100),await t.setRTS(!1),await t.setDTR(!1)}(this.transport);else{const t=e?"D0|R1|W100|W2000|D1|R0|W50|D0":"D0|R1|W100|D1|R0|W50|D0";await Zr(this.transport,t)}let r=0,i=!0;for(;i;){try{r+=(await this.transport.read(1e3)).length}catch(t){if(this.debug(t.message),t instanceof Error){i=!1;break}}await this._sleep(50)}for(this.transport.slipReaderEnabled=!0,r=7;r--;){try{const t=await this.sync();return this.debug(t[0].toString()),"success"}catch(t){t instanceof Error&&(e?this.info("_",!1):this.info(".",!1))}await this._sleep(50)}return"error"}async connect(t="default_reset",e=7,r=!1){let i,n;for(this.info("Connecting...",!1),await this.transport.connect(this.romBaudrate,this.serialOptions),i=0;i<e&&(n=await this._connectAttempt(t,!1),"success"!==n)&&(n=await this._connectAttempt(t,!0),"success"!==n);i++);if("success"!==n)throw new y("Failed to connect with the device");if(this.info("\n\r",!1),!r){const t=await this.readReg(1073745920)>>>0;this.debug("Chip Magic "+t.toString(16));const e=await async function(t){switch(t){case 15736195:{const{ESP32ROM:t}=await import("./c.sgEPk0PD.js");return new t}case 1867591791:case 2084675695:{const{ESP32C2ROM:t}=await import("./c.CN_AFYZY.js");return new t}case 1763790959:case 456216687:case 1216438383:case 1130455151:{const{ESP32C3ROM:t}=await import("./c.CpXYG9zO.js");return new t}case 752910447:{const{ESP32C6ROM:t}=await import("./c.BxIiUMhL.js");return new t}case 3619110528:{const{ESP32H2ROM:t}=await import("./c.D6YM25wR.js");return new t}case 9:{const{ESP32S3ROM:t}=await import("./c.C71Vrn7T.js");return new t}case 1990:{const{ESP32S2ROM:t}=await import("./c.DwDouVrb.js");return new t}case 4293968129:{const{ESP8266ROM:t}=await import("./c.Dg3X-8jX.js");return new t}default:return null}}(t);if(null===this.chip)throw new y(`Unexpected CHIP magic value ${t}. Failed to autodetect chip type.`);this.chip=e}}async detectChip(t="default_reset"){await this.connect(t),this.info("Detecting chip type... ",!1),null!=this.chip?this.info(this.chip.CHIP_NAME):this.info("unknown!")}async checkCommand(t="",e=null,r=new Uint8Array(0),i=0,n=3e3){this.debug("check_command "+t);const s=await this.command(e,r,i,void 0,n);return s[1].length>4?s[1]:s[0]}async memBegin(t,e,r,i){this.debug("mem_begin "+t+" "+e+" "+r+" "+i.toString(16));let n=this._appendArray(this._intToByteArray(t),this._intToByteArray(e));n=this._appendArray(n,this._intToByteArray(r)),n=this._appendArray(n,this._intToByteArray(i)),await this.checkCommand("enter RAM download mode",this.ESP_MEM_BEGIN,n)}async memBlock(t,e){let r=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(e));r=this._appendArray(r,this._intToByteArray(0)),r=this._appendArray(r,this._intToByteArray(0)),r=this._appendArray(r,t);const i=this.checksum(t);await this.checkCommand("write to target RAM",this.ESP_MEM_DATA,r,i)}async memFinish(t){const e=0===t?1:0,r=this._appendArray(this._intToByteArray(e),this._intToByteArray(t));await this.checkCommand("leave RAM download mode",this.ESP_MEM_END,r,void 0,50)}async flashSpiAttach(t){const e=this._intToByteArray(t);await this.checkCommand("configure SPI flash pins",this.ESP_SPI_ATTACH,e)}async flashBegin(t,e){const r=Math.floor((t+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),i=this.chip.getEraseSize(e,t),n=new Date,s=n.getTime();let a=3e3;0==this.IS_STUB&&(a=this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB,t)),this.debug("flash begin "+i+" "+r+" "+this.FLASH_WRITE_SIZE+" "+e+" "+t);let o=this._appendArray(this._intToByteArray(i),this._intToByteArray(r));o=this._appendArray(o,this._intToByteArray(this.FLASH_WRITE_SIZE)),o=this._appendArray(o,this._intToByteArray(e)),0==this.IS_STUB&&(o=this._appendArray(o,this._intToByteArray(0))),await this.checkCommand("enter Flash download mode",this.ESP_FLASH_BEGIN,o,void 0,a);const h=n.getTime();return 0!=t&&0==this.IS_STUB&&this.info("Took "+(h-s)/1e3+"."+(h-s)%1e3+"s to erase flash block"),r}async flashDeflBegin(t,e,r){const i=Math.floor((e+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),n=Math.floor((t+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),s=new Date,a=s.getTime();let o,h;this.IS_STUB?(o=t,h=3e3):(o=n*this.FLASH_WRITE_SIZE,h=this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB,o)),this.info("Compressed "+t+" bytes to "+e+"...");let l=this._appendArray(this._intToByteArray(o),this._intToByteArray(i));l=this._appendArray(l,this._intToByteArray(this.FLASH_WRITE_SIZE)),l=this._appendArray(l,this._intToByteArray(r)),"ESP32-S2"!==this.chip.CHIP_NAME&&"ESP32-S3"!==this.chip.CHIP_NAME&&"ESP32-C3"!==this.chip.CHIP_NAME&&"ESP32-C2"!==this.chip.CHIP_NAME||!1!==this.IS_STUB||(l=this._appendArray(l,this._intToByteArray(0))),await this.checkCommand("enter compressed flash mode",this.ESP_FLASH_DEFL_BEGIN,l,void 0,h);const c=s.getTime();return 0!=t&&!1===this.IS_STUB&&this.info("Took "+(c-a)/1e3+"."+(c-a)%1e3+"s to erase flash block"),i}async flashBlock(t,e,r){let i=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(e));i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,t);const n=this.checksum(t);await this.checkCommand("write to target Flash after seq "+e,this.ESP_FLASH_DATA,i,n,r)}async flashDeflBlock(t,e,r){let i=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(e));i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,t);const n=this.checksum(t);this.debug("flash_defl_block "+t[0].toString(16)+" "+t[1].toString(16)),await this.checkCommand("write compressed data to flash after seq "+e,this.ESP_FLASH_DEFL_DATA,i,n,r)}async flashFinish(t=!1){const e=t?0:1,r=this._intToByteArray(e);await this.checkCommand("leave Flash mode",this.ESP_FLASH_END,r)}async flashDeflFinish(t=!1){const e=t?0:1,r=this._intToByteArray(e);await this.checkCommand("leave compressed flash mode",this.ESP_FLASH_DEFL_END,r)}async runSpiflashCommand(t,e,r){const i=this.chip.SPI_REG_BASE,n=i+0,s=i+this.chip.SPI_USR_OFFS,a=i+this.chip.SPI_USR1_OFFS,o=i+this.chip.SPI_USR2_OFFS,h=i+this.chip.SPI_W0_OFFS;let l;l=null!=this.chip.SPI_MOSI_DLEN_OFFS?async(t,e)=>{const r=i+this.chip.SPI_MOSI_DLEN_OFFS,n=i+this.chip.SPI_MISO_DLEN_OFFS;t>0&&await this.writeReg(r,t-1),e>0&&await this.writeReg(n,e-1)}:async(t,e)=>{const r=a,i=(0===e?0:e-1)<<8|(0===t?0:t-1)<<17;await this.writeReg(r,i)};const c=1<<18;if(r>32)throw new y("Reading more than 32 bits back from a SPI flash operation is unsupported");if(e.length>64)throw new y("Writing more than 64 bytes of data with one SPI command is unsupported");const f=8*e.length,d=await this.readReg(s),u=await this.readReg(o);let _,p=1<<31;r>0&&(p|=268435456),f>0&&(p|=134217728),await l(f,r),await this.writeReg(s,p);let g=7<<28|t;if(await this.writeReg(o,g),0==f)await this.writeReg(h,0);else{if(e.length%4!=0){const t=new Uint8Array(e.length%4);e=this._appendArray(e,t)}let t=h;for(_=0;_<e.length-4;_+=4)g=this._byteArrayToInt(e[_],e[_+1],e[_+2],e[_+3]),await this.writeReg(t,g),t+=4}for(await this.writeReg(n,c),_=0;_<10&&(g=await this.readReg(n)&c,0!=g);_++);if(10===_)throw new y("SPI command did not complete in time");const m=await this.readReg(h);return await this.writeReg(s,d),await this.writeReg(o,u),m}async readFlashId(){const t=new Uint8Array(0);return await this.runSpiflashCommand(159,t,24)}async eraseFlash(){this.info("Erasing flash (this may take a while)...");let t=new Date;const e=t.getTime(),r=await this.checkCommand("erase flash",this.ESP_ERASE_FLASH,void 0,void 0,this.CHIP_ERASE_TIMEOUT);t=new Date;const i=t.getTime();return this.info("Chip erase completed successfully in "+(i-e)/1e3+"s"),r}toHex(t){return Array.prototype.map.call(t,(t=>("00"+t.toString(16)).slice(-2))).join("")}async flashMd5sum(t,e){const r=this.timeoutPerMb(this.MD5_TIMEOUT_PER_MB,e);let i=this._appendArray(this._intToByteArray(t),this._intToByteArray(e));i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,this._intToByteArray(0));let n=await this.checkCommand("calculate md5sum",this.ESP_SPI_FLASH_MD5,i,void 0,r);n instanceof Uint8Array&&n.length>16&&(n=n.slice(0,16));return this.toHex(n)}async readFlash(t,e,r=null){let i=this._appendArray(this._intToByteArray(t),this._intToByteArray(e));i=this._appendArray(i,this._intToByteArray(4096)),i=this._appendArray(i,this._intToByteArray(1024));const n=await this.checkCommand("read flash",this.ESP_READ_FLASH,i);if(0!=n)throw new y("Failed to read memory: "+n);let s=new Uint8Array(0);for(;s.length<e;){const t=await this.transport.read(this.FLASH_READ_TIMEOUT);if(!(t instanceof Uint8Array))throw new y("Failed to read memory: "+t);t.length>0&&(s=this._appendArray(s,t),await this.transport.write(this._intToByteArray(s.length)),r&&r(t,s.length,e))}return s}async runStub(){this.info("Uploading stub...");let t=Hr.Buffer.from(this.chip.ROM_TEXT,"base64").toString("binary"),e=t.split("").map((function(t){return t.charCodeAt(0)}));const r=new Uint8Array(e);t=Hr.Buffer.from(this.chip.ROM_DATA,"base64").toString("binary"),e=t.split("").map((function(t){return t.charCodeAt(0)}));const i=new Uint8Array(e);let n,s=Math.floor((r.length+this.ESP_RAM_BLOCK-1)/this.ESP_RAM_BLOCK);for(await this.memBegin(r.length,s,this.ESP_RAM_BLOCK,this.chip.TEXT_START),n=0;n<s;n++){const t=n*this.ESP_RAM_BLOCK,e=t+this.ESP_RAM_BLOCK;await this.memBlock(r.slice(t,e),n)}for(s=Math.floor((i.length+this.ESP_RAM_BLOCK-1)/this.ESP_RAM_BLOCK),await this.memBegin(i.length,s,this.ESP_RAM_BLOCK,this.chip.DATA_START),n=0;n<s;n++){const t=n*this.ESP_RAM_BLOCK,e=t+this.ESP_RAM_BLOCK;await this.memBlock(i.slice(t,e),n)}this.info("Running stub..."),await this.memFinish(this.chip.ENTRY);for(let t=0;t<100;t++){const t=await this.transport.read(1e3,6);if(79===t[0]&&72===t[1]&&65===t[2]&&73===t[3])return this.info("Stub running..."),this.IS_STUB=!0,this.FLASH_WRITE_SIZE=16384,this.chip}throw new y("Failed to start stub. Unexpected response")}async changeBaud(){this.info("Changing baudrate to "+this.baudrate);const t=this.IS_STUB?this.transport.baudrate:0,e=this._appendArray(this._intToByteArray(this.baudrate),this._intToByteArray(t)),r=await this.command(this.ESP_CHANGE_BAUDRATE,e);this.debug(r[0].toString()),this.info("Changed"),await this.transport.disconnect(),await this._sleep(50),await this.transport.connect(this.baudrate,this.serialOptions);try{let t=64;for(;t--;){try{await this.sync();break}catch(t){this.debug(t.message)}await this._sleep(10)}}catch(t){this.debug(t.message)}}async main(t="default_reset"){await this.detectChip(t);const e=await this.chip.getChipDescription(this);return this.info("Chip is "+e),this.info("Features: "+await this.chip.getChipFeatures(this)),this.info("Crystal is "+await this.chip.getCrystalFreq(this)+"MHz"),this.info("MAC: "+await this.chip.readMac(this)),await this.chip.readMac(this),void 0!==this.chip.postConnect&&await this.chip.postConnect(this),await this.runStub(),this.romBaudrate!==this.baudrate&&await this.changeBaud(),e}parseFlashSizeArg(t){if(void 0===this.chip.FLASH_SIZES[t])throw new y("Flash size "+t+" is not supported by this chip type. Supported sizes: "+this.chip.FLASH_SIZES);return this.chip.FLASH_SIZES[t]}_updateImageFlashParams(t,e,r,i,n){if(this.debug("_update_image_flash_params "+r+" "+i+" "+n),t.length<8)return t;if(e!=this.chip.BOOTLOADER_FLASH_OFFSET)return t;if("keep"===r&&"keep"===i&&"keep"===n)return this.info("Not changing the image"),t;const s=parseInt(t[0]);let a=parseInt(t[2]);const o=parseInt(t[3]);if(s!==this.ESP_IMAGE_MAGIC)return this.info("Warning: Image file at 0x"+e.toString(16)+" doesn't look like an image file, so not changing any flash settings."),t;if("keep"!==i){a={qio:0,qout:1,dio:2,dout:3}[i]}let h=15&o;if("keep"!==n){h={"40m":0,"26m":1,"20m":2,"80m":15}[n]}let l=240&o;"keep"!==r&&(l=this.parseFlashSizeArg(r));const c=a<<8|h+l;return this.info("Flash params set to "+c.toString(16)),parseInt(t[2])!==a<<8&&(t=t.substring(0,2)+(a<<8).toString()+t.substring(3)),parseInt(t[3])!==h+l&&(t=t.substring(0,3)+(h+l).toString()+t.substring(4)),t}async writeFlash(t){if(this.debug("EspLoader program"),"keep"!==t.flashSize){const e=this.flashSizeBytes(t.flashSize);for(let r=0;r<t.fileArray.length;r++)if(t.fileArray[r].data.length+t.fileArray[r].address>e)throw new y(`File ${r+1} doesn't fit in the available flash`)}let e,r;!0===this.IS_STUB&&!0===t.eraseAll&&await this.eraseFlash();for(let i=0;i<t.fileArray.length;i++){this.debug("Data Length "+t.fileArray[i].data.length),e=t.fileArray[i].data;const n=t.fileArray[i].data.length%4;if(n>0&&(e+="ÿÿÿÿ".substring(4-n)),r=t.fileArray[i].address,this.debug("Image Length "+e.length),0===e.length){this.debug("Warning: File is empty");continue}e=this._updateImageFlashParams(e,r,t.flashSize,t.flashMode,t.flashFreq);let s=null;t.calculateMD5Hash&&(s=t.calculateMD5Hash(e),this.debug("Image MD5 "+s));const a=e.length;let o;if(t.compress){const t=this.bstrToUi8(e);e=this.ui8ToBstr(Fr(t,{level:9})),o=await this.flashDeflBegin(a,e.length,r)}else o=await this.flashBegin(a,r);let h=0,l=0;const c=e.length;t.reportProgress&&t.reportProgress(i,0,c);let f=new Date;const d=f.getTime();let u=5e3;const _=new Pr({chunkSize:1});let p=0;for(_.onData=function(t){p+=t.byteLength};e.length>0;){this.debug("Write loop "+r+" "+h+" "+o),this.info("Writing at 0x"+(r+p).toString(16)+"... ("+Math.floor(100*(h+1)/o)+"%)");const n=this.bstrToUi8(e.slice(0,this.FLASH_WRITE_SIZE));if(!t.compress)throw new y("Yet to handle Non Compressed writes");{const t=p;_.push(n,!1);const e=p-t;let r=3e3;this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,e)>3e3&&(r=this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,e)),!1===this.IS_STUB&&(u=r),await this.flashDeflBlock(n,h,u),this.IS_STUB&&(u=r)}l+=n.length,e=e.slice(this.FLASH_WRITE_SIZE,e.length),h++,t.reportProgress&&t.reportProgress(i,l,c)}this.IS_STUB&&await this.readReg(this.CHIP_DETECT_MAGIC_REG_ADDR,u),f=new Date;const g=f.getTime()-d;if(t.compress&&this.info("Wrote "+a+" bytes ("+l+" compressed) at 0x"+r.toString(16)+" in "+g/1e3+" seconds."),s){const t=await this.flashMd5sum(r,a);if(new String(t).valueOf()!=new String(s).valueOf())throw this.info("File  md5: "+s),this.info("Flash md5: "+t),new y("MD5 of file does not match data in flash!");this.info("Hash of data verified.")}}this.info("Leaving..."),this.IS_STUB&&(await this.flashBegin(0,0),t.compress?await this.flashDeflFinish():await this.flashFinish())}async flashId(){this.debug("flash_id");const t=await this.readFlashId();this.info("Manufacturer: "+(255&t).toString(16));const e=t>>16&255;this.info("Device: "+(t>>8&255).toString(16)+e.toString(16)),this.info("Detected flash size: "+this.DETECTED_FLASH_SIZES[e])}async getFlashSize(){this.debug("flash_id");const t=await this.readFlashId()>>16&255;return this.DETECTED_FLASH_SIZES_NUM[t]}async hardReset(){await this.transport.setRTS(!0),await this._sleep(100),await this.transport.setRTS(!1)}async softReset(){if(this.IS_STUB){if("ESP8266"!=this.chip.CHIP_NAME)throw new y("Soft resetting is currently only supported on ESP8266");await this.command(this.ESP_RUN_USER_CODE,void 0,void 0,!1)}else await this.flashBegin(0,0),await this.flashFinish(!1)}}const ti=t=>{const e=new Nr(t);return new Qr({transport:e,baudrate:115200,romBaudrate:115200,enableTracing:!1})};export{_ as a,p as b,ti as c,g,m as o};
//# sourceMappingURL=c.Cyu20JQH.js.map
