@gisatcz/deckgl-geolib 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types/classes/geoImage/GeoImage.d.ts +38 -0
- package/dist/cjs/types/classes/geoImage/index.d.ts +1 -0
- package/dist/cjs/types/classes/geoImage/interface.d.ts +32 -0
- package/dist/cjs/types/classes/index.d.ts +1 -0
- package/dist/cjs/types/hooks/index.d.ts +1 -0
- package/dist/cjs/types/hooks/useGeoData/index.d.ts +1 -0
- package/dist/cjs/types/hooks/useGeoData/useGeoData.d.ts +9 -0
- package/dist/cjs/types/index.d.ts +2 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/classes/geoImage/GeoImage.d.ts +38 -0
- package/dist/esm/types/classes/geoImage/index.d.ts +1 -0
- package/dist/esm/types/classes/geoImage/interface.d.ts +32 -0
- package/dist/esm/types/classes/index.d.ts +1 -0
- package/dist/esm/types/hooks/index.d.ts +1 -0
- package/dist/esm/types/hooks/useGeoData/index.d.ts +1 -0
- package/dist/esm/types/hooks/useGeoData/useGeoData.d.ts +9 -0
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/index.d.ts +80 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# geoimage
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");
|
|
2
|
+
/*! *****************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */function t(e,t,i,r){return new(i||(i=Promise))((function(n,a){function s(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,o)}l((r=r.apply(e,t||[])).next())}))}function i(e,t){var i,r,n,a,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{i=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}function r(e){return(t,...i)=>a(e,t,i)}function n(e,t){return r(h(e,t).get)}const{apply:a,construct:s,defineProperty:o,get:l,getOwnPropertyDescriptor:h,getPrototypeOf:f,has:c,ownKeys:d,set:u,setPrototypeOf:g}=Reflect,{iterator:p,species:m,toStringTag:w,for:_}=Symbol,b=Object,{create:y,defineProperty:k,freeze:x,is:v}=b,A=Array.prototype[p],D=r(A),U=ArrayBuffer;n(U.prototype,"byteLength");const I="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:null;I&&n(I.prototype,"byteLength");const S=f(Uint8Array);S.from;const T=S.prototype;T[p],r(T.keys),r(T.values),r(T.entries),r(T.set),r(T.reverse),r(T.fill),r(T.copyWithin),r(T.sort),r(T.slice),r(T.subarray),n(T,"buffer"),n(T,"byteOffset"),n(T,"length"),n(T,w);const M=Uint32Array,E=Float32Array,P=f([][p]()),B=r(P.next),O=r(function*(){}().next),z=f(P),C=r(DataView.prototype.getUint16),R=WeakMap,L=R.prototype,V=r(L.get),F=r(L.set),G=new R,N=y(null,{next:{value:function(){const e=V(G,this);return B(e)}},[p]:{value:function(){return this}}});const Z=new R,H=y(z,{next:{value:function(){const e=V(Z,this);return O(e)},writable:!0,configurable:!0}});for(const e of d(P))"next"!==e&&k(H,e,h(P,e));const K=new U(4),j=new E(K),W=new M(K),Y=new M(512),X=new M(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(Y[e]=0,Y[256|e]=32768,X[e]=24,X[256|e]=24):t<-14?(Y[e]=1024>>-t-14,Y[256|e]=1024>>-t-14|32768,X[e]=-t-1,X[256|e]=-t-1):t<=15?(Y[e]=t+15<<10,Y[256|e]=t+15<<10|32768,X[e]=13,X[256|e]=13):t<128?(Y[e]=31744,Y[256|e]=64512,X[e]=24,X[256|e]=24):(Y[e]=31744,Y[256|e]=64512,X[e]=13,X[256|e]=13)}const q=new M(2048),$=new M(64),J=new M(64);for(let e=1;e<1024;++e){let t=e<<13,i=0;for(;0==(8388608&t);)t<<=1,i-=8388608;t&=-8388609,i+=947912704,q[e]=t|i}for(let e=1024;e<2048;++e)q[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)$[e]=e<<23;$[31]=1199570944,$[32]=2147483648;for(let e=33;e<63;++e)$[e]=2147483648+(e-32<<23);$[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(J[e]=1024);function Q(e,t,...i){return function(e){const t=e>>10;return W[0]=q[J[t]+(1023&e)]+$[t],j[0]}(C(e,t,...function(e){if(e[p]===A)return e;const t=y(N);return F(G,t,D(e)),t}(i)))}var ee=function(e,t,i){const r=i&&i.debug||!1;r&&console.log("getting "+t+" in "+e);const n="object"==typeof e?e.outer:e,a=`${t}\\="([^"]*)"`;r&&console.log("pattern:",a);const s=new RegExp(a).exec(n);if(r&&console.log("match:",s),s)return s[1]};const te=function(e,t,i){const r=new RegExp(t).exec(e.slice(i));return r?i+r.index:-1};const ie=function(e,t,i){const r=i&&i.debug||!1,n=i&&i.startIndex||0;r&&console.log("starting findTagByName with",t," and ",i);const a=te(e,`<${t}[ >]`,n);if(r&&console.log("start:",a),-1===a)return;const s=e.slice(a+t.length);let o=te(s,"[ /]"+t+">",0);const l=-1===o;l&&(o=te(s,"[ /]>",0));const h=a+t.length+o+1+(l?0:t.length)+1;if(r&&console.log("end:",h),-1===h)return;const f=e.slice(a,h);let c;return c=l?null:f.slice(f.indexOf(">")+1,f.lastIndexOf("<")),{inner:c,outer:f,start:a,end:h}};var re=function(e,t,i){const r=[],n=i&&i.debug||!1;let a,s=i&&i.startIndex||0;for(;a=ie(e,t,{debug:n,startIndex:s});)s=a.end,r.push(a);return n&&console.log("findTagsByName found",r.length,"tags"),r};const ne={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},ae={};for(const e in ne)ne.hasOwnProperty(e)&&(ae[ne[e]]=parseInt(e,10));const se=[ae.BitsPerSample,ae.ExtraSamples,ae.SampleFormat,ae.StripByteCounts,ae.StripOffsets,ae.StripRowCounts,ae.TileByteCounts,ae.TileOffsets,ae.SubIFDs],oe={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},le={};for(const e in oe)oe.hasOwnProperty(e)&&(le[oe[e]]=parseInt(e,10));const he=0,fe=1,ce=2,de=3,ue=5,ge=6,pe=8,me=0,we=1,_e=0,be=1,ye={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"};const ke=new Map;function xe(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>ke.set(e,t)))}function ve(e,t,i,r=1){return new(Object.getPrototypeOf(e).constructor)(t*i*r)}function Ae(e,t,i){return(1-i)*e+i*t}function De(e,t,i,r,n,a="nearest"){switch(a.toLowerCase()){case"nearest":return function(e,t,i,r,n){const a=t/r,s=i/n;return e.map((e=>{const o=ve(e,r,n);for(let l=0;l<n;++l){const n=Math.min(Math.round(s*l),i-1);for(let i=0;i<r;++i){const s=Math.min(Math.round(a*i),t-1),h=e[n*t+s];o[l*r+i]=h}}return o}))}(e,t,i,r,n);case"bilinear":case"linear":return function(e,t,i,r,n){const a=t/r,s=i/n;return e.map((e=>{const o=ve(e,r,n);for(let l=0;l<n;++l){const n=s*l,h=Math.floor(n),f=Math.min(Math.ceil(n),i-1);for(let i=0;i<r;++i){const s=a*i,c=s%1,d=Math.floor(s),u=Math.min(Math.ceil(s),t-1),g=e[h*t+d],p=e[h*t+u],m=e[f*t+d],w=e[f*t+u],_=Ae(Ae(g,p,c),Ae(m,w,c),n%1);o[l*r+i]=_}}return o}))}(e,t,i,r,n);default:throw new Error(`Unsupported resampling method: '${a}'`)}}function Ue(e,t,i,r,n,a,s="nearest"){switch(s.toLowerCase()){case"nearest":return function(e,t,i,r,n,a){const s=t/r,o=i/n,l=ve(e,r,n,a);for(let h=0;h<n;++h){const n=Math.min(Math.round(o*h),i-1);for(let i=0;i<r;++i){const o=Math.min(Math.round(s*i),t-1);for(let s=0;s<a;++s){const f=e[n*t*a+o*a+s];l[h*r*a+i*a+s]=f}}}return l}(e,t,i,r,n,a);case"bilinear":case"linear":return function(e,t,i,r,n,a){const s=t/r,o=i/n,l=ve(e,r,n,a);for(let h=0;h<n;++h){const n=o*h,f=Math.floor(n),c=Math.min(Math.ceil(n),i-1);for(let i=0;i<r;++i){const o=s*i,d=o%1,u=Math.floor(o),g=Math.min(Math.ceil(o),t-1);for(let s=0;s<a;++s){const o=e[f*t*a+u*a+s],p=e[f*t*a+g*a+s],m=e[c*t*a+u*a+s],w=e[c*t*a+g*a+s],_=Ae(Ae(o,p,d),Ae(m,w,d),n%1);l[h*r*a+i*a+s]=_}}}return l}(e,t,i,r,n,a);default:throw new Error(`Unsupported resampling method: '${s}'`)}}function Ie(e,t,i){let r=0;for(let n=t;n<i;++n)r+=e[n];return r}function Se(e,t,i){switch(e){case 1:if(t<=8)return new Uint8Array(i);if(t<=16)return new Uint16Array(i);if(t<=32)return new Uint32Array(i);break;case 2:if(8===t)return new Int8Array(i);if(16===t)return new Int16Array(i);if(32===t)return new Int32Array(i);break;case 3:switch(t){case 16:case 32:return new Float32Array(i);case 64:return new Float64Array(i)}}throw Error("Unsupported data format/bitsPerSample")}xe([void 0,1],(()=>Promise.resolve().then((function(){return Ke})).then((e=>e.default)))),xe(5,(()=>Promise.resolve().then((function(){return Ye})).then((e=>e.default)))),xe(6,(()=>{throw new Error("old style JPEG compression is not supported.")})),xe(7,(()=>Promise.resolve().then((function(){return et})).then((e=>e.default)))),xe([8,32946],(()=>Promise.resolve().then((function(){return Nr})).then((e=>e.default)))),xe(32773,(()=>Promise.resolve().then((function(){return Hr})).then((e=>e.default)))),xe(34887,(()=>Promise.resolve().then((function(){return Wr})).then((e=>e.default)))),xe(50001,(()=>Promise.resolve().then((function(){return Yr})).then((e=>e.default))));var Te=class{constructor(e,t,i,r,n,a){this.fileDirectory=e,this.geoKeys=t,this.dataView=i,this.littleEndian=r,this.tiles=n?{}:null,this.isTiled=!e.StripOffsets;const s=e.PlanarConfiguration;if(this.planarConfiguration=void 0===s?1:s,1!==this.planarConfiguration&&2!==this.planarConfiguration)throw new Error("Invalid planar configuration.");this.source=a}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.geoKeys}getWidth(){return this.fileDirectory.ImageWidth}getHeight(){return this.fileDirectory.ImageLength}getSamplesPerPixel(){return void 0!==this.fileDirectory.SamplesPerPixel?this.fileDirectory.SamplesPerPixel:1}getTileWidth(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}getTileHeight(){return this.isTiled?this.fileDirectory.TileLength:void 0!==this.fileDirectory.RowsPerStrip?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;for(let t=0;t<this.fileDirectory.BitsPerSample.length;++t)e+=this.getSampleByteSize(t);return e}getSampleByteSize(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}getReaderForSample(e){const t=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,i=this.fileDirectory.BitsPerSample[e];switch(t){case 1:if(i<=8)return DataView.prototype.getUint8;if(i<=16)return DataView.prototype.getUint16;if(i<=32)return DataView.prototype.getUint32;break;case 2:if(i<=8)return DataView.prototype.getInt8;if(i<=16)return DataView.prototype.getInt16;if(i<=32)return DataView.prototype.getInt32;break;case 3:switch(i){case 16:return function(e,t){return Q(this,e,t)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}getBitsPerSample(e=0){return this.fileDirectory.BitsPerSample[e]}getArrayForSample(e,t){return Se(this.getSampleFormat(e),this.getBitsPerSample(e),t)}async getTileOrStrip(e,t,i,r,n){const a=Math.ceil(this.getWidth()/this.getTileWidth()),s=Math.ceil(this.getHeight()/this.getTileHeight());let o;const{tiles:l}=this;let h,f;1===this.planarConfiguration?o=t*a+e:2===this.planarConfiguration&&(o=i*a*s+t*a+e),this.isTiled?(h=this.fileDirectory.TileOffsets[o],f=this.fileDirectory.TileByteCounts[o]):(h=this.fileDirectory.StripOffsets[o],f=this.fileDirectory.StripByteCounts[o]);const c=(await this.source.fetch([{offset:h,length:f}],n))[0];let d;return null!==l&&l[o]?d=l[o]:(d=(async()=>{let e=await r.decode(this.fileDirectory,c);const i=this.getSampleFormat(),n=this.getBitsPerSample();return function(e,t){return(1!==e&&2!==e||!(t<=32)||t%8!=0)&&(3!==e||16!==t&&32!==t&&64!==t)}(i,n)&&(e=function(e,t,i,r,n,a,s){const o=new DataView(e),l=2===i?1:r,h=Se(t,n,2===i?s*a:s*a*r),f=parseInt("1".repeat(n),2);if(1===t){let e;e=1===i?r*n:n;let t=a*e;0!=(7&t)&&(t=t+7&-8);for(let e=0;e<s;++e){const i=e*t;for(let t=0;t<a;++t){const r=i+t*l*n;for(let i=0;i<l;++i){const s=r+i*n,c=(e*a+t)*l+i,d=Math.floor(s/8),u=s%8;if(u+n<=8)h[c]=o.getUint8(d)>>8-n-u&f;else if(u+n<=16)h[c]=o.getUint16(d)>>16-n-u&f;else if(u+n<=24){const e=o.getUint16(d)<<8|o.getUint8(d+2);h[c]=e>>24-n-u&f}else h[c]=o.getUint32(d)>>32-n-u&f}}}}return h.buffer}(e,i,this.planarConfiguration,this.getSamplesPerPixel(),n,this.getTileWidth(),this.getBlockHeight(t))),e})(),null!==l&&(l[o]=d)),{x:e,y:t,sample:i,data:await d}}async _readRaster(e,t,i,r,n,a,s,o,l){const h=this.getTileWidth(),f=this.getTileHeight(),c=this.getWidth(),d=this.getHeight(),u=Math.max(Math.floor(e[0]/h),0),g=Math.min(Math.ceil(e[2]/h),Math.ceil(c/h)),p=Math.max(Math.floor(e[1]/f),0),m=Math.min(Math.ceil(e[3]/f),Math.ceil(d/f)),w=e[2]-e[0];let _=this.getBytesPerPixel();const b=[],y=[];for(let e=0;e<t.length;++e)1===this.planarConfiguration?b.push(Ie(this.fileDirectory.BitsPerSample,0,t[e])/8):b.push(0),y.push(this.getReaderForSample(t[e]));const k=[],{littleEndian:x}=this;for(let a=p;a<m;++a)for(let s=u;s<g;++s)for(let o=0;o<t.length;++o){const u=o,g=t[o];2===this.planarConfiguration&&(_=this.getSampleByteSize(o));const p=this.getTileOrStrip(s,a,g,n,l);k.push(p),p.then((n=>{const a=n.data,s=new DataView(a),o=this.getBlockHeight(n.y),l=n.y*f,g=n.x*h,p=l+o,m=(n.x+1)*h,k=y[u],v=Math.min(o,o-(p-e[3]),d-l),A=Math.min(h,h-(m-e[2]),c-g);for(let n=Math.max(0,e[1]-l);n<v;++n)for(let a=Math.max(0,e[0]-g);a<A;++a){const o=(n*h+a)*_,f=k.call(s,o+b[u],x);let c;r?(c=(n+l-e[1])*w*t.length+(a+g-e[0])*t.length+u,i[c]=f):(c=(n+l-e[1])*w+a+g-e[0],i[u][c]=f)}}))}if(await Promise.all(k),a&&e[2]-e[0]!==a||s&&e[3]-e[1]!==s){let n;return n=r?Ue(i,e[2]-e[0],e[3]-e[1],a,s,t.length,o):De(i,e[2]-e[0],e[3]-e[1],a,s,o),n.width=a,n.height=s,n}return i.width=a||e[2]-e[0],i.height=s||e[3]-e[1],i}async readRasters({window:e,samples:t=[],interleave:i,pool:r=null,width:n,height:a,resampleMethod:s,fillValue:o,signal:l}={}){const h=e||[0,0,this.getWidth(),this.getHeight()];if(h[0]>h[2]||h[1]>h[3])throw new Error("Invalid subsets");const f=(h[2]-h[0])*(h[3]-h[1]),c=this.getSamplesPerPixel();if(t&&t.length){for(let e=0;e<t.length;++e)if(t[e]>=c)return Promise.reject(new RangeError(`Invalid sample index '${t[e]}'.`))}else for(let e=0;e<c;++e)t.push(e);let d;if(i){d=Se(this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,Math.max.apply(null,this.fileDirectory.BitsPerSample),f*t.length),o&&d.fill(o)}else{d=[];for(let e=0;e<t.length;++e){const i=this.getArrayForSample(t[e],f);Array.isArray(o)&&e<o.length?i.fill(o[e]):o&&!Array.isArray(o)&&i.fill(o),d.push(i)}}const u=r||await async function(e){const t=ke.get(e.Compression);if(!t)throw new Error(`Unknown compression method identifier: ${e.Compression}`);return new(await t())(e)}(this.fileDirectory);return await this._readRaster(h,t,d,i,u,n,a,s,l)}async readRGB({window:e,interleave:t=!0,pool:i=null,width:r,height:n,resampleMethod:a,enableAlpha:s=!1,signal:o}={}){const l=e||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const h=this.fileDirectory.PhotometricInterpretation;if(h===ce){let l=[0,1,2];if(this.fileDirectory.ExtraSamples!==me&&s){l=[];for(let e=0;e<this.fileDirectory.BitsPerSample.length;e+=1)l.push(e)}return this.readRasters({window:e,interleave:t,samples:l,pool:i,width:r,height:n,resampleMethod:a,signal:o})}let f;switch(h){case he:case fe:case de:f=[0];break;case ue:f=[0,1,2,3];break;case ge:case pe:f=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const c={window:l,interleave:!0,samples:f,pool:i,width:r,height:n,resampleMethod:a,signal:o},{fileDirectory:d}=this,u=await this.readRasters(c),g=2**this.fileDirectory.BitsPerSample[0];let p;switch(h){case he:p=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3);let a;for(let i=0,r=0;i<e.length;++i,r+=3)a=256-e[i]/t*256,n[r]=a,n[r+1]=a,n[r+2]=a;return n}(u,g);break;case fe:p=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3);let a;for(let i=0,r=0;i<e.length;++i,r+=3)a=e[i]/t*256,n[r]=a,n[r+1]=a,n[r+2]=a;return n}(u,g);break;case de:p=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3),a=t.length/3,s=t.length/3*2;for(let i=0,r=0;i<e.length;++i,r+=3){const o=e[i];n[r]=t[o]/65536*256,n[r+1]=t[o+a]/65536*256,n[r+2]=t[o+s]/65536*256}return n}(u,d.ColorMap);break;case ue:p=function(e){const{width:t,height:i}=e,r=new Uint8Array(t*i*3);for(let t=0,i=0;t<e.length;t+=4,i+=3){const n=e[t],a=e[t+1],s=e[t+2],o=e[t+3];r[i]=(255-n)/256*255*((255-o)/256),r[i+1]=(255-a)/256*255*((255-o)/256),r[i+2]=(255-s)/256*255*((255-o)/256)}return r}(u);break;case ge:p=function(e){const{width:t,height:i}=e,r=new Uint8ClampedArray(t*i*3);for(let t=0,i=0;t<e.length;t+=3,i+=3){const n=e[t],a=e[t+1],s=e[t+2];r[i]=n+1.402*(s-128),r[i+1]=n-.34414*(a-128)-.71414*(s-128),r[i+2]=n+1.772*(a-128)}return r}(u);break;case pe:p=function(e){const{width:t,height:i}=e,r=new Uint8Array(t*i*3);for(let t=0,i=0;t<e.length;t+=3,i+=3){let n,a,s,o=(e[t+0]+16)/116,l=(e[t+1]<<24>>24)/500+o,h=o-(e[t+2]<<24>>24)/200;l=.95047*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),o=1*(o*o*o>.008856?o*o*o:(o-16/116)/7.787),h=1.08883*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),n=3.2406*l+-1.5372*o+-.4986*h,a=-.9689*l+1.8758*o+.0415*h,s=.0557*l+-.204*o+1.057*h,n=n>.0031308?1.055*n**(1/2.4)-.055:12.92*n,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,r[i]=255*Math.max(0,Math.min(1,n)),r[i+1]=255*Math.max(0,Math.min(1,a)),r[i+2]=255*Math.max(0,Math.min(1,s))}return r}(u);break;default:throw new Error("Unsupported photometric interpretation.")}if(!t){const e=new Uint8Array(p.length/3),t=new Uint8Array(p.length/3),i=new Uint8Array(p.length/3);for(let r=0,n=0;r<p.length;r+=3,++n)e[n]=p[r],t[n]=p[r+1],i[n]=p[r+2];p=[e,t,i]}return p.width=u.width,p.height=u.height,p}getTiePoints(){if(!this.fileDirectory.ModelTiepoint)return[];const e=[];for(let t=0;t<this.fileDirectory.ModelTiepoint.length;t+=6)e.push({i:this.fileDirectory.ModelTiepoint[t],j:this.fileDirectory.ModelTiepoint[t+1],k:this.fileDirectory.ModelTiepoint[t+2],x:this.fileDirectory.ModelTiepoint[t+3],y:this.fileDirectory.ModelTiepoint[t+4],z:this.fileDirectory.ModelTiepoint[t+5]});return e}getGDALMetadata(e=null){const t={};if(!this.fileDirectory.GDAL_METADATA)return null;const i=this.fileDirectory.GDAL_METADATA;let r=re(i,"Item");r=null===e?r.filter((e=>void 0===ee(e,"sample"))):r.filter((t=>Number(ee(t,"sample"))===e));for(let e=0;e<r.length;++e){const i=r[e];t[ee(i,"name")]=i.inner}return t}getGDALNoData(){if(!this.fileDirectory.GDAL_NODATA)return null;const e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}getOrigin(){const e=this.fileDirectory.ModelTiepoint,t=this.fileDirectory.ModelTransformation;if(e&&6===e.length)return[e[3],e[4],e[5]];if(t)return[t[3],t[7],t[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const t=this.fileDirectory.ModelPixelScale,i=this.fileDirectory.ModelTransformation;if(t)return[t[0],-t[1],t[2]];if(i)return[i[0],i[5],i[10]];if(e){const[t,i,r]=e.getResolution();return[t*e.getWidth()/this.getWidth(),i*e.getHeight()/this.getHeight(),r*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return 1===this.geoKeys.GTRasterTypeGeoKey}getBoundingBox(){const e=this.getOrigin(),t=this.getResolution(),i=e[0],r=e[1],n=i+t[0]*this.getWidth(),a=r+t[1]*this.getHeight();return[Math.min(i,n),Math.min(r,a),Math.max(i,n),Math.max(r,a)]}};class Me{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,t){const i=this.getUint32(e,t),r=this.getUint32(e+4,t);let n;if(t){if(n=i+2**32*r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}if(n=2**32*i+r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}getInt64(e,t){let i=0;const r=(128&this._dataView.getUint8(e+(t?7:0)))>0;let n=!0;for(let a=0;a<8;a++){let s=this._dataView.getUint8(e+(t?a:7-a));r&&(n?0!==s&&(s=255&~(s-1),n=!1):s=255&~s),i+=s*256**a}return r&&(i=-i),i}getUint8(e,t){return this._dataView.getUint8(e,t)}getInt8(e,t){return this._dataView.getInt8(e,t)}getUint16(e,t){return this._dataView.getUint16(e,t)}getInt16(e,t){return this._dataView.getInt16(e,t)}getUint32(e,t){return this._dataView.getUint32(e,t)}getInt32(e,t){return this._dataView.getInt32(e,t)}getFloat16(e,t){return Q(this._dataView,e,t)}getFloat32(e,t){return this._dataView.getFloat32(e,t)}getFloat64(e,t){return this._dataView.getFloat64(e,t)}}class Ee{constructor(e,t,i,r){this._dataView=new DataView(e),this._sliceOffset=t,this._littleEndian=i,this._bigTiff=r}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const t=this.readUint32(e),i=this.readUint32(e+4);let r;if(this._littleEndian){if(r=t+2**32*i,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}if(r=2**32*t+i,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}readInt64(e){let t=0;const i=(128&this._dataView.getUint8(e+(this._littleEndian?7:0)))>0;let r=!0;for(let n=0;n<8;n++){let a=this._dataView.getUint8(e+(this._littleEndian?n:7-n));i&&(r?0!==a&&(a=255&~(a-1),r=!1):a=255&~a),t+=a*256**n}return i&&(t=-t),t}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}class Pe extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,Pe),this.name="AbortError"}}class Be extends class{async fetch(e,t){return Promise.all(e.map((e=>this.fetchSlice(e,t))))}async fetchSlice(e){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}}{constructor(e){super(),this.arrayBuffer=e}fetchSlice(e,t){if(t&&t.aborted)throw new Pe("Request aborted");return this.arrayBuffer.slice(e.offset,e.offset+e.length)}}function Oe(e){switch(e){case le.BYTE:case le.ASCII:case le.SBYTE:case le.UNDEFINED:return 1;case le.SHORT:case le.SSHORT:return 2;case le.LONG:case le.SLONG:case le.FLOAT:case le.IFD:return 4;case le.RATIONAL:case le.SRATIONAL:case le.DOUBLE:case le.LONG8:case le.SLONG8:case le.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${e}`)}}function ze(e,t,i,r){let n=null,a=null;const s=Oe(t);switch(t){case le.BYTE:case le.ASCII:case le.UNDEFINED:n=new Uint8Array(i),a=e.readUint8;break;case le.SBYTE:n=new Int8Array(i),a=e.readInt8;break;case le.SHORT:n=new Uint16Array(i),a=e.readUint16;break;case le.SSHORT:n=new Int16Array(i),a=e.readInt16;break;case le.LONG:case le.IFD:n=new Uint32Array(i),a=e.readUint32;break;case le.SLONG:n=new Int32Array(i),a=e.readInt32;break;case le.LONG8:case le.IFD8:n=new Array(i),a=e.readUint64;break;case le.SLONG8:n=new Array(i),a=e.readInt64;break;case le.RATIONAL:n=new Uint32Array(2*i),a=e.readUint32;break;case le.SRATIONAL:n=new Int32Array(2*i),a=e.readInt32;break;case le.FLOAT:n=new Float32Array(i),a=e.readFloat32;break;case le.DOUBLE:n=new Float64Array(i),a=e.readFloat64;break;default:throw new RangeError(`Invalid field type: ${t}`)}if(t!==le.RATIONAL&&t!==le.SRATIONAL)for(let t=0;t<i;++t)n[t]=a.call(e,r+t*s);else for(let t=0;t<i;t+=2)n[t]=a.call(e,r+t*s),n[t+1]=a.call(e,r+(t*s+4));return t===le.ASCII?new TextDecoder("utf-8").decode(n):n}class Ce{constructor(e,t,i){this.fileDirectory=e,this.geoKeyDirectory=t,this.nextIFDByteOffset=i}}class Re extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}}class Le extends class{async readRasters(e={}){const{window:t,width:i,height:r}=e;let{resX:n,resY:a,bbox:s}=e;const o=await this.getImage();let l=o;const h=await this.getImageCount(),f=o.getBoundingBox();if(t&&s)throw new Error('Both "bbox" and "window" passed.');if(i||r){if(t){const[e,i]=o.getOrigin(),[r,n]=o.getResolution();s=[e+t[0]*r,i+t[1]*n,e+t[2]*r,i+t[3]*n]}const e=s||f;if(i){if(n)throw new Error("Both width and resX passed");n=(e[2]-e[0])/i}if(r){if(a)throw new Error("Both width and resY passed");a=(e[3]-e[1])/r}}if(n||a){const e=[];for(let t=0;t<h;++t){const i=await this.getImage(t),{SubfileType:r,NewSubfileType:n}=i.fileDirectory;(0===t||2===r||1&n)&&e.push(i)}e.sort(((e,t)=>e.getWidth()-t.getWidth()));for(let t=0;t<e.length;++t){const i=e[t],r=(f[2]-f[0])/i.getWidth(),s=(f[3]-f[1])/i.getHeight();if(l=i,n&&n>r||a&&a>s)break}}let c=t;if(s){const[e,t]=o.getOrigin(),[i,r]=l.getResolution(o);c=[Math.round((s[0]-e)/i),Math.round((s[1]-t)/r),Math.round((s[2]-e)/i),Math.round((s[3]-t)/r)],c=[Math.min(c[0],c[2]),Math.min(c[1],c[3]),Math.max(c[0],c[2]),Math.max(c[1],c[3])]}return l.readRasters({...e,window:c})}}{constructor(e,t,i,r,n={}){super(),this.source=e,this.littleEndian=t,this.bigTiff=i,this.firstIFDOffset=r,this.cache=n.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(e,t){const i=this.bigTiff?4048:1024;return new Ee((await this.source.fetch([{offset:e,length:void 0!==t?t:i}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const t=this.bigTiff?20:12,i=this.bigTiff?8:2;let r=await this.getSlice(e);const n=this.bigTiff?r.readUint64(e):r.readUint16(e),a=n*t+(this.bigTiff?16:6);r.covers(e,a)||(r=await this.getSlice(e,a));const s={};let o=e+(this.bigTiff?8:2);for(let e=0;e<n;o+=t,++e){const e=r.readUint16(o),t=r.readUint16(o+2),i=this.bigTiff?r.readUint64(o+4):r.readUint32(o+4);let n,a;const l=Oe(t),h=o+(this.bigTiff?12:8);if(l*i<=(this.bigTiff?8:4))n=ze(r,t,i,h);else{const e=r.readOffset(h),a=Oe(t)*i;if(r.covers(e,a))n=ze(r,t,i,e);else{n=ze(await this.getSlice(e,a),t,i,e)}}a=1===i&&-1===se.indexOf(e)&&t!==le.RATIONAL&&t!==le.SRATIONAL?n[0]:n,s[ne[e]]=a}const l=function(e){const t=e.GeoKeyDirectory;if(!t)return null;const i={};for(let r=4;r<=4*t[3];r+=4){const n=ye[t[r]],a=t[r+1]?ne[t[r+1]]:null,s=t[r+2],o=t[r+3];let l=null;if(a){if(l=e[a],null==l)throw new Error(`Could not get value of geoKey '${n}'.`);"string"==typeof l?l=l.substring(o,o+s-1):l.subarray&&(l=l.subarray(o,o+s),1===s&&(l=l[0]))}else l=o;i[n]=l}return i}(s),h=r.readOffset(e+i+t*n);return new Ce(s,l,h)}async requestIFD(e){if(this.ifdRequests[e])return this.ifdRequests[e];if(0===e)return this.ifdRequests[e]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[e];if(!this.ifdRequests[e-1])try{this.ifdRequests[e-1]=this.requestIFD(e-1)}catch(t){if(t instanceof Re)throw new Re(e);throw t}return this.ifdRequests[e]=(async()=>{const t=await this.ifdRequests[e-1];if(0===t.nextIFDByteOffset)throw new Re(e);return this.parseFileDirectoryAt(t.nextIFDByteOffset)})(),this.ifdRequests[e]}async getImage(e=0){const t=await this.requestIFD(e);return new Te(t.fileDirectory,t.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let e=0,t=!0;for(;t;)try{await this.requestIFD(e),++e}catch(e){if(!(e instanceof Re))throw e;t=!1}return e}async getGhostValues(){const e=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const t="GDAL_STRUCTURAL_METADATA_SIZE=",i=t.length+100;let r=await this.getSlice(e,i);if(t===ze(r,le.ASCII,t.length,e)){const t=ze(r,le.ASCII,i,e).split("\n")[0],n=Number(t.split("=")[1].split(" ")[0])+t.length;n>i&&(r=await this.getSlice(e,n));const a=ze(r,le.ASCII,n,e);this.ghostValues={},a.split("\n").filter((e=>e.length>0)).map((e=>e.split("="))).forEach((([e,t])=>{this.ghostValues[e]=t}))}return this.ghostValues}static async fromSource(e,t,i){const r=(await e.fetch([{offset:0,length:1024}],i))[0],n=new Me(r),a=n.getUint16(0,0);let s;if(18761===a)s=!0;else{if(19789!==a)throw new TypeError("Invalid byte order value.");s=!1}const o=n.getUint16(2,s);let l;if(42===o)l=!1;else{if(43!==o)throw new TypeError("Invalid magic number.");l=!0;if(8!==n.getUint16(4,s))throw new Error("Unsupported offset byte-size.")}const h=l?n.getUint64(8,s):n.getUint32(4,s);return new Le(e,s,l,h,t)}close(){return"function"==typeof this.source.close&&this.source.close()}}async function Ve(e,t){return Le.fromSource(function(e){return new Be(e)}(e),t)}var Fe=function(){function e(){var e=this;this.url="",this.origin=[0,0],this.boundingBox=[0,0,1,1],this.useHeatMap=!0,this.useAutoRange=!0,this.useClip=!1,this.useDataForOpacity=!1,this.rangeMin=0,this.rangeMax=255,this.clipLow=0,this.clipHigh=255,this.multiplier=1,this.color=[255,0,255],this.alpha=150,this.imageWidth=0,this.imageHeight=0,this.options={},this.useChannel=-1,this.scale=function(e,t,i,r,n){return(e-t)*(n-r)/(i-t)+r},this.getOrigin=function(){return e.origin},this.getBoundingBox=function(){return e.boundingBox}}return e.prototype.setUrl=function(e){return t(this,void 0,void 0,(function(){var t,r,n;return i(this,(function(i){switch(i.label){case 0:return[4,fetch(e)];case 1:return[4,i.sent().arrayBuffer()];case 2:return[4,Ve(i.sent())];case 3:return[4,i.sent().getImage(0)];case 4:return t=i.sent(),r=t.getOrigin(),n=t.getBoundingBox(),this.data=t,this.origin=r,this.boundingBox=n,[2]}}))}))},e.prototype.getHeightMap=function(e){return t(this,void 0,void 0,(function(){var t,r,n,a,s,o,l,h,f,c;return i(this,(function(i){switch(i.label){case 0:return"string"!=typeof e?[3,4]:e==this.url?[3,2]:(this.url=e,[4,this.setUrl(e)]);case 1:i.sent(),i.label=2;case 2:return[4,this.data.readRasters()];case 3:return t=i.sent(),r=this.data.getWidth(),n=this.data.getHeight(),[3,5];case 4:t=e.rasters,r=e.width,n=e.height,i.label=5;case 5:for(this.imageWidth=r,this.imageHeight=n,a=-1===this.useChannel?t[0]:t[this.useChannel],(s=document.createElement("canvas")).width=r,s.height=n,o=s.getContext("2d"),l=o.createImageData(r,n),h=r*n*4,f=0,c=0;c<h;c+=4)a[f]*=this.multiplier,l.data[c]=~~(1525878e-11*(1e5+10*a[f])),l.data[c+1]=~~(.00390625*(1e5+10*a[f]))-256*l.data[c],l.data[c+2]=~~(1e5+10*a[f])-65536*l.data[c]-256*l.data[c+1],l.data[c+3]=255,f++;return o.putImageData(l,0,0),[2,s.toDataURL("image/png")]}}))}))},e.prototype.getBitmap=function(e){return t(this,void 0,void 0,(function(){var t,r,n,a,s,o,l,h,f,c,d,u,g,p,m,w,_,b,y;return i(this,(function(i){switch(i.label){case 0:return t=[],"string"!=typeof e?[3,4]:e==this.url?[3,2]:(this.url=e,[4,this.setUrl(e)]);case 1:i.sent(),i.label=2;case 2:return[4,this.data.readRasters()];case 3:return t=i.sent(),r=t.length,n=this.data.getWidth(),a=this.data.getHeight(),[3,5];case 4:t=e.rasters,r=t.length,n=e.width,a=e.height,i.label=5;case 5:if(this.imageWidth=n,this.imageHeight=a,(s=document.createElement("canvas")).width=n,s.height=a,o=s.getContext("2d"),l=o.createImageData(n,a),u=n*a*4,1===r){if(t[0].length/(n*a)==1){if(g=t[0],this.useAutoRange){for(p=Number.MIN_VALUE,m=Number.MAX_VALUE,w=void 0,y=0;y<g.length;y++)(w=g[y])>p&&(p=w),w<m&&(m=w);this.rangeMin=m,this.rangeMax=p}for(_=0,b=0,y=0;y<u;y+=4)this.useHeatMap&&(_=2*(g[b]-this.rangeMin)/(this.rangeMax-this.rangeMin),this.color[2]=0>255*(1-_)?0:255*(1-_),this.color[0]=0>255*(_-1)?0:255*(_-1),this.color[1]=255-this.color[2]-this.color[0]),h=this.color[0],f=this.color[1],c=this.color[2],d=this.alpha,!0===this.useClip&&(g[b]<this.clipLow||g[b]>this.clipHigh)&&(d=0),this.useDataForOpacity&&(d=this.scale(g[b],this.rangeMin,this.rangeMax,0,255)),l.data[y]=h,l.data[y+1]=f,l.data[y+2]=c,l.data[y+3]=d,b++}if(t[0].length/(n*a)==3)for(console.log("geoImage: RGB 1 array of length: "+t[0].length),b=0,y=0;y<u;y+=4)l.data[y]=t[0][b++],l.data[y+1]=t[0][b++],l.data[y+2]=t[0][b++],l.data[y+3]=this.alpha;if(t[0].length/(n*a)==4)for(console.log("geoImage: RGBA 1 array"),y=0;y<u;y+=4)l.data[y]=t[0][y],l.data[y+1]=t[0][y+1],l.data[y+2]=t[0][y+2],l.data[y+3]=t[0][y+3]}if(-1===this.useChannel){if(3===r)for(b=0,y=0;y<u;y+=4)h=t[0][b],f=t[1][b],c=t[2][b],d=this.alpha,l.data[y]=h,l.data[y+1]=f,l.data[y+2]=c,l.data[y+3]=d,b++;if(4===r)for(b=0,y=0;y<n*a*4;y+=4)h=t[0][b],f=t[1][b],c=t[2][b],d=this.alpha,l.data[y]=h,l.data[y+1]=f,l.data[y+2]=c,l.data[y+3]=d,b++}else if(t[this.useChannel].length/(n*a)==1){if(g=t[this.useChannel],this.useAutoRange){for(p=Number.MIN_VALUE,m=Number.MAX_VALUE,w=void 0,y=0;y<g.length;y++)(w=g[y])>p&&(p=w),w<m&&(m=w);this.rangeMin=m,this.rangeMax=p}for(_=0,b=0,y=0;y<u;y+=4)this.useHeatMap&&(_=2*(g[b]-this.rangeMin)/(this.rangeMax-this.rangeMin),this.color[2]=0>255*(1-_)?0:255*(1-_),this.color[0]=0>255*(_-1)?0:255*(_-1),this.color[1]=255-this.color[2]-this.color[0]),h=this.color[0],f=this.color[1],c=this.color[2],d=this.alpha,!0===this.useClip&&(g[b]<this.clipLow||g[b]>this.clipHigh)&&(d=0),this.useDataForOpacity&&(d=this.scale(g[b],this.rangeMin,this.rangeMax,0,255)),l.data[y]=h,l.data[y+1]=f,l.data[y+2]=c,l.data[y+3]=d,b++}return o.putImageData(l,0,0),[2,s.toDataURL("image/png")]}}))}))},e.prototype.setDataOpacity=function(e){void 0===e&&(e=!0),this.useDataForOpacity=e},e.prototype.setHeatMap=function(e){void 0===e&&(e=!0),this.useHeatMap=e},e.prototype.setAutoRange=function(e){void 0===e&&(e=!0),this.useAutoRange=e},e.prototype.setDataClip=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),0===e&&0===t?(this.useClip=!1,this.clipLow=e,this.clipHigh=t):(this.useClip=!0,this.clipLow=e,this.clipHigh=t)},e.prototype.setDataRange=function(e,t){void 0===e&&(e=0),void 0===t&&(t=255),this.rangeMin=e,this.rangeMax=t},e.prototype.setMultiplier=function(e){void 0===e&&(e=1),this.multiplier=e},e.prototype.setColor=function(e,t,i){void 0===e&&(e=255),void 0===t&&(t=0),void 0===i&&(i=255),this.color=[e,t,i]},e.prototype.setOpacity=function(e){void 0===e&&(e=150),this.alpha=e},e}(),Ge={bbox:[0,0,0,0],image:"",viewState:{latitude:0,longitude:0,zoom:12},heightMap:"",loaded:!1};function Ne(e,t){let i=e.length-t,r=0;do{for(let i=t;i>0;i--)e[r+t]+=e[r],r++;i-=t}while(i>0)}function Ze(e,t,i){let r=0,n=e.length;const a=n/i;for(;n>t;){for(let i=t;i>0;--i)e[r+t]+=e[r],++r;n-=t}const s=e.slice();for(let t=0;t<a;++t)for(let r=0;r<i;++r)e[i*t+r]=s[(i-r-1)*a+t]}class He{async decode(e,t){const i=await this.decodeBlock(t),r=e.Predictor||1;if(1!==r){const t=!e.StripOffsets;return function(e,t,i,r,n,a){if(!t||1===t)return e;for(let e=0;e<n.length;++e){if(n[e]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(n[e]!==n[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const s=n[0]/8,o=2===a?1:n.length;for(let a=0;a<r&&!(a*o*i*s>=e.byteLength);++a){let r;if(2===t){switch(n[0]){case 8:r=new Uint8Array(e,a*o*i*s,o*i*s);break;case 16:r=new Uint16Array(e,a*o*i*s,o*i*s/2);break;case 32:r=new Uint32Array(e,a*o*i*s,o*i*s/4);break;default:throw new Error(`Predictor 2 not allowed with ${n[0]} bits per sample.`)}Ne(r,o)}else 3===t&&(r=new Uint8Array(e,a*o*i*s,o*i*s),Ze(r,o,s))}return e}(i,r,t?e.TileWidth:e.ImageWidth,t?e.TileLength:e.RowsPerStrip||e.ImageLength,e.BitsPerSample,e.PlanarConfiguration)}return i}}var Ke=Object.freeze({__proto__:null,default:class extends He{decodeBlock(e){return e}}});function je(e,t){for(let i=t.length-1;i>=0;i--)e.push(t[i]);return e}function We(e){const t=new Uint16Array(4093),i=new Uint8Array(4093);for(let e=0;e<=257;e++)t[e]=4096,i[e]=e;let r=258,n=9,a=0;function s(){r=258,n=9}function o(e){const t=function(e,t,i){const r=t%8,n=Math.floor(t/8),a=8-r,s=t+i-8*(n+1);let o=8*(n+2)-(t+i);const l=8*(n+2)-t;if(o=Math.max(0,o),n>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),257;let h=e[n]&2**(8-r)-1;h<<=i-a;let f=h;if(n+1<e.length){let t=e[n+1]>>>o;t<<=Math.max(0,i-l),f+=t}if(s>8&&n+2<e.length){const r=8*(n+3)-(t+i);f+=e[n+2]>>>r}return f}(e,a,n);return a+=n,t}function l(e,n){return i[r]=n,t[r]=e,r++,r-1}function h(e){const r=[];for(let n=e;4096!==n;n=t[n])r.push(i[n]);return r}const f=[];s();const c=new Uint8Array(e);let d,u=o(c);for(;257!==u;){if(256===u){for(s(),u=o(c);256===u;)u=o(c);if(257===u)break;if(u>256)throw new Error(`corrupted code at scanline ${u}`);je(f,h(u)),d=u}else if(u<r){const e=h(u);je(f,e),l(d,e[e.length-1]),d=u}else{const e=h(d);if(!e)throw new Error(`Bogus entry. Not in dictionary, ${d} / ${r}, position: ${a}`);je(f,e),f.push(e[e.length-1]),l(d,e[e.length-1]),d=u}r+1>=2**n&&(12===n?d=void 0:n++),u=o(c)}return new Uint8Array(f)}var Ye=Object.freeze({__proto__:null,default:class extends He{decodeBlock(e){return We(e).buffer}}});const Xe=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);function qe(e,t){let i=0;const r=[];let n=16;for(;n>0&&!e[n-1];)--n;r.push({children:[],index:0});let a,s=r[0];for(let o=0;o<n;o++){for(let n=0;n<e[o];n++){for(s=r.pop(),s.children[s.index]=t[i];s.index>0;)s=r.pop();for(s.index++,r.push(s);r.length<=o;)r.push(a={children:[],index:0}),s.children[s.index]=a.children,s=a;i++}o+1<n&&(r.push(a={children:[],index:0}),s.children[s.index]=a.children,s=a)}return r[0].children}function $e(e,t,i,r,n,a,s,o,l){const{mcusPerLine:h,progressive:f}=i,c=t;let d=t,u=0,g=0;function p(){if(g>0)return g--,u>>g&1;if(u=e[d++],255===u){const t=e[d++];if(t)throw new Error(`unexpected marker: ${(u<<8|t).toString(16)}`)}return g=7,u>>>7}function m(e){let t,i=e;for(;null!==(t=p());){if(i=i[t],"number"==typeof i)return i;if("object"!=typeof i)throw new Error("invalid huffman sequence")}return null}function w(e){let t=e,i=0;for(;t>0;){const e=p();if(null===e)return;i=i<<1|e,--t}return i}function _(e){const t=w(e);return t>=1<<e-1?t:t+(-1<<e)+1}let b=0;let y,k=0;function x(e,t,i,r,n){const a=i%h,s=(i/h|0)*e.v+r,o=a*e.h+n;t(e,e.blocks[s][o])}function v(e,t,i){const r=i/e.blocksPerLine|0,n=i%e.blocksPerLine;t(e,e.blocks[r][n])}const A=r.length;let D,U,I,S,T,M;M=f?0===a?0===o?function(e,t){const i=m(e.huffmanTableDC),r=0===i?0:_(i)<<l;e.pred+=r,t[0]=e.pred}:function(e,t){t[0]|=p()<<l}:0===o?function(e,t){if(b>0)return void b--;let i=a;const r=s;for(;i<=r;){const r=m(e.huffmanTableAC),n=15&r,a=r>>4;if(0===n){if(a<15){b=w(a)+(1<<a)-1;break}i+=16}else i+=a,t[Xe[i]]=_(n)*(1<<l),i++}}:function(e,t){let i=a;const r=s;let n=0;for(;i<=r;){const r=Xe[i],a=t[r]<0?-1:1;switch(k){case 0:{const t=m(e.huffmanTableAC),i=15&t;if(n=t>>4,0===i)n<15?(b=w(n)+(1<<n),k=4):(n=16,k=1);else{if(1!==i)throw new Error("invalid ACn encoding");y=_(i),k=n?2:3}continue}case 1:case 2:t[r]?t[r]+=(p()<<l)*a:(n--,0===n&&(k=2===k?3:0));break;case 3:t[r]?t[r]+=(p()<<l)*a:(t[r]=y<<l,k=0);break;case 4:t[r]&&(t[r]+=(p()<<l)*a)}i++}4===k&&(b--,0===b&&(k=0))}:function(e,t){const i=m(e.huffmanTableDC),r=0===i?0:_(i);e.pred+=r,t[0]=e.pred;let n=1;for(;n<64;){const i=m(e.huffmanTableAC),r=15&i,a=i>>4;if(0===r){if(a<15)break;n+=16}else n+=a,t[Xe[n]]=_(r),n++}};let E,P,B=0;P=1===A?r[0].blocksPerLine*r[0].blocksPerColumn:h*i.mcusPerColumn;const O=n||P;for(;B<P;){for(U=0;U<A;U++)r[U].pred=0;if(b=0,1===A)for(D=r[0],T=0;T<O;T++)v(D,M,B),B++;else for(T=0;T<O;T++){for(U=0;U<A;U++){D=r[U];const{h:e,v:t}=D;for(I=0;I<t;I++)for(S=0;S<e;S++)x(D,M,B,I,S)}if(B++,B===P)break}if(g=0,E=e[d]<<8|e[d+1],E<65280)throw new Error("marker was not found");if(!(E>=65488&&E<=65495))break;d+=2}return d-c}function Je(e,t){const i=[],{blocksPerLine:r,blocksPerColumn:n}=t,a=r<<3,s=new Int32Array(64),o=new Uint8Array(64);function l(e,i,r){const n=t.quantizationTable;let a,s,o,l,h,f,c,d,u;const g=r;let p;for(p=0;p<64;p++)g[p]=e[p]*n[p];for(p=0;p<8;++p){const e=8*p;0!==g[1+e]||0!==g[2+e]||0!==g[3+e]||0!==g[4+e]||0!==g[5+e]||0!==g[6+e]||0!==g[7+e]?(a=5793*g[0+e]+128>>8,s=5793*g[4+e]+128>>8,o=g[2+e],l=g[6+e],h=2896*(g[1+e]-g[7+e])+128>>8,d=2896*(g[1+e]+g[7+e])+128>>8,f=g[3+e]<<4,c=g[5+e]<<4,u=a-s+1>>1,a=a+s+1>>1,s=u,u=3784*o+1567*l+128>>8,o=1567*o-3784*l+128>>8,l=u,u=h-c+1>>1,h=h+c+1>>1,c=u,u=d+f+1>>1,f=d-f+1>>1,d=u,u=a-l+1>>1,a=a+l+1>>1,l=u,u=s-o+1>>1,s=s+o+1>>1,o=u,u=2276*h+3406*d+2048>>12,h=3406*h-2276*d+2048>>12,d=u,u=799*f+4017*c+2048>>12,f=4017*f-799*c+2048>>12,c=u,g[0+e]=a+d,g[7+e]=a-d,g[1+e]=s+c,g[6+e]=s-c,g[2+e]=o+f,g[5+e]=o-f,g[3+e]=l+h,g[4+e]=l-h):(u=5793*g[0+e]+512>>10,g[0+e]=u,g[1+e]=u,g[2+e]=u,g[3+e]=u,g[4+e]=u,g[5+e]=u,g[6+e]=u,g[7+e]=u)}for(p=0;p<8;++p){const e=p;0!==g[8+e]||0!==g[16+e]||0!==g[24+e]||0!==g[32+e]||0!==g[40+e]||0!==g[48+e]||0!==g[56+e]?(a=5793*g[0+e]+2048>>12,s=5793*g[32+e]+2048>>12,o=g[16+e],l=g[48+e],h=2896*(g[8+e]-g[56+e])+2048>>12,d=2896*(g[8+e]+g[56+e])+2048>>12,f=g[24+e],c=g[40+e],u=a-s+1>>1,a=a+s+1>>1,s=u,u=3784*o+1567*l+2048>>12,o=1567*o-3784*l+2048>>12,l=u,u=h-c+1>>1,h=h+c+1>>1,c=u,u=d+f+1>>1,f=d-f+1>>1,d=u,u=a-l+1>>1,a=a+l+1>>1,l=u,u=s-o+1>>1,s=s+o+1>>1,o=u,u=2276*h+3406*d+2048>>12,h=3406*h-2276*d+2048>>12,d=u,u=799*f+4017*c+2048>>12,f=4017*f-799*c+2048>>12,c=u,g[0+e]=a+d,g[56+e]=a-d,g[8+e]=s+c,g[48+e]=s-c,g[16+e]=o+f,g[40+e]=o-f,g[24+e]=l+h,g[32+e]=l-h):(u=5793*r[p+0]+8192>>14,g[0+e]=u,g[8+e]=u,g[16+e]=u,g[24+e]=u,g[32+e]=u,g[40+e]=u,g[48+e]=u,g[56+e]=u)}for(p=0;p<64;++p){const e=128+(g[p]+8>>4);i[p]=e<0?0:e>255?255:e}}for(let e=0;e<n;e++){const n=e<<3;for(let e=0;e<8;e++)i.push(new Uint8Array(a));for(let a=0;a<r;a++){l(t.blocks[e][a],o,s);let r=0;const h=a<<3;for(let e=0;e<8;e++){const t=i[n+e];for(let e=0;e<8;e++)t[h+e]=o[r++]}}}return i}class Qe{constructor(){this.jfif=null,this.adobe=null,this.quantizationTables=[],this.huffmanTablesAC=[],this.huffmanTablesDC=[],this.resetFrames()}resetFrames(){this.frames=[]}parse(e){let t=0;function i(){const i=e[t]<<8|e[t+1];return t+=2,i}function r(){const r=i(),n=e.subarray(t,t+r-2);return t+=n.length,n}function n(e){let t,i,r=0,n=0;for(i in e.components)e.components.hasOwnProperty(i)&&(t=e.components[i],r<t.h&&(r=t.h),n<t.v&&(n=t.v));const a=Math.ceil(e.samplesPerLine/8/r),s=Math.ceil(e.scanLines/8/n);for(i in e.components)if(e.components.hasOwnProperty(i)){t=e.components[i];const o=Math.ceil(Math.ceil(e.samplesPerLine/8)*t.h/r),l=Math.ceil(Math.ceil(e.scanLines/8)*t.v/n),h=a*t.h,f=s*t.v,c=[];for(let e=0;e<f;e++){const e=[];for(let t=0;t<h;t++)e.push(new Int32Array(64));c.push(e)}t.blocksPerLine=o,t.blocksPerColumn=l,t.blocks=c}e.maxH=r,e.maxV=n,e.mcusPerLine=a,e.mcusPerColumn=s}let a=i();if(65496!==a)throw new Error("SOI not found");for(a=i();65497!==a;){switch(a){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:{const e=r();65504===a&&74===e[0]&&70===e[1]&&73===e[2]&&70===e[3]&&0===e[4]&&(this.jfif={version:{major:e[5],minor:e[6]},densityUnits:e[7],xDensity:e[8]<<8|e[9],yDensity:e[10]<<8|e[11],thumbWidth:e[12],thumbHeight:e[13],thumbData:e.subarray(14,14+3*e[12]*e[13])}),65518===a&&65===e[0]&&100===e[1]&&111===e[2]&&98===e[3]&&101===e[4]&&0===e[5]&&(this.adobe={version:e[6],flags0:e[7]<<8|e[8],flags1:e[9]<<8|e[10],transformCode:e[11]});break}case 65499:{const r=i()+t-2;for(;t<r;){const r=e[t++],n=new Int32Array(64);if(r>>4==0)for(let i=0;i<64;i++){n[Xe[i]]=e[t++]}else{if(r>>4!=1)throw new Error("DQT: invalid table spec");for(let e=0;e<64;e++){n[Xe[e]]=i()}}this.quantizationTables[15&r]=n}break}case 65472:case 65473:case 65474:{i();const r={extended:65473===a,progressive:65474===a,precision:e[t++],scanLines:i(),samplesPerLine:i(),components:{},componentsOrder:[]},s=e[t++];let o;for(let i=0;i<s;i++){o=e[t];const i=e[t+1]>>4,n=15&e[t+1],a=e[t+2];r.componentsOrder.push(o),r.components[o]={h:i,v:n,quantizationIdx:a},t+=3}n(r),this.frames.push(r);break}case 65476:{const r=i();for(let i=2;i<r;){const r=e[t++],n=new Uint8Array(16);let a=0;for(let i=0;i<16;i++,t++)n[i]=e[t],a+=n[i];const s=new Uint8Array(a);for(let i=0;i<a;i++,t++)s[i]=e[t];i+=17+a,r>>4==0?this.huffmanTablesDC[15&r]=qe(n,s):this.huffmanTablesAC[15&r]=qe(n,s)}break}case 65501:i(),this.resetInterval=i();break;case 65498:{i();const r=e[t++],n=[],a=this.frames[0];for(let i=0;i<r;i++){const i=a.components[e[t++]],r=e[t++];i.huffmanTableDC=this.huffmanTablesDC[r>>4],i.huffmanTableAC=this.huffmanTablesAC[15&r],n.push(i)}const s=e[t++],o=e[t++],l=e[t++],h=$e(e,t,a,n,this.resetInterval,s,o,l>>4,15&l);t+=h;break}case 65535:255!==e[t]&&t--;break;default:if(255===e[t-3]&&e[t-2]>=192&&e[t-2]<=254){t-=3;break}throw new Error(`unknown JPEG marker ${a.toString(16)}`)}a=i()}}getResult(){const{frames:e}=this;if(0===this.frames.length)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(let e=0;e<this.frames.length;e++){const t=this.frames[e].components;for(const e of Object.keys(t))t[e].quantizationTable=this.quantizationTables[t[e].quantizationIdx],delete t[e].quantizationIdx}const t=e[0],{components:i,componentsOrder:r}=t,n=[],a=t.samplesPerLine,s=t.scanLines;for(let e=0;e<r.length;e++){const a=i[r[e]];n.push({lines:Je(0,a),scaleX:a.h/t.maxH,scaleY:a.v/t.maxV})}const o=new Uint8Array(a*s*n.length);let l=0;for(let e=0;e<s;++e)for(let t=0;t<a;++t)for(let i=0;i<n.length;++i){const r=n[i];o[l]=r.lines[0|e*r.scaleY][0|t*r.scaleX],++l}return o}}var et=Object.freeze({__proto__:null,default:class extends He{constructor(e){super(),this.reader=new Qe,e.JPEGTables&&this.reader.parse(e.JPEGTables)}decodeBlock(e){return this.reader.resetFrames(),this.reader.parse(new Uint8Array(e)),this.reader.getResult().buffer}}});
|
|
16
|
+
/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function tt(e){let t=e.length;for(;--t>=0;)e[t]=0}const it=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),rt=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),nt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),at=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),st=new Array(576);tt(st);const ot=new Array(60);tt(ot);const lt=new Array(512);tt(lt);const ht=new Array(256);tt(ht);const ft=new Array(29);tt(ft);const ct=new Array(30);function dt(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}let ut,gt,pt;function mt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}tt(ct);const wt=e=>e<256?lt[e]:lt[256+(e>>>7)],_t=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},bt=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,_t(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},yt=(e,t,i)=>{bt(e,i[2*t],i[2*t+1])},kt=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},xt=(e,t,i)=>{const r=new Array(16);let n,a,s=0;for(n=1;n<=15;n++)r[n]=s=s+i[n-1]<<1;for(a=0;a<=t;a++){let t=e[2*a+1];0!==t&&(e[2*a]=kt(r[t]++,t))}},vt=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},At=e=>{e.bi_valid>8?_t(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Dt=(e,t,i,r)=>{const n=2*t,a=2*i;return e[n]<e[a]||e[n]===e[a]&&r[t]<=r[i]},Ut=(e,t,i)=>{const r=e.heap[i];let n=i<<1;for(;n<=e.heap_len&&(n<e.heap_len&&Dt(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Dt(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r},It=(e,t,i)=>{let r,n,a,s,o=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],n=e.pending_buf[e.l_buf+o],o++,0===r?yt(e,n,t):(a=ht[n],yt(e,a+256+1,t),s=it[a],0!==s&&(n-=ft[a],bt(e,n,s)),r--,a=wt(r),yt(e,a,i),s=rt[a],0!==s&&(r-=ct[a],bt(e,r,s)))}while(o<e.last_lit);yt(e,256,t)},St=(e,t)=>{const i=t.dyn_tree,r=t.stat_desc.static_tree,n=t.stat_desc.has_stree,a=t.stat_desc.elems;let s,o,l,h=-1;for(e.heap_len=0,e.heap_max=573,s=0;s<a;s++)0!==i[2*s]?(e.heap[++e.heap_len]=h=s,e.depth[s]=0):i[2*s+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=h<2?++h:0,i[2*l]=1,e.depth[l]=0,e.opt_len--,n&&(e.static_len-=r[2*l+1]);for(t.max_code=h,s=e.heap_len>>1;s>=1;s--)Ut(e,i,s);l=a;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ut(e,i,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,i[2*l]=i[2*s]+i[2*o],e.depth[l]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,i[2*s+1]=i[2*o+1]=l,e.heap[1]=l++,Ut(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,r=t.max_code,n=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length;let h,f,c,d,u,g,p=0;for(d=0;d<=15;d++)e.bl_count[d]=0;for(i[2*e.heap[e.heap_max]+1]=0,h=e.heap_max+1;h<573;h++)f=e.heap[h],d=i[2*i[2*f+1]+1]+1,d>l&&(d=l,p++),i[2*f+1]=d,f>r||(e.bl_count[d]++,u=0,f>=o&&(u=s[f-o]),g=i[2*f],e.opt_len+=g*(d+u),a&&(e.static_len+=g*(n[2*f+1]+u)));if(0!==p){do{for(d=l-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[l]--,p-=2}while(p>0);for(d=l;0!==d;d--)for(f=e.bl_count[d];0!==f;)c=e.heap[--h],c>r||(i[2*c+1]!==d&&(e.opt_len+=(d-i[2*c+1])*i[2*c],i[2*c+1]=d),f--)}})(e,t),xt(i,h,e.bl_count)},Tt=(e,t,i)=>{let r,n,a=-1,s=t[1],o=0,l=7,h=4;for(0===s&&(l=138,h=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=s,s=t[2*(r+1)+1],++o<l&&n===s||(o<h?e.bl_tree[2*n]+=o:0!==n?(n!==a&&e.bl_tree[2*n]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,a=n,0===s?(l=138,h=3):n===s?(l=6,h=3):(l=7,h=4))},Mt=(e,t,i)=>{let r,n,a=-1,s=t[1],o=0,l=7,h=4;for(0===s&&(l=138,h=3),r=0;r<=i;r++)if(n=s,s=t[2*(r+1)+1],!(++o<l&&n===s)){if(o<h)do{yt(e,n,e.bl_tree)}while(0!=--o);else 0!==n?(n!==a&&(yt(e,n,e.bl_tree),o--),yt(e,16,e.bl_tree),bt(e,o-3,2)):o<=10?(yt(e,17,e.bl_tree),bt(e,o-3,3)):(yt(e,18,e.bl_tree),bt(e,o-11,7));o=0,a=n,0===s?(l=138,h=3):n===s?(l=6,h=3):(l=7,h=4)}};let Et=!1;const Pt=(e,t,i,r)=>{bt(e,0+(r?1:0),3),((e,t,i,r)=>{At(e),r&&(_t(e,i),_t(e,~i)),e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i})(e,t,i,!0)};var Bt=(e,t,i,r)=>{let n,a,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),St(e,e.l_desc),St(e,e.d_desc),s=(e=>{let t;for(Tt(e,e.dyn_ltree,e.l_desc.max_code),Tt(e,e.dyn_dtree,e.d_desc.max_code),St(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*at[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=n&&(n=a)):n=a=i+5,i+4<=n&&-1!==t?Pt(e,t,i,r):4===e.strategy||a===n?(bt(e,2+(r?1:0),3),It(e,st,ot)):(bt(e,4+(r?1:0),3),((e,t,i,r)=>{let n;for(bt(e,t-257,5),bt(e,i-1,5),bt(e,r-4,4),n=0;n<r;n++)bt(e,e.bl_tree[2*at[n]+1],3);Mt(e,e.dyn_ltree,t-1),Mt(e,e.dyn_dtree,i-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),It(e,e.dyn_ltree,e.dyn_dtree)),vt(e),r&&At(e)},Ot={_tr_init:e=>{Et||((()=>{let e,t,i,r,n;const a=new Array(16);for(i=0,r=0;r<28;r++)for(ft[r]=i,e=0;e<1<<it[r];e++)ht[i++]=r;for(ht[i-1]=r,n=0,r=0;r<16;r++)for(ct[r]=n,e=0;e<1<<rt[r];e++)lt[n++]=r;for(n>>=7;r<30;r++)for(ct[r]=n<<7,e=0;e<1<<rt[r]-7;e++)lt[256+n++]=r;for(t=0;t<=15;t++)a[t]=0;for(e=0;e<=143;)st[2*e+1]=8,e++,a[8]++;for(;e<=255;)st[2*e+1]=9,e++,a[9]++;for(;e<=279;)st[2*e+1]=7,e++,a[7]++;for(;e<=287;)st[2*e+1]=8,e++,a[8]++;for(xt(st,287,a),e=0;e<30;e++)ot[2*e+1]=5,ot[2*e]=kt(e,5);ut=new dt(st,it,257,286,15),gt=new dt(ot,rt,0,30,15),pt=new dt(new Array(0),nt,0,19,7)})(),Et=!0),e.l_desc=new mt(e.dyn_ltree,ut),e.d_desc=new mt(e.dyn_dtree,gt),e.bl_desc=new mt(e.bl_tree,pt),e.bi_buf=0,e.bi_valid=0,vt(e)},_tr_stored_block:Pt,_tr_flush_block:Bt,_tr_tally:(e,t,i)=>(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(ht[i]+256+1)]++,e.dyn_dtree[2*wt(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{bt(e,2,3),yt(e,256,st),(e=>{16===e.bi_valid?(_t(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var zt=(e,t,i,r)=>{let n=65535&e|0,a=e>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{n=n+t[r++]|0,a=a+n|0}while(--s);n%=65521,a%=65521}return n|a<<16|0};const Ct=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Rt=(e,t,i,r)=>{const n=Ct,a=r+i;e^=-1;for(let i=r;i<a;i++)e=e>>>8^n[255&(e^t[i])];return-1^e},Lt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Vt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ft,_tr_stored_block:Gt,_tr_flush_block:Nt,_tr_tally:Zt,_tr_align:Ht}=Ot,{Z_NO_FLUSH:Kt,Z_PARTIAL_FLUSH:jt,Z_FULL_FLUSH:Wt,Z_FINISH:Yt,Z_BLOCK:Xt,Z_OK:qt,Z_STREAM_END:$t,Z_STREAM_ERROR:Jt,Z_DATA_ERROR:Qt,Z_BUF_ERROR:ei,Z_DEFAULT_COMPRESSION:ti,Z_FILTERED:ii,Z_HUFFMAN_ONLY:ri,Z_RLE:ni,Z_FIXED:ai,Z_DEFAULT_STRATEGY:si,Z_UNKNOWN:oi,Z_DEFLATED:li}=Vt,hi=(e,t)=>(e.msg=Lt[t],t),fi=e=>(e<<1)-(e>4?9:0),ci=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let di=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const ui=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},gi=(e,t)=>{Nt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ui(e.strm)},pi=(e,t)=>{e.pending_buf[e.pending++]=t},mi=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},wi=(e,t,i,r)=>{let n=e.avail_in;return n>r&&(n=r),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),i),1===e.state.wrap?e.adler=zt(e.adler,t,n,i):2===e.state.wrap&&(e.adler=Rt(e.adler,t,n,i)),e.next_in+=n,e.total_in+=n,n)},_i=(e,t)=>{let i,r,n=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match;const l=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,h=e.window,f=e.w_mask,c=e.prev,d=e.strstart+258;let u=h[a+s-1],g=h[a+s];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do{if(i=t,h[i+s]===g&&h[i+s-1]===u&&h[i]===h[a]&&h[++i]===h[a+1]){a+=2,i++;do{}while(h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&a<d);if(r=258-(d-a),a=d-258,r>s){if(e.match_start=t,s=r,r>=o)break;u=h[a+s-1],g=h[a+s]}}}while((t=c[t&f])>l&&0!=--n);return s<=e.lookahead?s:e.lookahead},bi=e=>{const t=e.w_size;let i,r,n,a,s;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-262)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,i=r;do{n=e.head[--i],e.head[i]=n>=t?n-t:0}while(--r);r=t,i=r;do{n=e.prev[--i],e.prev[i]=n>=t?n-t:0}while(--r);a+=t}if(0===e.strm.avail_in)break;if(r=wi(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=r,e.lookahead+e.insert>=3)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=di(e,e.ins_h,e.window[s+1]);e.insert&&(e.ins_h=di(e,e.ins_h,e.window[s+3-1]),e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},yi=(e,t)=>{let i,r;for(;;){if(e.lookahead<262){if(bi(e),e.lookahead<262&&t===Kt)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=di(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-262&&(e.match_length=_i(e,i)),e.match_length>=3)if(r=Zt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=di(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=di(e,e.ins_h,e.window[e.strstart+1]);else r=Zt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(gi(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Yt?(gi(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(gi(e,!1),0===e.strm.avail_out)?1:2},ki=(e,t)=>{let i,r,n;for(;;){if(e.lookahead<262){if(bi(e),e.lookahead<262&&t===Kt)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=di(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-262&&(e.match_length=_i(e,i),e.match_length<=5&&(e.strategy===ii||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,r=Zt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=di(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(gi(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Zt(e,0,e.window[e.strstart-1]),r&&gi(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Zt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Yt?(gi(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(gi(e,!1),0===e.strm.avail_out)?1:2};function xi(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}const vi=[new xi(0,0,0,0,((e,t)=>{let i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(bi(e),0===e.lookahead&&t===Kt)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const r=e.block_start+i;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,gi(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(gi(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Yt?(gi(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(gi(e,!1),e.strm.avail_out),1)})),new xi(4,4,8,4,yi),new xi(4,5,16,8,yi),new xi(4,6,32,32,yi),new xi(4,4,16,16,ki),new xi(8,16,32,32,ki),new xi(8,16,128,128,ki),new xi(8,32,128,256,ki),new xi(32,128,258,1024,ki),new xi(32,258,258,4096,ki)];function Ai(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=li,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ci(this.dyn_ltree),ci(this.dyn_dtree),ci(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ci(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ci(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Di=e=>{if(!e||!e.state)return hi(e,Jt);e.total_in=e.total_out=0,e.data_type=oi;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=Kt,Ft(t),qt},Ui=e=>{const t=Di(e);var i;return t===qt&&((i=e.state).window_size=2*i.w_size,ci(i.head),i.max_lazy_match=vi[i.level].max_lazy,i.good_match=vi[i.level].good_length,i.nice_match=vi[i.level].nice_length,i.max_chain_length=vi[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Ii=(e,t,i,r,n,a)=>{if(!e)return Jt;let s=1;if(t===ti&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),n<1||n>9||i!==li||r<8||r>15||t<0||t>9||a<0||a>ai)return hi(e,Jt);8===r&&(r=9);const o=new Ai;return e.state=o,o.strm=e,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=a,o.method=i,Ui(e)};var Si={deflateInit:(e,t)=>Ii(e,t,li,15,8,si),deflateInit2:Ii,deflateReset:Ui,deflateResetKeep:Di,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?Jt:(e.state.gzhead=t,qt):Jt,deflate:(e,t)=>{let i,r;if(!e||!e.state||t>Xt||t<0)return e?hi(e,Jt):Jt;const n=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===n.status&&t!==Yt)return hi(e,0===e.avail_out?ei:Jt);n.strm=e;const a=n.last_flush;if(n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,pi(n,31),pi(n,139),pi(n,8),n.gzhead?(pi(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),pi(n,255&n.gzhead.time),pi(n,n.gzhead.time>>8&255),pi(n,n.gzhead.time>>16&255),pi(n,n.gzhead.time>>24&255),pi(n,9===n.level?2:n.strategy>=ri||n.level<2?4:0),pi(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(pi(n,255&n.gzhead.extra.length),pi(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Rt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(pi(n,0),pi(n,0),pi(n,0),pi(n,0),pi(n,0),pi(n,9===n.level?2:n.strategy>=ri||n.level<2?4:0),pi(n,3),n.status=113);else{let t=li+(n.w_bits-8<<4)<<8,i=-1;i=n.strategy>=ri||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=i<<6,0!==n.strstart&&(t|=32),t+=31-t%31,n.status=113,mi(n,t),0!==n.strstart&&(mi(n,e.adler>>>16),mi(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-i,i)),ui(e),i=n.pending,n.pending!==n.pending_buf_size));)pi(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-i,i)),ui(e),i=n.pending,n.pending===n.pending_buf_size)){r=1;break}r=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,pi(n,r)}while(0!==r);n.gzhead.hcrc&&n.pending>i&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-i,i)),0===r&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-i,i)),ui(e),i=n.pending,n.pending===n.pending_buf_size)){r=1;break}r=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,pi(n,r)}while(0!==r);n.gzhead.hcrc&&n.pending>i&&(e.adler=Rt(e.adler,n.pending_buf,n.pending-i,i)),0===r&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&ui(e),n.pending+2<=n.pending_buf_size&&(pi(n,255&e.adler),pi(n,e.adler>>8&255),e.adler=0,n.status=113)):n.status=113),0!==n.pending){if(ui(e),0===e.avail_out)return n.last_flush=-1,qt}else if(0===e.avail_in&&fi(t)<=fi(a)&&t!==Yt)return hi(e,ei);if(666===n.status&&0!==e.avail_in)return hi(e,ei);if(0!==e.avail_in||0!==n.lookahead||t!==Kt&&666!==n.status){let i=n.strategy===ri?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(bi(e),0===e.lookahead)){if(t===Kt)return 1;break}if(e.match_length=0,i=Zt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(gi(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Yt?(gi(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(gi(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===ni?((e,t)=>{let i,r,n,a;const s=e.window;for(;;){if(e.lookahead<=258){if(bi(e),e.lookahead<=258&&t===Kt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,r=s[n],r===s[++n]&&r===s[++n]&&r===s[++n])){a=e.strstart+258;do{}while(r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&n<a);e.match_length=258-(a-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Zt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Zt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(gi(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Yt?(gi(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(gi(e,!1),0===e.strm.avail_out)?1:2})(n,t):vi[n.level].func(n,t);if(3!==i&&4!==i||(n.status=666),1===i||3===i)return 0===e.avail_out&&(n.last_flush=-1),qt;if(2===i&&(t===jt?Ht(n):t!==Xt&&(Gt(n,0,0,!1),t===Wt&&(ci(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ui(e),0===e.avail_out))return n.last_flush=-1,qt}return t!==Yt?qt:n.wrap<=0?$t:(2===n.wrap?(pi(n,255&e.adler),pi(n,e.adler>>8&255),pi(n,e.adler>>16&255),pi(n,e.adler>>24&255),pi(n,255&e.total_in),pi(n,e.total_in>>8&255),pi(n,e.total_in>>16&255),pi(n,e.total_in>>24&255)):(mi(n,e.adler>>>16),mi(n,65535&e.adler)),ui(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?qt:$t)},deflateEnd:e=>{if(!e||!e.state)return Jt;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?hi(e,Jt):(e.state=null,113===t?hi(e,Qt):qt)},deflateSetDictionary:(e,t)=>{let i=t.length;if(!e||!e.state)return Jt;const r=e.state,n=r.wrap;if(2===n||1===n&&42!==r.status||r.lookahead)return Jt;if(1===n&&(e.adler=zt(e.adler,t,i,0)),r.wrap=0,i>=r.w_size){0===n&&(ci(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(i-r.w_size,i),0),t=e,i=r.w_size}const a=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,bi(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=di(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,bi(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=o,e.avail_in=a,r.wrap=n,qt},deflateInfo:"pako deflate (from Nodeca project)"};const Ti=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Mi=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Ti(i,t)&&(e[t]=i[t])}}return e},Ei=e=>{let t=0;for(let i=0,r=e.length;i<r;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,r=0,n=e.length;t<n;t++){let n=e[t];i.set(n,r),r+=n.length}return i};let Pi=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Pi=!1}const Bi=new Uint8Array(256);for(let e=0;e<256;e++)Bi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Bi[254]=Bi[254]=1;var Oi=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,r,n,a,s=e.length,o=0;for(n=0;n<s;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<s&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(o),a=0,n=0;a<o;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<s&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),i<128?t[a++]=i:i<2048?(t[a++]=192|i>>>6,t[a++]=128|63&i):i<65536?(t[a++]=224|i>>>12,t[a++]=128|i>>>6&63,t[a++]=128|63&i):(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63,t[a++]=128|i>>>6&63,t[a++]=128|63&i);return t},zi=(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,n;const a=new Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){a[n++]=t;continue}let s=Bi[t];if(s>4)a[n++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r<i;)t=t<<6|63&e[r++],s--;s>1?a[n++]=65533:t<65536?a[n++]=t:(t-=65536,a[n++]=55296|t>>10&1023,a[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Pi)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let r=0;r<t;r++)i+=String.fromCharCode(e[r]);return i})(a,n)},Ci=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Bi[e[i]]>t?i:t};var Ri=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Li=Object.prototype.toString,{Z_NO_FLUSH:Vi,Z_SYNC_FLUSH:Fi,Z_FULL_FLUSH:Gi,Z_FINISH:Ni,Z_OK:Zi,Z_STREAM_END:Hi,Z_DEFAULT_COMPRESSION:Ki,Z_DEFAULT_STRATEGY:ji,Z_DEFLATED:Wi}=Vt;function Yi(e){this.options=Mi({level:Ki,method:Wi,chunkSize:16384,windowBits:15,memLevel:8,strategy:ji},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ri,this.strm.avail_out=0;let i=Si.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Zi)throw new Error(Lt[i]);if(t.header&&Si.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Oi(t.dictionary):"[object ArrayBuffer]"===Li.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Si.deflateSetDictionary(this.strm,e),i!==Zi)throw new Error(Lt[i]);this._dict_set=!0}}Yi.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize;let n,a;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Ni:Vi,"string"==typeof e?i.input=Oi(e):"[object ArrayBuffer]"===Li.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),(a===Fi||a===Gi)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(n=Si.deflate(i,a),n===Hi)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=Si.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Zi;if(0!==i.avail_out){if(a>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Yi.prototype.onData=function(e){this.chunks.push(e)},Yi.prototype.onEnd=function(e){e===Zi&&(this.result=Ei(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Xi=function(e,t){let i,r,n,a,s,o,l,h,f,c,d,u,g,p,m,w,_,b,y,k,x,v,A,D;const U=e.state;i=e.next_in,A=e.input,r=i+(e.avail_in-5),n=e.next_out,D=e.output,a=n-(t-e.avail_out),s=n+(e.avail_out-257),o=U.dmax,l=U.wsize,h=U.whave,f=U.wnext,c=U.window,d=U.hold,u=U.bits,g=U.lencode,p=U.distcode,m=(1<<U.lenbits)-1,w=(1<<U.distbits)-1;e:do{u<15&&(d+=A[i++]<<u,u+=8,d+=A[i++]<<u,u+=8),_=g[d&m];t:for(;;){if(b=_>>>24,d>>>=b,u-=b,b=_>>>16&255,0===b)D[n++]=65535&_;else{if(!(16&b)){if(0==(64&b)){_=g[(65535&_)+(d&(1<<b)-1)];continue t}if(32&b){U.mode=12;break e}e.msg="invalid literal/length code",U.mode=30;break e}y=65535&_,b&=15,b&&(u<b&&(d+=A[i++]<<u,u+=8),y+=d&(1<<b)-1,d>>>=b,u-=b),u<15&&(d+=A[i++]<<u,u+=8,d+=A[i++]<<u,u+=8),_=p[d&w];i:for(;;){if(b=_>>>24,d>>>=b,u-=b,b=_>>>16&255,!(16&b)){if(0==(64&b)){_=p[(65535&_)+(d&(1<<b)-1)];continue i}e.msg="invalid distance code",U.mode=30;break e}if(k=65535&_,b&=15,u<b&&(d+=A[i++]<<u,u+=8,u<b&&(d+=A[i++]<<u,u+=8)),k+=d&(1<<b)-1,k>o){e.msg="invalid distance too far back",U.mode=30;break e}if(d>>>=b,u-=b,b=n-a,k>b){if(b=k-b,b>h&&U.sane){e.msg="invalid distance too far back",U.mode=30;break e}if(x=0,v=c,0===f){if(x+=l-b,b<y){y-=b;do{D[n++]=c[x++]}while(--b);x=n-k,v=D}}else if(f<b){if(x+=l+f-b,b-=f,b<y){y-=b;do{D[n++]=c[x++]}while(--b);if(x=0,f<y){b=f,y-=b;do{D[n++]=c[x++]}while(--b);x=n-k,v=D}}}else if(x+=f-b,b<y){y-=b;do{D[n++]=c[x++]}while(--b);x=n-k,v=D}for(;y>2;)D[n++]=v[x++],D[n++]=v[x++],D[n++]=v[x++],y-=3;y&&(D[n++]=v[x++],y>1&&(D[n++]=v[x++]))}else{x=n-k;do{D[n++]=D[x++],D[n++]=D[x++],D[n++]=D[x++],y-=3}while(y>2);y&&(D[n++]=D[x++],y>1&&(D[n++]=D[x++]))}break}}break}}while(i<r&&n<s);y=u>>3,i-=y,u-=y<<3,d&=(1<<u)-1,e.next_in=i,e.next_out=n,e.avail_in=i<r?r-i+5:5-(i-r),e.avail_out=n<s?s-n+257:257-(n-s),U.hold=d,U.bits=u};const qi=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),$i=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Ji=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Qi=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var er=(e,t,i,r,n,a,s,o)=>{const l=o.bits;let h,f,c,d,u,g,p=0,m=0,w=0,_=0,b=0,y=0,k=0,x=0,v=0,A=0,D=null,U=0;const I=new Uint16Array(16),S=new Uint16Array(16);let T,M,E,P=null,B=0;for(p=0;p<=15;p++)I[p]=0;for(m=0;m<r;m++)I[t[i+m]]++;for(b=l,_=15;_>=1&&0===I[_];_--);if(b>_&&(b=_),0===_)return n[a++]=20971520,n[a++]=20971520,o.bits=1,0;for(w=1;w<_&&0===I[w];w++);for(b<w&&(b=w),x=1,p=1;p<=15;p++)if(x<<=1,x-=I[p],x<0)return-1;if(x>0&&(0===e||1!==_))return-1;for(S[1]=0,p=1;p<15;p++)S[p+1]=S[p]+I[p];for(m=0;m<r;m++)0!==t[i+m]&&(s[S[t[i+m]]++]=m);if(0===e?(D=P=s,g=19):1===e?(D=qi,U-=257,P=$i,B-=257,g=256):(D=Ji,P=Qi,g=-1),A=0,m=0,p=w,u=a,y=b,k=0,c=-1,v=1<<b,d=v-1,1===e&&v>852||2===e&&v>592)return 1;for(;;){T=p-k,s[m]<g?(M=0,E=s[m]):s[m]>g?(M=P[B+s[m]],E=D[U+s[m]]):(M=96,E=0),h=1<<p-k,f=1<<y,w=f;do{f-=h,n[u+(A>>k)+f]=T<<24|M<<16|E|0}while(0!==f);for(h=1<<p-1;A&h;)h>>=1;if(0!==h?(A&=h-1,A+=h):A=0,m++,0==--I[p]){if(p===_)break;p=t[i+s[m]]}if(p>b&&(A&d)!==c){for(0===k&&(k=b),u+=w,y=p-k,x=1<<y;y+k<_&&(x-=I[y+k],!(x<=0));)y++,x<<=1;if(v+=1<<y,1===e&&v>852||2===e&&v>592)return 1;c=A&d,n[c]=b<<24|y<<16|u-a|0}}return 0!==A&&(n[u+A]=p-k<<24|64<<16|0),o.bits=b,0};const{Z_FINISH:tr,Z_BLOCK:ir,Z_TREES:rr,Z_OK:nr,Z_STREAM_END:ar,Z_NEED_DICT:sr,Z_STREAM_ERROR:or,Z_DATA_ERROR:lr,Z_MEM_ERROR:hr,Z_BUF_ERROR:fr,Z_DEFLATED:cr}=Vt,dr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ur(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const gr=e=>{if(!e||!e.state)return or;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,nr},pr=e=>{if(!e||!e.state)return or;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,gr(e)},mr=(e,t)=>{let i;if(!e||!e.state)return or;const r=e.state;return t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?or:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,pr(e))},wr=(e,t)=>{if(!e)return or;const i=new ur;e.state=i,i.window=null;const r=mr(e,t);return r!==nr&&(e.state=null),r};let _r,br,yr=!0;const kr=e=>{if(yr){_r=new Int32Array(512),br=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(er(1,e.lens,0,288,_r,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;er(2,e.lens,0,32,br,0,e.work,{bits:5}),yr=!1}e.lencode=_r,e.lenbits=9,e.distcode=br,e.distbits=5},xr=(e,t,i,r)=>{let n;const a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(t.subarray(i-a.wsize,i),0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>r&&(n=r),a.window.set(t.subarray(i-r,i-r+n),a.wnext),(r-=n)?(a.window.set(t.subarray(i-r,i),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0};var vr={inflateReset:pr,inflateReset2:mr,inflateResetKeep:gr,inflateInit:e=>wr(e,15),inflateInit2:wr,inflate:(e,t)=>{let i,r,n,a,s,o,l,h,f,c,d,u,g,p,m,w,_,b,y,k,x,v,A=0;const D=new Uint8Array(4);let U,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return or;i=e.state,12===i.mode&&(i.mode=13),s=e.next_out,n=e.output,l=e.avail_out,a=e.next_in,r=e.input,o=e.avail_in,h=i.hold,f=i.bits,c=o,d=l,v=nr;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;f<16;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(2&i.wrap&&35615===h){i.check=0,D[0]=255&h,D[1]=h>>>8&255,i.check=Rt(i.check,D,2,0),h=0,f=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",i.mode=30;break}if((15&h)!==cr){e.msg="unknown compression method",i.mode=30;break}if(h>>>=4,f-=4,x=8+(15&h),0===i.wbits)i.wbits=x;else if(x>i.wbits){e.msg="invalid window size",i.mode=30;break}i.dmax=1<<i.wbits,e.adler=i.check=1,i.mode=512&h?10:12,h=0,f=0;break;case 2:for(;f<16;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(i.flags=h,(255&i.flags)!==cr){e.msg="unknown compression method",i.mode=30;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=30;break}i.head&&(i.head.text=h>>8&1),512&i.flags&&(D[0]=255&h,D[1]=h>>>8&255,i.check=Rt(i.check,D,2,0)),h=0,f=0,i.mode=3;case 3:for(;f<32;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}i.head&&(i.head.time=h),512&i.flags&&(D[0]=255&h,D[1]=h>>>8&255,D[2]=h>>>16&255,D[3]=h>>>24&255,i.check=Rt(i.check,D,4,0)),h=0,f=0,i.mode=4;case 4:for(;f<16;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}i.head&&(i.head.xflags=255&h,i.head.os=h>>8),512&i.flags&&(D[0]=255&h,D[1]=h>>>8&255,i.check=Rt(i.check,D,2,0)),h=0,f=0,i.mode=5;case 5:if(1024&i.flags){for(;f<16;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}i.length=h,i.head&&(i.head.extra_len=h),512&i.flags&&(D[0]=255&h,D[1]=h>>>8&255,i.check=Rt(i.check,D,2,0)),h=0,f=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(u=i.length,u>o&&(u=o),u&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(r.subarray(a,a+u),x)),512&i.flags&&(i.check=Rt(i.check,r,u,a)),o-=u,a+=u,i.length-=u),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break e;u=0;do{x=r[a+u++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&u<o);if(512&i.flags&&(i.check=Rt(i.check,r,u,a)),o-=u,a+=u,x)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===o)break e;u=0;do{x=r[a+u++],i.head&&x&&i.length<65536&&(i.head.comment+=String.fromCharCode(x))}while(x&&u<o);if(512&i.flags&&(i.check=Rt(i.check,r,u,a)),o-=u,a+=u,x)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;f<16;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(h!==(65535&i.check)){e.msg="header crc mismatch",i.mode=30;break}h=0,f=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=12;break;case 10:for(;f<32;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}e.adler=i.check=dr(h),h=0,f=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,i.hold=h,i.bits=f,sr;e.adler=i.check=1,i.mode=12;case 12:if(t===ir||t===rr)break e;case 13:if(i.last){h>>>=7&f,f-=7&f,i.mode=27;break}for(;f<3;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}switch(i.last=1&h,h>>>=1,f-=1,3&h){case 0:i.mode=14;break;case 1:if(kr(i),i.mode=20,t===rr){h>>>=2,f-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=30}h>>>=2,f-=2;break;case 14:for(h>>>=7&f,f-=7&f;f<32;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if((65535&h)!=(h>>>16^65535)){e.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&h,h=0,f=0,i.mode=15,t===rr)break e;case 15:i.mode=16;case 16:if(u=i.length,u){if(u>o&&(u=o),u>l&&(u=l),0===u)break e;n.set(r.subarray(a,a+u),s),o-=u,a+=u,l-=u,s+=u,i.length-=u;break}i.mode=12;break;case 17:for(;f<14;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(i.nlen=257+(31&h),h>>>=5,f-=5,i.ndist=1+(31&h),h>>>=5,f-=5,i.ncode=4+(15&h),h>>>=4,f-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=30;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;f<3;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}i.lens[S[i.have++]]=7&h,h>>>=3,f-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,U={bits:i.lenbits},v=er(0,i.lens,0,19,i.lencode,0,i.work,U),i.lenbits=U.bits,v){e.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;A=i.lencode[h&(1<<i.lenbits)-1],m=A>>>24,w=A>>>16&255,_=65535&A,!(m<=f);){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(_<16)h>>>=m,f-=m,i.lens[i.have++]=_;else{if(16===_){for(I=m+2;f<I;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(h>>>=m,f-=m,0===i.have){e.msg="invalid bit length repeat",i.mode=30;break}x=i.lens[i.have-1],u=3+(3&h),h>>>=2,f-=2}else if(17===_){for(I=m+3;f<I;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}h>>>=m,f-=m,x=0,u=3+(7&h),h>>>=3,f-=3}else{for(I=m+7;f<I;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}h>>>=m,f-=m,x=0,u=11+(127&h),h>>>=7,f-=7}if(i.have+u>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=30;break}for(;u--;)i.lens[i.have++]=x}}if(30===i.mode)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,U={bits:i.lenbits},v=er(1,i.lens,0,i.nlen,i.lencode,0,i.work,U),i.lenbits=U.bits,v){e.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,U={bits:i.distbits},v=er(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,U),i.distbits=U.bits,v){e.msg="invalid distances set",i.mode=30;break}if(i.mode=20,t===rr)break e;case 20:i.mode=21;case 21:if(o>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,i.hold=h,i.bits=f,Xi(e,d),s=e.next_out,n=e.output,l=e.avail_out,a=e.next_in,r=e.input,o=e.avail_in,h=i.hold,f=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;A=i.lencode[h&(1<<i.lenbits)-1],m=A>>>24,w=A>>>16&255,_=65535&A,!(m<=f);){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(w&&0==(240&w)){for(b=m,y=w,k=_;A=i.lencode[k+((h&(1<<b+y)-1)>>b)],m=A>>>24,w=A>>>16&255,_=65535&A,!(b+m<=f);){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}h>>>=b,f-=b,i.back+=b}if(h>>>=m,f-=m,i.back+=m,i.length=_,0===w){i.mode=26;break}if(32&w){i.back=-1,i.mode=12;break}if(64&w){e.msg="invalid literal/length code",i.mode=30;break}i.extra=15&w,i.mode=22;case 22:if(i.extra){for(I=i.extra;f<I;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}i.length+=h&(1<<i.extra)-1,h>>>=i.extra,f-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;A=i.distcode[h&(1<<i.distbits)-1],m=A>>>24,w=A>>>16&255,_=65535&A,!(m<=f);){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(0==(240&w)){for(b=m,y=w,k=_;A=i.distcode[k+((h&(1<<b+y)-1)>>b)],m=A>>>24,w=A>>>16&255,_=65535&A,!(b+m<=f);){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}h>>>=b,f-=b,i.back+=b}if(h>>>=m,f-=m,i.back+=m,64&w){e.msg="invalid distance code",i.mode=30;break}i.offset=_,i.extra=15&w,i.mode=24;case 24:if(i.extra){for(I=i.extra;f<I;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}i.offset+=h&(1<<i.extra)-1,h>>>=i.extra,f-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===l)break e;if(u=d-l,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=30;break}u>i.wnext?(u-=i.wnext,g=i.wsize-u):g=i.wnext-u,u>i.length&&(u=i.length),p=i.window}else p=n,g=s-i.offset,u=i.length;u>l&&(u=l),l-=u,i.length-=u;do{n[s++]=p[g++]}while(--u);0===i.length&&(i.mode=21);break;case 26:if(0===l)break e;n[s++]=i.length,l--,i.mode=21;break;case 27:if(i.wrap){for(;f<32;){if(0===o)break e;o--,h|=r[a++]<<f,f+=8}if(d-=l,e.total_out+=d,i.total+=d,d&&(e.adler=i.check=i.flags?Rt(i.check,n,d,s-d):zt(i.check,n,d,s-d)),d=l,(i.flags?h:dr(h))!==i.check){e.msg="incorrect data check",i.mode=30;break}h=0,f=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;f<32;){if(0===o)break e;o--,h+=r[a++]<<f,f+=8}if(h!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=30;break}h=0,f=0}i.mode=29;case 29:v=ar;break e;case 30:v=lr;break e;case 31:return hr;default:return or}return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,i.hold=h,i.bits=f,(i.wsize||d!==e.avail_out&&i.mode<30&&(i.mode<27||t!==tr))&&xr(e,e.output,e.next_out,d-e.avail_out),c-=e.avail_in,d-=e.avail_out,e.total_in+=c,e.total_out+=d,i.total+=d,i.wrap&&d&&(e.adler=i.check=i.flags?Rt(i.check,n,d,e.next_out-d):zt(i.check,n,d,e.next_out-d)),e.data_type=i.bits+(i.last?64:0)+(12===i.mode?128:0)+(20===i.mode||15===i.mode?256:0),(0===c&&0===d||t===tr)&&v===nr&&(v=fr),v},inflateEnd:e=>{if(!e||!e.state)return or;let t=e.state;return t.window&&(t.window=null),e.state=null,nr},inflateGetHeader:(e,t)=>{if(!e||!e.state)return or;const i=e.state;return 0==(2&i.wrap)?or:(i.head=t,t.done=!1,nr)},inflateSetDictionary:(e,t)=>{const i=t.length;let r,n,a;return e&&e.state?(r=e.state,0!==r.wrap&&11!==r.mode?or:11===r.mode&&(n=1,n=zt(n,t,i,0),n!==r.check)?lr:(a=xr(e,t,i,i),a?(r.mode=31,hr):(r.havedict=1,nr))):or},inflateInfo:"pako inflate (from Nodeca project)"};var Ar=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Dr=Object.prototype.toString,{Z_NO_FLUSH:Ur,Z_FINISH:Ir,Z_OK:Sr,Z_STREAM_END:Tr,Z_NEED_DICT:Mr,Z_STREAM_ERROR:Er,Z_DATA_ERROR:Pr,Z_MEM_ERROR:Br}=Vt;function Or(e){this.options=Mi({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ri,this.strm.avail_out=0;let i=vr.inflateInit2(this.strm,t.windowBits);if(i!==Sr)throw new Error(Lt[i]);if(this.header=new Ar,vr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Oi(t.dictionary):"[object ArrayBuffer]"===Dr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=vr.inflateSetDictionary(this.strm,t.dictionary),i!==Sr)))throw new Error(Lt[i])}function zr(e,t){const i=new Or(t);if(i.push(e),i.err)throw i.msg||Lt[i.err];return i.result}Or.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize,n=this.options.dictionary;let a,s,o;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Ir:Ur,"[object ArrayBuffer]"===Dr.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),a=vr.inflate(i,s),a===Mr&&n&&(a=vr.inflateSetDictionary(i,n),a===Sr?a=vr.inflate(i,s):a===Pr&&(a=Mr));i.avail_in>0&&a===Tr&&i.state.wrap>0&&0!==e[i.next_in];)vr.inflateReset(i),a=vr.inflate(i,s);switch(a){case Er:case Pr:case Mr:case Br:return this.onEnd(a),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||a===Tr))if("string"===this.options.to){let e=Ci(i.output,i.next_out),t=i.next_out-e,n=zi(i.output,e);i.next_out=t,i.avail_out=r-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(a!==Sr||0!==o){if(a===Tr)return a=vr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Or.prototype.onData=function(e){this.chunks.push(e)},Or.prototype.onEnd=function(e){e===Sr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ei(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:Or,inflate:zr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,zr(e,t)},ungzip:zr,constants:Vt};const{Inflate:Rr,inflate:Lr,inflateRaw:Vr,ungzip:Fr}=Cr;var Gr=Lr;var Nr=Object.freeze({__proto__:null,default:class extends He{decodeBlock(e){return Gr(new Uint8Array(e)).buffer}}});var Zr,Hr=Object.freeze({__proto__:null,default:class extends He{decodeBlock(e){const t=new DataView(e),i=[];for(let r=0;r<e.byteLength;++r){let e=t.getInt8(r);if(e<0){const n=t.getUint8(r+1);e=-e;for(let t=0;t<=e;++t)i.push(n);r+=1}else{for(let n=0;n<=e;++n)i.push(t.getUint8(r+n+1));r+=e+1}}return new Uint8Array(i).buffer}}}),Kr={exports:{}};Zr=Kr,
|
|
17
|
+
/* Copyright 2015-2021 Esri. 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 @preserve */
|
|
18
|
+
function(){var e,t,i,r,n,a,s,o,l,h,f,c,d,u,g,p,m=(e={defaultNoDataValue:-34027999387901484e22,decode:function(a,s){var o=(s=s||{}).encodedMaskData||null===s.encodedMaskData,l=n(a,s.inputOffset||0,o),h=null!==s.noDataValue?s.noDataValue:e.defaultNoDataValue,f=t(l,s.pixelType||Float32Array,s.encodedMaskData,h,s.returnMask),c={width:l.width,height:l.height,pixelData:f.resultPixels,minValue:f.minValue,maxValue:l.pixels.maxValue,noDataValue:h};return f.resultMask&&(c.maskData=f.resultMask),s.returnEncodedMask&&l.mask&&(c.encodedMaskData=l.mask.bitset?l.mask.bitset:null),s.returnFileInfo&&(c.fileInfo=i(l),s.computeUsedBitDepths&&(c.fileInfo.bitDepths=r(l))),c}},t=function(e,t,i,r,n){var s,o,l,h=0,f=e.pixels.numBlocksX,c=e.pixels.numBlocksY,d=Math.floor(e.width/f),u=Math.floor(e.height/c),g=2*e.maxZError,p=Number.MAX_VALUE;i=i||(e.mask?e.mask.bitset:null),o=new t(e.width*e.height),n&&i&&(l=new Uint8Array(e.width*e.height));for(var m,w,_=new Float32Array(d*u),b=0;b<=c;b++){var y=b!==c?u:e.height%c;if(0!==y)for(var k=0;k<=f;k++){var x=k!==f?d:e.width%f;if(0!==x){var v,A,D,U,I=b*e.width*u+k*d,S=e.width-x,T=e.pixels.blocks[h];if(T.encoding<2?(0===T.encoding?v=T.rawData:(a(T.stuffedData,T.bitsPerPixel,T.numValidPixels,T.offset,g,_,e.pixels.maxValue),v=_),A=0):D=2===T.encoding?0:T.offset,i)for(w=0;w<y;w++){for(7&I&&(U=i[I>>3],U<<=7&I),m=0;m<x;m++)7&I||(U=i[I>>3]),128&U?(l&&(l[I]=1),p=p>(s=T.encoding<2?v[A++]:D)?s:p,o[I++]=s):(l&&(l[I]=0),o[I++]=r),U<<=1;I+=S}else if(T.encoding<2)for(w=0;w<y;w++){for(m=0;m<x;m++)p=p>(s=v[A++])?s:p,o[I++]=s;I+=S}else for(p=p>D?D:p,w=0;w<y;w++){for(m=0;m<x;m++)o[I++]=D;I+=S}if(1===T.encoding&&A!==T.numValidPixels)throw"Block and Mask do not match";h++}}}return{resultPixels:o,resultMask:l,minValue:p}},i=function(e){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,noDataValue:e.noDataValue}}},r=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,i={},r=0;r<t;r++){var n=e.pixels.blocks[r];0===n.encoding?i.float32=!0:1===n.encoding?i[n.bitsPerPixel]=!0:i[0]=!0}return Object.keys(i)},n=function(e,t,i){var r={},n=new Uint8Array(e,t,10);if(r.fileIdentifierString=String.fromCharCode.apply(null,n),"CntZImage"!==r.fileIdentifierString.trim())throw"Unexpected file identifier string: "+r.fileIdentifierString;t+=10;var a=new DataView(e,t,24);if(r.fileVersion=a.getInt32(0,!0),r.imageType=a.getInt32(4,!0),r.height=a.getUint32(8,!0),r.width=a.getUint32(12,!0),r.maxZError=a.getFloat64(16,!0),t+=24,!i)if(a=new DataView(e,t,16),r.mask={},r.mask.numBlocksY=a.getUint32(0,!0),r.mask.numBlocksX=a.getUint32(4,!0),r.mask.numBytes=a.getUint32(8,!0),r.mask.maxValue=a.getFloat32(12,!0),t+=16,r.mask.numBytes>0){var s=new Uint8Array(Math.ceil(r.width*r.height/8)),o=(a=new DataView(e,t,r.mask.numBytes)).getInt16(0,!0),l=2,h=0;do{if(o>0)for(;o--;)s[h++]=a.getUint8(l++);else{var f=a.getUint8(l++);for(o=-o;o--;)s[h++]=f}o=a.getInt16(l,!0),l+=2}while(l<r.mask.numBytes);if(-32768!==o||h<s.length)throw"Unexpected end of mask RLE encoding";r.mask.bitset=s,t+=r.mask.numBytes}else 0==(r.mask.numBytes|r.mask.numBlocksY|r.mask.maxValue)&&(r.mask.bitset=new Uint8Array(Math.ceil(r.width*r.height/8)));a=new DataView(e,t,16),r.pixels={},r.pixels.numBlocksY=a.getUint32(0,!0),r.pixels.numBlocksX=a.getUint32(4,!0),r.pixels.numBytes=a.getUint32(8,!0),r.pixels.maxValue=a.getFloat32(12,!0),t+=16;var c=r.pixels.numBlocksX,d=r.pixels.numBlocksY,u=c+(r.width%c>0?1:0),g=d+(r.height%d>0?1:0);r.pixels.blocks=new Array(u*g);for(var p=0,m=0;m<g;m++)for(var w=0;w<u;w++){var _=0,b=e.byteLength-t;a=new DataView(e,t,Math.min(10,b));var y={};r.pixels.blocks[p++]=y;var k=a.getUint8(0);if(_++,y.encoding=63&k,y.encoding>3)throw"Invalid block encoding ("+y.encoding+")";if(2!==y.encoding){if(0!==k&&2!==k){if(k>>=6,y.offsetType=k,2===k)y.offset=a.getInt8(1),_++;else if(1===k)y.offset=a.getInt16(1,!0),_+=2;else{if(0!==k)throw"Invalid block offset type";y.offset=a.getFloat32(1,!0),_+=4}if(1===y.encoding)if(k=a.getUint8(_),_++,y.bitsPerPixel=63&k,k>>=6,y.numValidPixelsType=k,2===k)y.numValidPixels=a.getUint8(_),_++;else if(1===k)y.numValidPixels=a.getUint16(_,!0),_+=2;else{if(0!==k)throw"Invalid valid pixel count type";y.numValidPixels=a.getUint32(_,!0),_+=4}}var x;if(t+=_,3!==y.encoding)if(0===y.encoding){var v=(r.pixels.numBytes-1)/4;if(v!==Math.floor(v))throw"uncompressed block has invalid length";x=new ArrayBuffer(4*v),new Uint8Array(x).set(new Uint8Array(e,t,4*v));var A=new Float32Array(x);y.rawData=A,t+=4*v}else if(1===y.encoding){var D=Math.ceil(y.numValidPixels*y.bitsPerPixel/8),U=Math.ceil(D/4);x=new ArrayBuffer(4*U),new Uint8Array(x).set(new Uint8Array(e,t,D)),y.stuffedData=new Uint32Array(x),t+=D}}else t++}return r.eofOffset=t,r},a=function(e,t,i,r,n,a,s){var o,l,h,f=(1<<t)-1,c=0,d=0,u=Math.ceil((s-r)/n),g=4*e.length-Math.ceil(t*i/8);for(e[e.length-1]<<=8*g,o=0;o<i;o++){if(0===d&&(h=e[c++],d=32),d>=t)l=h>>>d-t&f,d-=t;else{var p=t-d;l=(h&f)<<p&f,l+=(h=e[c++])>>>(d=32-p)}a[o]=l<u?r+l*n:s}return a},e),w=(s=function(e,t,i,r,n,a,s,o){var l,h,f,c,d,u=(1<<i)-1,g=0,p=0,m=4*e.length-Math.ceil(i*r/8);if(e[e.length-1]<<=8*m,n)for(l=0;l<r;l++)0===p&&(f=e[g++],p=32),p>=i?(h=f>>>p-i&u,p-=i):(h=(f&u)<<(c=i-p)&u,h+=(f=e[g++])>>>(p=32-c)),t[l]=n[h];else for(d=Math.ceil((o-a)/s),l=0;l<r;l++)0===p&&(f=e[g++],p=32),p>=i?(h=f>>>p-i&u,p-=i):(h=(f&u)<<(c=i-p)&u,h+=(f=e[g++])>>>(p=32-c)),t[l]=h<d?a+h*s:o},o=function(e,t,i,r,n,a){var s,o=(1<<t)-1,l=0,h=0,f=0,c=0,d=0,u=[],g=4*e.length-Math.ceil(t*i/8);e[e.length-1]<<=8*g;var p=Math.ceil((a-r)/n);for(h=0;h<i;h++)0===c&&(s=e[l++],c=32),c>=t?(d=s>>>c-t&o,c-=t):(d=(s&o)<<(f=t-c)&o,d+=(s=e[l++])>>>(c=32-f)),u[h]=d<p?r+d*n:a;return u.unshift(r),u},l=function(e,t,i,r,n,a,s,o){var l,h,f,c,d=(1<<i)-1,u=0,g=0,p=0;if(n)for(l=0;l<r;l++)0===g&&(f=e[u++],g=32,p=0),g>=i?(h=f>>>p&d,g-=i,p+=i):(h=f>>>p&d,g=32-(c=i-g),h|=((f=e[u++])&(1<<c)-1)<<i-c,p=c),t[l]=n[h];else{var m=Math.ceil((o-a)/s);for(l=0;l<r;l++)0===g&&(f=e[u++],g=32,p=0),g>=i?(h=f>>>p&d,g-=i,p+=i):(h=f>>>p&d,g=32-(c=i-g),h|=((f=e[u++])&(1<<c)-1)<<i-c,p=c),t[l]=h<m?a+h*s:o}return t},h=function(e,t,i,r,n,a){var s,o=(1<<t)-1,l=0,h=0,f=0,c=0,d=0,u=0,g=[],p=Math.ceil((a-r)/n);for(h=0;h<i;h++)0===c&&(s=e[l++],c=32,u=0),c>=t?(d=s>>>u&o,c-=t,u+=t):(d=s>>>u&o,c=32-(f=t-c),d|=((s=e[l++])&(1<<f)-1)<<t-f,u=f),g[h]=d<p?r+d*n:a;return g.unshift(r),g},f=function(e,t,i,r){var n,a,s,o,l=(1<<i)-1,h=0,f=0,c=4*e.length-Math.ceil(i*r/8);for(e[e.length-1]<<=8*c,n=0;n<r;n++)0===f&&(s=e[h++],f=32),f>=i?(a=s>>>f-i&l,f-=i):(a=(s&l)<<(o=i-f)&l,a+=(s=e[h++])>>>(f=32-o)),t[n]=a;return t},c=function(e,t,i,r){var n,a,s,o,l=(1<<i)-1,h=0,f=0,c=0;for(n=0;n<r;n++)0===f&&(s=e[h++],f=32,c=0),f>=i?(a=s>>>c&l,f-=i,c+=i):(a=s>>>c&l,f=32-(o=i-f),a|=((s=e[h++])&(1<<o)-1)<<i-o,c=o),t[n]=a;return t},d={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(e){for(var t=65535,i=65535,r=e.length,n=Math.floor(r/2),a=0;n;){var s=n>=359?359:n;n-=s;do{t+=e[a++]<<8,i+=t+=e[a++]}while(--s);t=(65535&t)+(t>>>16),i=(65535&i)+(i>>>16)}return 1&r&&(i+=t+=e[a]<<8),((i=(65535&i)+(i>>>16))<<16|(t=(65535&t)+(t>>>16)))>>>0},readHeaderInfo:function(e,t){var i=t.ptr,r=new Uint8Array(e,i,6),n={};if(n.fileIdentifierString=String.fromCharCode.apply(null,r),0!==n.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+n.fileIdentifierString;i+=6;var a,s=new DataView(e,i,8),o=s.getInt32(0,!0);if(n.fileVersion=o,i+=4,o>=3&&(n.checksum=s.getUint32(4,!0),i+=4),s=new DataView(e,i,12),n.height=s.getUint32(0,!0),n.width=s.getUint32(4,!0),i+=8,o>=4?(n.numDims=s.getUint32(8,!0),i+=4):n.numDims=1,s=new DataView(e,i,40),n.numValidPixel=s.getUint32(0,!0),n.microBlockSize=s.getInt32(4,!0),n.blobSize=s.getInt32(8,!0),n.imageType=s.getInt32(12,!0),n.maxZError=s.getFloat64(16,!0),n.zMin=s.getFloat64(24,!0),n.zMax=s.getFloat64(32,!0),i+=40,t.headerInfo=n,t.ptr=i,o>=3&&(a=o>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(e,i-a,n.blobSize-14))!==n.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var i=t.headerInfo,r=this.getDataTypeArray(i.imageType),n=i.numDims*this.getDataTypeSize(i.imageType),a=this.readSubArray(e,t.ptr,r,n),s=this.readSubArray(e,t.ptr+n,r,n);t.ptr+=2*n;var o,l=!0;for(o=0;o<i.numDims;o++)if(a[o]!==s[o]){l=!1;break}return i.minValues=a,i.maxValues=s,l},readSubArray:function(e,t,i,r){var n;if(i===Uint8Array)n=new Uint8Array(e,t,r);else{var a=new ArrayBuffer(r);new Uint8Array(a).set(new Uint8Array(e,t,r)),n=new i(a)}return n},readMask:function(e,t){var i,r,n=t.ptr,a=t.headerInfo,s=a.width*a.height,o=a.numValidPixel,l=new DataView(e,n,4),h={};if(h.numBytes=l.getUint32(0,!0),n+=4,(0===o||s===o)&&0!==h.numBytes)throw"invalid mask";if(0===o)i=new Uint8Array(Math.ceil(s/8)),h.bitset=i,r=new Uint8Array(s),t.pixels.resultMask=r,n+=h.numBytes;else if(h.numBytes>0){i=new Uint8Array(Math.ceil(s/8));var f=(l=new DataView(e,n,h.numBytes)).getInt16(0,!0),c=2,d=0,u=0;do{if(f>0)for(;f--;)i[d++]=l.getUint8(c++);else for(u=l.getUint8(c++),f=-f;f--;)i[d++]=u;f=l.getInt16(c,!0),c+=2}while(c<h.numBytes);if(-32768!==f||d<i.length)throw"Unexpected end of mask RLE encoding";r=new Uint8Array(s);var g=0,p=0;for(p=0;p<s;p++)7&p?(g=i[p>>3],g<<=7&p):g=i[p>>3],128&g&&(r[p]=1);t.pixels.resultMask=r,h.bitset=i,n+=h.numBytes}return t.ptr=n,t.mask=h,!0},readDataOneSweep:function(e,t,i,r){var n,a=t.ptr,s=t.headerInfo,o=s.numDims,l=s.width*s.height,h=s.imageType,f=s.numValidPixel*d.getDataTypeSize(h)*o,c=t.pixels.resultMask;if(i===Uint8Array)n=new Uint8Array(e,a,f);else{var u=new ArrayBuffer(f);new Uint8Array(u).set(new Uint8Array(e,a,f)),n=new i(u)}if(n.length===l*o)t.pixels.resultPixels=r?d.swapDimensionOrder(n,l,o,i,!0):n;else{t.pixels.resultPixels=new i(l*o);var g=0,p=0,m=0,w=0;if(o>1){if(r){for(p=0;p<l;p++)if(c[p])for(w=p,m=0;m<o;m++,w+=l)t.pixels.resultPixels[w]=n[g++]}else for(p=0;p<l;p++)if(c[p])for(w=p*o,m=0;m<o;m++)t.pixels.resultPixels[w+m]=n[g++]}else for(p=0;p<l;p++)c[p]&&(t.pixels.resultPixels[p]=n[g++])}return a+=f,t.ptr=a,!0},readHuffmanTree:function(e,t){var i=this.HUFFMAN_LUT_BITS_MAX,r=new DataView(e,t.ptr,16);if(t.ptr+=16,r.getInt32(0,!0)<2)throw"unsupported Huffman version";var n=r.getInt32(4,!0),a=r.getInt32(8,!0),s=r.getInt32(12,!0);if(a>=s)return!1;var o=new Uint32Array(s-a);d.decodeBits(e,t,o);var l,h,f,c,g=[];for(l=a;l<s;l++)g[h=l-(l<n?0:n)]={first:o[l-a],second:null};var p=e.byteLength-t.ptr,m=Math.ceil(p/4),w=new ArrayBuffer(4*m);new Uint8Array(w).set(new Uint8Array(e,t.ptr,p));var _,b=new Uint32Array(w),y=0,k=0;for(_=b[0],l=a;l<s;l++)(c=g[h=l-(l<n?0:n)].first)>0&&(g[h].second=_<<y>>>32-c,32-y>=c?32===(y+=c)&&(y=0,_=b[++k]):(y+=c-32,_=b[++k],g[h].second|=_>>>32-y));var x=0,v=0,A=new u;for(l=0;l<g.length;l++)void 0!==g[l]&&(x=Math.max(x,g[l].first));v=x>=i?i:x;var D,U,I,S,T,M=[];for(l=a;l<s;l++)if((c=g[h=l-(l<n?0:n)].first)>0)if(D=[c,h],c<=v)for(U=g[h].second<<v-c,I=1<<v-c,f=0;f<I;f++)M[U|f]=D;else for(U=g[h].second,T=A,S=c-1;S>=0;S--)U>>>S&1?(T.right||(T.right=new u),T=T.right):(T.left||(T.left=new u),T=T.left),0!==S||T.val||(T.val=D[1]);return{decodeLut:M,numBitsLUTQick:v,numBitsLUT:x,tree:A,stuffedData:b,srcPtr:k,bitPos:y}},readHuffman:function(e,t,i,r){var n,a,s,o,l,h,f,c,u,g=t.headerInfo.numDims,p=t.headerInfo.height,m=t.headerInfo.width,w=m*p,_=this.readHuffmanTree(e,t),b=_.decodeLut,y=_.tree,k=_.stuffedData,x=_.srcPtr,v=_.bitPos,A=_.numBitsLUTQick,D=_.numBitsLUT,U=0===t.headerInfo.imageType?128:0,I=t.pixels.resultMask,S=0;v>0&&(x++,v=0);var T,M=k[x],E=1===t.encodeMode,P=new i(w*g),B=P;if(g<2||E){for(T=0;T<g;T++)if(g>1&&(B=new i(P.buffer,w*T,w),S=0),t.headerInfo.numValidPixel===m*p)for(c=0,h=0;h<p;h++)for(f=0;f<m;f++,c++){if(a=0,l=o=M<<v>>>32-A,32-v<A&&(l=o|=k[x+1]>>>64-v-A),b[l])a=b[l][1],v+=b[l][0];else for(l=o=M<<v>>>32-D,32-v<D&&(l=o|=k[x+1]>>>64-v-D),n=y,u=0;u<D;u++)if(!(n=o>>>D-u-1&1?n.right:n.left).left&&!n.right){a=n.val,v=v+u+1;break}v>=32&&(v-=32,M=k[++x]),s=a-U,E?(s+=f>0?S:h>0?B[c-m]:S,s&=255,B[c]=s,S=s):B[c]=s}else for(c=0,h=0;h<p;h++)for(f=0;f<m;f++,c++)if(I[c]){if(a=0,l=o=M<<v>>>32-A,32-v<A&&(l=o|=k[x+1]>>>64-v-A),b[l])a=b[l][1],v+=b[l][0];else for(l=o=M<<v>>>32-D,32-v<D&&(l=o|=k[x+1]>>>64-v-D),n=y,u=0;u<D;u++)if(!(n=o>>>D-u-1&1?n.right:n.left).left&&!n.right){a=n.val,v=v+u+1;break}v>=32&&(v-=32,M=k[++x]),s=a-U,E?(f>0&&I[c-1]?s+=S:h>0&&I[c-m]?s+=B[c-m]:s+=S,s&=255,B[c]=s,S=s):B[c]=s}}else for(c=0,h=0;h<p;h++)for(f=0;f<m;f++)if(c=h*m+f,!I||I[c])for(T=0;T<g;T++,c+=w){if(a=0,l=o=M<<v>>>32-A,32-v<A&&(l=o|=k[x+1]>>>64-v-A),b[l])a=b[l][1],v+=b[l][0];else for(l=o=M<<v>>>32-D,32-v<D&&(l=o|=k[x+1]>>>64-v-D),n=y,u=0;u<D;u++)if(!(n=o>>>D-u-1&1?n.right:n.left).left&&!n.right){a=n.val,v=v+u+1;break}v>=32&&(v-=32,M=k[++x]),s=a-U,B[c]=s}t.ptr=t.ptr+4*(x+1)+(v>0?4:0),t.pixels.resultPixels=P,g>1&&!r&&(t.pixels.resultPixels=d.swapDimensionOrder(P,w,g,i))},decodeBits:function(e,t,i,r,n){var a=t.headerInfo,d=a.fileVersion,u=0,g=e.byteLength-t.ptr>=5?5:e.byteLength-t.ptr,p=new DataView(e,t.ptr,g),m=p.getUint8(0);u++;var w=m>>6,_=0===w?4:3-w,b=(32&m)>0,y=31&m,k=0;if(1===_)k=p.getUint8(u),u++;else if(2===_)k=p.getUint16(u,!0),u+=2;else{if(4!==_)throw"Invalid valid pixel count type";k=p.getUint32(u,!0),u+=4}var x,v,A,D,U,I,S,T,M,E=2*a.maxZError,P=a.numDims>1?a.maxValues[n]:a.zMax;if(b){for(t.counter.lut++,T=p.getUint8(u),u++,D=Math.ceil((T-1)*y/8),U=Math.ceil(D/4),v=new ArrayBuffer(4*U),A=new Uint8Array(v),t.ptr+=u,A.set(new Uint8Array(e,t.ptr,D)),S=new Uint32Array(v),t.ptr+=D,M=0;T-1>>>M;)M++;D=Math.ceil(k*M/8),U=Math.ceil(D/4),v=new ArrayBuffer(4*U),(A=new Uint8Array(v)).set(new Uint8Array(e,t.ptr,D)),x=new Uint32Array(v),t.ptr+=D,I=d>=3?h(S,y,T-1,r,E,P):o(S,y,T-1,r,E,P),d>=3?l(x,i,M,k,I):s(x,i,M,k,I)}else t.counter.bitstuffer++,M=y,t.ptr+=u,M>0&&(D=Math.ceil(k*M/8),U=Math.ceil(D/4),v=new ArrayBuffer(4*U),(A=new Uint8Array(v)).set(new Uint8Array(e,t.ptr,D)),x=new Uint32Array(v),t.ptr+=D,d>=3?null==r?c(x,i,M,k):l(x,i,M,k,!1,r,E,P):null==r?f(x,i,M,k):s(x,i,M,k,!1,r,E,P))},readTiles:function(e,t,i,r){var n=t.headerInfo,a=n.width,s=n.height,o=a*s,l=n.microBlockSize,h=n.imageType,f=d.getDataTypeSize(h),c=Math.ceil(a/l),u=Math.ceil(s/l);t.pixels.numBlocksY=u,t.pixels.numBlocksX=c,t.pixels.ptr=0;var g,p,m,w,_,b,y,k,x,v,A=0,D=0,U=0,I=0,S=0,T=0,M=0,E=0,P=0,B=0,O=0,z=0,C=0,R=0,L=0,V=new i(l*l),F=s%l||l,G=a%l||l,N=n.numDims,Z=t.pixels.resultMask,H=t.pixels.resultPixels,K=n.fileVersion>=5?14:15,j=n.zMax;for(U=0;U<u;U++)for(S=U!==u-1?l:F,I=0;I<c;I++)for(B=U*a*l+I*l,O=a-(T=I!==c-1?l:G),k=0;k<N;k++){if(N>1?(v=H,B=U*a*l+I*l,H=new i(t.pixels.resultPixels.buffer,o*k*f,o),j=n.maxValues[k]):v=null,M=e.byteLength-t.ptr,p={},L=0,E=(g=new DataView(e,t.ptr,Math.min(10,M))).getUint8(0),L++,x=n.fileVersion>=5?4&E:0,P=E>>6&255,(E>>2&K)!=(I*l>>3&K))throw"integrity issue";if(x&&0===k)throw"integrity issue";if((_=3&E)>3)throw t.ptr+=L,"Invalid block encoding ("+_+")";if(2!==_)if(0===_){if(x)throw"integrity issue";if(t.counter.uncompressed++,t.ptr+=L,z=(z=S*T*f)<(C=e.byteLength-t.ptr)?z:C,m=new ArrayBuffer(z%f==0?z:z+f-z%f),new Uint8Array(m).set(new Uint8Array(e,t.ptr,z)),w=new i(m),R=0,Z)for(A=0;A<S;A++){for(D=0;D<T;D++)Z[B]&&(H[B]=w[R++]),B++;B+=O}else for(A=0;A<S;A++){for(D=0;D<T;D++)H[B++]=w[R++];B+=O}t.ptr+=R*f}else if(b=d.getDataTypeUsed(x&&h<6?4:h,P),y=d.getOnePixel(p,L,b,g),L+=d.getDataTypeSize(b),3===_)if(t.ptr+=L,t.counter.constantoffset++,Z)for(A=0;A<S;A++){for(D=0;D<T;D++)Z[B]&&(H[B]=x?Math.min(j,v[B]+y):y),B++;B+=O}else for(A=0;A<S;A++){for(D=0;D<T;D++)H[B]=x?Math.min(j,v[B]+y):y,B++;B+=O}else if(t.ptr+=L,d.decodeBits(e,t,V,y,k),L=0,x)if(Z)for(A=0;A<S;A++){for(D=0;D<T;D++)Z[B]&&(H[B]=V[L++]+v[B]),B++;B+=O}else for(A=0;A<S;A++){for(D=0;D<T;D++)H[B]=V[L++]+v[B],B++;B+=O}else if(Z)for(A=0;A<S;A++){for(D=0;D<T;D++)Z[B]&&(H[B]=V[L++]),B++;B+=O}else for(A=0;A<S;A++){for(D=0;D<T;D++)H[B++]=V[L++];B+=O}else{if(x)if(Z)for(A=0;A<S;A++)for(D=0;D<T;D++)Z[B]&&(H[B]=v[B]),B++;else for(A=0;A<S;A++)for(D=0;D<T;D++)H[B]=v[B],B++;t.counter.constant++,t.ptr+=L}}N>1&&!r&&(t.pixels.resultPixels=d.swapDimensionOrder(t.pixels.resultPixels,o,N,i))},formatFileInfo:function(e){return{fileIdentifierString:e.headerInfo.fileIdentifierString,fileVersion:e.headerInfo.fileVersion,imageType:e.headerInfo.imageType,height:e.headerInfo.height,width:e.headerInfo.width,numValidPixel:e.headerInfo.numValidPixel,microBlockSize:e.headerInfo.microBlockSize,blobSize:e.headerInfo.blobSize,maxZError:e.headerInfo.maxZError,pixelType:d.getPixelType(e.headerInfo.imageType),eofOffset:e.eofOffset,mask:e.mask?{numBytes:e.mask.numBytes}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,maxValue:e.headerInfo.zMax,minValue:e.headerInfo.zMin,noDataValue:e.noDataValue}}},constructConstantSurface:function(e,t){var i=e.headerInfo.zMax,r=e.headerInfo.zMin,n=e.headerInfo.maxValues,a=e.headerInfo.numDims,s=e.headerInfo.height*e.headerInfo.width,o=0,l=0,h=0,f=e.pixels.resultMask,c=e.pixels.resultPixels;if(f)if(a>1){if(t)for(o=0;o<a;o++)for(h=o*s,i=n[o],l=0;l<s;l++)f[l]&&(c[h+l]=i);else for(l=0;l<s;l++)if(f[l])for(h=l*a,o=0;o<a;o++)c[h+a]=n[o]}else for(l=0;l<s;l++)f[l]&&(c[l]=i);else if(a>1&&r!==i)if(t)for(o=0;o<a;o++)for(h=o*s,i=n[o],l=0;l<s;l++)c[h+l]=i;else for(l=0;l<s;l++)for(h=l*a,o=0;o<a;o++)c[h+o]=n[o];else for(l=0;l<s*a;l++)c[l]=i},getDataTypeArray:function(e){var t;switch(e){case 0:t=Int8Array;break;case 1:t=Uint8Array;break;case 2:t=Int16Array;break;case 3:t=Uint16Array;break;case 4:t=Int32Array;break;case 5:t=Uint32Array;break;case 6:default:t=Float32Array;break;case 7:t=Float64Array}return t},getPixelType:function(e){var t;switch(e){case 0:t="S8";break;case 1:t="U8";break;case 2:t="S16";break;case 3:t="U16";break;case 4:t="S32";break;case 5:t="U32";break;case 6:default:t="F32";break;case 7:t="F64"}return t},isValidPixelValue:function(e,t){if(null==t)return!1;var i;switch(e){case 0:i=t>=-128&&t<=127;break;case 1:i=t>=0&&t<=255;break;case 2:i=t>=-32768&&t<=32767;break;case 3:i=t>=0&&t<=65536;break;case 4:i=t>=-2147483648&&t<=2147483647;break;case 5:i=t>=0&&t<=4294967296;break;case 6:i=t>=-34027999387901484e22&&t<=34027999387901484e22;break;case 7:i=t>=-17976931348623157e292&&t<=17976931348623157e292;break;default:i=!1}return i},getDataTypeSize:function(e){var t=0;switch(e){case 0:case 1:t=1;break;case 2:case 3:t=2;break;case 4:case 5:case 6:t=4;break;case 7:t=8;break;default:t=e}return t},getDataTypeUsed:function(e,t){var i=e;switch(e){case 2:case 4:i=e-t;break;case 3:case 5:i=e-2*t;break;case 6:i=0===t?e:1===t?2:1;break;case 7:i=0===t?e:e-2*t+1;break;default:i=e}return i},getOnePixel:function(e,t,i,r){var n=0;switch(i){case 0:n=r.getInt8(t);break;case 1:n=r.getUint8(t);break;case 2:n=r.getInt16(t,!0);break;case 3:n=r.getUint16(t,!0);break;case 4:n=r.getInt32(t,!0);break;case 5:n=r.getUInt32(t,!0);break;case 6:n=r.getFloat32(t,!0);break;case 7:n=r.getFloat64(t,!0);break;default:throw"the decoder does not understand this pixel type"}return n},swapDimensionOrder:function(e,t,i,r,n){var a=0,s=0,o=0,l=0,h=e;if(i>1)if(h=new r(t*i),n)for(a=0;a<t;a++)for(l=a,o=0;o<i;o++,l+=t)h[l]=e[s++];else for(a=0;a<t;a++)for(l=a,o=0;o<i;o++,l+=t)h[s++]=e[l];return h}},u=function(e,t,i){this.val=e,this.left=t,this.right=i},{decode:function(e,t){var i=(t=t||{}).noDataValue,r=0,n={};n.ptr=t.inputOffset||0,n.pixels={},d.readHeaderInfo(e,n);var a=n.headerInfo,s=a.fileVersion,o=d.getDataTypeArray(a.imageType);if(s>5)throw"unsupported lerc version 2."+s;d.readMask(e,n),a.numValidPixel===a.width*a.height||n.pixels.resultMask||(n.pixels.resultMask=t.maskData);var l=a.width*a.height;n.pixels.resultPixels=new o(l*a.numDims),n.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var h,f=!t.returnPixelInterleavedDims;if(0!==a.numValidPixel)if(a.zMax===a.zMin)d.constructConstantSurface(n,f);else if(s>=4&&d.checkMinMaxRanges(e,n))d.constructConstantSurface(n,f);else{var c=new DataView(e,n.ptr,2),u=c.getUint8(0);if(n.ptr++,u)d.readDataOneSweep(e,n,o,f);else if(s>1&&a.imageType<=1&&Math.abs(a.maxZError-.5)<1e-5){var g=c.getUint8(1);if(n.ptr++,n.encodeMode=g,g>2||s<4&&g>1)throw"Invalid Huffman flag "+g;g?d.readHuffman(e,n,o,f):d.readTiles(e,n,o,f)}else d.readTiles(e,n,o,f)}n.eofOffset=n.ptr,t.inputOffset?(h=n.headerInfo.blobSize+t.inputOffset-n.ptr,Math.abs(h)>=1&&(n.eofOffset=t.inputOffset+n.headerInfo.blobSize)):(h=n.headerInfo.blobSize-n.ptr,Math.abs(h)>=1&&(n.eofOffset=n.headerInfo.blobSize));var p={width:a.width,height:a.height,pixelData:n.pixels.resultPixels,minValue:a.zMin,maxValue:a.zMax,validPixelCount:a.numValidPixel,dimCount:a.numDims,dimStats:{minValues:a.minValues,maxValues:a.maxValues},maskData:n.pixels.resultMask};if(n.pixels.resultMask&&d.isValidPixelValue(a.imageType,i)){var m=n.pixels.resultMask;for(r=0;r<l;r++)m[r]||(p.pixelData[r]=i);p.noDataValue=i}return n.noDataValue=i,t.returnFileInfo&&(p.fileInfo=d.formatFileInfo(n)),p},getBandCount:function(e){for(var t=0,i=0,r={ptr:0,pixels:{}};i<e.byteLength-58;)d.readHeaderInfo(e,r),i+=r.headerInfo.blobSize,t++,r.ptr=i;return t}}),_=(g=new ArrayBuffer(4),p=new Uint8Array(g),new Uint32Array(g)[0]=1,1===p[0]),b={decode:function(e,t){if(!_)throw"Big endian system is not supported.";var i,r,n=(t=t||{}).inputOffset||0,a=new Uint8Array(e,n,10),s=String.fromCharCode.apply(null,a);if("CntZImage"===s.trim())i=m,r=1;else{if("Lerc2"!==s.substring(0,5))throw"Unexpected file identifier string: "+s;i=w,r=2}for(var o,l,h,f,c,d,u=0,g=e.byteLength-10,p=[],b={width:0,height:0,pixels:[],pixelType:t.pixelType,mask:null,statistics:[]},y=0;n<g;){var k=i.decode(e,{inputOffset:n,encodedMaskData:o,maskData:h,returnMask:0===u,returnEncodedMask:0===u,returnFileInfo:!0,returnPixelInterleavedDims:t.returnPixelInterleavedDims,pixelType:t.pixelType||null,noDataValue:t.noDataValue||null});n=k.fileInfo.eofOffset,h=k.maskData,0===u&&(o=k.encodedMaskData,b.width=k.width,b.height=k.height,b.dimCount=k.dimCount||1,b.pixelType=k.pixelType||k.fileInfo.pixelType,b.mask=h),r>1&&(h&&p.push(h),k.fileInfo.mask&&k.fileInfo.mask.numBytes>0&&y++),u++,b.pixels.push(k.pixelData),b.statistics.push({minValue:k.minValue,maxValue:k.maxValue,noDataValue:k.noDataValue,dimStats:k.dimStats})}if(r>1&&y>1){for(d=b.width*b.height,b.bandMasks=p,(h=new Uint8Array(d)).set(p[0]),f=1;f<p.length;f++)for(l=p[f],c=0;c<d;c++)h[c]=h[c]&l[c];b.maskData=h}return b}};Zr.exports?Zr.exports=b:this.Lerc=b}();var jr=Kr.exports;var Wr=Object.freeze({__proto__:null,default:class extends He{constructor(e){super(),this.planarConfiguration=void 0!==e.PlanarConfiguration?e.PlanarConfiguration:1,this.samplesPerPixel=void 0!==e.SamplesPerPixel?e.SamplesPerPixel:1,this.addCompression=e.LercParameters[we]}decodeBlock(e){switch(this.addCompression){case _e:break;case be:e=Gr(new Uint8Array(e)).buffer;break;default:throw new Error(`Unsupported LERC additional compression method identifier: ${this.addCompression}`)}return jr.decode(e,{returnPixelInterleavedDims:1===this.planarConfiguration}).pixels[0].buffer}}});var Yr=Object.freeze({__proto__:null,default:class extends He{constructor(){if(super(),"undefined"==typeof createImageBitmap)throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");if("undefined"==typeof document&&"undefined"==typeof OffscreenCanvas)throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available")}async decode(e,t){const i=new Blob([t]),r=await createImageBitmap(i);let n;"undefined"!=typeof document?(n=document.createElement("canvas"),n.width=r.width,n.height=r.height):n=new OffscreenCanvas(r.width,r.height);const a=n.getContext("2d");return a.drawImage(r,0,0),a.getImageData(0,0,r.width,r.height).data.buffer}}});exports.GeoImage=Fe,exports.useGeoData=function(r,n,a){void 0===n&&(n=!1);var s=new Fe,o=e.useState(Ge),l=o[0],h=o[1];return e.useEffect((function(){r&&(h(Ge),t(void 0,void 0,void 0,(function(){var e,t,a,o;return i(this,(function(i){switch(i.label){case 0:return[4,s.getBitmap(r)];case 1:return e=i.sent(),t=s.getBoundingBox(),console.log(t),a={longitude:t[0],latitude:t[1],zoom:12},o="",n?[4,s.getHeightMap(r)]:[3,3];case 2:o=i.sent(),i.label=3;case 3:return h({image:e,bbox:t,viewState:a,heightMap:o,loaded:!0}),[2]}}))})))}),[r,a]),l};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|