var Ye={3941:(a,u,h)=>{a.exports=h.p+"compresso.0d45ed2ede4537f701f8.wasm"},3200:(a,u,h)=>{a.exports=h.p+"libpng.4e1203f419dab329d4f3.wasm"}},Ve={};function ye(a){var u=Ve[a];if(u!==void 0)return u.exports;var h=Ve[a]={exports:{}};return Ye[a](h,h.exports,ye),h.exports}ye.m=Ye,ye.d=(a,u)=>{for(var h in u)ye.o(u,h)&&!ye.o(a,h)&&Object.defineProperty(a,h,{enumerable:!0,get:u[h]})},ye.f={},ye.e=a=>Promise.all(Object.keys(ye.f).reduce((u,h)=>(ye.f[h](a,u),u),[])),ye.u=a=>""+a+"."+{75:"341b092d9d141aac7d7b",121:"c6004b15e0939feb3a91",505:"8e29ab74b52def8d63dd"}[a]+".js",ye.miniCssF=a=>{},ye.o=(a,u)=>Object.prototype.hasOwnProperty.call(a,u),ye.r=a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},(()=>{var a;if(typeof import.meta.url=="string"&&(a=import.meta.url),!a)throw new Error("Automatic publicPath is not supported in this browser");a=a.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),ye.p=a})(),(()=>{ye.b=new URL("./",import.meta.url);var a={491:0},u=h=>{var{ids:o,modules:C,runtime:I}=h,x,w,p=0;for(x in C)ye.o(C,x)&&(ye.m[x]=C[x]);for(I&&I(ye);p<o.length;p++)w=o[p],ye.o(a,w)&&a[w]&&a[w][0](),a[o[p]]=0};ye.f.j=(h,o)=>{var C=ye.o(a,h)?a[h]:void 0;if(C!==0)if(C)o.push(C[1]);else{var I=import("./"+ye.u(h)).then(u,x=>{throw a[h]!==0&&(a[h]=void 0),x}),I=Promise.race([I,new Promise(x=>C=a[h]=[x])]);o.push(C[1]=I)}}})();var rt={};/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function Ee(a){return{id:a}}/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const vr=Ee("encodeCompressedSegmentationUint32"),ur=Ee("encodeCompressedSegmentationUint64");/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Re=new Map;function fr(a){self.onmessage=u=>{const{t:h,id:o,args:C}=u.data;Re.get(h)(...C).then(({value:x,transfer:w})=>a.postMessage({id:o,value:x},{transfer:w}),x=>a.postMessage({id:o,error:x instanceof Error?x.message:x.toString()}))},self.postMessage(null)}fr(self);function Se(a,u){Re.set(a.id,u)}/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const mr=2;function pr(){return new Map}function gr(a,u,h,o,C,I){if(C>0)switch(C){case 1:for(let x=0,w=0;x<I;++x){let p=0;p|=o[h[w+0]]<<0,p|=o[h[w+1]]<<1,p|=o[h[w+2]]<<2,p|=o[h[w+3]]<<3,p|=o[h[w+4]]<<4,p|=o[h[w+5]]<<5,p|=o[h[w+6]]<<6,p|=o[h[w+7]]<<7,p|=o[h[w+8]]<<8,p|=o[h[w+9]]<<9,p|=o[h[w+10]]<<10,p|=o[h[w+11]]<<11,p|=o[h[w+12]]<<12,p|=o[h[w+13]]<<13,p|=o[h[w+14]]<<14,p|=o[h[w+15]]<<15,p|=o[h[w+16]]<<16,p|=o[h[w+17]]<<17,p|=o[h[w+18]]<<18,p|=o[h[w+19]]<<19,p|=o[h[w+20]]<<20,p|=o[h[w+21]]<<21,p|=o[h[w+22]]<<22,p|=o[h[w+23]]<<23,p|=o[h[w+24]]<<24,p|=o[h[w+25]]<<25,p|=o[h[w+26]]<<26,p|=o[h[w+27]]<<27,p|=o[h[w+28]]<<28,p|=o[h[w+29]]<<29,p|=o[h[w+30]]<<30,p|=o[h[w+31]]<<31,a[u+x]=p,w+=32}break;case 2:for(let x=0,w=0;x<I;++x){let p=0;p|=o[h[w+0]]<<0,p|=o[h[w+1]]<<2,p|=o[h[w+2]]<<4,p|=o[h[w+3]]<<6,p|=o[h[w+4]]<<8,p|=o[h[w+5]]<<10,p|=o[h[w+6]]<<12,p|=o[h[w+7]]<<14,p|=o[h[w+8]]<<16,p|=o[h[w+9]]<<18,p|=o[h[w+10]]<<20,p|=o[h[w+11]]<<22,p|=o[h[w+12]]<<24,p|=o[h[w+13]]<<26,p|=o[h[w+14]]<<28,p|=o[h[w+15]]<<30,a[u+x]=p,w+=16}break;case 4:for(let x=0,w=0;x<I;++x){let p=0;p|=o[h[w+0]]<<0,p|=o[h[w+1]]<<4,p|=o[h[w+2]]<<8,p|=o[h[w+3]]<<12,p|=o[h[w+4]]<<16,p|=o[h[w+5]]<<20,p|=o[h[w+6]]<<24,p|=o[h[w+7]]<<28,a[u+x]=p,w+=8}break;case 8:for(let x=0,w=0;x<I;++x){let p=0;p|=o[h[w+0]]<<0,p|=o[h[w+1]]<<8,p|=o[h[w+2]]<<16,p|=o[h[w+3]]<<24,a[u+x]=p,w+=4}break;case 16:for(let x=0,w=0;x<I;++x){let p=0;p|=o[h[w+0]]<<0,p|=o[h[w+1]]<<16,a[u+x]=p,w+=2}break;case 32:for(let x=0,w=0;x<I;++x){let p=0;p|=o[h[w+0]]<<0,a[u+x]=p,w+=1}break}}function Ne(a,u,h,o,C,I,x,w,p){let F;if(C===1)F=0;else for(F=1;1<<F<C;)F*=2;const N=Math.ceil(F*o/32),te=a.length;let xe=N,ge=!1;const fe=Array.prototype.join.call(I.subarray(0,C*p),",");let W=h.get(fe);W===void 0&&(ge=!0,xe+=C*p,W=te+N-u,h.set(fe,W)),a.resize(te+xe);const ie=a.data;if(gr(ie,te,x,w,F,N),ge){let X=te+N;for(let G=0,Z=C*p;G<Z;++G)ie[X++]=I[G]}return[F,W]}function wr(a,u,h,o,C,I,x){const w=pr(),p=new Array(3);let F=mr;for(let pe=0;pe<3;++pe){const de=p[pe]=Math.ceil(o[pe]/u[pe]);F*=de}const N=p[0],te=p[1],xe=p[2],ge=o[0],fe=o[1],W=o[2],ie=u[0],X=u[1],G=u[2],Z=a.length;let ue=Z;const le=[0,0,0];a.resize(Z+F);const Pe=I[0],ce=I[1],be=I[2];for(let pe=0;pe<xe;++pe){le[2]=Math.min(G,W-pe*G);for(let de=0;de<te;++de){le[1]=Math.min(X,fe-de*X);for(let we=0;we<N;++we){le[0]=Math.min(ie,ge-we*ie);const _e=pe*G*be+de*X*ce+we*ie*Pe,Ae=a.length-Z,[me,M]=x(h,C+_e,I,u,le,Z,w,a),O=a.data;O[ue++]=M|me<<24,O[ue++]=Ae}}}}function Ze(a,u,h,o,C,I,x){const w=a.length,p=o[3];a.resize(w+p);for(let F=0;F<p;++F)a.data[w+F]=a.length,wr(a,u,h,o,C+I[3]*F,I,x)}/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function tt(a,u,h,o){for(;u<h;){const C=a[u];if(o(C)){++u;continue}--h,a[u]=a[h],a[h]=C}return h}function nt(a,u){const h=a.length;let o=0;for(let C=0;C<h;++C)u(a[C],C,a)&&(a[o]=a[C],++o);a.length=o}function at(a,u){if(a.length===u)return a;const h=new a.constructor(u);return h.set(a),h}function Qe(a,u=1){const h=a.length,o=new Array(h);let C=o[0]=u;for(let I=1;I<h;++I)C*=a[I-1],o[I]=C;return o}function dr(a,u,h){const o=new a.constructor(a.length);for(let C=0;C<u*h;C+=h)for(let I=0;I<h;I++){const x=C/h;o[I*u+x]=a[C+I]}return o}function it(a,u,h,o){const C=a.length/u,I=a.length*h*o,x=new a.constructor(I),w=a.length*o,p=u,F=u*o;for(let N=0;N<C;++N)for(let te=0;te<u;++te){const xe=a[N*u+te],ge=N*F+te;for(let fe=0;fe<h;++fe)for(let W=0;W<o;++W)x[fe*w+W*p+ge]=xe}return x}function st(a,u,h,o=0,C=a.length){for(;o<C;){const I=o+C-1>>1,x=h(u,a[I]);if(x>0)o=I+1;else if(x<0)C=I;else return I}return~o}function ot(a,u,h,o=0,C=a.length){let I=-1,x=1/0;for(;o<C;){const w=o+C-1>>1,p=h(u,a[w]);if(p>0)o=w+1;else if(p<0)C=w;else return w;const F=Math.abs(p);F<x&&(x=F,I=w)}return I}function lt(a,u,h){let o=u-a;for(;o>0;){const C=Math.floor(o/2),I=a+C;h(I)?o=C:(a=I+1,o-=C+1)}return a}function yr(a,u){const h=[];for(let o=0,C=a.length;o<C;++o)a[o]===u&&h.push(o);return h}function ct(a,u){const h=[];h.length=u;for(const o of a)h[o]=!0;return yr(h,void 0)}function ht(a,u){const h=a.length;if(u.length!==h)return!1;for(let o=0;o<h;++o)if(a[o]!==u[o])return!1;return!0}function vt(a,u,h=(o,C)=>o===C){const o=a.length;if(u.length!==o)return!1;for(let C=0;C<o;++C)if(!h(a[C],u[C]))return!1;return!0}function ut(a,u,h){const o=[];if(h===u){for(let C=0;C<a;++C)o[C]=C;return o}o[h]=u;for(let C=0,I=0;C<a;){if(C===u){++C;continue}I===h&&++I,o[I++]=C++}return o}function ft(a,u,h){for(let o=0,C=h.length;o<C;++o){const I=h[o];I!==-1&&(a[I]=u[o])}return a}function mt(a,u,h){for(let o=0,C=h.length;o<C;++o){const I=h[o];I!==-1&&(a[o]=u[I])}return a}function pt(a){const u=[];for(let h=0,o=a.length;h<o;++h){const C=a[h];for(let I=0,x=C.length;I<x;++I){let w=u[I];w===void 0&&(w=u[I]=[]),w.push(C[I])}}return u}function gt(a,u){const h=[];let o=0;for(let I=0,x=u.length;I<x;++I){const{retainCount:w,deleteCount:p,insertCount:F}=u[I];w!==0&&(h.push(a.slice(o,o+w)),o+=w),o+=p,F!==0&&h.push(new Array(F))}const C=a.length;return o!==C&&h.push(a.slice(o)),new Array(0).concat(...h)}function wt(a,u,h){const o=[];let C=0,I=0;const x=a.length,w=u.length;for(;C<x&&I<w;){let p;const F=a[C],N=u[I];if(p=h(F,N),p===0){let te=1;for(++C,++I;C<x&&I<w&&(p=h(a[C],u[I]))===0;)++te,++C,++I;o.push({retainCount:te,deleteCount:0,insertCount:0});continue}if(p<0){let te=1;for(;++C<x&&(p=h(a[C],N))<0;)++te;o.push({retainCount:0,deleteCount:te,insertCount:0});continue}if(p>0){let te=1;for(;++I<w&&(p=h(F,u[I]))>0;)++te;o.push({retainCount:0,deleteCount:0,insertCount:te})}}return(C<x||I<w)&&o.push({retainCount:0,deleteCount:x-C,insertCount:w-I}),o}function dt(a,u,h){const o=[];let C=0,I=0;const x=a.length,w=u.length;for(;C<x;){let p=0;for(;C<x&&I<w&&h(a[C],u[I]);)++p,++C,++I;p!==0&&o.push({retainCount:p,deleteCount:0,insertCount:0});let F=0;for(;C<x&&(I===w||!h(a[C],u[I]));)++F,++C;F!==0&&o.push({retainCount:0,deleteCount:F,insertCount:0})}return I!==w&&o.push({retainCount:0,deleteCount:0,insertCount:w-I}),o}function yt(a,u,h,o,C,I){let x=0,w=0;if(a!==0&&u!==0)for(;;){const p=h(x,w);if(p<0){if(o(x),++x===a)break}else if(p>0){if(C(w),++w===u)break}else if(I(x,w),++x,++w,x===a||w===u)break}for(;x<a;)o(x),++x;for(;w<u;)C(w),++w}/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */let Fe,qe,We,Ke,Be;const Oe=1;function je(a,u,h,o,C,I,x,w){const p=C[0],F=C[1],N=C[2],te=o[0],xe=o[1],ge=o[2],fe=h[0];let W=h[1],ie=h[2];if(ie-=W*F,W-=fe*p,p*F*N===0)return[0,0];const X=te*xe*ge+31;(Fe===void 0||Fe.length<X)&&(Fe=new Uint32Array(X),qe=new Uint32Array(X*Oe),We=new Uint32Array(X*Oe),Ke=new Uint32Array(X),Be=new Uint32Array(X));const G=Fe.subarray(0,X);G.fill(0);const Z=qe,ue=We,le=Ke,Pe=Be;let ce=0;{let pe=a[u]+1>>>0,de=u,we=0;const _e=te-p,Ae=te*xe-te*F;for(let me=0;me<N;++me,de+=ie,we+=Ae)for(let M=0;M<F;++M,de+=W,we+=_e)for(let O=0;O<p;++O,de+=fe){const Y=a[de];Y!==pe&&(pe=Z[ce*1]=Y,le[ce]=ce++),G[we++]=ce}}le.subarray(0,ce).sort((pe,de)=>Z[pe]-Z[de]);let be=-1;{let pe=Z[le[0]*Oe]+1>>>0;for(let de=0;de<ce;++de){const we=le[de],_e=we*Oe,Ae=Z[_e];if(Ae!==pe){++be;const me=be*Oe;pe=ue[me]=Ae}Pe[we+1]=be}++be}return Ne(w,I,x,te*xe*ge,be,ue,G,Pe,Oe)}function bt(a,u,h,o,C=0,I=getFortranOrderStrides(o,1)){return encodeChannelCommon(a,u,h,o,C,I,je)}function br(a,u,h,o,C=0,I=Qe(o,1)){return Ze(a,u,h,o,C,I,je)}/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */let ze,er,rr,tr,nr;const Ue=2;function ar(a,u,h,o,C,I,x,w){const p=C[0],F=C[1],N=C[2],te=o[0],xe=o[1],ge=o[2],fe=h[0];let W=h[1],ie=h[2];if(ie-=W*F,W-=fe*p,p*F*N===0)return[0,0];const X=te*xe*ge+31;(ze===void 0||ze.length<X)&&(ze=new Uint32Array(X),er=new Uint32Array(X*Ue),rr=new Uint32Array(X*Ue),tr=new Uint32Array(X),nr=new Uint32Array(X));const G=ze.subarray(0,X);G.fill(0);const Z=er,ue=rr,le=tr,Pe=nr;let ce=0;{let pe=a[u]+1>>>0,de=0,we=u,_e=0;const Ae=te-p,me=te*xe-te*F;for(let M=0;M<N;++M,we+=ie,_e+=me)for(let O=0;O<F;++O,we+=W,_e+=Ae)for(let Y=0;Y<p;++Y,we+=fe){const J=a[we],_=a[we+1];(J!==pe||_!==de)&&(pe=Z[ce*2]=J,de=Z[ce*2+1]=_,le[ce]=ce++),G[_e++]=ce}}le.subarray(0,ce).sort((pe,de)=>{const we=Z[2*pe+1],_e=Z[2*de+1],Ae=Z[2*pe],me=Z[2*de];return we-_e||Ae-me});let be=-1;{let pe=Z[le[0]*Ue]+1>>>0,de=0;for(let we=0;we<ce;++we){const _e=le[we],Ae=_e*Ue,me=Z[Ae],M=Z[Ae+1];if(me!==pe||M!==de){++be;const O=be*Ue;pe=ue[O]=me,de=ue[O+1]=M}Pe[_e+1]=be}++be}return Ne(w,I,x,te*xe*ge,be,ue,G,Pe,Ue)}function Ct(a,u,h,o,C=0,I=getFortranOrderStrides(o,2)){return encodeChannelCommon(a,u,h,o,C,I,ar)}function Cr(a,u,h,o,C=0,I=Qe(o,2)){return Ze(a,u,h,o,C,I,ar)}/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class ir{constructor(u=16){this.length=0,this.data=new Uint32Array(u)}resize(u){const{data:h}=this;if(u>h.length){const o=new Uint32Array(Math.max(u,h.length*2));o.set(h.subarray(0,this.length)),this.data=o}this.length=u}get view(){const{data:u}=this;return new Uint32Array(u.buffer,u.byteOffset,this.length)}shrinkToFit(){this.data=new Uint32Array(this.view)}clear(){this.length=0}appendArray(u){const{length:h}=this;this.resize(h+u.length),this.data.set(u,h)}eraseRange(u,h){this.data.copyWithin(u,h,this.length),this.length-=h-u}}/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const De=new ir(2e4);Se(vr,async(a,u,h)=>(De.clear(),br(De,h,a,u),{value:De.view})),Se(ur,async(a,u,h)=>(De.clear(),Cr(De,h,a,u),{value:De.view}));/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ir=Ee("decodeJpeg");/**
 * @license
 * Copyright 2015 Mozilla Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function xr(a,u){if(a.indexOf("data:")===0){for(var h=a.indexOf("base64,")+7,o=atob(a.substring(h)),C=new Uint8Array(o.length),I=o.length-1;I>=0;I--)C[I]=o.charCodeAt(I);u(C.buffer);return}var x=new XMLHttpRequest;x.open("GET",a,!0),x.responseType="arraybuffer",x.onload=function(){u(x.response)},x.send(null)}var It=function(){function u(){this._src=null,this._parser=new Je.JpegImage,this.onload=null}return u.prototype={get src(){return this._src},set src(h){this.load(h)},get width(){return this._parser.width},get height(){return this._parser.height},load:function(o){this._src=o,xr(o,function(C){this.parse(new Uint8Array(C)),this.onload&&this.onload()}.bind(this))},parse:function(h){this._parser.parse(h)},getData:function(h,o){return this._parser.getData(h,o,!1)},copyToImageData:function(o){if(this._parser.numComponents===2||this._parser.numComponents>4)throw new Error("Unsupported amount of components");var C=o.width,I=o.height,x=C*I*4,w=o.data,p,F;if(this._parser.numComponents===1){var N=this._parser.getData(C,I,!1);for(p=0,F=0;p<x;){var te=N[F++];w[p++]=te,w[p++]=te,w[p++]=te,w[p++]=255}return}var xe=this._parser.getData(C,I,!0);for(p=0,F=0;p<x;)w[p++]=xe[F++],w[p++]=xe[F++],w[p++]=xe[F++],w[p++]=255}},u}(),Je;(function(a){"use strict";var u=function(){var fe=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),W=4017,ie=799,X=3406,G=2276,Z=1567,ue=3784,le=5793,Pe=2896;function ce(){}function be(me,M){for(var O=0,Y=[],J,_,se=16;se>0&&!me[se-1];)se--;Y.push({children:[],index:0});var j=Y[0],A;for(J=0;J<se;J++){for(_=0;_<me[J];_++){for(j=Y.pop(),j.children[j.index]=M[O];j.index>0;)j=Y.pop();for(j.index++,Y.push(j);Y.length<=J;)Y.push(A={children:[],index:0}),j.children[j.index]=A.children,j=A;O++}J+1<se&&(Y.push(A={children:[],index:0}),j.children[j.index]=A.children,j=A)}return Y[0].children}function pe(me,M,O){return 64*((me.blocksPerLine+1)*M+O)}function de(me,M,O,Y,J,_,se,j,A){var k=O.precision,T=O.samplesPerLine,v=O.scanLines,r=O.mcusPerLine,m=O.progressive,e=O.maxH,l=O.maxV,g=M,n=0,i=0;function t(){if(i>0)return i--,n>>i&1;if(n=me[M++],n===255){var V=me[M++];if(V)throw"unexpected marker: "+(n<<8|V).toString(16)}return i=7,n>>>7}function s(V){for(var ae=V;;){if(ae=ae[t()],typeof ae=="number")return ae;if(typeof ae!="object")throw"invalid huffman sequence"}}function c(V){for(var ae=0;V>0;)ae=ae<<1|t(),V--;return ae}function f(V){if(V===1)return t()===1?1:-1;var ae=c(V);return ae>=1<<V-1?ae:ae+(-1<<V)+1}function P(V,ae){var B=s(V.huffmanTableDC),Ce=B===0?0:f(B);V.blockData[ae]=V.pred+=Ce;for(var ve=1;ve<64;){var ne=s(V.huffmanTableAC),Te=ne&15,ke=ne>>4;if(Te===0){if(ke<15)break;ve+=16;continue}ve+=ke;var Le=fe[ve];V.blockData[ae+Le]=f(Te),ve++}}function L(V,ae){var B=s(V.huffmanTableDC),Ce=B===0?0:f(B)<<A;V.blockData[ae]=V.pred+=Ce}function d(V,ae){V.blockData[ae]|=t()<<A}var b=0;function y(V,ae){if(b>0){b--;return}for(var B=_,Ce=se;B<=Ce;){var ve=s(V.huffmanTableAC),ne=ve&15,Te=ve>>4;if(ne===0){if(Te<15){b=c(Te)+(1<<Te)-1;break}B+=16;continue}B+=Te;var ke=fe[B];V.blockData[ae+ke]=f(ne)*(1<<A),B++}}var S=0,D;function U(V,ae){for(var B=_,Ce=se,ve=0,ne,Te;B<=Ce;){var ke=fe[B];switch(S){case 0:if(Te=s(V.huffmanTableAC),ne=Te&15,ve=Te>>4,ne===0)ve<15?(b=c(ve)+(1<<ve),S=4):(ve=16,S=1);else{if(ne!==1)throw"invalid ACn encoding";D=f(ne),S=ve?2:3}continue;case 1:case 2:V.blockData[ae+ke]?V.blockData[ae+ke]+=t()<<A:(ve--,ve===0&&(S=S===2?3:0));break;case 3:V.blockData[ae+ke]?V.blockData[ae+ke]+=t()<<A:(V.blockData[ae+ke]=D<<A,S=0);break;case 4:V.blockData[ae+ke]&&(V.blockData[ae+ke]+=t()<<A);break}B++}S===4&&(b--,b===0&&(S=0))}function $(V,ae,B,Ce,ve){var ne=B/r|0,Te=B%r,ke=ne*V.v+Ce,Le=Te*V.h+ve,He=pe(V,ke,Le);ae(V,He)}function z(V,ae,B){var Ce=B/V.blocksPerLine|0,ve=B%V.blocksPerLine,ne=pe(V,Ce,ve);ae(V,ne)}var K=Y.length,H,E,Q,ee,he,R;m?_===0?R=j===0?L:d:R=j===0?y:U:R=P;var q=0,oe,re;K===1?re=Y[0].blocksPerLine*Y[0].blocksPerColumn:re=r*O.mcusPerColumn,J||(J=re);for(var Ie,Me;q<re;){for(E=0;E<K;E++)Y[E].pred=0;if(b=0,K===1)for(H=Y[0],he=0;he<J;he++)z(H,R,q),q++;else for(he=0;he<J;he++){for(E=0;E<K;E++)for(H=Y[E],Ie=H.h,Me=H.v,Q=0;Q<Me;Q++)for(ee=0;ee<Ie;ee++)$(H,R,q,Q,ee);q++}if(i=0,oe=me[M]<<8|me[M+1],oe<=65280)throw"marker was not found";if(oe>=65488&&oe<=65495)M+=2;else break}return M-g}function we(me,M,O){for(var Y=me.quantizationTable,J=me.blockData,_,se,j,A,k,T,v,r,m,e,l,g,n,i,t,s,c,f=0;f<64;f+=8){if(m=J[M+f],e=J[M+f+1],l=J[M+f+2],g=J[M+f+3],n=J[M+f+4],i=J[M+f+5],t=J[M+f+6],s=J[M+f+7],m*=Y[f],!(e|l|g|n|i|t|s)){c=le*m+512>>10,O[f]=c,O[f+1]=c,O[f+2]=c,O[f+3]=c,O[f+4]=c,O[f+5]=c,O[f+6]=c,O[f+7]=c;continue}e*=Y[f+1],l*=Y[f+2],g*=Y[f+3],n*=Y[f+4],i*=Y[f+5],t*=Y[f+6],s*=Y[f+7],_=le*m+128>>8,se=le*n+128>>8,j=l,A=t,k=Pe*(e-s)+128>>8,r=Pe*(e+s)+128>>8,T=g<<4,v=i<<4,_=_+se+1>>1,se=_-se,c=j*ue+A*Z+128>>8,j=j*Z-A*ue+128>>8,A=c,k=k+v+1>>1,v=k-v,r=r+T+1>>1,T=r-T,_=_+A+1>>1,A=_-A,se=se+j+1>>1,j=se-j,c=k*G+r*X+2048>>12,k=k*X-r*G+2048>>12,r=c,c=T*ie+v*W+2048>>12,T=T*W-v*ie+2048>>12,v=c,O[f]=_+r,O[f+7]=_-r,O[f+1]=se+v,O[f+6]=se-v,O[f+2]=j+T,O[f+5]=j-T,O[f+3]=A+k,O[f+4]=A-k}for(var P=0;P<8;++P){if(m=O[P],e=O[P+8],l=O[P+16],g=O[P+24],n=O[P+32],i=O[P+40],t=O[P+48],s=O[P+56],!(e|l|g|n|i|t|s)){c=le*m+8192>>14,c=c<-2040?0:c>=2024?255:c+2056>>4,J[M+P]=c,J[M+P+8]=c,J[M+P+16]=c,J[M+P+24]=c,J[M+P+32]=c,J[M+P+40]=c,J[M+P+48]=c,J[M+P+56]=c;continue}_=le*m+2048>>12,se=le*n+2048>>12,j=l,A=t,k=Pe*(e-s)+2048>>12,r=Pe*(e+s)+2048>>12,T=g,v=i,_=(_+se+1>>1)+4112,se=_-se,c=j*ue+A*Z+2048>>12,j=j*Z-A*ue+2048>>12,A=c,k=k+v+1>>1,v=k-v,r=r+T+1>>1,T=r-T,_=_+A+1>>1,A=_-A,se=se+j+1>>1,j=se-j,c=k*G+r*X+2048>>12,k=k*X-r*G+2048>>12,r=c,c=T*ie+v*W+2048>>12,T=T*W-v*ie+2048>>12,v=c,m=_+r,s=_-r,e=se+v,t=se-v,l=j+T,i=j-T,g=A+k,n=A-k,m=m<16?0:m>=4080?255:m>>4,e=e<16?0:e>=4080?255:e>>4,l=l<16?0:l>=4080?255:l>>4,g=g<16?0:g>=4080?255:g>>4,n=n<16?0:n>=4080?255:n>>4,i=i<16?0:i>=4080?255:i>>4,t=t<16?0:t>=4080?255:t>>4,s=s<16?0:s>=4080?255:s>>4,J[M+P]=m,J[M+P+8]=e,J[M+P+16]=l,J[M+P+24]=g,J[M+P+32]=n,J[M+P+40]=i,J[M+P+48]=t,J[M+P+56]=s}}function _e(me,M){for(var O=M.blocksPerLine,Y=M.blocksPerColumn,J=new Int16Array(64),_=0;_<Y;_++)for(var se=0;se<O;se++){var j=pe(M,_,se);we(M,j,J)}return M.blockData}function Ae(me){return me<=0?0:me>=255?255:me}return ce.prototype={parse:function(M){function O(){var B=M[_]<<8|M[_+1];return _+=2,B}function Y(){var B=O(),Ce=M.subarray(_,_+B-2);return _+=Ce.length,Ce}function J(B){for(var Ce=Math.ceil(B.samplesPerLine/8/B.maxH),ve=Math.ceil(B.scanLines/8/B.maxV),ne=0;ne<B.components.length;ne++){q=B.components[ne];var Te=Math.ceil(Math.ceil(B.samplesPerLine/8)*q.h/B.maxH),ke=Math.ceil(Math.ceil(B.scanLines/8)*q.v/B.maxV),Le=Ce*q.h,He=ve*q.v,hr=64*He*(Le+1);q.blockData=new Int16Array(hr),q.blocksPerLine=Te,q.blocksPerColumn=ke}B.mcusPerLine=Ce,B.mcusPerColumn=ve}var _=0,se=M.length,j=null,A=null,k=null,T,v,r=[],m=[],e=[],l=O();if(l!==65496)throw"SOI not found";for(l=O();l!==65497;){var g,n,i;switch(l){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var t=Y();l===65504&&t[0]===74&&t[1]===70&&t[2]===73&&t[3]===70&&t[4]===0&&(j={version:{major:t[5],minor:t[6]},densityUnits:t[7],xDensity:t[8]<<8|t[9],yDensity:t[10]<<8|t[11],thumbWidth:t[12],thumbHeight:t[13],thumbData:t.subarray(14,14+3*t[12]*t[13])}),l===65518&&t[0]===65&&t[1]===100&&t[2]===111&&t[3]===98&&t[4]===101&&t[5]===0&&(A={version:t[6],flags0:t[7]<<8|t[8],flags1:t[9]<<8|t[10],transformCode:t[11]});break;case 65499:for(var s=O(),c=s+_-2,f;_<c;){var P=M[_++],L=new Uint16Array(64);if(P>>4)if(P>>4===1)for(n=0;n<64;n++)f=fe[n],L[f]=O();else throw"DQT: invalid table spec";else for(n=0;n<64;n++)f=fe[n],L[f]=M[_++];r[P&15]=L}break;case 65472:case 65473:case 65474:if(T)throw"Only single frame JPEGs supported";O(),T={},T.extended=l===65473,T.progressive=l===65474,T.precision=M[_++],T.scanLines=O(),T.samplesPerLine=O(),T.components=[],T.componentIds={};var d=M[_++],b,y=0,S=0;for(g=0;g<d;g++){b=M[_];var D=M[_+1]>>4,U=M[_+1]&15;y<D&&(y=D),S<U&&(S=U);var $=M[_+2];i=T.components.push({h:D,v:U,quantizationTable:r[$]}),T.componentIds[b]=i-1,_+=3}T.maxH=y,T.maxV=S,J(T);break;case 65476:var z=O();for(g=2;g<z;){var K=M[_++],H=new Uint8Array(16),E=0;for(n=0;n<16;n++,_++)E+=H[n]=M[_];var Q=new Uint8Array(E);for(n=0;n<E;n++,_++)Q[n]=M[_];g+=17+E,(K>>4?m:e)[K&15]=be(H,Q)}break;case 65501:O(),v=O();break;case 65498:var ee=O(),he=M[_++],R=[],q;for(g=0;g<he;g++){var oe=T.componentIds[M[_++]];q=T.components[oe];var re=M[_++];q.huffmanTableDC=e[re>>4],q.huffmanTableAC=m[re&15],R.push(q)}var Ie=M[_++],Me=M[_++],V=M[_++],ae=de(M,_,T,R,v,Ie,Me,V>>4,V&15);_+=ae;break;case 65535:M[_]!==255&&_--;break;default:if(M[_-3]===255&&M[_-2]>=192&&M[_-2]<=254){_-=3;break}throw"unknown JPEG marker "+l.toString(16)}l=O()}for(this.width=T.samplesPerLine,this.height=T.scanLines,this.jfif=j,this.adobe=A,this.components=[],g=0;g<T.components.length;g++)q=T.components[g],this.components.push({output:_e(T,q),scaleX:q.h/T.maxH,scaleY:q.v/T.maxV,blocksPerLine:q.blocksPerLine,blocksPerColumn:q.blocksPerColumn});this.numComponents=this.components.length},_getLinearizedBlockData:function(M,O){var Y=this.width/M,J=this.height/O,_,se,j,A,k,T,v,r,m,e,l=0,g,n=this.components.length,i=M*O*n,t=new Uint8Array(i),s=new Uint32Array(M),c=4294967288;for(v=0;v<n;v++){for(_=this.components[v],se=_.scaleX*Y,j=_.scaleY*J,l=v,g=_.output,A=_.blocksPerLine+1<<3,k=0;k<M;k++)r=0|k*se,s[k]=(r&c)<<3|r&7;for(T=0;T<O;T++)for(r=0|T*j,e=A*(r&c)|(r&7)<<3,k=0;k<M;k++)t[l]=g[e+s[k]],l+=n}var f=this.decodeTransform;if(f)for(v=0;v<i;)for(r=0,m=0;r<n;r++,v++,m+=2)t[v]=(t[v]*f[m]>>8)+f[m+1];return t},_isColorConversionNeeded:function(){return this.adobe&&this.adobe.transformCode?!0:this.numComponents===3},_convertYccToRgb:function(M){for(var O,Y,J,_=0,se=M.length;_<se;_+=3)O=M[_],Y=M[_+1],J=M[_+2],M[_]=Ae(O-179.456+1.402*J),M[_+1]=Ae(O+135.459-.344*Y-.714*J),M[_+2]=Ae(O-226.816+1.772*Y);return M},_convertYcckToRgb:function(M){for(var O,Y,J,_,se=0,j=0,A=M.length;j<A;j+=4){O=M[j],Y=M[j+1],J=M[j+2],_=M[j+3];var k=-122.67195406894+Y*(-660635669420364e-19*Y+.000437130475926232*J-54080610064599e-18*O+.00048449797120281*_-.154362151871126)+J*(-.000957964378445773*J+.000817076911346625*O-.00477271405408747*_+1.53380253221734)+O*(.000961250184130688*O-.00266257332283933*_+.48357088451265)+_*(-.000336197177618394*_+.484791561490776),T=107.268039397724+Y*(219927104525741e-19*Y-.000640992018297945*J+.000659397001245577*O+.000426105652938837*_-.176491792462875)+J*(-.000778269941513683*J+.00130872261408275*O+.000770482631801132*_-.151051492775562)+O*(.00126935368114843*O-.00265090189010898*_+.25802910206845)+_*(-.000318913117588328*_-.213742400323665),v=-20.810012546947+Y*(-.000570115196973677*Y-263409051004589e-19*J+.0020741088115012*O-.00288260236853442*_+.814272968359295)+J*(-153496057440975e-19*J-.000132689043961446*O+.000560833691242812*_-.195152027534049)+O*(.00174418132927582*O-.00255243321439347*_+.116935020465145)+_*(-.000343531996510555*_+.24165260232407);M[se++]=Ae(k),M[se++]=Ae(T),M[se++]=Ae(v)}return M},_convertYcckToCmyk:function(M){for(var O,Y,J,_=0,se=M.length;_<se;_+=4)O=M[_],Y=M[_+1],J=M[_+2],M[_]=Ae(434.456-O-1.402*J),M[_+1]=Ae(119.541-O+.344*Y+.714*J),M[_+2]=Ae(481.816-O-1.772*Y);return M},_convertCmykToRgb:function(M){for(var O,Y,J,_,se=0,j=-255*255*255,A=1/255/255,k=0,T=M.length;k<T;k+=4){O=M[k],Y=M[k+1],J=M[k+2],_=M[k+3];var v=O*(-4.387332384609988*O+54.48615194189176*Y+18.82290502165302*J+212.25662451639585*_-72734.4411664936)+Y*(1.7149763477362134*Y-5.6096736904047315*J-17.873870861415444*_-1401.7366389350734)+J*(-2.5217340131683033*J-21.248923337353073*_+4465.541406466231)-_*(21.86122147463605*_+48317.86113160301),r=O*(8.841041422036149*O+60.118027045597366*Y+6.871425592049007*J+31.159100130055922*_-20220.756542821975)+Y*(-15.310361306967817*Y+17.575251261109482*J+131.35250912493976*_-48691.05921601825)+J*(4.444339102852739*J+9.8632861493405*_-6341.191035517494)-_*(20.737325471181034*_+47890.15695978492),m=O*(.8842522430003296*O+8.078677503112928*Y+30.89978309703729*J-.23883238689178934*_-3616.812083916688)+Y*(10.49593273432072*Y+63.02378494754052*J+50.606957656360734*_-28620.90484698408)+J*(.03296041114873217*J+115.60384449646641*_-49363.43385999684)-_*(22.33816807309886*_+45932.16563550634);M[se++]=v>=0?255:v<=j?0:255+v*A|0,M[se++]=r>=0?255:r<=j?0:255+r*A|0,M[se++]=m>=0?255:m<=j?0:255+m*A|0}return M},getData:function(M,O,Y){if(this.numComponents>4)throw"Unsupported color mode";var J=this._getLinearizedBlockData(M,O);if(this.numComponents===3)return this._convertYccToRgb(J);if(this.numComponents===4){if(this._isColorConversionNeeded())return Y?this._convertYcckToRgb(J):this._convertYcckToCmyk(J);if(Y)return this._convertCmykToRgb(J)}return J}},ce}(),h=function(){var fe=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];function W(ie,X,G){this.data=ie,this.bp=X,this.dataEnd=G,this.chigh=ie[X],this.clow=0,this.byteIn(),this.chigh=this.chigh<<7&65535|this.clow>>9&127,this.clow=this.clow<<7&65535,this.ct-=7,this.a=32768}return W.prototype={byteIn:function(){var X=this.data,G=this.bp;if(X[G]===255){var Z=X[G+1];Z>143?(this.clow+=65280,this.ct=8):(G++,this.clow+=X[G]<<9,this.ct=7,this.bp=G)}else G++,this.clow+=G<this.dataEnd?X[G]<<8:65280,this.ct=8,this.bp=G;this.clow>65535&&(this.chigh+=this.clow>>16,this.clow&=65535)},readBit:function(X,G){var Z=X[G]>>1,ue=X[G]&1,le=fe[Z],Pe=le.qe,ce,be=this.a-Pe;if(this.chigh<Pe)be<Pe?(be=Pe,ce=ue,Z=le.nmps):(be=Pe,ce=1^ue,le.switchFlag===1&&(ue=ce),Z=le.nlps);else{if(this.chigh-=Pe,be&32768)return this.a=be,ue;be<Pe?(ce=1^ue,le.switchFlag===1&&(ue=ce),Z=le.nlps):(ce=ue,Z=le.nmps)}do this.ct===0&&this.byteIn(),be<<=1,this.chigh=this.chigh<<1&65535|this.clow>>15&1,this.clow=this.clow<<1&65535,this.ct--;while(!(be&32768));return this.a=be,X[G]=Z<<1|ue,ce}},W}(),o=function(){var fe={LL:0,LH:1,HL:1,HH:2};function W(){this.failOnCorruptedImage=!1}W.prototype={parse:function(r){var m=w(r,0);if(m===65359){this.parseCodestream(r,0,r.length);return}for(var e=0,l=r.length;e<l;){var g=8,n=p(r,e),i=p(r,e+4);if(e+=g,n===1&&(n=p(r,e)*4294967296+p(r,e+4),e+=8,g+=8),n===0&&(n=l-e+g),n<g)throw new Error("JPX Error: Invalid box field size");var t=n-g,s=!0;switch(i){case 1785737832:s=!1;break;case 1668246642:var c=r[e],f=r[e+1],P=r[e+2];if(c===1){var L=p(r,e+3);switch(L){case 16:case 17:case 18:break;default:te("Unknown colorspace "+L);break}}else c===2&&xe("ICC profile not supported");break;case 1785737827:this.parseCodestream(r,e,e+t);break;case 1783636e3:p(r,e)!==218793738&&te("Invalid JP2 signature");break;case 1783634458:case 1718909296:case 1920099697:case 1919251232:case 1768449138:break;default:var d=String.fromCharCode(i>>24&255,i>>16&255,i>>8&255,i&255);te("Unsupported header type "+i+" ("+d+")");break}s&&(e+=t)}},parseImageProperties:function(r){for(var m=r.getByte();m>=0;){var e=m;m=r.getByte();var l=e<<8|m;if(l===65361){r.skip(4);var g=r.getInt32()>>>0,n=r.getInt32()>>>0,i=r.getInt32()>>>0,t=r.getInt32()>>>0;r.skip(16);var s=r.getUint16();this.width=g-i,this.height=n-t,this.componentsCount=s,this.bitsPerComponent=8;return}}throw new Error("JPX Error: No size marker found in JPX stream")},parseCodestream:function(r,m,e){var l={};try{for(var g=!1,n=m;n+1<e;){var i=w(r,n);n+=2;var t=0,s,c,f,P,L,d;switch(i){case 65359:l.mainHeader=!0;break;case 65497:break;case 65361:t=w(r,n);var b={};b.Xsiz=p(r,n+4),b.Ysiz=p(r,n+8),b.XOsiz=p(r,n+12),b.YOsiz=p(r,n+16),b.XTsiz=p(r,n+20),b.YTsiz=p(r,n+24),b.XTOsiz=p(r,n+28),b.YTOsiz=p(r,n+32);var y=w(r,n+36);b.Csiz=y;var S=[];s=n+38;for(var D=0;D<y;D++){var U={precision:(r[s]&127)+1,isSigned:!!(r[s]&128),XRsiz:r[s+1],YRsiz:r[s+1]};ie(U,b),S.push(U)}l.SIZ=b,l.components=S,X(l,S),l.QCC=[],l.COC=[];break;case 65372:t=w(r,n);var $={};switch(s=n+2,c=r[s++],c&31){case 0:P=8,L=!0;break;case 1:P=16,L=!1;break;case 2:P=16,L=!0;break;default:throw new Error("JPX Error: Invalid SQcd value "+c)}for($.noQuantization=P===8,$.scalarExpounded=L,$.guardBits=c>>5,f=[];s<t+n;){var z={};P===8?(z.epsilon=r[s++]>>3,z.mu=0):(z.epsilon=r[s]>>3,z.mu=(r[s]&7)<<8|r[s+1],s+=2),f.push(z)}$.SPqcds=f,l.mainHeader?l.QCD=$:(l.currentTile.QCD=$,l.currentTile.QCC=[]);break;case 65373:t=w(r,n);var K={};s=n+2;var H;switch(l.SIZ.Csiz<257?H=r[s++]:(H=w(r,s),s+=2),c=r[s++],c&31){case 0:P=8,L=!0;break;case 1:P=16,L=!1;break;case 2:P=16,L=!0;break;default:throw new Error("JPX Error: Invalid SQcd value "+c)}for(K.noQuantization=P===8,K.scalarExpounded=L,K.guardBits=c>>5,f=[];s<t+n;)z={},P===8?(z.epsilon=r[s++]>>3,z.mu=0):(z.epsilon=r[s]>>3,z.mu=(r[s]&7)<<8|r[s+1],s+=2),f.push(z);K.SPqcds=f,l.mainHeader?l.QCC[H]=K:l.currentTile.QCC[H]=K;break;case 65362:t=w(r,n);var E={};s=n+2;var Q=r[s++];E.entropyCoderWithCustomPrecincts=!!(Q&1),E.sopMarkerUsed=!!(Q&2),E.ephMarkerUsed=!!(Q&4),E.progressionOrder=r[s++],E.layersCount=w(r,s),s+=2,E.multipleComponentTransform=r[s++],E.decompositionLevelsCount=r[s++],E.xcb=(r[s++]&15)+2,E.ycb=(r[s++]&15)+2;var ee=r[s++];if(E.selectiveArithmeticCodingBypass=!!(ee&1),E.resetContextProbabilities=!!(ee&2),E.terminationOnEachCodingPass=!!(ee&4),E.verticalyStripe=!!(ee&8),E.predictableTermination=!!(ee&16),E.segmentationSymbolUsed=!!(ee&32),E.reversibleTransformation=r[s++],E.entropyCoderWithCustomPrecincts){for(var he=[];s<t+n;){var R=r[s++];he.push({PPx:R&15,PPy:R>>4})}E.precinctsSizes=he}var q=[];if(E.selectiveArithmeticCodingBypass&&q.push("selectiveArithmeticCodingBypass"),E.resetContextProbabilities&&q.push("resetContextProbabilities"),E.terminationOnEachCodingPass&&q.push("terminationOnEachCodingPass"),E.verticalyStripe&&q.push("verticalyStripe"),E.predictableTermination&&q.push("predictableTermination"),q.length>0)throw g=!0,new Error("JPX Error: Unsupported COD options ("+q.join(", ")+")");l.mainHeader?l.COD=E:(l.currentTile.COD=E,l.currentTile.COC=[]);break;case 65424:t=w(r,n),d={},d.index=w(r,n+2),d.length=p(r,n+4),d.dataEnd=d.length+n-2,d.partIndex=r[n+8],d.partsCount=r[n+9],l.mainHeader=!1,d.partIndex===0&&(d.COD=l.COD,d.COC=l.COC.slice(0),d.QCD=l.QCD,d.QCC=l.QCC.slice(0)),l.currentTile=d;break;case 65427:d=l.currentTile,d.partIndex===0&&(J(l,d.index),Ae(l)),t=d.dataEnd-n,me(l,r,n,t);break;case 65365:case 65367:case 65368:case 65380:t=w(r,n);break;case 65363:throw new Error("JPX Error: Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("JPX Error: Unknown codestream code: "+i.toString(16))}n+=t}}catch(oe){if(g||this.failOnCorruptedImage)throw oe;te("Trying to recover from "+oe.message)}this.tiles=Y(l),this.width=l.SIZ.Xsiz-l.SIZ.XOsiz,this.height=l.SIZ.Ysiz-l.SIZ.YOsiz,this.componentsCount=l.SIZ.Csiz}};function ie(v,r){v.x0=Math.ceil(r.XOsiz/v.XRsiz),v.x1=Math.ceil(r.Xsiz/v.XRsiz),v.y0=Math.ceil(r.YOsiz/v.YRsiz),v.y1=Math.ceil(r.Ysiz/v.YRsiz),v.width=v.x1-v.x0,v.height=v.y1-v.y0}function X(v,r){for(var m=v.SIZ,e,l=[],g=Math.ceil((m.Xsiz-m.XTOsiz)/m.XTsiz),n=Math.ceil((m.Ysiz-m.YTOsiz)/m.YTsiz),i=0;i<n;i++)for(var t=0;t<g;t++)e={},e.tx0=Math.max(m.XTOsiz+t*m.XTsiz,m.XOsiz),e.ty0=Math.max(m.YTOsiz+i*m.YTsiz,m.YOsiz),e.tx1=Math.min(m.XTOsiz+(t+1)*m.XTsiz,m.Xsiz),e.ty1=Math.min(m.YTOsiz+(i+1)*m.YTsiz,m.Ysiz),e.width=e.tx1-e.tx0,e.height=e.ty1-e.ty0,e.components=[],l.push(e);v.tiles=l;for(var s=m.Csiz,c=0,f=s;c<f;c++)for(var P=r[c],L=0,d=l.length;L<d;L++){var b={};e=l[L],b.tcx0=Math.ceil(e.tx0/P.XRsiz),b.tcy0=Math.ceil(e.ty0/P.YRsiz),b.tcx1=Math.ceil(e.tx1/P.XRsiz),b.tcy1=Math.ceil(e.ty1/P.YRsiz),b.width=b.tcx1-b.tcx0,b.height=b.tcy1-b.tcy0,e.components[c]=b}}function G(v,r,m){var e=r.codingStyleParameters,l={};return e.entropyCoderWithCustomPrecincts?(l.PPx=e.precinctsSizes[m].PPx,l.PPy=e.precinctsSizes[m].PPy):(l.PPx=15,l.PPy=15),l.xcb_=m>0?Math.min(e.xcb,l.PPx-1):Math.min(e.xcb,l.PPx),l.ycb_=m>0?Math.min(e.ycb,l.PPy-1):Math.min(e.ycb,l.PPy),l}function Z(v,r,m){var e=1<<m.PPx,l=1<<m.PPy,g=r.resLevel===0,n=1<<m.PPx+(g?0:-1),i=1<<m.PPy+(g?0:-1),t=r.trx1>r.trx0?Math.ceil(r.trx1/e)-Math.floor(r.trx0/e):0,s=r.try1>r.try0?Math.ceil(r.try1/l)-Math.floor(r.try0/l):0,c=t*s;r.precinctParameters={precinctWidth:e,precinctHeight:l,numprecinctswide:t,numprecinctshigh:s,numprecincts:c,precinctWidthInSubband:n,precinctHeightInSubband:i}}function ue(v,r,m){var e=m.xcb_,l=m.ycb_,g=1<<e,n=1<<l,i=r.tbx0>>e,t=r.tby0>>l,s=r.tbx1+g-1>>e,c=r.tby1+n-1>>l,f=r.resolution.precinctParameters,P=[],L=[],d,b,y,S;for(b=t;b<c;b++)for(d=i;d<s;d++){y={cbx:d,cby:b,tbx0:g*d,tby0:n*b,tbx1:g*(d+1),tby1:n*(b+1)},y.tbx0_=Math.max(r.tbx0,y.tbx0),y.tby0_=Math.max(r.tby0,y.tby0),y.tbx1_=Math.min(r.tbx1,y.tbx1),y.tby1_=Math.min(r.tby1,y.tby1);var D=Math.floor((y.tbx0_-r.tbx0)/f.precinctWidthInSubband),U=Math.floor((y.tby0_-r.tby0)/f.precinctHeightInSubband);if(S=D+U*f.numprecinctswide,y.precinctNumber=S,y.subbandType=r.type,y.Lblock=3,!(y.tbx1_<=y.tbx0_||y.tby1_<=y.tby0_)){P.push(y);var $=L[S];$!==void 0?(d<$.cbxMin?$.cbxMin=d:d>$.cbxMax&&($.cbxMax=d),b<$.cbyMin?$.cbxMin=b:b>$.cbyMax&&($.cbyMax=b)):L[S]=$={cbxMin:d,cbyMin:b,cbxMax:d,cbyMax:b},y.precinct=$}}r.codeblockParameters={codeblockWidth:e,codeblockHeight:l,numcodeblockwide:s-i+1,numcodeblockhigh:c-t+1},r.codeblocks=P,r.precincts=L}function le(v,r,m){for(var e=[],l=v.subbands,g=0,n=l.length;g<n;g++)for(var i=l[g],t=i.codeblocks,s=0,c=t.length;s<c;s++){var f=t[s];f.precinctNumber===r&&e.push(f)}return{layerNumber:m,codeblocks:e}}function Pe(v){for(var r=v.SIZ,m=v.currentTile.index,e=v.tiles[m],l=e.codingStyleDefaultParameters.layersCount,g=r.Csiz,n=0,i=0;i<g;i++)n=Math.max(n,e.components[i].codingStyleParameters.decompositionLevelsCount);var t=0,s=0,c=0,f=0;this.nextPacket=function(){for(;t<l;t++){for(;s<=n;s++){for(;c<g;c++){var L=e.components[c];if(!(s>L.codingStyleParameters.decompositionLevelsCount)){for(var d=L.resolutions[s],b=d.precinctParameters.numprecincts;f<b;){var y=le(d,f,t);return f++,y}f=0}}c=0}s=0}throw new Error("JPX Error: Out of packets")}}function ce(v){for(var r=v.SIZ,m=v.currentTile.index,e=v.tiles[m],l=e.codingStyleDefaultParameters.layersCount,g=r.Csiz,n=0,i=0;i<g;i++)n=Math.max(n,e.components[i].codingStyleParameters.decompositionLevelsCount);var t=0,s=0,c=0,f=0;this.nextPacket=function(){for(;t<=n;t++){for(;s<l;s++){for(;c<g;c++){var L=e.components[c];if(!(t>L.codingStyleParameters.decompositionLevelsCount)){for(var d=L.resolutions[t],b=d.precinctParameters.numprecincts;f<b;){var y=le(d,f,s);return f++,y}f=0}}c=0}s=0}throw new Error("JPX Error: Out of packets")}}function be(v){var r=v.SIZ,m=v.currentTile.index,e=v.tiles[m],l=e.codingStyleDefaultParameters.layersCount,g=r.Csiz,n,i,t,s,c=0;for(t=0;t<g;t++){var f=e.components[t];c=Math.max(c,f.codingStyleParameters.decompositionLevelsCount)}var P=new Int32Array(c+1);for(i=0;i<=c;++i){var L=0;for(t=0;t<g;++t){var d=e.components[t].resolutions;i<d.length&&(L=Math.max(L,d[i].precinctParameters.numprecincts))}P[i]=L}n=0,i=0,t=0,s=0,this.nextPacket=function(){for(;i<=c;i++){for(;s<P[i];s++){for(;t<g;t++){var y=e.components[t];if(!(i>y.codingStyleParameters.decompositionLevelsCount)){var S=y.resolutions[i],D=S.precinctParameters.numprecincts;if(!(s>=D)){for(;n<l;){var U=le(S,s,n);return n++,U}n=0}}}t=0}s=0}throw new Error("JPX Error: Out of packets")}}function pe(v){var r=v.SIZ,m=v.currentTile.index,e=v.tiles[m],l=e.codingStyleDefaultParameters.layersCount,g=r.Csiz,n=_e(e),i=n,t=0,s=0,c=0,f=0,P=0;this.nextPacket=function(){for(;P<i.maxNumHigh;P++){for(;f<i.maxNumWide;f++){for(;c<g;c++){for(var d=e.components[c],b=d.codingStyleParameters.decompositionLevelsCount;s<=b;s++){var y=d.resolutions[s],S=n.components[c].resolutions[s],D=we(f,P,S,i,y);if(D!==null){for(;t<l;){var U=le(y,D,t);return t++,U}t=0}}s=0}c=0}f=0}throw new Error("JPX Error: Out of packets")}}function de(v){var r=v.SIZ,m=v.currentTile.index,e=v.tiles[m],l=e.codingStyleDefaultParameters.layersCount,g=r.Csiz,n=_e(e),i=0,t=0,s=0,c=0,f=0;this.nextPacket=function(){for(;s<g;++s){for(var L=e.components[s],d=n.components[s],b=L.codingStyleParameters.decompositionLevelsCount;f<d.maxNumHigh;f++){for(;c<d.maxNumWide;c++){for(;t<=b;t++){var y=L.resolutions[t],S=d.resolutions[t],D=we(c,f,S,d,y);if(D!==null){for(;i<l;){var U=le(y,D,i);return i++,U}i=0}}t=0}c=0}f=0}throw new Error("JPX Error: Out of packets")}}function we(v,r,m,e,l){var g=v*e.minWidth,n=r*e.minHeight;if(g%m.width!==0||n%m.height!==0)return null;var i=n/m.width*l.precinctParameters.numprecinctswide;return g/m.height+i}function _e(v){for(var r=v.components.length,m=Number.MAX_VALUE,e=Number.MAX_VALUE,l=0,g=0,n=new Array(r),i=0;i<r;i++){for(var t=v.components[i],s=t.codingStyleParameters.decompositionLevelsCount,c=new Array(s+1),f=Number.MAX_VALUE,P=Number.MAX_VALUE,L=0,d=0,b=1,y=s;y>=0;--y){var S=t.resolutions[y],D=b*S.precinctParameters.precinctWidth,U=b*S.precinctParameters.precinctHeight;f=Math.min(f,D),P=Math.min(P,U),L=Math.max(L,S.precinctParameters.numprecinctswide),d=Math.max(d,S.precinctParameters.numprecinctshigh),c[y]={width:D,height:U},b<<=1}m=Math.min(m,f),e=Math.min(e,P),l=Math.max(l,L),g=Math.max(g,d),n[i]={resolutions:c,minWidth:f,minHeight:P,maxNumWide:L,maxNumHigh:d}}return{components:n,minWidth:m,minHeight:e,maxNumWide:l,maxNumHigh:g}}function Ae(v){for(var r=v.SIZ,m=v.currentTile.index,e=v.tiles[m],l=r.Csiz,g=0;g<l;g++){for(var n=e.components[g],i=n.codingStyleParameters.decompositionLevelsCount,t=[],s=[],c=0;c<=i;c++){var f=G(v,n,c),P={},L=1<<i-c;P.trx0=Math.ceil(n.tcx0/L),P.try0=Math.ceil(n.tcy0/L),P.trx1=Math.ceil(n.tcx1/L),P.try1=Math.ceil(n.tcy1/L),P.resLevel=c,Z(v,P,f),t.push(P);var d;if(c===0)d={},d.type="LL",d.tbx0=Math.ceil(n.tcx0/L),d.tby0=Math.ceil(n.tcy0/L),d.tbx1=Math.ceil(n.tcx1/L),d.tby1=Math.ceil(n.tcy1/L),d.resolution=P,ue(v,d,f),s.push(d),P.subbands=[d];else{var b=1<<i-c+1,y=[];d={},d.type="HL",d.tbx0=Math.ceil(n.tcx0/b-.5),d.tby0=Math.ceil(n.tcy0/b),d.tbx1=Math.ceil(n.tcx1/b-.5),d.tby1=Math.ceil(n.tcy1/b),d.resolution=P,ue(v,d,f),s.push(d),y.push(d),d={},d.type="LH",d.tbx0=Math.ceil(n.tcx0/b),d.tby0=Math.ceil(n.tcy0/b-.5),d.tbx1=Math.ceil(n.tcx1/b),d.tby1=Math.ceil(n.tcy1/b-.5),d.resolution=P,ue(v,d,f),s.push(d),y.push(d),d={},d.type="HH",d.tbx0=Math.ceil(n.tcx0/b-.5),d.tby0=Math.ceil(n.tcy0/b-.5),d.tbx1=Math.ceil(n.tcx1/b-.5),d.tby1=Math.ceil(n.tcy1/b-.5),d.resolution=P,ue(v,d,f),s.push(d),y.push(d),P.subbands=y}}n.resolutions=t,n.subbands=s}var S=e.codingStyleDefaultParameters.progressionOrder;switch(S){case 0:e.packetsIterator=new Pe(v);break;case 1:e.packetsIterator=new ce(v);break;case 2:e.packetsIterator=new be(v);break;case 3:e.packetsIterator=new pe(v);break;case 4:e.packetsIterator=new de(v);break;default:throw new Error("JPX Error: Unsupported progression order "+S)}}function me(v,r,m,e){var l=0,g,n=0,i=!1;function t(ne){for(;n<ne;){var Te=r[m+l];l++,i?(g=g<<7|Te,n+=7,i=!1):(g=g<<8|Te,n+=8),Te===255&&(i=!0)}return n-=ne,g>>>n&(1<<ne)-1}function s(ne){return r[m+l-1]===255&&r[m+l]===ne?(c(1),!0):r[m+l]===255&&r[m+l+1]===ne?(c(2),!0):!1}function c(ne){l+=ne}function f(){n=0,i&&(l++,i=!1)}function P(){if(t(1)===0)return 1;if(t(1)===0)return 2;var ne=t(2);return ne<3?ne+3:(ne=t(5),ne<31?ne+6:(ne=t(7),ne+37))}for(var L=v.currentTile.index,d=v.tiles[L],b=v.COD.sopMarkerUsed,y=v.COD.ephMarkerUsed,S=d.packetsIterator;l<e;){f(),b&&s(145)&&c(4);var D=S.nextPacket();if(t(1)){for(var U=D.layerNumber,$=[],z,K=0,H=D.codeblocks.length;K<H;K++){z=D.codeblocks[K];var E=z.precinct,Q=z.cbx-E.cbxMin,ee=z.cby-E.cbyMin,he=!1,R=!1,q;if(z.included!==void 0)he=!!t(1);else{E=z.precinct;var oe,re;if(E.inclusionTree!==void 0)oe=E.inclusionTree;else{var Ie=E.cbxMax-E.cbxMin+1,Me=E.cbyMax-E.cbyMin+1;oe=new se(Ie,Me,U),re=new _(Ie,Me),E.inclusionTree=oe,E.zeroBitPlanesTree=re}if(oe.reset(Q,ee,U))for(;;)if(t(1)){if(q=!oe.nextLevel(),q){z.included=!0,he=R=!0;break}}else{oe.incrementValue(U);break}}if(he){if(R){for(re=E.zeroBitPlanesTree,re.reset(Q,ee);;)if(t(1)){if(q=!re.nextLevel(),q)break}else re.incrementValue();z.zeroBitPlanes=re.value}for(var V=P();t(1);)z.Lblock++;var ae=I(V),B=(V<1<<ae?ae-1:ae)+z.Lblock,Ce=t(B);$.push({codeblock:z,codingpasses:V,dataLength:Ce})}}for(f(),y&&s(146);$.length>0;){var ve=$.shift();z=ve.codeblock,z.data===void 0&&(z.data=[]),z.data.push({data:r,start:m+l,end:m+l+ve.dataLength,codingpasses:ve.codingpasses}),l+=ve.dataLength}}}return l}function M(v,r,m,e,l,g,n,i){for(var t=e.tbx0,s=e.tby0,c=e.tbx1-e.tbx0,f=e.codeblocks,P=e.type.charAt(0)==="H"?1:0,L=e.type.charAt(1)==="H"?r:0,d=0,b=f.length;d<b;++d){var y=f[d],S=y.tbx1_-y.tbx0_,D=y.tby1_-y.tby0_;if(!(S===0||D===0)&&y.data!==void 0){var U,$;U=new j(S,D,y.subbandType,y.zeroBitPlanes,g),$=2;var z=y.data,K=0,H=0,E,Q,ee;for(E=0,Q=z.length;E<Q;E++)ee=z[E],K+=ee.end-ee.start,H+=ee.codingpasses;var he=new Uint8Array(K),R=0;for(E=0,Q=z.length;E<Q;E++){ee=z[E];var q=ee.data.subarray(ee.start,ee.end);he.set(q,R),R+=q.length}var oe=new h(he,0,K);for(U.setDecoder(oe),E=0;E<H;E++){switch($){case 0:U.runSignificancePropogationPass();break;case 1:U.runMagnitudeRefinementPass();break;case 2:U.runCleanupPass(),i&&U.checkSegmentationSymbol();break}$=($+1)%3}var re=y.tbx0_-t+(y.tby0_-s)*c,Ie=U.coefficentsSign,Me=U.coefficentsMagnitude,V=U.bitsDecoded,ae=n?0:.5,B,Ce,ve;R=0;var ne=e.type!=="LL";for(E=0;E<D;E++){var Te=re/c|0,ke=2*Te*(r-c)+P+L;for(B=0;B<S;B++){if(Ce=Me[R],Ce!==0){Ce=(Ce+ae)*l,Ie[R]!==0&&(Ce=-Ce),ve=V[R];var Le=ne?ke+(re<<1):re;n&&ve>=g?v[Le]=Ce:v[Le]=Ce*(1<<g-ve)}re++,R++}re+=c-S}}}}function O(v,r,m){for(var e=r.components[m],l=e.codingStyleParameters,g=e.quantizationParameters,n=l.decompositionLevelsCount,i=g.SPqcds,t=g.scalarExpounded,s=g.guardBits,c=l.segmentationSymbolUsed,f=v.components[m].precision,P=l.reversibleTransformation,L=P?new T:new k,d=[],b=0,y=0;y<=n;y++){for(var S=e.resolutions[y],D=S.trx1-S.trx0,U=S.try1-S.try0,$=new Float32Array(D*U),z=0,K=S.subbands.length;z<K;z++){var H,E;t?(H=i[b].mu,E=i[b].epsilon,b++):(H=i[0].mu,E=i[0].epsilon+(y>0?1-y:0));var Q=S.subbands[z],ee=fe[Q.type],he=P?1:Math.pow(2,f+ee-E)*(1+H/2048),R=s+E-1;M($,D,U,Q,he,R,P,c)}d.push({width:D,height:U,items:$})}var q=L.calculate(d,e.tcx0,e.tcy0);return{left:e.tcx0,top:e.tcy0,width:q.width,height:q.height,items:q.items}}function Y(v){for(var r=v.SIZ,m=v.components,e=r.Csiz,l=[],g=0,n=v.tiles.length;g<n;g++){var i=v.tiles[g],t=[],s;for(s=0;s<e;s++)t[s]=O(v,i,s);var c=t[0],f=new Uint8Array(c.items.length*e),P={left:c.left,top:c.top,width:c.width,height:c.height,items:f},L,d,b,y,S,D=0,U,$,z,K,H,E,Q,ee,he,R;if(i.codingStyleDefaultParameters.multipleComponentTransform){var q=e===4,oe=t[0].items,re=t[1].items,Ie=t[2].items,Me=q?t[3].items:null;L=m[0].precision-8,d=(128<<L)+.5,b=255*(1<<L),S=b*.5,y=-S;var V=i.components[0],ae=e-3;if($=oe.length,V.codingStyleParameters.reversibleTransformation)for(U=0;U<$;U++,D+=ae)z=oe[U]+d,K=re[U],H=Ie[U],Q=z-(H+K>>2),E=Q+H,ee=Q+K,f[D++]=E<=0?0:E>=b?255:E>>L,f[D++]=Q<=0?0:Q>=b?255:Q>>L,f[D++]=ee<=0?0:ee>=b?255:ee>>L;else for(U=0;U<$;U++,D+=ae)z=oe[U]+d,K=re[U],H=Ie[U],E=z+1.402*H,Q=z-.34413*K-.71414*H,ee=z+1.772*K,f[D++]=E<=0?0:E>=b?255:E>>L,f[D++]=Q<=0?0:Q>=b?255:Q>>L,f[D++]=ee<=0?0:ee>=b?255:ee>>L;if(q)for(U=0,D=3;U<$;U++,D+=4)he=Me[U],f[D]=he<=y?0:he>=S?255:he+d>>L}else for(s=0;s<e;s++){var B=t[s].items;for(L=m[s].precision-8,d=(128<<L)+.5,b=127.5*(1<<L),y=-b,D=s,U=0,$=B.length;U<$;U++)R=B[U],f[D]=R<=y?0:R>=b?255:R+d>>L,D+=e}l.push(P)}return l}function J(v,r){for(var m=v.SIZ,e=m.Csiz,l=v.tiles[r],g=0;g<e;g++){var n=l.components[g],i=v.currentTile.QCC[g]!==void 0?v.currentTile.QCC[g]:v.currentTile.QCD;n.quantizationParameters=i;var t=v.currentTile.COC[g]!==void 0?v.currentTile.COC[g]:v.currentTile.COD;n.codingStyleParameters=t}l.codingStyleDefaultParameters=v.currentTile.COD}var _=function(){function r(m,e){var l=I(Math.max(m,e))+1;this.levels=[];for(var g=0;g<l;g++){var n={width:m,height:e,items:[]};this.levels.push(n),m=Math.ceil(m/2),e=Math.ceil(e/2)}}return r.prototype={reset:function(e,l){for(var g=0,n=0,i;g<this.levels.length;){i=this.levels[g];var t=e+l*i.width;if(i.items[t]!==void 0){n=i.items[t];break}i.index=t,e>>=1,l>>=1,g++}g--,i=this.levels[g],i.items[i.index]=n,this.currentLevel=g,delete this.value},incrementValue:function(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function(){var e=this.currentLevel,l=this.levels[e],g=l.items[l.index];return e--,e<0?(this.value=g,!1):(this.currentLevel=e,l=this.levels[e],l.items[l.index]=g,!0)}},r}(),se=function(){function r(m,e,l){var g=I(Math.max(m,e))+1;this.levels=[];for(var n=0;n<g;n++){for(var i=new Uint8Array(m*e),t=0,s=i.length;t<s;t++)i[t]=l;var c={width:m,height:e,items:i};this.levels.push(c),m=Math.ceil(m/2),e=Math.ceil(e/2)}}return r.prototype={reset:function(e,l,g){for(var n=0;n<this.levels.length;){var i=this.levels[n],t=e+l*i.width;i.index=t;var s=i.items[t];if(s===255)break;if(s>g)return this.currentLevel=n,this.propagateValues(),!1;e>>=1,l>>=1,n++}return this.currentLevel=n-1,!0},incrementValue:function(e){var l=this.levels[this.currentLevel];l.items[l.index]=e+1,this.propagateValues()},propagateValues:function(){for(var e=this.currentLevel,l=this.levels[e],g=l.items[l.index];--e>=0;)l=this.levels[e],l.items[l.index]=g},nextLevel:function(){var e=this.currentLevel,l=this.levels[e],g=l.items[l.index];return l.items[l.index]=255,e--,e<0?!1:(this.currentLevel=e,l=this.levels[e],l.items[l.index]=g,!0)}},r}(),j=function(){var r=17,m=18,e=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]),l=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]),g=new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]);function n(i,t,s,c,f){this.width=i,this.height=t,this.contextLabelTable=s==="HH"?g:s==="HL"?l:e;var P=i*t;this.neighborsSignificance=new Uint8Array(P),this.coefficentsSign=new Uint8Array(P),this.coefficentsMagnitude=f>14?new Uint32Array(P):f>6?new Uint16Array(P):new Uint8Array(P),this.processingFlags=new Uint8Array(P);var L=new Uint8Array(P);if(c!==0)for(var d=0;d<P;d++)L[d]=c;this.bitsDecoded=L,this.reset()}return n.prototype={setDecoder:function(t){this.decoder=t},reset:function(){this.contexts=new Int8Array(19),this.contexts[0]=8,this.contexts[r]=92,this.contexts[m]=6},setNeighborsSignificance:function(t,s,c){var f=this.neighborsSignificance,P=this.width,L=this.height,d=s>0,b=s+1<P,y;t>0&&(y=c-P,d&&(f[y-1]+=16),b&&(f[y+1]+=16),f[y]+=4),t+1<L&&(y=c+P,d&&(f[y-1]+=16),b&&(f[y+1]+=16),f[y]+=4),d&&(f[c-1]+=1),b&&(f[c+1]+=1),f[c]|=128},runSignificancePropogationPass:function(){for(var t=this.decoder,s=this.width,c=this.height,f=this.coefficentsMagnitude,P=this.coefficentsSign,L=this.neighborsSignificance,d=this.processingFlags,b=this.contexts,y=this.contextLabelTable,S=this.bitsDecoded,D=-2,U=1,$=2,z=0;z<c;z+=4)for(var K=0;K<s;K++)for(var H=z*s+K,E=0;E<4;E++,H+=s){var Q=z+E;if(Q>=c)break;if(d[H]&=D,!(f[H]||!L[H])){var ee=y[L[H]],he=t.readBit(b,ee);if(he){var R=this.decodeSignBit(Q,K,H);P[H]=R,f[H]=1,this.setNeighborsSignificance(Q,K,H),d[H]|=$}S[H]++,d[H]|=U}}},decodeSignBit:function(t,s,c){var f=this.width,P=this.height,L=this.coefficentsMagnitude,d=this.coefficentsSign,b,y,S,D,U,$;D=s>0&&L[c-1]!==0,s+1<f&&L[c+1]!==0?(S=d[c+1],D?(y=d[c-1],b=1-S-y):b=1-S-S):D?(y=d[c-1],b=1-y-y):b=0;var z=3*b;return D=t>0&&L[c-f]!==0,t+1<P&&L[c+f]!==0?(S=d[c+f],D?(y=d[c-f],b=1-S-y+z):b=1-S-S+z):D?(y=d[c-f],b=1-y-y+z):b=z,b>=0?(U=9+b,$=this.decoder.readBit(this.contexts,U)):(U=9-b,$=this.decoder.readBit(this.contexts,U)^1),$},runMagnitudeRefinementPass:function(){for(var t=this.decoder,s=this.width,c=this.height,f=this.coefficentsMagnitude,P=this.neighborsSignificance,L=this.contexts,d=this.bitsDecoded,b=this.processingFlags,y=1,S=2,D=s*c,U=s*4,$=0,z;$<D;$=z){z=Math.min(D,$+U);for(var K=0;K<s;K++)for(var H=$+K;H<z;H+=s)if(!(!f[H]||b[H]&y)){var E=16;if(b[H]&S){b[H]^=S;var Q=P[H]&127;E=Q===0?15:14}var ee=t.readBit(L,E);f[H]=f[H]<<1|ee,d[H]++,b[H]|=y}}},runCleanupPass:function(){for(var t=this.decoder,s=this.width,c=this.height,f=this.neighborsSignificance,P=this.coefficentsMagnitude,L=this.coefficentsSign,d=this.contexts,b=this.contextLabelTable,y=this.bitsDecoded,S=this.processingFlags,D=1,U=2,$=s,z=s*2,K=s*3,H,E=0;E<c;E=H){H=Math.min(E+4,c);for(var Q=E*s,ee=E+3<c,he=0;he<s;he++){var R=Q+he,q=ee&&S[R]===0&&S[R+$]===0&&S[R+z]===0&&S[R+K]===0&&f[R]===0&&f[R+$]===0&&f[R+z]===0&&f[R+K]===0,oe=0,re=R,Ie=E,Me;if(q){var V=t.readBit(d,m);if(!V){y[R]++,y[R+$]++,y[R+z]++,y[R+K]++;continue}oe=t.readBit(d,r)<<1|t.readBit(d,r),oe!==0&&(Ie=E+oe,re+=oe*s),Me=this.decodeSignBit(Ie,he,re),L[re]=Me,P[re]=1,this.setNeighborsSignificance(Ie,he,re),S[re]|=U,re=R;for(var ae=E;ae<=Ie;ae++,re+=s)y[re]++;oe++}for(Ie=E+oe;Ie<H;Ie++,re+=s)if(!(P[re]||S[re]&D)){var B=b[f[re]],Ce=t.readBit(d,B);Ce===1&&(Me=this.decodeSignBit(Ie,he,re),L[re]=Me,P[re]=1,this.setNeighborsSignificance(Ie,he,re),S[re]|=U),y[re]++}}}},checkSegmentationSymbol:function(){var t=this.decoder,s=this.contexts,c=t.readBit(s,r)<<3|t.readBit(s,r)<<2|t.readBit(s,r)<<1|t.readBit(s,r);if(c!==10)throw new Error("JPX Error: Invalid segmentation symbol")}},n}(),A=function(){function r(){}return r.prototype.calculate=function(e,l,g){for(var n=e[0],i=1,t=e.length;i<t;i++)n=this.iterate(n,e[i],l,g);return n},r.prototype.extend=function(e,l,g){var n=l-1,i=l+1,t=l+g-2,s=l+g;e[n--]=e[i++],e[s++]=e[t--],e[n--]=e[i++],e[s++]=e[t--],e[n--]=e[i++],e[s++]=e[t--],e[n]=e[i],e[s]=e[t]},r.prototype.iterate=function(e,l,g,n){var i=e.width,t=e.height,s=e.items,c=l.width,f=l.height,P=l.items,L,d,b,y,S,D;for(b=0,L=0;L<t;L++)for(y=L*2*c,d=0;d<i;d++,b++,y+=2)P[y]=s[b];s=e.items=null;var U=4,$=new Float32Array(c+2*U);if(c===1){if(g&1)for(D=0,b=0;D<f;D++,b+=c)P[b]*=.5}else for(D=0,b=0;D<f;D++,b+=c)$.set(P.subarray(b,b+c),U),this.extend($,U,c),this.filter($,U,c),P.set($.subarray(U,U+c),b);var z=16,K=[];for(L=0;L<z;L++)K.push(new Float32Array(f+2*U));var H,E=0;if(e=U+f,f===1){if(n&1)for(S=0;S<c;S++)P[S]*=.5}else for(S=0;S<c;S++){if(E===0){for(z=Math.min(c-S,z),b=S,y=U;y<e;b+=c,y++)for(H=0;H<z;H++)K[H][y]=P[b+H];E=z}E--;var Q=K[E];if(this.extend(Q,U,f),this.filter(Q,U,f),E===0)for(b=S-z+1,y=U;y<e;b+=c,y++)for(H=0;H<z;H++)P[b+H]=K[H][y]}return{width:c,height:f,items:P}},r}(),k=function(){function r(){A.call(this)}return r.prototype=Object.create(A.prototype),r.prototype.filter=function(e,l,g){var n=g>>1;l=l|0;var i,t,s,c,f=-1.586134342059924,P=-.052980118572961,L=.882911075530934,d=.443506852043971,b=1.230174104914001,y=1/b;for(i=l-3,t=n+4;t--;i+=2)e[i]*=y;for(i=l-2,s=d*e[i-1],t=n+3;t--&&(c=d*e[i+1],e[i]=b*e[i]-s-c,t--);i+=2)i+=2,s=d*e[i+1],e[i]=b*e[i]-s-c;for(i=l-1,s=L*e[i-1],t=n+2;t--&&(c=L*e[i+1],e[i]-=s+c,t--);i+=2)i+=2,s=L*e[i+1],e[i]-=s+c;for(i=l,s=P*e[i-1],t=n+1;t--&&(c=P*e[i+1],e[i]-=s+c,t--);i+=2)i+=2,s=P*e[i+1],e[i]-=s+c;if(n!==0)for(i=l+1,s=f*e[i-1],t=n;t--&&(c=f*e[i+1],e[i]-=s+c,t--);i+=2)i+=2,s=f*e[i+1],e[i]-=s+c},r}(),T=function(){function r(){A.call(this)}return r.prototype=Object.create(A.prototype),r.prototype.filter=function(e,l,g){var n=g>>1;l=l|0;var i,t;for(i=l,t=n+1;t--;i+=2)e[i]-=e[i-1]+e[i+1]+2>>2;for(i=l+1,t=n;t--;i+=2)e[i]+=e[i-1]+e[i+1]>>1},r}();return W}(),C=function(){function fe(){}fe.prototype={getContexts:function(A){return A in this?this[A]:this[A]=new Int8Array(65536)}};function W(A,k,T){this.data=A,this.start=k,this.end=T}W.prototype={get decoder(){var A=new h(this.data,this.start,this.end);return F(this,"decoder",A)},get contextCache(){var A=new fe;return F(this,"contextCache",A)}};function ie(A,k,T){var v=A.getContexts(k),r=1;function m(g){for(var n=0,i=0;i<g;i++){var t=T.readBit(v,r);r=r<256?r<<1|t:(r<<1|t)&511|256,n=n<<1|t}return n>>>0}var e=m(1),l=m(1)?m(1)?m(1)?m(1)?m(1)?m(32)+4436:m(12)+340:m(8)+84:m(6)+20:m(4)+4:m(2);return e===0?l:l>0?-l:null}function X(A,k,T){for(var v=A.getContexts("IAID"),r=1,m=0;m<T;m++){var e=k.readBit(v,r);r=r<<1|e}return T<31?r&(1<<T)-1:r&2147483647}var G=["SymbolDictionary",null,null,null,"IntermediateTextRegion",null,"ImmediateTextRegion","ImmediateLosslessTextRegion",null,null,null,null,null,null,null,null,"patternDictionary",null,null,null,"IntermediateHalftoneRegion",null,"ImmediateHalftoneRegion","ImmediateLosslessHalftoneRegion",null,null,null,null,null,null,null,null,null,null,null,null,"IntermediateGenericRegion",null,"ImmediateGenericRegion","ImmediateLosslessGenericRegion","IntermediateGenericRefinementRegion",null,"ImmediateGenericRefinementRegion","ImmediateLosslessGenericRefinementRegion",null,null,null,null,"PageInformation","EndOfPage","EndOfStripe","EndOfFile","Profiles","Tables",null,null,null,null,null,null,null,null,"Extension"],Z=[[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:2,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-2,y:0},{x:-1,y:0}],[{x:-3,y:-1},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}]],ue=[{coding:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:-1,y:1},{x:0,y:1},{x:1,y:1}]},{coding:[{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:0,y:1},{x:1,y:1}]}],le=[39717,1941,229,405],Pe=[32,8];function ce(A,k,T){var v=T.decoder,r=T.contextCache.getContexts("GB"),m,e,l,g,n,i,t,s=[],c=31735;for(e=0;e<k;e++)for(n=s[e]=new Uint8Array(A),i=e<1?n:s[e-1],t=e<2?n:s[e-2],m=t[0]<<13|t[1]<<12|t[2]<<11|i[0]<<7|i[1]<<6|i[2]<<5|i[3]<<4,l=0;l<A;l++)n[l]=g=v.readBit(r,m),m=(m&c)<<1|(l+3<A?t[l+3]<<11:0)|(l+4<A?i[l+4]<<4:0)|g;return s}function be(A,k,T,v,r,m,e,l){if(A&&N("JBIG2 error: MMR encoding is not supported"),v===0&&!m&&!r&&e.length===4&&e[0].x===3&&e[0].y===-1&&e[1].x===-3&&e[1].y===-1&&e[2].x===2&&e[2].y===-2&&e[3].x===-2&&e[3].y===-2)return ce(k,T,l);var g=!!m,n=Z[v].concat(e);n.sort(function(ne,Te){return ne.y-Te.y||ne.x-Te.x});var i=n.length,t=new Int8Array(i),s=new Int8Array(i),c=[],f=0,P=0,L=0,d=0,b,y;for(y=0;y<i;y++)t[y]=n[y].x,s[y]=n[y].y,P=Math.min(P,n[y].x),L=Math.max(L,n[y].x),d=Math.min(d,n[y].y),y<i-1&&n[y].y===n[y+1].y&&n[y].x===n[y+1].x-1?f|=1<<i-1-y:c.push(y);var S=c.length,D=new Int8Array(S),U=new Int8Array(S),$=new Uint16Array(S);for(b=0;b<S;b++)y=c[b],D[b]=n[y].x,U[b]=n[y].y,$[b]=1<<i-1-y;for(var z=-P,K=-d,H=k-L,E=le[v],Q=new Uint8Array(k),ee=[],he=l.decoder,R=l.contextCache.getContexts("GB"),q=0,oe,re,Ie,Me=0,V,ae,B=0;B<T;B++){if(r){var Ce=he.readBit(R,E);if(q^=Ce,q){ee.push(Q);continue}}for(Q=new Uint8Array(Q),ee.push(Q),oe=0;oe<k;oe++){if(g&&m[B][oe]){Q[oe]=0;continue}if(oe>=z&&oe<H&&B>=K)for(Me=Me<<1&f,y=0;y<S;y++)re=B+U[y],Ie=oe+D[y],V=ee[re][Ie],V&&(V=$[y],Me|=V);else for(Me=0,ae=i-1,y=0;y<i;y++,ae--)Ie=oe+t[y],Ie>=0&&Ie<k&&(re=B+s[y],re>=0&&(V=ee[re][Ie],V&&(Me|=V<<ae)));var ve=he.readBit(R,Me);Q[oe]=ve}}return ee}function pe(A,k,T,v,r,m,e,l,g){var n=ue[T].coding;T===0&&(n=n.concat([l[0]]));var i=n.length,t=new Int32Array(i),s=new Int32Array(i),c;for(c=0;c<i;c++)t[c]=n[c].x,s[c]=n[c].y;var f=ue[T].reference;T===0&&(f=f.concat([l[1]]));var P=f.length,L=new Int32Array(P),d=new Int32Array(P);for(c=0;c<P;c++)L[c]=f[c].x,d[c]=f[c].y;for(var b=v[0].length,y=v.length,S=Pe[T],D=[],U=g.decoder,$=g.contextCache.getContexts("GR"),z=0,K=0;K<k;K++){if(e){var H=U.readBit($,S);z^=H,z&&N("JBIG2 error: prediction is not supported")}var E=new Uint8Array(A);D.push(E);for(var Q=0;Q<A;Q++){var ee,he,R=0;for(c=0;c<i;c++)ee=K+s[c],he=Q+t[c],ee<0||he<0||he>=A?R<<=1:R=R<<1|D[ee][he];for(c=0;c<P;c++)ee=K+d[c]+m,he=Q+L[c]+r,ee<0||ee>=y||he<0||he>=b?R<<=1:R=R<<1|v[ee][he];var q=U.readBit($,R);E[Q]=q}}return D}function de(A,k,T,v,r,m,e,l,g,n,i){A&&N("JBIG2 error: huffman is not supported");for(var t=[],s=0,c=I(T.length+v),f=i.decoder,P=i.contextCache;t.length<v;){var L=ie(P,"IADH",f);s+=L;for(var d=0,b=0;;){var y=ie(P,"IADW",f);if(y===null)break;d+=y,b+=d;var S;if(k){var D=ie(P,"IAAI",f);if(D>1)S=we(A,k,d,s,0,D,1,T.concat(t),c,0,0,1,0,m,g,n,i);else{var U=X(P,f,c),$=ie(P,"IARDX",f),z=ie(P,"IARDY",f),K=U<T.length?T[U]:t[U-T.length];S=pe(d,s,g,K,$,z,!1,n,i)}}else S=be(!1,d,s,e,!1,null,l,i);t.push(S)}}for(var H=[],E=[],Q=!1,ee=T.length+v;E.length<ee;){for(var he=ie(P,"IAEX",f);he--;)E.push(Q);Q=!Q}for(var R=0,q=T.length;R<q;R++)E[R]&&H.push(T[R]);for(var oe=0;oe<v;R++,oe++)E[R]&&H.push(t[oe]);return H}function we(A,k,T,v,r,m,e,l,g,n,i,t,s,c,f,P,L){A&&N("JBIG2 error: huffman is not supported");var d=[],b,y;for(b=0;b<v;b++){if(y=new Uint8Array(T),r)for(var S=0;S<T;S++)y[S]=r;d.push(y)}var D=L.decoder,U=L.contextCache,$=-ie(U,"IADT",D),z=0;for(b=0;b<m;){var K=ie(U,"IADT",D);$+=K;var H=ie(U,"IAFS",D);z+=H;var E=z;do{var Q=e===1?0:ie(U,"IAIT",D),ee=e*$+Q,he=X(U,D,g),R=k&&ie(U,"IARI",D),q=l[he],oe=q[0].length,re=q.length;if(R){var Ie=ie(U,"IARDW",D),Me=ie(U,"IARDH",D),V=ie(U,"IARDX",D),ae=ie(U,"IARDY",D);oe+=Ie,re+=Me,q=pe(oe,re,f,q,(Ie>>1)+V,(Me>>1)+ae,!1,P,L)}var B=ee-(t&1?0:re),Ce=E-(t&2?oe:0),ve,ne,Te;if(n){for(ve=0;ve<re;ve++)if(y=d[Ce+ve],!!y){Te=q[ve];var ke=Math.min(T-B,oe);switch(s){case 0:for(ne=0;ne<ke;ne++)y[B+ne]|=Te[ne];break;case 2:for(ne=0;ne<ke;ne++)y[B+ne]^=Te[ne];break;default:N("JBIG2 error: operator "+s+" is not supported")}}E+=re-1}else{for(ne=0;ne<re;ne++)if(y=d[B+ne],!!y)switch(Te=q[ne],s){case 0:for(ve=0;ve<oe;ve++)y[Ce+ve]|=Te[ve];break;case 2:for(ve=0;ve<oe;ve++)y[Ce+ve]^=Te[ve];break;default:N("JBIG2 error: operator "+s+" is not supported")}E+=oe-1}b++;var Le=ie(U,"IADS",D);if(Le===null)break;E+=Le+i}while(!0)}return d}function _e(A,k){var T={};T.number=p(A,k);var v=A[k+4],r=v&63;G[r]||N("JBIG2 error: invalid segment type: "+r),T.type=r,T.typeName=G[r],T.deferredNonRetain=!!(v&128);var m=!!(v&64),e=A[k+5],l=e>>5&7,g=[e&31],n=k+6;if(e===7){l=p(A,n-1)&536870911,n+=3;var i=l+7>>3;for(g[0]=A[n++];--i>0;)g.push(A[n++])}else(e===5||e===6)&&N("JBIG2 error: invalid referred-to flags");T.retainBits=g;var t=T.number<=256?1:T.number<=65536?2:4,s=[],c,f;for(c=0;c<l;c++){var P=t===1?A[n]:t===2?w(A,n):p(A,n);s.push(P),n+=t}if(T.referredTo=s,m?(T.pageAssociation=p(A,n),n+=4):T.pageAssociation=A[n++],T.length=p(A,n),n+=4,T.length===4294967295)if(r===38){var L=me(A,n),d=A[n+M],b=!!(d&1),y=6,S=new Uint8Array(y);for(b||(S[0]=255,S[1]=172),S[2]=L.height>>>24&255,S[3]=L.height>>16&255,S[4]=L.height>>8&255,S[5]=L.height&255,c=n,f=A.length;c<f;c++){for(var D=0;D<y&&S[D]===A[c+D];)D++;if(D===y){T.length=c+y;break}}T.length===4294967295&&N("JBIG2 error: segment end was not found")}else N("JBIG2 error: invalid unknown segment length");return T.headerEnd=n,T}function Ae(A,k,T,v){for(var r=[],m=T;m<v;){var e=_e(k,m);m=e.headerEnd;var l={header:e,data:k};if(A.randomAccess||(l.start=m,m+=e.length,l.end=m),r.push(l),e.type===51)break}if(A.randomAccess)for(var g=0,n=r.length;g<n;g++)r[g].start=m,m+=r[g].header.length,r[g].end=m;return r}function me(A,k){return{width:p(A,k),height:p(A,k+4),x:p(A,k+8),y:p(A,k+12),combinationOperator:A[k+16]&7}}var M=17;function O(A,k){var T=A.header,v=A.data,r=A.start,m=A.end,e,l,g,n;switch(T.type){case 0:var i={},t=w(v,r);if(i.huffman=!!(t&1),i.refinement=!!(t&2),i.huffmanDHSelector=t>>2&3,i.huffmanDWSelector=t>>4&3,i.bitmapSizeSelector=t>>6&1,i.aggregationInstancesSelector=t>>7&1,i.bitmapCodingContextUsed=!!(t&256),i.bitmapCodingContextRetained=!!(t&512),i.template=t>>10&3,i.refinementTemplate=t>>12&1,r+=2,!i.huffman){for(n=i.template===0?4:1,l=[],g=0;g<n;g++)l.push({x:x(v,r),y:x(v,r+1)}),r+=2;i.at=l}if(i.refinement&&!i.refinementTemplate){for(l=[],g=0;g<2;g++)l.push({x:x(v,r),y:x(v,r+1)}),r+=2;i.refinementAt=l}i.numberOfExportedSymbols=p(v,r),r+=4,i.numberOfNewSymbols=p(v,r),r+=4,e=[i,T.number,T.referredTo,v,r,m];break;case 6:case 7:var s={};s.info=me(v,r),r+=M;var c=w(v,r);if(r+=2,s.huffman=!!(c&1),s.refinement=!!(c&2),s.stripSize=1<<(c>>2&3),s.referenceCorner=c>>4&3,s.transposed=!!(c&64),s.combinationOperator=c>>7&3,s.defaultPixelValue=c>>9&1,s.dsOffset=c<<17>>27,s.refinementTemplate=c>>15&1,s.huffman){var f=w(v,r);r+=2,s.huffmanFS=f&3,s.huffmanDS=f>>2&3,s.huffmanDT=f>>4&3,s.huffmanRefinementDW=f>>6&3,s.huffmanRefinementDH=f>>8&3,s.huffmanRefinementDX=f>>10&3,s.huffmanRefinementDY=f>>12&3,s.huffmanRefinementSizeSelector=!!(f&14)}if(s.refinement&&!s.refinementTemplate){for(l=[],g=0;g<2;g++)l.push({x:x(v,r),y:x(v,r+1)}),r+=2;s.refinementAt=l}s.numberOfSymbolInstances=p(v,r),r+=4,s.huffman&&N("JBIG2 error: huffman is not supported"),e=[s,T.referredTo,v,r,m];break;case 38:case 39:var P={};P.info=me(v,r),r+=M;var L=v[r++];if(P.mmr=!!(L&1),P.template=L>>1&3,P.prediction=!!(L&8),!P.mmr){for(n=P.template===0?4:1,l=[],g=0;g<n;g++)l.push({x:x(v,r),y:x(v,r+1)}),r+=2;P.at=l}e=[P,v,r,m];break;case 48:var d={width:p(v,r),height:p(v,r+4),resolutionX:p(v,r+8),resolutionY:p(v,r+12)};d.height===4294967295&&delete d.height;var b=v[r+16],y=w(v,r+17);d.lossless=!!(b&1),d.refinement=!!(b&2),d.defaultPixelValue=b>>2&1,d.combinationOperator=b>>3&3,d.requiresBuffer=!!(b&32),d.combinationOperatorOverride=!!(b&64),e=[d];break;case 49:break;case 50:break;case 51:break;case 62:break;default:N("JBIG2 error: segment type "+T.typeName+"("+T.type+") is not implemented")}var S="on"+T.typeName;S in k&&k[S].apply(k,e)}function Y(A,k){for(var T=0,v=A.length;T<v;T++)O(A[T],k)}function J(A,k,T){var v=k;(A[v]!==151||A[v+1]!==74||A[v+2]!==66||A[v+3]!==50||A[v+4]!==13||A[v+5]!==10||A[v+6]!==26||A[v+7]!==10)&&N("JBIG2 error: invalid header");var r={};v+=8;var m=A[v++];r.randomAccess=!(m&1),m&2||(r.numberOfPages=p(A,v),v+=4);var e=Ae(r,A,v,T);N("Not implemented")}function _(A){for(var k=new se,T=0,v=A.length;T<v;T++){var r=A[T],m=Ae({},r.data,r.start,r.end);Y(m,k)}return k}function se(){}se.prototype={onPageInformation:function(k){this.currentPageInfo=k;var T=k.width+7>>3,v=new Uint8Array(T*k.height);if(k.defaultPixelValue)for(var r=0,m=v.length;r<m;r++)v[r]=255;this.buffer=v},drawBitmap:function(k,T){var v=this.currentPageInfo,r=k.width,m=k.height,e=v.width+7>>3,l=v.combinationOperatorOverride?k.combinationOperator:v.combinationOperator,g=this.buffer,n=128>>(k.x&7),i=k.y*e+(k.x>>3),t,s,c,f;switch(l){case 0:for(t=0;t<m;t++){for(c=n,f=i,s=0;s<r;s++)T[t][s]&&(g[f]|=c),c>>=1,c||(c=128,f++);i+=e}break;case 2:for(t=0;t<m;t++){for(c=n,f=i,s=0;s<r;s++)T[t][s]&&(g[f]^=c),c>>=1,c||(c=128,f++);i+=e}break;default:N("JBIG2 error: operator "+l+" is not supported")}},onImmediateGenericRegion:function(k,T,v,r){var m=k.info,e=new W(T,v,r),l=be(k.mmr,m.width,m.height,k.template,k.prediction,null,k.at,e);this.drawBitmap(m,l)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(k,T,v,r,m,e){var l;k.huffman&&N("JBIG2 error: huffman is not supported");var g=this.symbols;g||(this.symbols=g={});for(var n=[],i=0,t=v.length;i<t;i++)n=n.concat(g[v[i]]);var s=new W(r,m,e);g[T]=de(k.huffman,k.refinement,n,k.numberOfNewSymbols,k.numberOfExportedSymbols,l,k.template,k.at,k.refinementTemplate,k.refinementAt,s)},onImmediateTextRegion:function(k,T,v,r,m){for(var e=k.info,l,g=this.symbols,n=[],i=0,t=T.length;i<t;i++)n=n.concat(g[T[i]]);var s=I(n.length),c=new W(v,r,m),f=we(k.huffman,k.refinement,e.width,e.height,k.defaultPixelValue,k.numberOfSymbolInstances,k.stripSize,n,s,k.transposed,k.dsOffset,k.referenceCorner,k.combinationOperator,l,k.refinementTemplate,k.refinementAt,c);this.drawBitmap(e,f)},onImmediateLosslessTextRegion:function(){this.onImmediateTextRegion.apply(this,arguments)}};function j(){}return j.prototype={parseChunks:function(k){return _(k)}},j}();function I(ge){for(var fe=1,W=0;ge>fe;)fe<<=1,W++;return W}function x(ge,fe){return ge[fe]<<24>>24}function w(ge,fe){return ge[fe]<<8|ge[fe+1]}function p(ge,fe){return(ge[fe]<<24|ge[fe+1]<<16|ge[fe+2]<<8|ge[fe+3])>>>0}function F(ge,fe,W){return Object.defineProperty(ge,fe,{value:W,enumerable:!0,configurable:!0,writable:!1}),W}var N=function(){throw console.error.apply(console,arguments),new Error("PDFJS error: "+arguments[0])},te=function(){console.warn.apply(console,arguments)},xe=function(){console.info.apply(console,arguments)};C.prototype.parse=function(ce){var W=0,ie=ce.length;(ce[W]!==151||ce[W+1]!==74||ce[W+2]!==66||ce[W+3]!==50||ce[W+4]!==13||ce[W+5]!==10||ce[W+6]!==26||ce[W+7]!==10)&&N("JBIG2 error: invalid header");var X={};W+=8;var G=ce[W++];X.randomAccess=!(G&1),G&2||(X.numberOfPages=p(ce,W),W+=4);for(var Z=this.parseChunks([{data:ce,start:W,end:ie}]),ue=Z.currentPageInfo.width,le=Z.currentPageInfo.height,Pe=Z.buffer,ce=new Uint8Array(ue*le),be=0,pe=0,de=0;de<le;de++)for(var we=0,_e,Ae=0;Ae<ue;Ae++)we||(we=128,_e=Pe[pe++]),ce[be++]=_e&we?0:255,we>>=1;this.width=ue,this.height=le,this.data=ce},a.JpegImage=u,a.JpxImage=o,a.Jbig2Image=C})(Je||(Je={}));var Pr=Je.JpegImage,xt=Je.JpxImage,Pt=Je.Jbig2Image;/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */Se(Ir,async(a,u,h,o,C)=>{const I=new Pr;if(I.parse(a),u!==void 0&&h!==void 0&&I.width*I.height!==u*h)throw new Error(`JPEG data does not have the expected dimensions: width=${I.width}, height=${I.height}, expected width=${u}, expected height=${h}`);if(u=I.width,h=I.height,o!==void 0&&I.numComponents!==o)throw new Error(`JPEG data does not have the expected number of components: components=${I.numComponents}, expected=${o}`);o=I.numComponents;let x;if(I.numComponents===1)x=I.getData(I.width,I.height,!1);else if(I.numComponents===3)if(x=I.getData(I.width,I.height,!1),C){const w=u*h,p=new Uint8Array(w);for(let F=0;F<w;++F)p[F]=x[F*3];x=p}else x=dr(x,I.width*I.height,3);else throw new Error(`JPEG data has an unsupported number of components: components=${I.numComponents}`);return{value:{width:u,height:h,numComponents:o,uint8Array:x},transfer:[x.buffer]}});/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ar=Ee("decodeGzip");/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */Se(Ar,async a=>{const u=(await ye.e(75).then(ye.bind(ye,3075))).inflate(a);return{value:u,transfer:[u.buffer]}});/**
 * @license
 * Copyright 2022 William Silversmith
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Tr=Ee("decodePng");/**
 * @license
 * Copyright 2022 William Silvermsith
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const sr={emscripten_notify_memory_growth:()=>{},proc_exit:a=>{throw`proc exit: ${a}`}};let Xe;function Mr(){return Xe===void 0&&(Xe=(async()=>{const a=(await WebAssembly.instantiateStreaming(fetch(new URL(ye(3200),ye.b)),{env:sr,wasi_snapshot_preview1:sr})).instance;return a.exports._initialize(),a})()),Xe}var _r=(a=>(a[a.GRAYSCALE=0]="GRAYSCALE",a[a.RGB=2]="RGB",a[a.PALETTE=3]="PALETTE",a[a.GRAYSCALE_ALPHA=4]="GRAYSCALE_ALPHA",a[a.RGBA=6]="RGBA",a))(_r||{});const Ge=[137,80,78,71,13,10,26,10],kr=["I","H","D","R"];function Lr(a){function u(X,G){return X.every((Z,ue)=>Z===G[ue])}if(a.length<12)throw new Error("png: Invalid image size: {buffer.length}");if(!u(Ge,a))throw new Error("png: didn't match magic numbers: {buffer.slice(0,8)}");const o=new DataView(a.buffer,Ge.length),C=o.getUint32(0,!1);if(a.length<Ge.length+C+12)throw new Error("png: Invalid image size: {buffer.length}");const x=[4,5,6,7].map(X=>String.fromCharCode(o.getUint8(X)));if(!u(x,kr))throw new Error(`png: Invalid header code (should be IHDR): ${x}`);const w=o.getUint32(8,!1),p=o.getUint32(12,!1),F=o.getUint8(16),N=o.getUint8(17),te=o.getUint8(18),xe=o.getUint8(19),ge=o.getUint8(20);if(w===0||p===0)throw new Error(`png: 0 is not a valid width or height. width: ${w} height: ${p}`);if(te!==0)throw new Error(`png: Invalid compression method Only 0 is supported (DEFLATE). Got: ${te}`);if(xe!==0)throw new Error(`png: Invalid filter method. Only 0 (adaptive filtering) is supported. Got: ${xe}`);if(ge>1)throw new Error(`png: invalid interlace method. Only 0 (no interlace) and 1 (adam7) are supported. Got: ${ge}`);const fe=[1,2,4,8,16];if(fe.indexOf(F)===-1)throw new Error(`png: invalid bit depth. Got: ${F} Valid Depths: ${fe}`);let W=F<=8?1:2,ie=1;if(N!==0)if(N===2){if(F!==8&&F!==16)throw new Error(`png: invalid bit depth for RGB colorspace. Got: ${F}`);ie=3}else if(N===3)W=1,ie=3;else if(N===6){if(F!==8&&F!==16)throw new Error(`png: invalid bit depth for RGBA colorspace. Got: ${F}`);ie=4}else if(N===4){if(F!==8&&F!==16)throw new Error(`png: invalid bit depth for grayscale + alpha channel colorspace. Got: ${F}`);ie=4}else throw new Error(`png: Invalid color space: ${N}`);return{sx:w,sy:p,dataWidth:W,numChannels:ie}}async function Er(a,u,h,o,C,I){const x=await Mr();let{sx:w,sy:p,dataWidth:F,numChannels:N}=Lr(a);if(I&&(F=1,N=1),u!==void 0&&w!==u||h!==void 0&&p!==h||o!==void 0&&o!==N||C!==F)throw new Error(`png: Image decode parameters did not match expected chunk parameters.
         Expected: width: ${u} height: ${h} channels: ${o} bytes per pixel: ${C} 
         Decoded:  width: ${w} height: ${p} channels: ${N} bytes per pixel: ${F}
         Convert to Grayscale? ${I}
        `);const te=w*p*F*N;if(te<0)throw new Error(`png: Failed to decode png image size. image size: ${te}`);const xe=x.exports.malloc(a.byteLength),ge=x.exports.malloc(te);new Uint8Array(x.exports.memory.buffer).set(a,xe);const W=x.exports.png_decompress(xe,a.byteLength,ge,te,I);try{if(W!==0)throw new Error(`png: Failed to decode png image. decoder code: ${W}`);const ie=new Uint8Array(x.exports.memory.buffer,ge,te);return{width:w,height:p,numComponents:N,uint8Array:ie.slice(0)}}finally{x.exports.free(xe),x.exports.free(ge)}}/**
 * @license
 * Copyright 2022 William Silversmith
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */Se(Tr,async(a,u,h,o,C,I)=>{const x=await Er(a,u,h,o,C,I);return{value:x,transfer:[x.uint8Array.buffer]}});/**
 * @license
 * Copyright 2020 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Sr=Ee("decodeBlosc");/**
 * @license
 * Copyright 2020 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */Se(Sr,async a=>{const{default:u}=await ye.e(121).then(ye.bind(ye,5121)),o=await u.fromConfig({id:"blosc"}).decode(a);return{value:o,transfer:[o.buffer]}});/**
 * @license
 * Copyright 2023 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Or=Ee("decodeZstd");/**
 * @license
 * Copyright 2023 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */Se(Or,async a=>{const{default:u}=await ye.e(505).then(ye.bind(ye,7505)),o=await u.fromConfig({id:"blosc"}).decode(a);return{value:o,transfer:[o.buffer]}});/**
 * @license
 * Copyright 2020 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ur=Ee("parseOBJFromArrayBuffer");/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class Dr{constructor(u=16){this.length=0,this.data=new Float32Array(u)}resize(u){const{data:h}=this;if(u>h.length){const o=new Float32Array(Math.max(u,h.length*2));o.set(h.subarray(0,this.length)),this.data=o}this.length=u}get view(){const{data:u}=this;return new Float32Array(u.buffer,u.byteOffset,this.length)}shrinkToFit(){this.data=new Float32Array(this.view)}clear(){this.length=0}appendArray(u){const{length:h}=this;this.resize(h+u.length),this.data.set(u,h)}eraseRange(u,h){this.data.copyWithin(u,h,this.length),this.length-=h-u}}/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function Jr(a){const u=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);return u.length>2&&u[0]===31&&u[1]===139}async function or(a){let u;return a instanceof ArrayBuffer?u=new Uint8Array(a):u=new Uint8Array(a.buffer,a.byteOffset,a.byteLength),Jr(u)?(await ye.e(75).then(ye.bind(ye,3075))).inflate(u):u}/**
 * @license
 * Copyright 2020 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */Se(Ur,async a=>{a=await or(a);let u=new TextDecoder().decode(a);u=u.replace(/#.*/g,"");const h=new Dr,o=new ir;for(const x of u.matchAll(/^v\s+([-0-9.eE]+)\s+([-0-9.eE]+)\s+([-0-9.eE]+)\s*$/gm))h.appendArray([parseFloat(x[1]),parseFloat(x[2]),parseFloat(x[3])]);for(const x of u.matchAll(/^f\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s*$/gm))o.appendArray([parseInt(x[1],10)-1,parseInt(x[2],10)-1,parseInt(x[3],10)-1]);h.shrinkToFit(),o.shrinkToFit();const C={info:{numVertices:h.length/3,numTriangles:o.length/3,vertexAttributes:[]},vertexPositions:h.view,indices:o.view,vertexAttributes:[]},I=C.vertexPositions.byteLength+C.indices.byteLength;return console.log(C),{value:{data:C,size:I},transfer:[C.indices.buffer,C.vertexPositions.buffer]}});/**
 * @license
 * Copyright 2021 William Silversmith
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Fr=Ee("decodeCompresso");/**
 * @license
 * Copyright 2021 William Silvermsith
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const lr={emscripten_notify_memory_growth:()=>{},proc_exit:a=>{throw`proc exit: ${a}`}};let $e;function zr(){return $e===void 0&&($e=(async()=>{const a=(await WebAssembly.instantiateStreaming(fetch(new URL(ye(3941),ye.b)),{env:lr,wasi_snapshot_preview1:lr})).instance;return a.exports._initialize(),a})()),$e}function Hr(a){if(!(a[0]===99&&a[1]===112&&a[2]===115&&a[3]===111))throw new Error("compresso: didn't match magic numbers");if(a[4]>1)throw new Error("compresso: didn't match format version");const o=new DataView(a.buffer,0),C=a[5],I=o.getUint16(6,!0),x=o.getUint16(8,!0),w=o.getUint16(10,!0);return{sx:I,sy:x,sz:w,dataWidth:C}}async function Xr(a){const u=await zr(),{sx:h,sy:o,sz:C,dataWidth:I}=Hr(a),x=h*o*C,w=x*I;if(w<0)throw new Error(`Failed to decode compresso image. image size: ${w}`);const p=u.exports.malloc(w),F=u.exports.malloc(a.byteLength);new Uint8Array(u.exports.memory.buffer).set(a,F);const te=u.exports.compresso_decompress(F,a.byteLength,p);try{if(te!==0)throw new Error(`Failed to decode compresso image. decoder code: ${te}`);return new Uint8Array(u.exports.memory.buffer,p,x*I).slice(0)}finally{u.exports.free(F),u.exports.free(p)}}/**
 * @license
 * Copyright 2021 William Silversmith
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */Se(Fr,async a=>{const u=await Xr(a);return{value:u,transfer:[u.buffer]}});/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Gr=Ee("parseVTKFromArrayBuffer");/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const $r=1e3,Yr=/^[ \t]*#[ \t]+vtk[ \t]+DataFile[ \t]+Version[ \t]+([^\s]+)[ \t]*\n(.*)\n[ \t]*(ASCII|BINARY)[ \t]*\n[ \t]*DATASET[ \t]+([^ ]+)[ \t]*\n/,Vr=/^[ \t]*POINT_DATA[ \t]+([0-9]+)[ \t]*$/,Rr=/^[ \t]*POINTS[ \t]+([0-9]+)[ \t]+([^\s]+)[ \t]*$/,Nr=/^[ \t]*SCALARS[ \t]+([^\s]+)[ \t]+([^\s]+)(?:[ \t]+([0-9]+))?[ \t]*$/,Zr=/^[ \t]*LOOKUP_TABLE[ \t]+([^\s]+)[ \t]*$/,Qr=/^[ \t]*POLYGONS[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]*$/,qr=/^[ \t]*3[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]*$/,cr=/^[ \t]*$/;class Wr{constructor(u,h,o,C,I,x){this.header=u,this.numVertices=h,this.vertexPositions=o,this.numTriangles=C,this.indices=I,this.vertexAttributes=x}}function Kr(a){let u=a.vertexPositions.byteLength+a.indices.byteLength;for(const h of a.vertexAttributes)u+=h.data.byteLength;return u}function Br(a,u){const C=new TextDecoder().decode(u).split(`
`),I=C.length;let x=0,w=-1,p,F=-1,N;const te=new Array;function xe(X,G,Z,ue){const le=RegExp("^[ 	]*"+"([^s]+)[ 	]+".repeat(Z-1)+"([^s]+)[ 	]*$");if(I-x<G)throw new Error(`VTK data ended unexpectedly while parsing ${X}.`);const Pe=new Float32Array(G*Z);let ce=0;for(let be=0;be<G;++be){const pe=C[x++],de=pe.match(le);if(de===null)throw new Error(`Failed to parse ${X} line ${be}: ${JSON.stringify(pe)}.`);for(let we=0;we<Z;++we)Pe[ce++]=parseFloat(de[we+1])}return Pe}function ge(X,G){if(N!==void 0)throw new Error("POINTS specified more than once.");w=X,p=xe("POINTS",X,3,G)}function fe(X,G){if(N!==void 0)throw new Error("VERTICES specified more than once.");if(I-x<X)throw new Error("VTK data ended unexpectedly");if(G!==X*4)throw new Error("Only triangular faces are supported.");F=X,N=new Uint32Array(X*3);let Z=0;for(let ue=0;ue<X;++ue){const le=C[x++].match(qr);if(le===null)throw new Error(`Failed to parse indices for face ${ue}`);N[Z++]=parseInt(le[1],10),N[Z++]=parseInt(le[2],10),N[Z++]=parseInt(le[3],10)}}function W(X,G,Z){if(x===I)throw new Error("Expected LOOKUP_TABLE directive.");const ue=C[x++],le=ue.match(Zr);if(le===null)throw new Error(`Expected LOOKUP_TABLE directive in ${JSON.stringify(ue)}.`);const Pe=le[1],ce=xe(`SCALARS(${X})`,w,Z,G);te.push({name:X,data:ce,numComponents:Z,dataType:G,tableName:Pe})}function ie(X){if(w!==X)throw new Error(`Number of vertices specified in POINT_DATA section (${X}) must match number of points (${w}).`);for(;x<I;){const G=C[x];if(G.match(cr)){++x;continue}const Z=G.match(Nr);if(Z!==null){let ue;Z[3]===void 0?ue=1:ue=parseInt(Z[3],10),++x,W(Z[1],Z[2],ue)}}}for(;x<I;){const X=C[x];if(X.match(cr)){++x;continue}let G;if(G=X.match(Rr),G!==null){++x,ge(parseInt(G[1],10),G[2]);continue}if(G=X.match(Qr),G!==null){++x,fe(parseInt(G[1],10),parseInt(G[2],10));continue}if(G=X.match(Vr),G!==null){++x,ie(parseInt(G[1],10));break}throw new Error(`Failed to parse VTK line ${JSON.stringify(X)}.`)}if(p===void 0)throw new Error("Vertex positions not specified.");if(N===void 0)throw new Error("Indices not specified.");return new Wr(a,w,p,F,N,te)}const jr=new Map([["POLYDATA",Br]]);function et(a){const o=new TextDecoder().decode(new Uint8Array(a.buffer,a.byteOffset,Math.min(a.byteLength,$r))).match(Yr);if(o===null)throw new Error("Failed to parse VTK file header.");const C=o[0].length,I=o[4],x=o[3],w={version:o[1],comment:o[2],datasetType:I,dataFormat:x},p=new Uint8Array(a.buffer,a.byteOffset+C,a.byteLength-C);if(x==="ASCII"){const F=jr.get(I);if(F===void 0)throw new Error(`VTK dataset type ${JSON.stringify(I)} is not supported.`);return F(w,p)}throw new Error(`VTK data format ${JSON.stringify(x)} is not supported.`)}/**
 * @license
 * Copyright 2019 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */Se(Gr,async a=>{const u=et(await or(a));return{value:{data:u,size:Kr(u)},transfer:[u.indices.buffer,u.vertexPositions.buffer,...Array.from(u.vertexAttributes.values()).map(h=>h.data.buffer)]}});

//# sourceMappingURL=neuroglancer_async_computation.0e1ff0b6cf9b1e029679.js.map