All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
5 lines
230 KiB
JavaScript
5 lines
230 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).GeoTIFF={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e){if(Array.isArray(e))return e}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function a(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(e,t){return r(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a=[],o=!0,s=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==r.return||r.return()}finally{if(s)throw i}}return a}}(e,t)||i(e,t)||a()}function s(e,t,r,n,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function o(e){s(a,n,i,o,u,"next",e)}function u(e){s(a,n,i,o,u,"throw",e)}o(void 0)}))}}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),e}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function g(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function y(e,t,r){return y=g()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&c(i,r.prototype),i},y.apply(null,arguments)}function w(e){var t="function"==typeof Map?new Map:void 0;return w=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return y(e,arguments,m(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)},w(e)}function b(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var k={exports:{}};!function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),o=new U(n||[]);return a._invoke=function(e,t,r){var n=c;return function(i,a){if(n===p)throw new Error("Generator is already running");if(n===v){if("throw"===i)throw a;return D()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=I(o,r);if(s){if(s===m)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===c)throw n=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var u=l(e,t,r);if("normal"===u.type){if(n=r.done?v:h,u.arg===m)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=v,r.method="throw",r.arg=u.arg)}}}(e,r,o),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var c="suspendedStart",h="suspendedYield",p="executing",v="completed",m={};function g(){}function y(){}function w(){}var b={};u(b,a,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(O([])));x&&x!==r&&n.call(x,a)&&(b=x);var A=w.prototype=g.prototype=Object.create(b);function P(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function r(i,a,o,s){var u=l(e[i],e,a);if("throw"!==u.type){var f=u.arg,c=f.value;return c&&"object"===d(c)&&n.call(c,"__await")?t.resolve(c.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(c).then((function(e){f.value=e,o(f)}),(function(e){return r("throw",e,o,s)}))}s(u.arg)}var i;this._invoke=function(e,n){function a(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(a,a):a()}}function I(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method))return m;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var i=l(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function U(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function O(e){if(e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}return{next:D}}function D(){return{value:t,done:!0}}return y.prototype=w,u(A,"constructor",w),u(w,"constructor",y),y.displayName=u(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,u(e,s,"GeneratorFunction")),e.prototype=Object.create(A),e},e.awrap=function(e){return{__await:e}},P(_.prototype),u(_.prototype,o,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new _(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},P(A),u(A,s,"Generator"),u(A,a,(function(){return this})),u(A,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=O,U.prototype={constructor:U,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),f=n.call(o,"finallyLoc");if(u&&f){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!f)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"===("undefined"==typeof globalThis?"undefined":d(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(k);for(var x=k.exports,A=new ArrayBuffer(4),P=new Float32Array(A),_=new Uint32Array(A),I=new Uint32Array(512),S=new Uint32Array(512),T=0;T<256;++T){var U=T-127;U<-27?(I[T]=0,I[256|T]=32768,S[T]=24,S[256|T]=24):U<-14?(I[T]=1024>>-U-14,I[256|T]=1024>>-U-14|32768,S[T]=-U-1,S[256|T]=-U-1):U<=15?(I[T]=U+15<<10,I[256|T]=U+15<<10|32768,S[T]=13,S[256|T]=13):U<128?(I[T]=31744,I[256|T]=64512,S[T]=24,S[256|T]=24):(I[T]=31744,I[256|T]=64512,S[T]=13,S[256|T]=13)}var O=new Uint32Array(2048),D=new Uint32Array(64),E=new Uint32Array(64);O[0]=0;for(var R=1;R<1024;++R){for(var M=R<<13,B=0;0==(8388608&M);)B-=8388608,M<<=1;M&=-8388609,B+=947912704,O[R]=M|B}for(var C=1024;C<2048;++C)O[C]=939524096+(C-1024<<13);D[0]=0;for(var L=1;L<31;++L)D[L]=L<<23;D[31]=1199570944,D[32]=2147483648;for(var F=33;F<63;++F)D[F]=2147483648+(F-32<<23);D[63]=3347054592,E[0]=0;for(var V=1;V<64;++V)E[V]=32===V?0:1024;function G(e){var t=e>>10;return _[0]=O[E[t]+(1023&e)]+D[t],P[0]}var j=Reflect.getPrototypeOf(Uint8Array).prototype,N=Reflect.getOwnPropertyDescriptor(j,Symbol.toStringTag).get;var z=Object.prototype.toString;function K(e){return!!ArrayBuffer.isView(e)&&(!function(e){return void 0!==N.call(e)}(e)&&"[object DataView]"===z.call(e))}function Z(e,t){if(!K(e))throw new TypeError("First argument to getFloat16 function must be a DataView");for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return G(e.getUint16.apply(e,[t].concat(n)))}var H=function(e,t,r){var n=r&&r.debug||!1;n&&console.log("getting "+t+" in "+e);var i="object"===d(e)?e.outer:e,a="".concat(t,'\\="([^"]*)"');n&&console.log("pattern:",a);var o=new RegExp(a).exec(i);if(n&&console.log("match:",o),o)return o[1]};var Y=function(e,t,r){var n=new RegExp(t).exec(e.slice(r));return n?r+n.index:-1};var q=function(e,t,r){var n=r&&r.debug||!1,i=r&&r.startIndex||0;n&&console.log("starting findTagByName with",t," and ",r);var a=Y(e,"<".concat(t,"[ >]"),i);if(n&&console.log("start:",a),-1!==a){var o=e.slice(a+t.length),s=Y(o,"[ /]"+t+">",0),u=-1===s;u&&(s=Y(o,"[ /]>",0));var f=a+t.length+s+1+(u?0:t.length)+1;if(n&&console.log("end:",f),-1!==f){var l=e.slice(a,f);return{inner:u?null:l.slice(l.indexOf(">")+1,l.lastIndexOf("<")),outer:l,start:a,end:f}}}};var X=function(e,t,r){for(var n,i=[],a=r&&r.debug||!1,o=r&&r.startIndex||0;n=q(e,t,{debug:a,startIndex:o});)o=n.end,i.push(n);return a&&console.log("findTagsByName found",i.length,"tags"),i},W={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"},J={};for(var Q in W)W.hasOwnProperty(Q)&&(J[W[Q]]=parseInt(Q,10));var $={256:"SHORT",257:"SHORT",258:"SHORT",259:"SHORT",262:"SHORT",273:"LONG",274:"SHORT",277:"SHORT",278:"LONG",279:"LONG",282:"RATIONAL",283:"RATIONAL",284:"SHORT",286:"SHORT",287:"RATIONAL",296:"SHORT",297:"SHORT",305:"ASCII",306:"ASCII",338:"SHORT",339:"SHORT",513:"LONG",514:"LONG",1024:"SHORT",1025:"SHORT",2048:"SHORT",2049:"ASCII",3072:"SHORT",3073:"ASCII",33550:"DOUBLE",33922:"DOUBLE",34665:"LONG",34735:"SHORT",34737:"ASCII",42113:"ASCII"},ee=[J.BitsPerSample,J.ExtraSamples,J.SampleFormat,J.StripByteCounts,J.StripOffsets,J.StripRowCounts,J.TileByteCounts,J.TileOffsets,J.SubIFDs],te={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"},re={};for(var ne in te)te.hasOwnProperty(ne)&&(re[te[ne]]=parseInt(ne,10));var ie={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9},ae={Unspecified:0,Assocalpha:1,Unassalpha:2},oe={Version:0,AddCompression:1},se={None:0,Deflate:1},ue={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"},fe={};for(var le in ue)ue.hasOwnProperty(le)&&(fe[ue[le]]=parseInt(le,10));var ce=Object.freeze({__proto__:null,fieldTagNames:W,fieldTags:J,fieldTagTypes:$,arrayFields:ee,fieldTypeNames:te,fieldTypes:re,photometricInterpretations:ie,ExtraSamplesValues:ae,LercParameters:oe,LercAddCompression:se,geoKeyNames:ue,geoKeys:fe});function he(e,t){for(var r,n=e.width,i=e.height,a=new Uint8Array(n*i*3),o=0,s=0;o<e.length;++o,s+=3)r=256-e[o]/t*256,a[s]=r,a[s+1]=r,a[s+2]=r;return a}function de(e,t){for(var r,n=e.width,i=e.height,a=new Uint8Array(n*i*3),o=0,s=0;o<e.length;++o,s+=3)r=e[o]/t*256,a[s]=r,a[s+1]=r,a[s+2]=r;return a}function pe(e,t){for(var r=e.width,n=e.height,i=new Uint8Array(r*n*3),a=t.length/3,o=t.length/3*2,s=0,u=0;s<e.length;++s,u+=3){var f=e[s];i[u]=t[f]/65536*256,i[u+1]=t[f+a]/65536*256,i[u+2]=t[f+o]/65536*256}return i}function ve(e){for(var t=e.width,r=e.height,n=new Uint8Array(t*r*3),i=0,a=0;i<e.length;i+=4,a+=3){var o=e[i],s=e[i+1],u=e[i+2],f=e[i+3];n[a]=(255-o)/256*255*((255-f)/256),n[a+1]=(255-s)/256*255*((255-f)/256),n[a+2]=(255-u)/256*255*((255-f)/256)}return n}function me(e){for(var t=e.width,r=e.height,n=new Uint8ClampedArray(t*r*3),i=0,a=0;i<e.length;i+=3,a+=3){var o=e[i],s=e[i+1],u=e[i+2];n[a]=o+1.402*(u-128),n[a+1]=o-.34414*(s-128)-.71414*(u-128),n[a+2]=o+1.772*(s-128)}return n}function ge(e){for(var t=e.width,r=e.height,n=new Uint8Array(t*r*3),i=0,a=0;i<e.length;i+=3,a+=3){var o=(e[i+0]+16)/116,s=(e[i+1]<<24>>24)/500+o,u=o-(e[i+2]<<24>>24)/200,f=void 0,l=void 0,c=void 0;l=-.9689*(s=.95047*(s*s*s>.008856?s*s*s:(s-16/116)/7.787))+1.8758*(o=1*(o*o*o>.008856?o*o*o:(o-16/116)/7.787))+.0415*(u=1.08883*(u*u*u>.008856?u*u*u:(u-16/116)/7.787)),c=.0557*s+-.204*o+1.057*u,f=(f=3.2406*s+-1.5372*o+-.4986*u)>.0031308?1.055*Math.pow(f,1/2.4)-.055:12.92*f,l=l>.0031308?1.055*Math.pow(l,1/2.4)-.055:12.92*l,c=c>.0031308?1.055*Math.pow(c,1/2.4)-.055:12.92*c,n[a]=255*Math.max(0,Math.min(1,f)),n[a+1]=255*Math.max(0,Math.min(1,l)),n[a+2]=255*Math.max(0,Math.min(1,c))}return n}var ye=Object.freeze({__proto__:null,fromWhiteIsZero:he,fromBlackIsZero:de,fromPalette:pe,fromCMYK:ve,fromYCbCr:me,fromCIELab:ge}),we=new Map;function be(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){return we.set(e,t)}))}function ke(e){return xe.apply(this,arguments)}function xe(){return(xe=u(x.mark((function e(t){var r,n;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=we.get(t.Compression)){e.next=3;break}throw new Error("Unknown compression method identifier: ".concat(t.Compression));case 3:return e.next=5,r();case 5:return n=e.sent,e.abrupt("return",new n(t));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ae(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return new(Object.getPrototypeOf(e).constructor)(t*r*n)}function Pe(e,t,r,n,i){var a=t/n,o=r/i;return e.map((function(e){for(var s=Ae(e,n,i),u=0;u<i;++u)for(var f=Math.min(Math.round(o*u),r-1),l=0;l<n;++l){var c=Math.min(Math.round(a*l),t-1),h=e[f*t+c];s[u*n+l]=h}return s}))}function _e(e,t,r){return(1-r)*e+r*t}function Ie(e,t,r,n,i){var a=t/n,o=r/i;return e.map((function(e){for(var s=Ae(e,n,i),u=0;u<i;++u)for(var f=o*u,l=Math.floor(f),c=Math.min(Math.ceil(f),r-1),h=0;h<n;++h){var d=a*h,p=d%1,v=Math.floor(d),m=Math.min(Math.ceil(d),t-1),g=e[l*t+v],y=e[l*t+m],w=e[c*t+v],b=e[c*t+m],k=_e(_e(g,y,p),_e(w,b,p),f%1);s[u*n+h]=k}return s}))}function Se(e,t,r,n,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"nearest";switch(a.toLowerCase()){case"nearest":return Pe(e,t,r,n,i);case"bilinear":case"linear":return Ie(e,t,r,n,i);default:throw new Error("Unsupported resampling method: '".concat(a,"'"))}}function Te(e,t,r,n,i,a){for(var o=t/n,s=r/i,u=Ae(e,n,i,a),f=0;f<i;++f)for(var l=Math.min(Math.round(s*f),r-1),c=0;c<n;++c)for(var h=Math.min(Math.round(o*c),t-1),d=0;d<a;++d){var p=e[l*t*a+h*a+d];u[f*n*a+c*a+d]=p}return u}function Ue(e,t,r,n,i,a){for(var o=t/n,s=r/i,u=Ae(e,n,i,a),f=0;f<i;++f)for(var l=s*f,c=Math.floor(l),h=Math.min(Math.ceil(l),r-1),d=0;d<n;++d)for(var p=o*d,v=p%1,m=Math.floor(p),g=Math.min(Math.ceil(p),t-1),y=0;y<a;++y){var w=e[c*t*a+m*a+y],b=e[c*t*a+g*a+y],k=e[h*t*a+m*a+y],x=e[h*t*a+g*a+y],A=_e(_e(w,b,v),_e(k,x,v),l%1);u[f*n*a+d*a+y]=A}return u}function Oe(e,t,r,n,i,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"nearest";switch(o.toLowerCase()){case"nearest":return Te(e,t,r,n,i,a);case"bilinear":case"linear":return Ue(e,t,r,n,i,a);default:throw new Error("Unsupported resampling method: '".concat(o,"'"))}}function De(e,t,r){for(var n=0,i=t;i<r;++i)n+=e[i];return n}function Ee(e,t,r){switch(e){case 1:if(t<=8)return new Uint8Array(r);if(t<=16)return new Uint16Array(r);if(t<=32)return new Uint32Array(r);break;case 2:if(8===t)return new Int8Array(r);if(16===t)return new Int16Array(r);if(32===t)return new Int32Array(r);break;case 3:switch(t){case 16:case 32:return new Float32Array(r);case 64:return new Float64Array(r)}}throw Error("Unsupported data format/bitsPerSample")}function Re(e,t){return(1!==e&&2!==e||!(t<=32)||t%8!=0)&&(3!==e||16!==t&&32!==t&&64!==t)}function Me(e,t,r,n,i,a,o){var s=new DataView(e),u=2===r?1:n,f=Ee(t,i,2===r?o*a:o*a*n),l=parseInt("1".repeat(i),2);if(1===t){var c=a*(1===r?n*i:i);0!=(7&c)&&(c=c+7&-8);for(var h=0;h<o;++h)for(var d=h*c,p=0;p<a;++p)for(var v=d+p*u*i,m=0;m<u;++m){var g=v+m*i,y=(h*a+p)*u+m,w=Math.floor(g/8),b=g%8;if(b+i<=8)f[y]=s.getUint8(w)>>8-i-b&l;else if(b+i<=16)f[y]=s.getUint16(w)>>16-i-b&l;else if(b+i<=24){var k=s.getUint16(w)<<8|s.getUint8(w+2);f[y]=k>>24-i-b&l}else f[y]=s.getUint32(w)>>32-i-b&l}}return f.buffer}be([void 0,1],(function(){return Promise.resolve().then((function(){return an})).then((function(e){return e.default}))})),be(5,(function(){return Promise.resolve().then((function(){return ln})).then((function(e){return e.default}))})),be(6,(function(){throw new Error("old style JPEG compression is not supported.")})),be(7,(function(){return Promise.resolve().then((function(){return In})).then((function(e){return e.default}))})),be([8,32946],(function(){return Promise.resolve().then((function(){return Ci})).then((function(e){return e.default}))})),be(32773,(function(){return Promise.resolve().then((function(){return Vi})).then((function(e){return e.default}))})),be(34887,(function(){return Promise.resolve().then((function(){return Ki})).then((function(e){return e.default}))})),be(50001,(function(){return Promise.resolve().then((function(){return Yi})).then((function(e){return e.default}))}));var Be=function(){function e(t,r,n,i,a,o){b(this,e),this.fileDirectory=t,this.geoKeys=r,this.dataView=n,this.littleEndian=i,this.tiles=a?{}:null,this.isTiled=!t.StripOffsets;var s=t.PlanarConfiguration;if(this.planarConfiguration=void 0===s?1:s,1!==this.planarConfiguration&&2!==this.planarConfiguration)throw new Error("Invalid planar configuration.");this.source=o}var t,r,n,i;return l(e,[{key:"getFileDirectory",value:function(){return this.fileDirectory}},{key:"getGeoKeys",value:function(){return this.geoKeys}},{key:"getWidth",value:function(){return this.fileDirectory.ImageWidth}},{key:"getHeight",value:function(){return this.fileDirectory.ImageLength}},{key:"getSamplesPerPixel",value:function(){return void 0!==this.fileDirectory.SamplesPerPixel?this.fileDirectory.SamplesPerPixel:1}},{key:"getTileWidth",value:function(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}},{key:"getTileHeight",value:function(){return this.isTiled?this.fileDirectory.TileLength:void 0!==this.fileDirectory.RowsPerStrip?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}},{key:"getBlockWidth",value:function(){return this.getTileWidth()}},{key:"getBlockHeight",value:function(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}},{key:"getBytesPerPixel",value:function(){for(var e=0,t=0;t<this.fileDirectory.BitsPerSample.length;++t)e+=this.getSampleByteSize(t);return e}},{key:"getSampleByteSize",value:function(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError("Sample index ".concat(e," is out of range."));return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}},{key:"getReaderForSample",value:function(e){var t=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,r=this.fileDirectory.BitsPerSample[e];switch(t){case 1:if(r<=8)return DataView.prototype.getUint8;if(r<=16)return DataView.prototype.getUint16;if(r<=32)return DataView.prototype.getUint32;break;case 2:if(r<=8)return DataView.prototype.getInt8;if(r<=16)return DataView.prototype.getInt16;if(r<=32)return DataView.prototype.getInt32;break;case 3:switch(r){case 16:return function(e,t){return Z(this,e,t)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}throw Error("Unsupported data format/bitsPerSample")}},{key:"getSampleFormat",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}},{key:"getBitsPerSample",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.fileDirectory.BitsPerSample[e]}},{key:"getArrayForSample",value:function(e,t){return Ee(this.getSampleFormat(e),this.getBitsPerSample(e),t)}},{key:"getTileOrStrip",value:(i=u(x.mark((function e(t,r,n,i,a){var o,s,f,l,c,h,d,p,v=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=Math.ceil(this.getWidth()/this.getTileWidth()),s=Math.ceil(this.getHeight()/this.getTileHeight()),l=this.tiles,1===this.planarConfiguration?f=r*o+t:2===this.planarConfiguration&&(f=n*o*s+r*o+t),this.isTiled?(c=this.fileDirectory.TileOffsets[f],h=this.fileDirectory.TileByteCounts[f]):(c=this.fileDirectory.StripOffsets[f],h=this.fileDirectory.StripByteCounts[f]),e.next=7,this.source.fetch([{offset:c,length:h}],a);case 7:return d=e.sent[0],null!==l&&l[f]?p=l[f]:(p=u(x.mark((function e(){var t,n,a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.decode(v.fileDirectory,d);case 2:return t=e.sent,n=v.getSampleFormat(),a=v.getBitsPerSample(),Re(n,a)&&(t=Me(t,n,v.planarConfiguration,v.getSamplesPerPixel(),a,v.getTileWidth(),v.getBlockHeight(r))),e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})))(),null!==l&&(l[f]=p)),e.t0=t,e.t1=r,e.t2=n,e.next=14,p;case 14:return e.t3=e.sent,e.abrupt("return",{x:e.t0,y:e.t1,sample:e.t2,data:e.t3});case 16:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return i.apply(this,arguments)})},{key:"_readRaster",value:(n=u(x.mark((function e(t,r,n,i,a,o,s,u,f){var l,c,h,d,p,v,m,g,y,w,b,k,A,P,_,I,S,T,U,O,D=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(l=this.getTileWidth(),c=this.getTileHeight(),h=this.getWidth(),d=this.getHeight(),p=Math.max(Math.floor(t[0]/l),0),v=Math.min(Math.ceil(t[2]/l),Math.ceil(h/l)),m=Math.max(Math.floor(t[1]/c),0),g=Math.min(Math.ceil(t[3]/c),Math.ceil(d/c)),y=t[2]-t[0],w=this.getBytesPerPixel(),b=[],k=[],A=0;A<r.length;++A)1===this.planarConfiguration?b.push(De(this.fileDirectory.BitsPerSample,0,r[A])/8):b.push(0),k.push(this.getReaderForSample(r[A]));for(P=[],_=this.littleEndian,I=m;I<g;++I)for(S=p;S<v;++S)for(T=function(e){var o=e,s=r[e];2===D.planarConfiguration&&(w=D.getSampleByteSize(e));var u=D.getTileOrStrip(S,I,s,a,f);P.push(u),u.then((function(e){for(var a=e.data,s=new DataView(a),u=D.getBlockHeight(e.y),f=e.y*c,p=e.x*l,v=f+u,m=(e.x+1)*l,g=k[o],x=Math.min(u,u-(v-t[3]),d-f),A=Math.min(l,l-(m-t[2]),h-p),P=Math.max(0,t[1]-f);P<x;++P)for(var I=Math.max(0,t[0]-p);I<A;++I){var S=(P*l+I)*w,T=g.call(s,S+b[o],_),U=void 0;i?(U=(P+f-t[1])*y*r.length+(I+p-t[0])*r.length+o,n[U]=T):(U=(P+f-t[1])*y+I+p-t[0],n[o][U]=T)}}))},U=0;U<r.length;++U)T(U);return e.next=18,Promise.all(P);case 18:if(!(o&&t[2]-t[0]!==o||s&&t[3]-t[1]!==s)){e.next=23;break}return(O=i?Oe(n,t[2]-t[0],t[3]-t[1],o,s,r.length,u):Se(n,t[2]-t[0],t[3]-t[1],o,s,u)).width=o,O.height=s,e.abrupt("return",O);case 23:return n.width=o||t[2]-t[0],n.height=s||t[3]-t[1],e.abrupt("return",n);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,a,o,s,u,f){return n.apply(this,arguments)})},{key:"readRasters",value:(r=u(x.mark((function e(){var t,r,n,i,a,o,s,u,f,l,c,h,d,p,v,m,g,y,w,b,k,A,P,_,I,S,T=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=T.length>0&&void 0!==T[0]?T[0]:{},r=t.window,n=t.samples,i=void 0===n?[]:n,a=t.interleave,o=t.pool,s=void 0===o?null:o,u=t.width,f=t.height,l=t.resampleMethod,c=t.fillValue,h=t.signal,!((d=r||[0,0,this.getWidth(),this.getHeight()])[0]>d[2]||d[1]>d[3])){e.next=4;break}throw new Error("Invalid subsets");case 4:if(p=d[2]-d[0],v=d[3]-d[1],m=p*v,g=this.getSamplesPerPixel(),i&&i.length){e.next=12;break}for(y=0;y<g;++y)i.push(y);e.next=19;break;case 12:w=0;case 13:if(!(w<i.length)){e.next=19;break}if(!(i[w]>=g)){e.next=16;break}return e.abrupt("return",Promise.reject(new RangeError("Invalid sample index '".concat(i[w],"'."))));case 16:++w,e.next=13;break;case 19:if(a)k=this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,A=Math.max.apply(null,this.fileDirectory.BitsPerSample),b=Ee(k,A,m*i.length),c&&b.fill(c);else for(b=[],P=0;P<i.length;++P)_=this.getArrayForSample(i[P],m),Array.isArray(c)&&P<c.length?_.fill(c[P]):c&&!Array.isArray(c)&&_.fill(c),b.push(_);if(e.t0=s,e.t0){e.next=25;break}return e.next=24,ke(this.fileDirectory);case 24:e.t0=e.sent;case 25:return I=e.t0,e.next=28,this._readRaster(d,i,b,a,I,u,f,l,h);case 28:return S=e.sent,e.abrupt("return",S);case 30:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"readRGB",value:(t=u(x.mark((function e(){var t,r,n,i,a,o,s,u,f,l,c,h,d,p,v,m,g,y,w,b,k,A,P,_,I,S,T,U=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=U.length>0&&void 0!==U[0]?U[0]:{},r=t.window,n=t.interleave,i=void 0===n||n,a=t.pool,o=void 0===a?null:a,s=t.width,u=t.height,f=t.resampleMethod,l=t.enableAlpha,c=void 0!==l&&l,h=t.signal,!((d=r||[0,0,this.getWidth(),this.getHeight()])[0]>d[2]||d[1]>d[3])){e.next=4;break}throw new Error("Invalid subsets");case 4:if((p=this.fileDirectory.PhotometricInterpretation)!==ie.RGB){e.next=9;break}if(v=[0,1,2],this.fileDirectory.ExtraSamples!==ae.Unspecified&&c)for(v=[],m=0;m<this.fileDirectory.BitsPerSample.length;m+=1)v.push(m);return e.abrupt("return",this.readRasters({window:r,interleave:i,samples:v,pool:o,width:s,height:u,resampleMethod:f,signal:h}));case 9:e.t0=p,e.next=e.t0===ie.WhiteIsZero||e.t0===ie.BlackIsZero||e.t0===ie.Palette?12:e.t0===ie.CMYK?14:e.t0===ie.YCbCr||e.t0===ie.CIELab?16:18;break;case 12:return g=[0],e.abrupt("break",19);case 14:return g=[0,1,2,3],e.abrupt("break",19);case 16:return g=[0,1,2],e.abrupt("break",19);case 18:throw new Error("Invalid or unsupported photometric interpretation.");case 19:return y={window:d,interleave:!0,samples:g,pool:o,width:s,height:u,resampleMethod:f,signal:h},w=this.fileDirectory,e.next=23,this.readRasters(y);case 23:b=e.sent,k=Math.pow(2,this.fileDirectory.BitsPerSample[0]),e.t1=p,e.next=e.t1===ie.WhiteIsZero?28:e.t1===ie.BlackIsZero?30:e.t1===ie.Palette?32:e.t1===ie.CMYK?34:e.t1===ie.YCbCr?36:e.t1===ie.CIELab?38:40;break;case 28:return A=he(b,k),e.abrupt("break",41);case 30:return A=de(b,k),e.abrupt("break",41);case 32:return A=pe(b,w.ColorMap),e.abrupt("break",41);case 34:return A=ve(b),e.abrupt("break",41);case 36:return A=me(b),e.abrupt("break",41);case 38:return A=ge(b),e.abrupt("break",41);case 40:throw new Error("Unsupported photometric interpretation.");case 41:if(!i){for(P=new Uint8Array(A.length/3),_=new Uint8Array(A.length/3),I=new Uint8Array(A.length/3),S=0,T=0;S<A.length;S+=3,++T)P[T]=A[S],_[T]=A[S+1],I[T]=A[S+2];A=[P,_,I]}return A.width=b.width,A.height=b.height,e.abrupt("return",A);case 45:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getTiePoints",value:function(){if(!this.fileDirectory.ModelTiepoint)return[];for(var e=[],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}},{key:"getGDALMetadata",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t={};if(!this.fileDirectory.GDAL_METADATA)return null;var r=this.fileDirectory.GDAL_METADATA,n=X(r,"Item");n=null===e?n.filter((function(e){return void 0===H(e,"sample")})):n.filter((function(t){return Number(H(t,"sample"))===e}));for(var i=0;i<n.length;++i){var a=n[i];t[H(a,"name")]=a.inner}return t}},{key:"getGDALNoData",value:function(){if(!this.fileDirectory.GDAL_NODATA)return null;var e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}},{key:"getOrigin",value:function(){var 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.")}},{key:"getResolution",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this.fileDirectory.ModelPixelScale,r=this.fileDirectory.ModelTransformation;if(t)return[t[0],-t[1],t[2]];if(r)return[r[0],r[5],r[10]];if(e){var n=e.getResolution(),i=o(n,3),a=i[0],s=i[1],u=i[2];return[a*e.getWidth()/this.getWidth(),s*e.getHeight()/this.getHeight(),u*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}},{key:"pixelIsArea",value:function(){return 1===this.geoKeys.GTRasterTypeGeoKey}},{key:"getBoundingBox",value:function(){var e=this.getOrigin(),t=this.getResolution(),r=e[0],n=e[1],i=r+t[0]*this.getWidth(),a=n+t[1]*this.getHeight();return[Math.min(r,i),Math.min(n,a),Math.max(r,i),Math.max(n,a)]}}]),e}(),Ce=Be,Le=function(){function e(t){b(this,e),this._dataView=new DataView(t)}return l(e,[{key:"buffer",get:function(){return this._dataView.buffer}},{key:"getUint64",value:function(e,t){var r,n=this.getUint32(e,t),i=this.getUint32(e+4,t);if(t){if(r=n+Math.pow(2,32)*i,!Number.isSafeInteger(r))throw new Error("".concat(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=Math.pow(2,32)*n+i,!Number.isSafeInteger(r))throw new Error("".concat(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}},{key:"getInt64",value:function(e,t){for(var r=0,n=(128&this._dataView.getUint8(e+(t?7:0)))>0,i=!0,a=0;a<8;a++){var o=this._dataView.getUint8(e+(t?a:7-a));n&&(i?0!==o&&(o=255&~(o-1),i=!1):o=255&~o),r+=o*Math.pow(256,a)}return n&&(r=-r),r}},{key:"getUint8",value:function(e,t){return this._dataView.getUint8(e,t)}},{key:"getInt8",value:function(e,t){return this._dataView.getInt8(e,t)}},{key:"getUint16",value:function(e,t){return this._dataView.getUint16(e,t)}},{key:"getInt16",value:function(e,t){return this._dataView.getInt16(e,t)}},{key:"getUint32",value:function(e,t){return this._dataView.getUint32(e,t)}},{key:"getInt32",value:function(e,t){return this._dataView.getInt32(e,t)}},{key:"getFloat16",value:function(e,t){return Z(this._dataView,e,t)}},{key:"getFloat32",value:function(e,t){return this._dataView.getFloat32(e,t)}},{key:"getFloat64",value:function(e,t){return this._dataView.getFloat64(e,t)}}]),e}(),Fe=function(){function e(t,r,n,i){b(this,e),this._dataView=new DataView(t),this._sliceOffset=r,this._littleEndian=n,this._bigTiff=i}return l(e,[{key:"sliceOffset",get:function(){return this._sliceOffset}},{key:"sliceTop",get:function(){return this._sliceOffset+this.buffer.byteLength}},{key:"littleEndian",get:function(){return this._littleEndian}},{key:"bigTiff",get:function(){return this._bigTiff}},{key:"buffer",get:function(){return this._dataView.buffer}},{key:"covers",value:function(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}},{key:"readUint8",value:function(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}},{key:"readInt8",value:function(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}},{key:"readUint16",value:function(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}},{key:"readInt16",value:function(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}},{key:"readUint32",value:function(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}},{key:"readInt32",value:function(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}},{key:"readFloat32",value:function(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}},{key:"readFloat64",value:function(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}},{key:"readUint64",value:function(e){var t,r=this.readUint32(e),n=this.readUint32(e+4);if(this._littleEndian){if(t=r+Math.pow(2,32)*n,!Number.isSafeInteger(t))throw new Error("".concat(t," exceeds MAX_SAFE_INTEGER. ")+"Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues");return t}if(t=Math.pow(2,32)*r+n,!Number.isSafeInteger(t))throw new Error("".concat(t," exceeds MAX_SAFE_INTEGER. ")+"Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues");return t}},{key:"readInt64",value:function(e){for(var t=0,r=(128&this._dataView.getUint8(e+(this._littleEndian?7:0)))>0,n=!0,i=0;i<8;i++){var a=this._dataView.getUint8(e+(this._littleEndian?i:7-i));r&&(n?0!==a&&(a=255&~(a-1),n=!1):a=255&~a),t+=a*Math.pow(256,i)}return r&&(t=-t),t}},{key:"readOffset",value:function(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}]),e}(),Ve="undefined"!=typeof navigator&&navigator.hardwareConcurrency||2,Ge=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ve,n=arguments.length>1?arguments[1]:void 0;b(this,e),this.workers=null,this._awaitingDecoder=null,this.size=r,this.messageId=0,r&&(this._awaitingDecoder=n?Promise.resolve(n):new Promise((function(e){Promise.resolve().then((function(){return Xi})).then((function(t){e(t.create)}))})),this._awaitingDecoder.then((function(e){t._awaitingDecoder=null,t.workers=[];for(var n=0;n<r;n++)t.workers.push({worker:e(),idle:!0})})))}var t;return l(e,[{key:"decode",value:(t=u(x.mark((function e(t,r){var n=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._awaitingDecoder){e.next=3;break}return e.next=3,this._awaitingDecoder;case 3:return e.abrupt("return",0===this.size?ke(t).then((function(e){return e.decode(t,r)})):new Promise((function(e){var i=n.workers.find((function(e){return e.idle}))||n.workers[Math.floor(Math.random()*n.size)];i.idle=!1;var a=n.messageId++;i.worker.addEventListener("message",(function t(r){r.data.id===a&&(i.idle=!0,e(r.data.decoded),i.worker.removeEventListener("message",t))})),i.worker.postMessage({fileDirectory:t,buffer:r,id:a},[r])})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this.workers&&(this.workers.forEach((function(e){e.worker.terminate()})),this.workers=null)}}]),e}(),je=Ge;function Ne(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function ze(e){return r(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||i(e)||a()}function Ke(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Ze(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ze(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function Ze(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var He="\r\n\r\n";function Ye(e){if(void 0!==Object.fromEntries)return Object.fromEntries(e);var t,r={},n=Ke(e);try{for(n.s();!(t=n.n()).done;){var i=o(t.value,2),a=i[0],s=i[1];r[a.toLowerCase()]=s}}catch(e){n.e(e)}finally{n.f()}return r}function qe(e){return Ye(e.split("\r\n").map((function(e){var t=e.split(":").map((function(e){return e.trim()}));return t[0]=t[0].toLowerCase(),t})))}function Xe(e){var t,r,n;if(e){var i=o(e.match(/bytes (\d+)-(\d+)\/(\d+)/),4);t=i[1],r=i[2],n=i[3],t=parseInt(t,10),r=parseInt(r,10),n=parseInt(n,10)}return{start:t,end:r,total:n}}function We(e,t){for(var r=null,n=new TextDecoder("ascii"),i=[],a="--".concat(t),o="".concat(a,"--"),s=0;s<10;++s){n.decode(new Uint8Array(e,s,a.length))===a&&(r=s)}if(null===r)throw new Error("Could not find initial boundary");for(;r<e.byteLength;){var u=n.decode(new Uint8Array(e,r,Math.min(a.length+1024,e.byteLength-r)));if(0===u.length||u.startsWith(o))break;if(!u.startsWith(a))throw new Error("Part does not start with boundary");var f=u.substr(a.length+2);if(0===f.length)break;var l=f.indexOf(He),c=qe(f.substr(0,l)),h=Xe(c["content-range"]),d=h.start,p=h.end,v=h.total,m=r+a.length+l+He.length,g=parseInt(p,10)+1-parseInt(d,10);i.push({headers:c,data:e.slice(m,m+g),offset:d,length:g,fileSize:v}),r=m+g+4}return i}var Je=function(){function e(){b(this,e)}var t,r,n;return l(e,[{key:"fetch",value:(n=u(x.mark((function e(t){var r,n=this,i=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:void 0,e.abrupt("return",Promise.all(t.map((function(e){return n.fetchSlice(e,r)}))));case 2:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"fetchSlice",value:(r=u(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("fetching of slice ".concat(t," not possible, not implemented"));case 1:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"fileSize",get:function(){return null}},{key:"close",value:(t=u(x.mark((function e(){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}]),e}(),Qe=$e;function $e(e){var t=this;if(t instanceof $e||(t=new $e),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)t.push(arguments[r]);return t}function et(e,t,r){var n=t===e.head?new nt(r,null,t,e):new nt(r,t,t.next,e);return null===n.next&&(e.tail=n),null===n.prev&&(e.head=n),e.length++,n}function tt(e,t){e.tail=new nt(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function rt(e,t){e.head=new nt(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function nt(e,t,r,n){if(!(this instanceof nt))return new nt(e,t,r,n);this.list=n,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}$e.Node=nt,$e.create=$e,$e.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},$e.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},$e.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},$e.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)tt(this,arguments[e]);return this.length},$e.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)rt(this,arguments[e]);return this.length},$e.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},$e.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},$e.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,n=0;null!==r;n++)e.call(t,r.value,n,this),r=r.next},$e.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,n=this.length-1;null!==r;n--)e.call(t,r.value,n,this),r=r.prev},$e.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},$e.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},$e.prototype.map=function(e,t){t=t||this;for(var r=new $e,n=this.head;null!==n;)r.push(e.call(t,n.value,this)),n=n.next;return r},$e.prototype.mapReverse=function(e,t){t=t||this;for(var r=new $e,n=this.tail;null!==n;)r.push(e.call(t,n.value,this)),n=n.prev;return r},$e.prototype.reduce=function(e,t){var r,n=this.head;if(arguments.length>1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var i=0;null!==n;i++)r=e(r,n.value,i),n=n.next;return r},$e.prototype.reduceReverse=function(e,t){var r,n=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var i=this.length-1;null!==n;i--)r=e(r,n.value,i),n=n.prev;return r},$e.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},$e.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},$e.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new $e;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=0,i=this.head;null!==i&&n<e;n++)i=i.next;for(;null!==i&&n<t;n++,i=i.next)r.push(i.value);return r},$e.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new $e;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=this.length,i=this.tail;null!==i&&n>t;n--)i=i.prev;for(;null!==i&&n>e;n--,i=i.prev)r.push(i.value);return r},$e.prototype.splice=function(e,t){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,n=this.head;null!==n&&r<e;r++)n=n.next;var i=[];for(r=0;n&&r<t;r++)i.push(n.value),n=this.removeNode(n);null===n&&(n=this.tail),n!==this.head&&n!==this.tail&&(n=n.prev);for(r=0;r<(arguments.length<=2?0:arguments.length-2);r++)n=et(this,n,r+2<2||arguments.length<=r+2?void 0:arguments[r+2]);return i},$e.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=t,this.tail=e,this};try{require("./iterator.js")($e)}catch(e){}var it=Qe,at=Symbol("max"),ot=Symbol("length"),st=Symbol("lengthCalculator"),ut=Symbol("allowStale"),ft=Symbol("maxAge"),lt=Symbol("dispose"),ct=Symbol("noDisposeOnSet"),ht=Symbol("lruList"),dt=Symbol("cache"),pt=Symbol("updateAgeOnGet"),vt=function(){return 1},mt=function(){function e(t){if(b(this,e),"number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[at]=t.max||1/0;var r=t.length||vt;if(this[st]="function"!=typeof r?vt:r,this[ut]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[ft]=t.maxAge||0,this[lt]=t.dispose,this[ct]=t.noDisposeOnSet||!1,this[pt]=t.updateAgeOnGet||!1,this.reset()}return l(e,[{key:"max",get:function(){return this[at]},set:function(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[at]=e||1/0,wt(this)}},{key:"allowStale",get:function(){return this[ut]},set:function(e){this[ut]=!!e}},{key:"maxAge",get:function(){return this[ft]},set:function(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[ft]=e,wt(this)}},{key:"lengthCalculator",get:function(){return this[st]},set:function(e){var t=this;"function"!=typeof e&&(e=vt),e!==this[st]&&(this[st]=e,this[ot]=0,this[ht].forEach((function(e){e.length=t[st](e.value,e.key),t[ot]+=e.length}))),wt(this)}},{key:"length",get:function(){return this[ot]}},{key:"itemCount",get:function(){return this[ht].length}},{key:"rforEach",value:function(e,t){t=t||this;for(var r=this[ht].tail;null!==r;){var n=r.prev;xt(this,e,r,t),r=n}}},{key:"forEach",value:function(e,t){t=t||this;for(var r=this[ht].head;null!==r;){var n=r.next;xt(this,e,r,t),r=n}}},{key:"keys",value:function(){return this[ht].toArray().map((function(e){return e.key}))}},{key:"values",value:function(){return this[ht].toArray().map((function(e){return e.value}))}},{key:"reset",value:function(){var e=this;this[lt]&&this[ht]&&this[ht].length&&this[ht].forEach((function(t){return e[lt](t.key,t.value)})),this[dt]=new Map,this[ht]=new it,this[ot]=0}},{key:"dump",value:function(){var e=this;return this[ht].map((function(t){return!yt(e,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)}})).toArray().filter((function(e){return e}))}},{key:"dumpLru",value:function(){return this[ht]}},{key:"set",value:function(e,t,r){if((r=r||this[ft])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");var n=r?Date.now():0,i=this[st](t,e);if(this[dt].has(e)){if(i>this[at])return bt(this,this[dt].get(e)),!1;var a=this[dt].get(e).value;return this[lt]&&(this[ct]||this[lt](e,a.value)),a.now=n,a.maxAge=r,a.value=t,this[ot]+=i-a.length,a.length=i,this.get(e),wt(this),!0}var o=new kt(e,t,i,n,r);return o.length>this[at]?(this[lt]&&this[lt](e,t),!1):(this[ot]+=o.length,this[ht].unshift(o),this[dt].set(e,this[ht].head),wt(this),!0)}},{key:"has",value:function(e){if(!this[dt].has(e))return!1;var t=this[dt].get(e).value;return!yt(this,t)}},{key:"get",value:function(e){return gt(this,e,!0)}},{key:"peek",value:function(e){return gt(this,e,!1)}},{key:"pop",value:function(){var e=this[ht].tail;return e?(bt(this,e),e.value):null}},{key:"del",value:function(e){bt(this,this[dt].get(e))}},{key:"load",value:function(e){this.reset();for(var t=Date.now(),r=e.length-1;r>=0;r--){var n=e[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else{var a=i-t;a>0&&this.set(n.k,n.v,a)}}}},{key:"prune",value:function(){var e=this;this[dt].forEach((function(t,r){return gt(e,r,!1)}))}}]),e}(),gt=function(e,t,r){var n=e[dt].get(t);if(n){var i=n.value;if(yt(e,i)){if(bt(e,n),!e[ut])return}else r&&(e[pt]&&(n.value.now=Date.now()),e[ht].unshiftNode(n));return i.value}},yt=function(e,t){if(!t||!t.maxAge&&!e[ft])return!1;var r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[ft]&&r>e[ft]},wt=function(e){if(e[ot]>e[at])for(var t=e[ht].tail;e[ot]>e[at]&&null!==t;){var r=t.prev;bt(e,t),t=r}},bt=function(e,t){if(t){var r=t.value;e[lt]&&e[lt](r.key,r.value),e[ot]-=r.length,e[dt].delete(r.key),e[ht].removeNode(t)}},kt=function e(t,r,n,i,a){b(this,e),this.key=t,this.value=r,this.length=n,this.now=i,this.maxAge=a||0},xt=function(e,t,r,n){var i=r.value;yt(e,i)&&(bt(e,r),e[ut]||(i=void 0)),i&&t.call(n,i.value,i.key,e)},At=mt;function Pt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}function _t(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])}function It(e,t){return!(e.length<t.length)&&e.substr(e.length-t.length)===t}function St(e){var t={};for(var r in e){if(e.hasOwnProperty(r))t[e[r]]=r}return t}function Tt(e,t){for(var r=[],n=0;n<e;n++)r.push(t(n));return r}function Ut(e){return Ot.apply(this,arguments)}function Ot(){return(Ot=u(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){return setTimeout(e,t)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Dt(e,t){var r=Array.isArray(e)?e:Array.from(e),n=Array.isArray(t)?t:Array.from(t);return r.map((function(e,t){return[e,n[t]]}))}var Et=function(e){h(r,e);var t=Pt(r);function r(e){var n;return b(this,r),n=t.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(p(n),r),n.name="AbortError",n}return r}(w(Error)),Rt=function(e){h(r,e);var t=Pt(r);function r(e,n){var i;return b(this,r),(i=t.call(this,n)).errors=e,i.message=n,i.name="AggregateError",i}return r}(w(Error));function Mt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Bt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Bt(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function Bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ct(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var Lt=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;b(this,e),this.offset=t,this.length=r,this.data=n}return l(e,[{key:"top",get:function(){return this.offset+this.length}}]),e}(),Ft=function e(t,r,n){b(this,e),this.offset=t,this.length=r,this.blockIds=n},Vt=function(e){h(n,e);var t,r=Ct(n);function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.blockSize,o=void 0===a?65536:a,s=i.cacheSize,u=void 0===s?100:s;return b(this,n),(t=r.call(this)).source=e,t.blockSize=o,t.blockCache=new At({max:u}),t.blockRequests=new Map,t.blockIdsToFetch=new Set,t}return l(n,[{key:"fileSize",get:function(){return this.source.fileSize}},{key:"fetch",value:(t=u(x.mark((function e(t,r){var n,i,a,s,u,f,l,c,h,d,p,v,m,g,y,w,b,k,A,P,_,I,S,T,U,O,D,E,R,M,B,C,L,F,V,G,j,N;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=new Map,i=new Map,a=new Set,s=Mt(t);try{for(s.s();!(u=s.n()).done;)for(f=u.value,l=f.offset,c=f.length,h=l+c,null!==(d=this.fileSize)&&(h=Math.min(h,d)),p=Math.floor(l/this.blockSize)*this.blockSize,v=p;v<h;v+=this.blockSize)m=Math.floor(v/this.blockSize),this.blockCache.has(m)?n.set(m,this.blockCache.get(m)):this.blockRequests.has(m)?i.set(m,this.blockRequests.get(m)):(this.blockIdsToFetch.has(m)||this.blockIdsToFetch.add(m),a.add(m))}catch(e){s.e(e)}finally{s.f()}return e.next=7,Ut();case 7:this.fetchBlocks(r),g=Mt(a),e.prev=9,g.s();case 11:if((y=g.n()).done){e.next=26;break}if(w=y.value,b=this.blockRequests.get(w),k=this.blockCache.get(w),!b){e.next=19;break}i.set(w,b),e.next=24;break;case 19:if(!k){e.next=23;break}n.set(w,k),e.next=24;break;case 23:throw new Error("Block ".concat(w," is not in the block requests"));case 24:e.next=11;break;case 26:e.next=31;break;case 28:e.prev=28,e.t0=e.catch(9),g.e(e.t0);case 31:return e.prev=31,g.f(),e.finish(31);case 34:return e.next=36,Promise.allSettled(Array.from(i.values()));case 36:if(!(A=e.sent).some((function(e){return"rejected"===e.status}))){e.next=65;break}P=new Set,_=Mt(Dt(i.keys(),A));try{for(_.s();!(I=_.n()).done;)S=o(I.value,2),T=S[0],U=S[1],O=U.rejected,D=U.reason,O&&"AbortError"===D.name&&D.signal!==r&&(this.blockIdsToFetch.add(T),P.add(T))}catch(e){_.e(e)}finally{_.f()}if(!(this.blockIdsToFetch.length>0)){e.next=65;break}this.fetchBlocks(r),E=Mt(P),e.prev=44,E.s();case 46:if((R=E.n()).done){e.next=54;break}if(M=R.value,B=this.blockRequests.get(M)){e.next=51;break}throw new Error("Block ".concat(M," is not in the block requests"));case 51:i.set(M,B);case 52:e.next=46;break;case 54:e.next=59;break;case 56:e.prev=56,e.t1=e.catch(44),E.e(e.t1);case 59:return e.prev=59,E.f(),e.finish(59);case 62:return e.next=64,Promise.allSettled(Array.from(i.values()));case 64:A=e.sent;case 65:if(!A.some((function(e){return"rejected"===e.status}))){e.next=69;break}if(!r||!r.aborted){e.next=68;break}throw new Et("Request was aborted");case 68:throw new Rt(A.filter((function(e){return"rejected"===e.status})).map((function(e){return e.reason})),"Request failed");case 69:C=A.map((function(e){return e.value})),L=new Map(Dt(Array.from(i.keys()),C)),F=Mt(n);try{for(F.s();!(V=F.n()).done;)G=o(V.value,2),j=G[0],N=G[1],L.set(j,N)}catch(e){F.e(e)}finally{F.f()}return e.abrupt("return",this.readSliceData(t,L));case 74:case"end":return e.stop()}}),e,this,[[9,28,31,34],[44,56,59,62]])}))),function(e,r){return t.apply(this,arguments)})},{key:"fetchBlocks",value:function(e){var t=this;this.blockIdsToFetch.size>0&&function(){for(var r=t.groupBlocks(t.blockIdsToFetch),n=t.source.fetch(r,e),i=function(i){var a,o=Mt(r[i].blockIds);try{var s=function(){var r=a.value,o=u(x.mark((function a(){var o,s,u,f,l,c;return x.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,n;case 3:return a.t0=i,o=a.sent[a.t0],s=r*t.blockSize,u=s-o.offset,f=Math.min(u+t.blockSize,o.data.byteLength),l=o.data.slice(u,f),c=new Lt(s,l.byteLength,l),t.blockCache.set(r,c),a.abrupt("return",c);case 14:throw a.prev=14,a.t1=a.catch(0),"AbortError"===a.t1.name&&(a.t1.signal=e),a.t1;case 18:return a.prev=18,t.blockRequests.delete(r),a.finish(18);case 21:case"end":return a.stop()}}),a,null,[[0,14,18,21]])})))();t.blockRequests.set(r,o)};for(o.s();!(a=o.n()).done;)s()}catch(e){o.e(e)}finally{o.f()}},a=0;a<r.length;++a)i(a);t.blockIdsToFetch.clear()}()}},{key:"groupBlocks",value:function(e){var t=Array.from(e).sort((function(e,t){return e-t}));if(0===t.length)return[];var r,n=[],i=null,a=[],o=Mt(t);try{for(o.s();!(r=o.n()).done;){var s=r.value;null===i||i+1===s?(n.push(s),i=s):(a.push(new Ft(n[0]*this.blockSize,n.length*this.blockSize,n)),n=[s],i=s)}}catch(e){o.e(e)}finally{o.f()}return a.push(new Ft(n[0]*this.blockSize,n.length*this.blockSize,n)),a}},{key:"readSliceData",value:function(e,t){var r=this;return e.map((function(e){for(var n=e.offset+e.length,i=Math.floor(e.offset/r.blockSize),a=Math.floor((e.offset+e.length)/r.blockSize),o=new ArrayBuffer(e.length),s=new Uint8Array(o),u=i;u<=a;++u){var f=t.get(u),l=f.offset-e.offset,c=0,h=0,d=void 0;l<0?c=-l:l>0&&(h=l),d=f.top-n<0?f.length-c:n-f.offset-c;var p=new Uint8Array(f.data,c,d);s.set(p,h)}return o}))}}]),n}(Je),Gt=function(){function e(){b(this,e)}var t;return l(e,[{key:"ok",get:function(){return this.status>=200&&this.status<=299}},{key:"status",get:function(){throw new Error("not implemented")}},{key:"getHeader",value:function(e){throw new Error("not implemented")}},{key:"getData",value:(t=u(x.mark((function e(){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}]),e}(),jt=function(){function e(t){b(this,e),this.url=t}var t;return l(e,[{key:"request",value:(t=u(x.mark((function e(){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("request is not implemented");case 2:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}]),e}();function Nt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var zt=function(e){h(n,e);var t,r=Nt(n);function n(e){var t;return b(this,n),(t=r.call(this)).response=e,t}return l(n,[{key:"status",get:function(){return this.response.status}},{key:"getHeader",value:function(e){return this.response.headers.get(e)}},{key:"getData",value:(t=u(x.mark((function e(){var t;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.response.arrayBuffer){e.next=6;break}return e.next=3,this.response.arrayBuffer();case 3:e.t0=e.sent,e.next=9;break;case 6:return e.next=8,this.response.buffer();case 8:e.t0=e.sent.buffer;case 9:return t=e.t0,e.abrupt("return",t);case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(Gt),Kt=function(e){h(n,e);var t,r=Nt(n);function n(e,t){var i;return b(this,n),(i=r.call(this,e)).credentials=t,i}return l(n,[{key:"request",value:(t=u(x.mark((function e(){var t,r,n,i,a,o=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.headers,n=t.credentials,i=t.signal,e.next=3,fetch(this.url,{headers:r,credentials:n,signal:i});case 3:return a=e.sent,e.abrupt("return",new zt(a));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(jt);function Zt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var Ht=function(e){h(n,e);var t,r=Zt(n);function n(e,t){var i;return b(this,n),(i=r.call(this)).xhr=e,i.data=t,i}return l(n,[{key:"status",get:function(){return this.xhr.status}},{key:"getHeader",value:function(e){return this.xhr.getResponseHeader(e)}},{key:"getData",value:(t=u(x.mark((function e(){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.data);case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(Gt),Yt=function(e){h(n,e);var t,r=Zt(n);function n(){return b(this,n),r.apply(this,arguments)}return l(n,[{key:"constructRequest",value:function(e,t){var r=this;return new Promise((function(n,i){var a=new XMLHttpRequest;a.open("GET",r.url),a.responseType="arraybuffer";for(var s=0,u=Object.entries(e);s<u.length;s++){var f=o(u[s],2),l=f[0],c=f[1];a.setRequestHeader(l,c)}a.onload=function(){var e=a.response;n(new Ht(a,e))},a.onerror=i,a.onabort=function(){return i(new Et("Request aborted"))},a.send(),t&&(t.aborted&&a.abort(),t.addEventListener("abort",(function(){return a.abort()})))}))}},{key:"request",value:(t=u(x.mark((function e(){var t,r,n,i,a=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:{},r=t.headers,n=t.signal,e.next=3,this.constructRequest(r,n);case 3:return i=e.sent,e.abrupt("return",i);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(jt),qt={};function Xt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Wt(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?Xt(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Jt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var Qt=function(e){h(n,e);var t,r=Jt(n);function n(e,t){var i;return b(this,n),(i=r.call(this)).response=e,i.dataPromise=t,i}return l(n,[{key:"status",get:function(){return this.response.statusCode}},{key:"getHeader",value:function(e){return this.response.headers[e]}},{key:"getData",value:(t=u(x.mark((function e(){var t;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.dataPromise;case 2:return t=e.sent,e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(Gt),$t=function(e){h(n,e);var t,r=Jt(n);function n(e){var t;return b(this,n),(t=r.call(this,e)).parsedUrl=qt.parse(t.url),t.httpApi=(t.parsedUrl.protocol,qt),t}return l(n,[{key:"constructRequest",value:function(e,t){var r=this;return new Promise((function(n,i){var a=r.httpApi.get(Wt(Wt({},r.parsedUrl),{},{headers:e}),(function(e){var t=new Promise((function(t){var r=[];e.on("data",(function(e){r.push(e)})),e.on("end",(function(){var e=Buffer.concat(r).buffer;t(e)})),e.on("error",i)}));n(new Qt(e,t))}));a.on("error",i),t&&(t.aborted&&a.destroy(new Et("Request aborted")),t.addEventListener("abort",(function(){return a.destroy(new Et("Request aborted"))})))}))}},{key:"request",value:(t=u(x.mark((function e(){var t,r,n,i,a=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:{},r=t.headers,n=t.signal,e.next=3,this.constructRequest(r,n);case 3:return i=e.sent,e.abrupt("return",i);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(jt),er=["headers","credentials","maxRanges","allowFullFile"],tr=["headers","maxRanges","allowFullFile"],rr=["headers","maxRanges","allowFullFile"],nr=["forceXHR"];function ir(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ar(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?ir(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ir(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function or(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var sr=function(e){h(a,e);var t,r,n,i=or(a);function a(e,t,r,n){var o;return b(this,a),(o=i.call(this)).client=e,o.headers=t,o.maxRanges=r,o.allowFullFile=n,o._fileSize=null,o}return l(a,[{key:"fetch",value:(n=u(x.mark((function e(t,r){var n=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.maxRanges>=t.length)){e.next=4;break}return e.abrupt("return",this.fetchSlices(t,r));case 4:this.maxRanges>0&&t.length;case 5:return e.abrupt("return",Promise.all(t.map((function(e){return n.fetchSlice(e,r)}))));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"fetchSlices",value:(r=u(x.mark((function e(t,r){var n,i,a,o,s,u,f,l,c,h,d,p,v=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.request({headers:ar(ar({},this.headers),{},{Range:"bytes=".concat(t.map((function(e){var t=e.offset,r=e.length;return"".concat(t,"-").concat(t+r)})).join(","))}),signal:r});case 2:if((n=e.sent).ok){e.next=7;break}throw new Error("Error fetching data.");case 7:if(206!==n.status){e.next=32;break}if(m=n.getHeader("content-type"),g=void 0,g=ze(m.split(";").map((function(e){return e.trim()}))),i={type:g[0],params:Ye(g.slice(1).map((function(e){return e.split("=")})))},a=i.params,"multipart/byteranges"!==i.type){e.next=18;break}return e.t0=We,e.next=13,n.getData();case 13:return e.t1=e.sent,e.t2=a.boundary,o=(0,e.t0)(e.t1,e.t2),this._fileSize=o[0].fileSize||null,e.abrupt("return",o);case 18:return e.next=20,n.getData();case 20:if(s=e.sent,u=Xe(n.getHeader("content-range")),f=u.start,l=u.end,c=u.total,this._fileSize=c||null,h=[{data:s,offset:f,length:l-f}],!(t.length>1)){e.next=29;break}return e.next=27,Promise.all(t.slice(1).map((function(e){return v.fetchSlice(e,r)})));case 27:return d=e.sent,e.abrupt("return",h.concat(d));case 29:return e.abrupt("return",h);case 32:if(this.allowFullFile){e.next=34;break}throw new Error("Server responded with full file");case 34:return e.next=36,n.getData();case 36:return p=e.sent,this._fileSize=p.byteLength,e.abrupt("return",[{data:p,offset:0,length:p.byteLength}]);case 39:case"end":return e.stop()}var m,g}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"fetchSlice",value:(t=u(x.mark((function e(t,r){var n,i,a,o,s,u,f;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.offset,i=t.length,e.next=3,this.client.request({headers:ar(ar({},this.headers),{},{Range:"bytes=".concat(n,"-").concat(n+i)}),signal:r});case 3:if((a=e.sent).ok){e.next=8;break}throw new Error("Error fetching data.");case 8:if(206!==a.status){e.next=17;break}return e.next=11,a.getData();case 11:return o=e.sent,s=Xe(a.getHeader("content-range")),u=s.total,this._fileSize=u||null,e.abrupt("return",{data:o,offset:n,length:i});case 17:if(this.allowFullFile){e.next=19;break}throw new Error("Server responded with full file");case 19:return e.next=21,a.getData();case 21:return f=e.sent,this._fileSize=f.byteLength,e.abrupt("return",{data:f,offset:0,length:f.byteLength});case 24:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"fileSize",get:function(){return this._fileSize}}]),a}(Je);function ur(e,t){var r=t.blockSize,n=t.cacheSize;return null===r?e:new Vt(e,r,n)}function fr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.headers,n=void 0===r?{}:r,i=t.credentials,a=t.maxRanges,o=void 0===a?0:a,s=t.allowFullFile,u=void 0!==s&&s,f=Ne(t,er),l=new Kt(e,i),c=new sr(l,n,o,u);return ur(c,f)}function lr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.headers,n=void 0===r?{}:r,i=t.maxRanges,a=void 0===i?0:i,o=t.allowFullFile,s=void 0!==o&&o,u=Ne(t,tr),f=new Yt(e),l=new sr(f,n,a,s);return ur(l,u)}function cr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.headers,n=void 0===r?{}:r,i=t.maxRanges,a=void 0===i?0:i,o=t.allowFullFile,s=void 0!==o&&o,u=Ne(t,rr),f=new $t(e),l=new sr(f,n,a,s);return ur(l,u)}function hr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.forceXHR,n=void 0!==r&&r,i=Ne(t,nr);return"function"!=typeof fetch||n?"undefined"!=typeof XMLHttpRequest?lr(e,i):cr(e,i):fr(e,i)}function dr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var pr=function(e){h(r,e);var t=dr(r);function r(e){var n;return b(this,r),(n=t.call(this)).arrayBuffer=e,n}return l(r,[{key:"fetchSlice",value:function(e,t){if(t&&t.aborted)throw new Et("Request aborted");return this.arrayBuffer.slice(e.offset,e.offset+e.length)}}]),r}(Je);function vr(e){return new pr(e)}function mr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var gr=function(e){h(n,e);var t,r=mr(n);function n(e){var t;return b(this,n),(t=r.call(this)).file=e,t}return l(n,[{key:"fetchSlice",value:(t=u(x.mark((function e(t,r){var n=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,i){var a=n.file.slice(t.offset,t.offset+t.length),o=new FileReader;o.onload=function(t){return e(t.target.result)},o.onerror=i,o.onabort=i,o.readAsArrayBuffer(a),r&&r.addEventListener("abort",(function(){return o.abort()}))})));case 1:case"end":return e.stop()}}),e)}))),function(e,r){return t.apply(this,arguments)})}]),n}(Je);function yr(e){return new gr(e)}function wr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}function br(e){return new Promise((function(t,r){qt.close(e,(function(e){e?r(e):t()}))}))}function kr(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return new Promise((function(e,r){qt.read.apply(qt,t.concat([function(t,n,i){t?r(t):e({bytesRead:n,buffer:i})}]))}))}var xr=function(e){h(i,e);var t,r,n=wr(i);function i(e){var t;return b(this,i),(t=n.call(this)).path=e,t.openRequest=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return new Promise((function(n,i){qt.open(e,t,r,(function(e,t){e?i(e):n(t)}))}))}(e,"r"),t}return l(i,[{key:"fetchSlice",value:(r=u(x.mark((function e(t){var r,n,i;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.openRequest;case 2:return r=e.sent,e.next=5,kr(r,Buffer.alloc(t.length),0,t.length,t.offset);case 5:return n=e.sent,i=n.buffer,e.abrupt("return",i.buffer);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"close",value:(t=u(x.mark((function e(){var t;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.openRequest;case 2:return t=e.sent,e.next=5,br(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),i}(Je);function Ar(e){return new xr(e)}function Pr(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return _r(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _r(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function _r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Ir=St(W),Sr=St(ue),Tr={};_t(Tr,Ir),_t(Tr,Sr);var Ur=St(te),Or=1e3,Dr={nextZero:function(e,t){for(var r=t;0!==e[r];)r++;return r},readUshort:function(e,t){return e[t]<<8|e[t+1]},readShort:function(e,t){var r=Dr.ui8;return r[0]=e[t+1],r[1]=e[t+0],Dr.i16[0]},readInt:function(e,t){var r=Dr.ui8;return r[0]=e[t+3],r[1]=e[t+2],r[2]=e[t+1],r[3]=e[t+0],Dr.i32[0]},readUint:function(e,t){var r=Dr.ui8;return r[0]=e[t+3],r[1]=e[t+2],r[2]=e[t+1],r[3]=e[t+0],Dr.ui32[0]},readASCII:function(e,t,r){return r.map((function(r){return String.fromCharCode(e[t+r])})).join("")},readFloat:function(e,t){var r=Dr.ui8;return Tt(4,(function(n){r[n]=e[t+3-n]})),Dr.fl32[0]},readDouble:function(e,t){var r=Dr.ui8;return Tt(8,(function(n){r[n]=e[t+7-n]})),Dr.fl64[0]},writeUshort:function(e,t,r){e[t]=r>>8&255,e[t+1]=255&r},writeUint:function(e,t,r){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r>>0&255},writeASCII:function(e,t,r){Tt(r.length,(function(n){e[t+n]=r.charCodeAt(n)}))},ui8:new Uint8Array(8)};Dr.fl64=new Float64Array(Dr.ui8.buffer),Dr.writeDouble=function(e,t,r){Dr.fl64[0]=r,Tt(8,(function(r){e[t+r]=Dr.ui8[7-r]}))};var Er=function(e){var t=new Uint8Array(Or),r=4,n=Dr;t[0]=77,t[1]=77,t[3]=42;var i=8;if(n.writeUint(t,r,i),r+=4,e.forEach((function(r,a){var o=function(e,t,r,n){var i=r,a=Object.keys(n).filter((function(e){return null!=e&&"undefined"!==e}));e.writeUshort(t,i,a.length);var o,s=(i+=2)+12*a.length+4,u=Pr(a);try{var f=function(){var r=o.value,a=null;"number"==typeof r?a=r:"string"==typeof r&&(a=parseInt(r,10));var u=$[a],f=Ur[u];if(null==u||void 0===u||void 0===u)throw new Error("unknown type of tag: ".concat(a));var l=n[r];if(void 0===l)throw new Error("failed to get value for key ".concat(r));"ASCII"===u&&"string"==typeof l&&!1===It(l,"\0")&&(l+="\0");var c=l.length;e.writeUshort(t,i,a),i+=2,e.writeUshort(t,i,f),i+=2,e.writeUint(t,i,c);var h=[-1,1,1,2,4,8,0,0,0,0,0,0,8][f]*c,d=i+=4;h>4&&(e.writeUint(t,i,s),d=s),"ASCII"===u?e.writeASCII(t,d,l):"SHORT"===u?Tt(c,(function(r){e.writeUshort(t,d+2*r,l[r])})):"LONG"===u?Tt(c,(function(r){e.writeUint(t,d+4*r,l[r])})):"RATIONAL"===u?Tt(c,(function(r){e.writeUint(t,d+8*r,Math.round(1e4*l[r])),e.writeUint(t,d+8*r+4,1e4)})):"DOUBLE"===u&&Tt(c,(function(r){e.writeDouble(t,d+8*r,l[r])})),h>4&&(s+=h+=1&h),i+=4};for(u.s();!(o=u.n()).done;)f()}catch(e){u.e(e)}finally{u.f()}return[i,s]}(n,t,i,r);i=o[1],a<e.length-1&&n.writeUint(t,o[0],i)})),t.slice)return t.slice(0,i).buffer;for(var a=new Uint8Array(i),o=0;o<i;o++)a[o]=t[o];return a.buffer},Rr=[["Compression",1],["PlanarConfiguration",1],["ExtraSamples",0]];function Mr(e,t){var r,n,i,a;"number"==typeof e[0]?(r=t.height||t.ImageLength,i=t.width||t.ImageWidth,n=e.length/(r*i),a=e):(n=e.length,r=e[0].length,i=e[0][0].length,a=[],Tt(r,(function(t){Tt(i,(function(r){Tt(n,(function(n){a.push(e[n][t][r])}))}))}))),t.ImageLength=r,delete t.height,t.ImageWidth=i,delete t.width,t.BitsPerSample||(t.BitsPerSample=Tt(n,(function(){return 8}))),Rr.forEach((function(e){var r=e[0];if(!t[r]){var n=e[1];t[r]=n}})),t.PhotometricInterpretation||(t.PhotometricInterpretation=3===t.BitsPerSample.length?2:1),t.SamplesPerPixel||(t.SamplesPerPixel=[n]),t.StripByteCounts||(t.StripByteCounts=[n*r*i]),t.ModelPixelScale||(t.ModelPixelScale=[360/i,180/r,0]),t.SampleFormat||(t.SampleFormat=Tt(n,(function(){return 1}))),t.hasOwnProperty("GeographicTypeGeoKey")||t.hasOwnProperty("ProjectedCSTypeGeoKey")||(t.GeographicTypeGeoKey=4326,t.ModelTiepoint=[0,0,0,-180,90,0],t.GeogCitationGeoKey="WGS 84",t.GTModelTypeGeoKey=2);var o=Object.keys(t).filter((function(e){return It(e,"GeoKey")})).sort((function(e,t){return Tr[e]-Tr[t]}));if(!t.GeoAsciiParams){var s="";o.forEach((function(e){var r=Number(Tr[e]);"ASCII"===$[r]&&(s+="".concat(t[e].toString(),"\0"))})),s.length>0&&(t.GeoAsciiParams=s)}if(!t.GeoKeyDirectory){var u=[1,1,0,o.length];o.forEach((function(e){var r,n,i,a=Number(Tr[e]);u.push(a),"SHORT"===$[a]?(r=1,n=0,i=t[e]):"GeogCitationGeoKey"===e?(r=t.GeoAsciiParams.length,n=Number(Tr.GeoAsciiParams),i=0):console.log("[geotiff.js] couldn't get TIFFTagLocation for ".concat(e)),u.push(n),u.push(r),u.push(i)})),t.GeoKeyDirectory=u}for(var f in o)o.hasOwnProperty(f)&&delete t[f];["Compression","ExtraSamples","GeographicTypeGeoKey","GTModelTypeGeoKey","GTRasterTypeGeoKey","ImageLength","ImageWidth","Orientation","PhotometricInterpretation","ProjectedCSTypeGeoKey","PlanarConfiguration","ResolutionUnit","SamplesPerPixel","XPosition","YPosition"].forEach((function(e){var r;t[e]&&(t[e]=(r=t[e],Array.isArray(r)?r:[r]))}));var l=function(e){var t={};for(var r in e)"StripOffsets"!==r&&(Tr[r]||console.error(r,"not in name2code:",Object.keys(Tr)),t[Tr[r]]=e[r]);return t}(t),c=function(e,t,r,n){if(null==r)throw new Error("you passed into encodeImage a width of type ".concat(r));if(null==t)throw new Error("you passed into encodeImage a width of type ".concat(t));var i={256:[t],257:[r],273:[Or],278:[r],305:"geotiff.js"};if(n)for(var a in n)n.hasOwnProperty(a)&&(i[a]=n[a]);var o=new Uint8Array(Er([i])),s=new Uint8Array(e),u=i[277],f=new Uint8Array(Or+t*r*u);return Tt(o.length,(function(e){f[e]=o[e]})),function(e,t){for(var r=e.length,n=0;n<r;n++)t(e[n],n)}(s,(function(e,t){f[Or+t]=e})),f.buffer}(a,i,r,l);return c}var Br=function(){function e(){b(this,e)}return l(e,[{key:"log",value:function(){}},{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}},{key:"time",value:function(){}},{key:"timeEnd",value:function(){}}]),e}();function Cr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Lr(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?Cr(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Fr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}function Vr(e){switch(e){case re.BYTE:case re.ASCII:case re.SBYTE:case re.UNDEFINED:return 1;case re.SHORT:case re.SSHORT:return 2;case re.LONG:case re.SLONG:case re.FLOAT:case re.IFD:return 4;case re.RATIONAL:case re.SRATIONAL:case re.DOUBLE:case re.LONG8:case re.SLONG8:case re.IFD8:return 8;default:throw new RangeError("Invalid field type: ".concat(e))}}function Gr(e){var t=e.GeoKeyDirectory;if(!t)return null;for(var r={},n=4;n<=4*t[3];n+=4){var i=ue[t[n]],a=t[n+1]?W[t[n+1]]:null,o=t[n+2],s=t[n+3],u=null;if(a){if(null==(u=e[a]))throw new Error("Could not get value of geoKey '".concat(i,"'."));"string"==typeof u?u=u.substring(s,s+o-1):u.subarray&&(u=u.subarray(s,s+o),1===o&&(u=u[0]))}else u=s;r[i]=u}return r}function jr(e,t,r,n){var i=null,a=null,o=Vr(t);switch(t){case re.BYTE:case re.ASCII:case re.UNDEFINED:i=new Uint8Array(r),a=e.readUint8;break;case re.SBYTE:i=new Int8Array(r),a=e.readInt8;break;case re.SHORT:i=new Uint16Array(r),a=e.readUint16;break;case re.SSHORT:i=new Int16Array(r),a=e.readInt16;break;case re.LONG:case re.IFD:i=new Uint32Array(r),a=e.readUint32;break;case re.SLONG:i=new Int32Array(r),a=e.readInt32;break;case re.LONG8:case re.IFD8:i=new Array(r),a=e.readUint64;break;case re.SLONG8:i=new Array(r),a=e.readInt64;break;case re.RATIONAL:i=new Uint32Array(2*r),a=e.readUint32;break;case re.SRATIONAL:i=new Int32Array(2*r),a=e.readInt32;break;case re.FLOAT:i=new Float32Array(r),a=e.readFloat32;break;case re.DOUBLE:i=new Float64Array(r),a=e.readFloat64;break;default:throw new RangeError("Invalid field type: ".concat(t))}if(t!==re.RATIONAL&&t!==re.SRATIONAL)for(var s=0;s<r;++s)i[s]=a.call(e,n+s*o);else for(var u=0;u<r;u+=2)i[u]=a.call(e,n+u*o),i[u+1]=a.call(e,n+(u*o+4));return t===re.ASCII?new TextDecoder("utf-8").decode(i):i}new Br;var Nr=function e(t,r,n){b(this,e),this.fileDirectory=t,this.geoKeyDirectory=r,this.nextIFDByteOffset=n},zr=function(e){h(r,e);var t=Fr(r);function r(e){var n;return b(this,r),(n=t.call(this,"No image at index ".concat(e))).index=e,n}return r}(w(Error)),Kr=function(){function e(){b(this,e)}var t;return l(e,[{key:"readRasters",value:(t=u(x.mark((function e(){var t,r,n,i,a,s,u,f,l,c,h,d,p,v,m,g,y,w,b,k,A,P,_,I,S,T,U,O,D,E,R,M,B,C,L,F,V,G,j,N=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=N.length>0&&void 0!==N[0]?N[0]:{},r=t.window,n=t.width,i=t.height,a=t.resX,s=t.resY,u=t.bbox,e.next=5,this.getImage();case 5:return f=e.sent,l=f,e.next=9,this.getImageCount();case 9:if(c=e.sent,h=f.getBoundingBox(),!r||!u){e.next=13;break}throw new Error('Both "bbox" and "window" passed.');case 13:if(!n&&!i){e.next=24;break}if(r&&(d=f.getOrigin(),p=o(d,2),v=p[0],m=p[1],g=f.getResolution(),y=o(g,2),w=y[0],b=y[1],u=[v+r[0]*w,m+r[1]*b,v+r[2]*w,m+r[3]*b]),k=u||h,!n){e.next=20;break}if(!a){e.next=19;break}throw new Error("Both width and resX passed");case 19:a=(k[2]-k[0])/n;case 20:if(!i){e.next=24;break}if(!s){e.next=23;break}throw new Error("Both width and resY passed");case 23:s=(k[3]-k[1])/i;case 24:if(!a&&!s){e.next=48;break}A=[],P=0;case 27:if(!(P<c)){e.next=36;break}return e.next=30,this.getImage(P);case 30:_=e.sent,I=_.fileDirectory,S=I.SubfileType,T=I.NewSubfileType,(0===P||2===S||1&T)&&A.push(_);case 33:++P,e.next=27;break;case 36:A.sort((function(e,t){return e.getWidth()-t.getWidth()})),U=0;case 38:if(!(U<A.length)){e.next=48;break}if(O=A[U],D=(h[2]-h[0])/O.getWidth(),E=(h[3]-h[1])/O.getHeight(),l=O,!(a&&a>D||s&&s>E)){e.next=45;break}return e.abrupt("break",48);case 45:++U,e.next=38;break;case 48:return R=r,u&&(M=f.getOrigin(),B=o(M,2),C=B[0],L=B[1],F=l.getResolution(f),V=o(F,2),G=V[0],j=V[1],R=[Math.round((u[0]-C)/G),Math.round((u[1]-L)/j),Math.round((u[2]-C)/G),Math.round((u[3]-L)/j)],R=[Math.min(R[0],R[2]),Math.min(R[1],R[3]),Math.max(R[0],R[2]),Math.max(R[1],R[3])]),e.abrupt("return",l.readRasters(Lr(Lr({},t),{},{window:R})));case 51:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Zr=function(e){h(d,e);var t,r,n,i,a,s,f,c=Fr(d);function d(e,t,r,n){var i,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return b(this,d),(i=c.call(this)).source=e,i.littleEndian=t,i.bigTiff=r,i.firstIFDOffset=n,i.cache=a.cache||!1,i.ifdRequests=[],i.ghostValues=null,i}return l(d,[{key:"getSlice",value:(f=u(x.mark((function e(t,r){var n;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.bigTiff?4048:1024,e.t0=Fe,e.next=4,this.source.fetch([{offset:t,length:void 0!==r?r:n}]);case 4:return e.t1=e.sent[0],e.t2=t,e.t3=this.littleEndian,e.t4=this.bigTiff,e.abrupt("return",new e.t0(e.t1,e.t2,e.t3,e.t4));case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"parseFileDirectoryAt",value:(s=u(x.mark((function e(t){var r,n,i,a,o,s,u,f,l,c,h,d,p,v,m,g,y,w,b,k;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.bigTiff?20:12,n=this.bigTiff?8:2,e.next=4,this.getSlice(t);case 4:if(i=e.sent,a=this.bigTiff?i.readUint64(t):i.readUint16(t),o=a*r+(this.bigTiff?16:6),i.covers(t,o)){e.next=11;break}return e.next=10,this.getSlice(t,o);case 10:i=e.sent;case 11:s={},u=t+(this.bigTiff?8:2),f=0;case 14:if(!(f<a)){e.next=41;break}if(l=i.readUint16(u),c=i.readUint16(u+2),h=this.bigTiff?i.readUint64(u+4):i.readUint32(u+4),d=void 0,p=void 0,v=Vr(c),m=u+(this.bigTiff?12:8),!(v*h<=(this.bigTiff?8:4))){e.next=26;break}d=jr(i,c,h,m),e.next=36;break;case 26:if(g=i.readOffset(m),y=Vr(c)*h,!i.covers(g,y)){e.next=32;break}d=jr(i,c,h,g),e.next=36;break;case 32:return e.next=34,this.getSlice(g,y);case 34:w=e.sent,d=jr(w,c,h,g);case 36:p=1===h&&-1===ee.indexOf(l)&&c!==re.RATIONAL&&c!==re.SRATIONAL?d[0]:d,s[W[l]]=p;case 38:u+=r,++f,e.next=14;break;case 41:return b=Gr(s),k=i.readOffset(t+n+r*a),e.abrupt("return",new Nr(s,b,k));case 44:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"requestIFD",value:(a=u(x.mark((function e(t){var r=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.ifdRequests[t]){e.next=4;break}return e.abrupt("return",this.ifdRequests[t]);case 4:if(0!==t){e.next=9;break}return this.ifdRequests[t]=this.parseFileDirectoryAt(this.firstIFDOffset),e.abrupt("return",this.ifdRequests[t]);case 9:if(this.ifdRequests[t-1]){e.next=19;break}e.prev=10,this.ifdRequests[t-1]=this.requestIFD(t-1),e.next=19;break;case 14:if(e.prev=14,e.t0=e.catch(10),!(e.t0 instanceof zr)){e.next=18;break}throw new zr(t);case 18:throw e.t0;case 19:return this.ifdRequests[t]=u(x.mark((function e(){var n;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.ifdRequests[t-1];case 2:if(0!==(n=e.sent).nextIFDByteOffset){e.next=5;break}throw new zr(t);case 5:return e.abrupt("return",r.parseFileDirectoryAt(n.nextIFDByteOffset));case 6:case"end":return e.stop()}}),e)})))(),e.abrupt("return",this.ifdRequests[t]);case 21:case"end":return e.stop()}}),e,this,[[10,14]])}))),function(e){return a.apply(this,arguments)})},{key:"getImage",value:(i=u(x.mark((function e(){var t,r,n=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:0,e.next=3,this.requestIFD(t);case 3:return r=e.sent,e.abrupt("return",new Ce(r.fileDirectory,r.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getImageCount",value:(n=u(x.mark((function e(){var t,r;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=0,r=!0;case 2:if(!r){e.next=18;break}return e.prev=3,e.next=6,this.requestIFD(t);case 6:++t,e.next=16;break;case 9:if(e.prev=9,e.t0=e.catch(3),!(e.t0 instanceof zr)){e.next=15;break}r=!1,e.next=16;break;case 15:throw e.t0;case 16:e.next=2;break;case 18:return e.abrupt("return",t);case 19:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(){return n.apply(this,arguments)})},{key:"getGhostValues",value:(r=u(x.mark((function e(){var t,r,n,i,a,s,u,f,l=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.bigTiff?16:8,!this.ghostValues){e.next=3;break}return e.abrupt("return",this.ghostValues);case 3:return n=(r="GDAL_STRUCTURAL_METADATA_SIZE=").length+100,e.next=7,this.getSlice(t,n);case 7:if(i=e.sent,r!==jr(i,re.ASCII,r.length,t)){e.next=19;break}if(a=jr(i,re.ASCII,n,t),s=a.split("\n")[0],!((u=Number(s.split("=")[1].split(" ")[0])+s.length)>n)){e.next=16;break}return e.next=15,this.getSlice(t,u);case 15:i=e.sent;case 16:f=jr(i,re.ASCII,u,t),this.ghostValues={},f.split("\n").filter((function(e){return e.length>0})).map((function(e){return e.split("=")})).forEach((function(e){var t=o(e,2),r=t[0],n=t[1];l.ghostValues[r]=n}));case 19:return e.abrupt("return",this.ghostValues);case 20:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"close",value:function(){return"function"==typeof this.source.close&&this.source.close()}}],[{key:"fromSource",value:(t=u(x.mark((function e(t,r,n){var i,a,o,s,u,f,l;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.fetch([{offset:0,length:1024}],n);case 2:if(i=e.sent[0],a=new Le(i),18761!==(o=a.getUint16(0,0))){e.next=9;break}s=!0,e.next=14;break;case 9:if(19789!==o){e.next=13;break}s=!1,e.next=14;break;case 13:throw new TypeError("Invalid byte order value.");case 14:if(42!==(u=a.getUint16(2,s))){e.next=19;break}f=!1,e.next=27;break;case 19:if(43!==u){e.next=26;break}if(f=!0,8===a.getUint16(4,s)){e.next=24;break}throw new Error("Unsupported offset byte-size.");case 24:e.next=27;break;case 26:throw new TypeError("Invalid magic number.");case 27:return l=f?a.getUint64(8,s):a.getUint32(4,s),e.abrupt("return",new d(t,s,f,l,r));case 29:case"end":return e.stop()}}),e)}))),function(e,r,n){return t.apply(this,arguments)})}]),d}(Kr),Hr=function(e){h(a,e);var t,r,n,i=Fr(a);function a(e,t){var r;return b(this,a),(r=i.call(this)).mainFile=e,r.overviewFiles=t,r.imageFiles=[e].concat(t),r.fileDirectoriesPerFile=null,r.fileDirectoriesPerFileParsing=null,r.imageCount=null,r}return l(a,[{key:"parseFileDirectoriesPerFile",value:(n=u(x.mark((function e(){var t;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[this.mainFile.parseFileDirectoryAt(this.mainFile.firstIFDOffset)].concat(this.overviewFiles.map((function(e){return e.parseFileDirectoryAt(e.firstIFDOffset)}))),e.next=3,Promise.all(t);case 3:return this.fileDirectoriesPerFile=e.sent,e.abrupt("return",this.fileDirectoriesPerFile);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getImage",value:(r=u(x.mark((function e(){var t,r,n,i,a,o,s,u=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:0,e.next=3,this.getImageCount();case 3:return e.next=5,this.parseFileDirectoriesPerFile();case 5:r=0,n=0,i=0;case 8:if(!(i<this.imageFiles.length)){e.next=26;break}a=this.imageFiles[i],o=0;case 11:if(!(o<this.imageCounts[i])){e.next=22;break}if(t!==r){e.next=17;break}return e.next=15,a.requestIFD(n);case 15:return s=e.sent,e.abrupt("return",new Ce(s.fileDirectory,s.geoKeyDirectory,a.dataView,a.littleEndian,a.cache,a.source));case 17:r++,n++;case 19:o++,e.next=11;break;case 22:n=0;case 23:i++,e.next=8;break;case 26:throw new RangeError("Invalid image index");case 27:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getImageCount",value:(t=u(x.mark((function e(){var t;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===this.imageCount){e.next=2;break}return e.abrupt("return",this.imageCount);case 2:return t=[this.mainFile.getImageCount()].concat(this.overviewFiles.map((function(e){return e.getImageCount()}))),e.next=5,Promise.all(t);case 5:return this.imageCounts=e.sent,this.imageCount=this.imageCounts.reduce((function(e,t){return e+t}),0),e.abrupt("return",this.imageCount);case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),a}(Kr);function Yr(){return Yr=u(x.mark((function e(t){var r,n,i=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:{},n=i.length>2?i[2]:void 0,e.abrupt("return",Zr.fromSource(hr(t,r),n));case 3:case"end":return e.stop()}}),e)}))),Yr.apply(this,arguments)}function qr(){return(qr=u(x.mark((function e(t,r){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Zr.fromSource(vr(t),r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Xr(){return(Xr=u(x.mark((function e(t,r){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Zr.fromSource(Ar(t),r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Wr(){return(Wr=u(x.mark((function e(t,r){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Zr.fromSource(yr(t),r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Jr(){return Jr=u(x.mark((function e(t){var r,n,i,a,o,s=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:[],n=s.length>2&&void 0!==s[2]?s[2]:{},i=s.length>3?s[3]:void 0,e.next=5,Zr.fromSource(hr(t,n),i);case 5:return a=e.sent,e.next=8,Promise.all(r.map((function(e){return Zr.fromSource(hr(e,n))})));case 8:return o=e.sent,e.abrupt("return",new Hr(a,o));case 10:case"end":return e.stop()}}),e)}))),Jr.apply(this,arguments)}function Qr(e,t){var r=e.length-t,n=0;do{for(var i=t;i>0;i--)e[n+t]+=e[n],n++;r-=t}while(r>0)}function $r(e,t,r){for(var n=0,i=e.length,a=i/r;i>t;){for(var o=t;o>0;--o)e[n+t]+=e[n],++n;i-=t}for(var s=e.slice(),u=0;u<a;++u)for(var f=0;f<r;++f)e[r*u+f]=s[(r-f-1)*a+u]}function en(e,t,r,n,i,a){if(!t||1===t)return e;for(var o=0;o<i.length;++o){if(i[o]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(i[o]!==i[0])throw new Error("When decoding with predictor, all samples must have the same size.")}for(var s=i[0]/8,u=2===a?1:i.length,f=0;f<n&&!(f*u*r*s>=e.byteLength);++f){var l=void 0;if(2===t){switch(i[0]){case 8:l=new Uint8Array(e,f*u*r*s,u*r*s);break;case 16:l=new Uint16Array(e,f*u*r*s,u*r*s/2);break;case 32:l=new Uint32Array(e,f*u*r*s,u*r*s/4);break;default:throw new Error("Predictor 2 not allowed with ".concat(i[0]," bits per sample."))}Qr(l,u)}else 3===t&&$r(l=new Uint8Array(e,f*u*r*s,u*r*s),u,s)}return e}var tn=function(){function e(){b(this,e)}var t;return l(e,[{key:"decode",value:(t=u(x.mark((function e(t,r){var n,i,a,o,s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.decodeBlock(r);case 2:if(n=e.sent,1===(i=t.Predictor||1)){e.next=9;break}return a=!t.StripOffsets,o=a?t.TileWidth:t.ImageWidth,s=a?t.TileLength:t.RowsPerStrip||t.ImageLength,e.abrupt("return",en(n,i,o,s,t.BitsPerSample,t.PlanarConfiguration));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),e}();function rn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var nn=function(e){h(r,e);var t=rn(r);function r(){return b(this,r),t.apply(this,arguments)}return l(r,[{key:"decodeBlock",value:function(e){return e}}]),r}(tn),an=Object.freeze({__proto__:null,default:nn});function on(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}function sn(e,t){for(var r=t.length-1;r>=0;r--)e.push(t[r]);return e}function un(e){for(var t=new Uint16Array(4093),r=new Uint8Array(4093),n=0;n<=257;n++)t[n]=4096,r[n]=n;var i=258,a=9,o=0;function s(){i=258,a=9}function u(e){var t=function(e,t,r){var n=t%8,i=Math.floor(t/8),a=8-n,o=t+r-8*(i+1),s=8*(i+2)-(t+r),u=8*(i+2)-t;if(s=Math.max(0,s),i>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),257;var f=e[i]&Math.pow(2,8-n)-1,l=f<<=r-a;if(i+1<e.length){var c=e[i+1]>>>s;l+=c<<=Math.max(0,r-u)}if(o>8&&i+2<e.length){var h=8*(i+3)-(t+r);l+=e[i+2]>>>h}return l}(e,o,a);return o+=a,t}function f(e,n){return r[i]=n,t[i]=e,++i-1}function l(e){for(var n=[],i=e;4096!==i;i=t[i])n.push(r[i]);return n}var c=[];s();for(var h,d=new Uint8Array(e),p=u(d);257!==p;){if(256===p){for(s(),p=u(d);256===p;)p=u(d);if(257===p)break;if(p>256)throw new Error("corrupted code at scanline ".concat(p));sn(c,l(p)),h=p}else if(p<i){var v=l(p);sn(c,v),f(h,v[v.length-1]),h=p}else{var m=l(h);if(!m)throw new Error("Bogus entry. Not in dictionary, ".concat(h," / ").concat(i,", position: ").concat(o));sn(c,m),c.push(m[m.length-1]),f(h,m[m.length-1]),h=p}i+1>=Math.pow(2,a)&&(12===a?h=void 0:a++),p=u(d)}return new Uint8Array(c)}var fn=function(e){h(r,e);var t=on(r);function r(){return b(this,r),t.apply(this,arguments)}return l(r,[{key:"decodeBlock",value:function(e){return un(e).buffer}}]),r}(tn),ln=Object.freeze({__proto__:null,default:fn});function cn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var hn=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]),dn=4017,pn=799,vn=3406,mn=2276,gn=1567,yn=3784,wn=5793,bn=2896;function kn(e,t){for(var r=0,n=[],i=16;i>0&&!e[i-1];)--i;n.push({children:[],index:0});for(var a,o=n[0],s=0;s<i;s++){for(var u=0;u<e[s];u++){for((o=n.pop()).children[o.index]=t[r];o.index>0;)o=n.pop();for(o.index++,n.push(o);n.length<=s;)n.push(a={children:[],index:0}),o.children[o.index]=a.children,o=a;r++}s+1<i&&(n.push(a={children:[],index:0}),o.children[o.index]=a.children,o=a)}return n[0].children}function xn(e,t,r,n,i,a,o,s,u){var f=r.mcusPerLine,l=r.progressive,c=t,h=t,p=0,v=0;function m(){if(v>0)return v--,p>>v&1;if(255===(p=e[h++])){var t=e[h++];if(t)throw new Error("unexpected marker: ".concat((p<<8|t).toString(16)))}return v=7,p>>>7}function g(e){for(var t,r=e;null!==(t=m());){if("number"==typeof(r=r[t]))return r;if("object"!==d(r))throw new Error("invalid huffman sequence")}return null}function y(e){for(var t=e,r=0;t>0;){var n=m();if(null===n)return;r=r<<1|n,--t}return r}function w(e){var t=y(e);return t>=1<<e-1?t:t+(-1<<e)+1}var b=0;var k,x=0;function A(e,t,r,n,i){var a=r%f,o=(r/f|0)*e.v+n,s=a*e.h+i;t(e,e.blocks[o][s])}function P(e,t,r){var n=r/e.blocksPerLine|0,i=r%e.blocksPerLine;t(e,e.blocks[n][i])}var _,I,S,T,U,O,D=n.length;O=l?0===a?0===s?function(e,t){var r=g(e.huffmanTableDC),n=0===r?0:w(r)<<u;e.pred+=n,t[0]=e.pred}:function(e,t){t[0]|=m()<<u}:0===s?function(e,t){if(b>0)b--;else for(var r=a,n=o;r<=n;){var i=g(e.huffmanTableAC),s=15&i,f=i>>4;if(0===s){if(f<15){b=y(f)+(1<<f)-1;break}r+=16}else t[hn[r+=f]]=w(s)*(1<<u),r++}}:function(e,t){for(var r=a,n=o,i=0;r<=n;){var s=hn[r],f=t[s]<0?-1:1;switch(x){case 0:var l=g(e.huffmanTableAC),c=15&l;if(i=l>>4,0===c)i<15?(b=y(i)+(1<<i),x=4):(i=16,x=1);else{if(1!==c)throw new Error("invalid ACn encoding");k=w(c),x=i?2:3}continue;case 1:case 2:t[s]?t[s]+=(m()<<u)*f:0==--i&&(x=2===x?3:0);break;case 3:t[s]?t[s]+=(m()<<u)*f:(t[s]=k<<u,x=0);break;case 4:t[s]&&(t[s]+=(m()<<u)*f)}r++}4===x&&0==--b&&(x=0)}:function(e,t){var r=g(e.huffmanTableDC),n=0===r?0:w(r);e.pred+=n,t[0]=e.pred;for(var i=1;i<64;){var a=g(e.huffmanTableAC),o=15&a,s=a>>4;if(0===o){if(s<15)break;i+=16}else t[hn[i+=s]]=w(o),i++}};var E,R,M=0;R=1===D?n[0].blocksPerLine*n[0].blocksPerColumn:f*r.mcusPerColumn;for(var B=i||R;M<R;){for(I=0;I<D;I++)n[I].pred=0;if(b=0,1===D)for(_=n[0],U=0;U<B;U++)P(_,O,M),M++;else for(U=0;U<B;U++){for(I=0;I<D;I++){var C=_=n[I],L=C.h,F=C.v;for(S=0;S<F;S++)for(T=0;T<L;T++)A(_,O,M,S,T)}if(++M===R)break}if(v=0,(E=e[h]<<8|e[h+1])<65280)throw new Error("marker was not found");if(!(E>=65488&&E<=65495))break;h+=2}return h-c}function An(e,t){var r=[],n=t.blocksPerLine,i=t.blocksPerColumn,a=n<<3,o=new Int32Array(64),s=new Uint8Array(64);function u(e,r,n){var i,a,o,s,u,f,l,c,h,d,p=t.quantizationTable,v=n;for(d=0;d<64;d++)v[d]=e[d]*p[d];for(d=0;d<8;++d){var m=8*d;0!==v[1+m]||0!==v[2+m]||0!==v[3+m]||0!==v[4+m]||0!==v[5+m]||0!==v[6+m]||0!==v[7+m]?(i=wn*v[0+m]+128>>8,a=wn*v[4+m]+128>>8,o=v[2+m],s=v[6+m],u=bn*(v[1+m]-v[7+m])+128>>8,c=bn*(v[1+m]+v[7+m])+128>>8,f=v[3+m]<<4,l=v[5+m]<<4,h=i-a+1>>1,i=i+a+1>>1,a=h,h=o*yn+s*gn+128>>8,o=o*gn-s*yn+128>>8,s=h,h=u-l+1>>1,u=u+l+1>>1,l=h,h=c+f+1>>1,f=c-f+1>>1,c=h,h=i-s+1>>1,i=i+s+1>>1,s=h,h=a-o+1>>1,a=a+o+1>>1,o=h,h=u*mn+c*vn+2048>>12,u=u*vn-c*mn+2048>>12,c=h,h=f*pn+l*dn+2048>>12,f=f*dn-l*pn+2048>>12,l=h,v[0+m]=i+c,v[7+m]=i-c,v[1+m]=a+l,v[6+m]=a-l,v[2+m]=o+f,v[5+m]=o-f,v[3+m]=s+u,v[4+m]=s-u):(h=wn*v[0+m]+512>>10,v[0+m]=h,v[1+m]=h,v[2+m]=h,v[3+m]=h,v[4+m]=h,v[5+m]=h,v[6+m]=h,v[7+m]=h)}for(d=0;d<8;++d){var g=d;0!==v[8+g]||0!==v[16+g]||0!==v[24+g]||0!==v[32+g]||0!==v[40+g]||0!==v[48+g]||0!==v[56+g]?(i=wn*v[0+g]+2048>>12,a=wn*v[32+g]+2048>>12,o=v[16+g],s=v[48+g],u=bn*(v[8+g]-v[56+g])+2048>>12,c=bn*(v[8+g]+v[56+g])+2048>>12,f=v[24+g],l=v[40+g],h=i-a+1>>1,i=i+a+1>>1,a=h,h=o*yn+s*gn+2048>>12,o=o*gn-s*yn+2048>>12,s=h,h=u-l+1>>1,u=u+l+1>>1,l=h,h=c+f+1>>1,f=c-f+1>>1,c=h,h=i-s+1>>1,i=i+s+1>>1,s=h,h=a-o+1>>1,a=a+o+1>>1,o=h,h=u*mn+c*vn+2048>>12,u=u*vn-c*mn+2048>>12,c=h,h=f*pn+l*dn+2048>>12,f=f*dn-l*pn+2048>>12,l=h,v[0+g]=i+c,v[56+g]=i-c,v[8+g]=a+l,v[48+g]=a-l,v[16+g]=o+f,v[40+g]=o-f,v[24+g]=s+u,v[32+g]=s-u):(h=wn*n[d+0]+8192>>14,v[0+g]=h,v[8+g]=h,v[16+g]=h,v[24+g]=h,v[32+g]=h,v[40+g]=h,v[48+g]=h,v[56+g]=h)}for(d=0;d<64;++d){var y=128+(v[d]+8>>4);r[d]=y<0?0:y>255?255:y}}for(var f=0;f<i;f++){for(var l=f<<3,c=0;c<8;c++)r.push(new Uint8Array(a));for(var h=0;h<n;h++){u(t.blocks[f][h],s,o);for(var d=0,p=h<<3,v=0;v<8;v++)for(var m=r[l+v],g=0;g<8;g++)m[p+g]=s[d++]}}return r}var Pn=function(){function e(){b(this,e),this.jfif=null,this.adobe=null,this.quantizationTables=[],this.huffmanTablesAC=[],this.huffmanTablesDC=[],this.resetFrames()}return l(e,[{key:"resetFrames",value:function(){this.frames=[]}},{key:"parse",value:function(e){var t=0;function r(){var r=e[t]<<8|e[t+1];return t+=2,r}function n(e){var t,r,n=0,i=0;for(r in e.components)e.components.hasOwnProperty(r)&&(n<(t=e.components[r]).h&&(n=t.h),i<t.v&&(i=t.v));var a=Math.ceil(e.samplesPerLine/8/n),o=Math.ceil(e.scanLines/8/i);for(r in e.components)if(e.components.hasOwnProperty(r)){t=e.components[r];for(var s=Math.ceil(Math.ceil(e.samplesPerLine/8)*t.h/n),u=Math.ceil(Math.ceil(e.scanLines/8)*t.v/i),f=a*t.h,l=o*t.v,c=[],h=0;h<l;h++){for(var d=[],p=0;p<f;p++)d.push(new Int32Array(64));c.push(d)}t.blocksPerLine=s,t.blocksPerColumn=u,t.blocks=c}e.maxH=n,e.maxV=i,e.mcusPerLine=a,e.mcusPerColumn=o}var i,a,o=r();if(65496!==o)throw new Error("SOI not found");for(o=r();65497!==o;){switch(o){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:var s=(i=void 0,a=void 0,i=r(),a=e.subarray(t,t+i-2),t+=a.length,a);65504===o&&74===s[0]&&70===s[1]&&73===s[2]&&70===s[3]&&0===s[4]&&(this.jfif={version:{major:s[5],minor:s[6]},densityUnits:s[7],xDensity:s[8]<<8|s[9],yDensity:s[10]<<8|s[11],thumbWidth:s[12],thumbHeight:s[13],thumbData:s.subarray(14,14+3*s[12]*s[13])}),65518===o&&65===s[0]&&100===s[1]&&111===s[2]&&98===s[3]&&101===s[4]&&0===s[5]&&(this.adobe={version:s[6],flags0:s[7]<<8|s[8],flags1:s[9]<<8|s[10],transformCode:s[11]});break;case 65499:for(var u=r()+t-2;t<u;){var f=e[t++],l=new Int32Array(64);if(f>>4==0)for(var c=0;c<64;c++){l[hn[c]]=e[t++]}else{if(f>>4!=1)throw new Error("DQT: invalid table spec");for(var h=0;h<64;h++){l[hn[h]]=r()}}this.quantizationTables[15&f]=l}break;case 65472:case 65473:case 65474:r();for(var d={extended:65473===o,progressive:65474===o,precision:e[t++],scanLines:r(),samplesPerLine:r(),components:{},componentsOrder:[]},p=e[t++],v=void 0,m=0;m<p;m++){v=e[t];var g=e[t+1]>>4,y=15&e[t+1],w=e[t+2];d.componentsOrder.push(v),d.components[v]={h:g,v:y,quantizationIdx:w},t+=3}n(d),this.frames.push(d);break;case 65476:for(var b=r(),k=2;k<b;){for(var x=e[t++],A=new Uint8Array(16),P=0,_=0;_<16;_++,t++)A[_]=e[t],P+=A[_];for(var I=new Uint8Array(P),S=0;S<P;S++,t++)I[S]=e[t];k+=17+P,x>>4==0?this.huffmanTablesDC[15&x]=kn(A,I):this.huffmanTablesAC[15&x]=kn(A,I)}break;case 65501:r(),this.resetInterval=r();break;case 65498:r();for(var T=e[t++],U=[],O=this.frames[0],D=0;D<T;D++){var E=O.components[e[t++]],R=e[t++];E.huffmanTableDC=this.huffmanTablesDC[R>>4],E.huffmanTableAC=this.huffmanTablesAC[15&R],U.push(E)}var M=e[t++],B=e[t++],C=e[t++],L=xn(e,t,O,U,this.resetInterval,M,B,C>>4,15&C);t+=L;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 ".concat(o.toString(16)))}o=r()}}},{key:"getResult",value:function(){var e=this.frames;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(var t=0;t<this.frames.length;t++)for(var r=this.frames[t].components,n=0,i=Object.keys(r);n<i.length;n++){var a=i[n];r[a].quantizationTable=this.quantizationTables[r[a].quantizationIdx],delete r[a].quantizationIdx}for(var o=e[0],s=o.components,u=o.componentsOrder,f=[],l=o.samplesPerLine,c=o.scanLines,h=0;h<u.length;h++){var d=s[u[h]];f.push({lines:An(0,d),scaleX:d.h/o.maxH,scaleY:d.v/o.maxV})}for(var p=new Uint8Array(l*c*f.length),v=0,m=0;m<c;++m)for(var g=0;g<l;++g)for(var y=0;y<f.length;++y){var w=f[y];p[v]=w.lines[0|m*w.scaleY][0|g*w.scaleX],++v}return p}}]),e}(),_n=function(e){h(r,e);var t=cn(r);function r(e){var n;return b(this,r),(n=t.call(this)).reader=new Pn,e.JPEGTables&&n.reader.parse(e.JPEGTables),n}return l(r,[{key:"decodeBlock",value:function(e){return this.reader.resetFrames(),this.reader.parse(new Uint8Array(e)),this.reader.getResult().buffer}}]),r}(tn),In=Object.freeze({__proto__:null,default:_n});function Sn(e){for(var t=e.length;--t>=0;)e[t]=0}Sn(new Array(576)),Sn(new Array(60)),Sn(new Array(512)),Sn(new Array(256)),Sn(new Array(29)),Sn(new Array(30));var Tn=function(e,t,r,n){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0},Un=new Uint32Array(function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}()),On=function(e,t,r,n){var i=Un,a=n+r;e^=-1;for(var o=n;o<a;o++)e=e>>>8^i[255&(e^t[o])];return-1^e},Dn={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"},En={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},Rn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},Mn=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!==d(r))throw new TypeError(r+"must be non-object");for(var n in r)Rn(r,n)&&(e[n]=r[n])}}return e},Bn=function(e){for(var t=0,r=0,n=e.length;r<n;r++)t+=e[r].length;for(var i=new Uint8Array(t),a=0,o=0,s=e.length;a<s;a++){var u=e[a];i.set(u,o),o+=u.length}return i},Cn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Cn=!1}for(var Ln=new Uint8Array(256),Fn=0;Fn<256;Fn++)Ln[Fn]=Fn>=252?6:Fn>=248?5:Fn>=240?4:Fn>=224?3:Fn>=192?2:1;Ln[254]=Ln[254]=1;var Vn=function(e){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,r,n,i,a,o=e.length,s=0;for(i=0;i<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[a++]=r:r<2048?(t[a++]=192|r>>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},Gn=function(e,t){var r,n,i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var a=new Array(2*i);for(n=0,r=0;r<i;){var o=e[r++];if(o<128)a[n++]=o;else{var s=Ln[o];if(s>4)a[n++]=65533,r+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&r<i;)o=o<<6|63&e[r++],s--;s>1?a[n++]=65533:o<65536?a[n++]=o:(o-=65536,a[n++]=55296|o>>10&1023,a[n++]=56320|1023&o)}}}return function(e,t){if(t<65534&&e.subarray&&Cn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}(a,n)},jn=function(e,t){(t=t||e.length)>e.length&&(t=e.length);for(var r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Ln[e[r]]>t?r:t};var Nn=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},zn=function(e,t){var r,n,i,a,o,s,u,f,l,c,h,d,p,v,m,g,y,w,b,k,x,A,P,_,I=e.state;r=e.next_in,P=e.input,n=r+(e.avail_in-5),i=e.next_out,_=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=I.dmax,u=I.wsize,f=I.whave,l=I.wnext,c=I.window,h=I.hold,d=I.bits,p=I.lencode,v=I.distcode,m=(1<<I.lenbits)-1,g=(1<<I.distbits)-1;e:do{d<15&&(h+=P[r++]<<d,d+=8,h+=P[r++]<<d,d+=8),y=p[h&m];t:for(;;){if(h>>>=w=y>>>24,d-=w,0===(w=y>>>16&255))_[i++]=65535&y;else{if(!(16&w)){if(0==(64&w)){y=p[(65535&y)+(h&(1<<w)-1)];continue t}if(32&w){I.mode=12;break e}e.msg="invalid literal/length code",I.mode=30;break e}b=65535&y,(w&=15)&&(d<w&&(h+=P[r++]<<d,d+=8),b+=h&(1<<w)-1,h>>>=w,d-=w),d<15&&(h+=P[r++]<<d,d+=8,h+=P[r++]<<d,d+=8),y=v[h&g];r:for(;;){if(h>>>=w=y>>>24,d-=w,!(16&(w=y>>>16&255))){if(0==(64&w)){y=v[(65535&y)+(h&(1<<w)-1)];continue r}e.msg="invalid distance code",I.mode=30;break e}if(k=65535&y,d<(w&=15)&&(h+=P[r++]<<d,(d+=8)<w&&(h+=P[r++]<<d,d+=8)),(k+=h&(1<<w)-1)>s){e.msg="invalid distance too far back",I.mode=30;break e}if(h>>>=w,d-=w,k>(w=i-a)){if((w=k-w)>f&&I.sane){e.msg="invalid distance too far back",I.mode=30;break e}if(x=0,A=c,0===l){if(x+=u-w,w<b){b-=w;do{_[i++]=c[x++]}while(--w);x=i-k,A=_}}else if(l<w){if(x+=u+l-w,(w-=l)<b){b-=w;do{_[i++]=c[x++]}while(--w);if(x=0,l<b){b-=w=l;do{_[i++]=c[x++]}while(--w);x=i-k,A=_}}}else if(x+=l-w,w<b){b-=w;do{_[i++]=c[x++]}while(--w);x=i-k,A=_}for(;b>2;)_[i++]=A[x++],_[i++]=A[x++],_[i++]=A[x++],b-=3;b&&(_[i++]=A[x++],b>1&&(_[i++]=A[x++]))}else{x=i-k;do{_[i++]=_[x++],_[i++]=_[x++],_[i++]=_[x++],b-=3}while(b>2);b&&(_[i++]=_[x++],b>1&&(_[i++]=_[x++]))}break}}break}}while(r<n&&i<o);r-=b=d>>3,h&=(1<<(d-=b<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r<n?n-r+5:5-(r-n),e.avail_out=i<o?o-i+257:257-(i-o),I.hold=h,I.bits=d},Kn=15,Zn=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]),Hn=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]),Yn=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]),qn=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]),Xn=function(e,t,r,n,i,a,o,s){var u,f,l,c,h,d,p,v,m,g=s.bits,y=0,w=0,b=0,k=0,x=0,A=0,P=0,_=0,I=0,S=0,T=null,U=0,O=new Uint16Array(16),D=new Uint16Array(16),E=null,R=0;for(y=0;y<=Kn;y++)O[y]=0;for(w=0;w<n;w++)O[t[r+w]]++;for(x=g,k=Kn;k>=1&&0===O[k];k--);if(x>k&&(x=k),0===k)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(b=1;b<k&&0===O[b];b++);for(x<b&&(x=b),_=1,y=1;y<=Kn;y++)if(_<<=1,(_-=O[y])<0)return-1;if(_>0&&(0===e||1!==k))return-1;for(D[1]=0,y=1;y<Kn;y++)D[y+1]=D[y]+O[y];for(w=0;w<n;w++)0!==t[r+w]&&(o[D[t[r+w]]++]=w);if(0===e?(T=E=o,d=19):1===e?(T=Zn,U-=257,E=Hn,R-=257,d=256):(T=Yn,E=qn,d=-1),S=0,w=0,y=b,h=a,A=x,P=0,l=-1,c=(I=1<<x)-1,1===e&&I>852||2===e&&I>592)return 1;for(;;){p=y-P,o[w]<d?(v=0,m=o[w]):o[w]>d?(v=E[R+o[w]],m=T[U+o[w]]):(v=96,m=0),u=1<<y-P,b=f=1<<A;do{i[h+(S>>P)+(f-=u)]=p<<24|v<<16|m|0}while(0!==f);for(u=1<<y-1;S&u;)u>>=1;if(0!==u?(S&=u-1,S+=u):S=0,w++,0==--O[y]){if(y===k)break;y=t[r+o[w]]}if(y>x&&(S&c)!==l){for(0===P&&(P=x),h+=b,_=1<<(A=y-P);A+P<k&&!((_-=O[A+P])<=0);)A++,_<<=1;if(I+=1<<A,1===e&&I>852||2===e&&I>592)return 1;i[l=S&c]=x<<24|A<<16|h-a|0}}return 0!==S&&(i[h+S]=y-P<<24|64<<16|0),s.bits=x,0},Wn=En.Z_FINISH,Jn=En.Z_BLOCK,Qn=En.Z_TREES,$n=En.Z_OK,ei=En.Z_STREAM_END,ti=En.Z_NEED_DICT,ri=En.Z_STREAM_ERROR,ni=En.Z_DATA_ERROR,ii=En.Z_MEM_ERROR,ai=En.Z_BUF_ERROR,oi=En.Z_DEFLATED,si=12,ui=30,fi=function(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)};function li(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var ci,hi,di=function(e){if(!e||!e.state)return ri;var 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,$n},pi=function(e){if(!e||!e.state)return ri;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,di(e)},vi=function(e,t){var r;if(!e||!e.state)return ri;var n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ri:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,pi(e))},mi=function(e,t){if(!e)return ri;var r=new li;e.state=r,r.window=null;var n=vi(e,t);return n!==$n&&(e.state=null),n},gi=!0,yi=function(e){if(gi){ci=new Int32Array(512),hi=new Int32Array(32);for(var t=0;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(Xn(1,e.lens,0,288,ci,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Xn(2,e.lens,0,32,hi,0,e.work,{bits:5}),gi=!1}e.lencode=ci,e.lenbits=9,e.distcode=hi,e.distbits=5},wi=function(e,t,r,n){var i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},bi={inflateReset:pi,inflateReset2:vi,inflateResetKeep:di,inflateInit:function(e){return mi(e,15)},inflateInit2:mi,inflate:function(e,t){var r,n,i,a,o,s,u,f,l,c,h,d,p,v,m,g,y,w,b,k,x,A,P,_,I=0,S=new Uint8Array(4),T=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 ri;(r=e.state).mode===si&&(r.mode=13),o=e.next_out,i=e.output,u=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,f=r.hold,l=r.bits,c=s,h=u,A=$n;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(2&r.wrap&&35615===f){r.check=0,S[0]=255&f,S[1]=f>>>8&255,r.check=On(r.check,S,2,0),f=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&f)<<8)+(f>>8))%31){e.msg="incorrect header check",r.mode=ui;break}if((15&f)!==oi){e.msg="unknown compression method",r.mode=ui;break}if(l-=4,x=8+(15&(f>>>=4)),0===r.wbits)r.wbits=x;else if(x>r.wbits){e.msg="invalid window size",r.mode=ui;break}r.dmax=1<<r.wbits,e.adler=r.check=1,r.mode=512&f?10:si,f=0,l=0;break;case 2:for(;l<16;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(r.flags=f,(255&r.flags)!==oi){e.msg="unknown compression method",r.mode=ui;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=ui;break}r.head&&(r.head.text=f>>8&1),512&r.flags&&(S[0]=255&f,S[1]=f>>>8&255,r.check=On(r.check,S,2,0)),f=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.time=f),512&r.flags&&(S[0]=255&f,S[1]=f>>>8&255,S[2]=f>>>16&255,S[3]=f>>>24&255,r.check=On(r.check,S,4,0)),f=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=255&f,r.head.os=f>>8),512&r.flags&&(S[0]=255&f,S[1]=f>>>8&255,r.check=On(r.check,S,2,0)),f=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}r.length=f,r.head&&(r.head.extra_len=f),512&r.flags&&(S[0]=255&f,S[1]=f>>>8&255,r.check=On(r.check,S,2,0)),f=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>s&&(d=s),d&&(r.head&&(x=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+d),x)),512&r.flags&&(r.check=On(r.check,n,d,a)),s-=d,a+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;d=0;do{x=n[a+d++],r.head&&x&&r.length<65536&&(r.head.name+=String.fromCharCode(x))}while(x&&d<s);if(512&r.flags&&(r.check=On(r.check,n,d,a)),s-=d,a+=d,x)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===s)break e;d=0;do{x=n[a+d++],r.head&&x&&r.length<65536&&(r.head.comment+=String.fromCharCode(x))}while(x&&d<s);if(512&r.flags&&(r.check=On(r.check,n,d,a)),s-=d,a+=d,x)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(f!==(65535&r.check)){e.msg="header crc mismatch",r.mode=ui;break}f=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=si;break;case 10:for(;l<32;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}e.adler=r.check=fi(f),f=0,l=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=o,e.avail_out=u,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,ti;e.adler=r.check=1,r.mode=si;case si:if(t===Jn||t===Qn)break e;case 13:if(r.last){f>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}switch(r.last=1&f,l-=1,3&(f>>>=1)){case 0:r.mode=14;break;case 1:if(yi(r),r.mode=20,t===Qn){f>>>=2,l-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=ui}f>>>=2,l-=2;break;case 14:for(f>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if((65535&f)!=(f>>>16^65535)){e.msg="invalid stored block lengths",r.mode=ui;break}if(r.length=65535&f,f=0,l=0,r.mode=15,t===Qn)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>s&&(d=s),d>u&&(d=u),0===d)break e;i.set(n.subarray(a,a+d),o),s-=d,a+=d,u-=d,o+=d,r.length-=d;break}r.mode=si;break;case 17:for(;l<14;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(r.nlen=257+(31&f),f>>>=5,l-=5,r.ndist=1+(31&f),f>>>=5,l-=5,r.ncode=4+(15&f),f>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=ui;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}r.lens[T[r.have++]]=7&f,f>>>=3,l-=3}for(;r.have<19;)r.lens[T[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,P={bits:r.lenbits},A=Xn(0,r.lens,0,19,r.lencode,0,r.work,P),r.lenbits=P.bits,A){e.msg="invalid code lengths set",r.mode=ui;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;g=(I=r.lencode[f&(1<<r.lenbits)-1])>>>16&255,y=65535&I,!((m=I>>>24)<=l);){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(y<16)f>>>=m,l-=m,r.lens[r.have++]=y;else{if(16===y){for(_=m+2;l<_;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(f>>>=m,l-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=ui;break}x=r.lens[r.have-1],d=3+(3&f),f>>>=2,l-=2}else if(17===y){for(_=m+3;l<_;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}l-=m,x=0,d=3+(7&(f>>>=m)),f>>>=3,l-=3}else{for(_=m+7;l<_;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}l-=m,x=0,d=11+(127&(f>>>=m)),f>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=ui;break}for(;d--;)r.lens[r.have++]=x}}if(r.mode===ui)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=ui;break}if(r.lenbits=9,P={bits:r.lenbits},A=Xn(1,r.lens,0,r.nlen,r.lencode,0,r.work,P),r.lenbits=P.bits,A){e.msg="invalid literal/lengths set",r.mode=ui;break}if(r.distbits=6,r.distcode=r.distdyn,P={bits:r.distbits},A=Xn(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,P),r.distbits=P.bits,A){e.msg="invalid distances set",r.mode=ui;break}if(r.mode=20,t===Qn)break e;case 20:r.mode=21;case 21:if(s>=6&&u>=258){e.next_out=o,e.avail_out=u,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,zn(e,h),o=e.next_out,i=e.output,u=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,f=r.hold,l=r.bits,r.mode===si&&(r.back=-1);break}for(r.back=0;g=(I=r.lencode[f&(1<<r.lenbits)-1])>>>16&255,y=65535&I,!((m=I>>>24)<=l);){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(g&&0==(240&g)){for(w=m,b=g,k=y;g=(I=r.lencode[k+((f&(1<<w+b)-1)>>w)])>>>16&255,y=65535&I,!(w+(m=I>>>24)<=l);){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}f>>>=w,l-=w,r.back+=w}if(f>>>=m,l-=m,r.back+=m,r.length=y,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=si;break}if(64&g){e.msg="invalid literal/length code",r.mode=ui;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(_=r.extra;l<_;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(I=r.distcode[f&(1<<r.distbits)-1])>>>16&255,y=65535&I,!((m=I>>>24)<=l);){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(0==(240&g)){for(w=m,b=g,k=y;g=(I=r.distcode[k+((f&(1<<w+b)-1)>>w)])>>>16&255,y=65535&I,!(w+(m=I>>>24)<=l);){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}f>>>=w,l-=w,r.back+=w}if(f>>>=m,l-=m,r.back+=m,64&g){e.msg="invalid distance code",r.mode=ui;break}r.offset=y,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(_=r.extra;l<_;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=ui;break}r.mode=25;case 25:if(0===u)break e;if(d=h-u,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=ui;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),v=r.window}else v=i,p=o-r.offset,d=r.length;d>u&&(d=u),u-=d,r.length-=d;do{i[o++]=v[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===u)break e;i[o++]=r.length,u--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===s)break e;s--,f|=n[a++]<<l,l+=8}if(h-=u,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=r.flags?On(r.check,i,h,o-h):Tn(r.check,i,h,o-h)),h=u,(r.flags?f:fi(f))!==r.check){e.msg="incorrect data check",r.mode=ui;break}f=0,l=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===s)break e;s--,f+=n[a++]<<l,l+=8}if(f!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=ui;break}f=0,l=0}r.mode=29;case 29:A=ei;break e;case ui:A=ni;break e;case 31:return ii;default:return ri}return e.next_out=o,e.avail_out=u,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,(r.wsize||h!==e.avail_out&&r.mode<ui&&(r.mode<27||t!==Wn))&&wi(e,e.output,e.next_out,h-e.avail_out),c-=e.avail_in,h-=e.avail_out,e.total_in+=c,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=r.flags?On(r.check,i,h,e.next_out-h):Tn(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===si?128:0)+(20===r.mode||15===r.mode?256:0),(0===c&&0===h||t===Wn)&&A===$n&&(A=ai),A},inflateEnd:function(e){if(!e||!e.state)return ri;var t=e.state;return t.window&&(t.window=null),e.state=null,$n},inflateGetHeader:function(e,t){if(!e||!e.state)return ri;var r=e.state;return 0==(2&r.wrap)?ri:(r.head=t,t.done=!1,$n)},inflateSetDictionary:function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?ri:11===r.mode&&Tn(1,t,n,0)!==r.check?ni:wi(e,t,n,n)?(r.mode=31,ii):(r.havedict=1,$n):ri},inflateInfo:"pako inflate (from Nodeca project)"};var ki=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},xi=Object.prototype.toString,Ai=En.Z_NO_FLUSH,Pi=En.Z_FINISH,_i=En.Z_OK,Ii=En.Z_STREAM_END,Si=En.Z_NEED_DICT,Ti=En.Z_STREAM_ERROR,Ui=En.Z_DATA_ERROR,Oi=En.Z_MEM_ERROR;function Di(e){this.options=Mn({chunkSize:65536,windowBits:15,to:""},e||{});var 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 Nn,this.strm.avail_out=0;var r=bi.inflateInit2(this.strm,t.windowBits);if(r!==_i)throw new Error(Dn[r]);if(this.header=new ki,bi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Vn(t.dictionary):"[object ArrayBuffer]"===xi.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=bi.inflateSetDictionary(this.strm,t.dictionary))!==_i))throw new Error(Dn[r])}function Ei(e,t){var r=new Di(t);if(r.push(e),r.err)throw r.msg||Dn[r.err];return r.result}Di.prototype.push=function(e,t){var r,n,i,a=this.strm,o=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?Pi:Ai,"[object ArrayBuffer]"===xi.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(o),a.next_out=0,a.avail_out=o),(r=bi.inflate(a,n))===Si&&s&&((r=bi.inflateSetDictionary(a,s))===_i?r=bi.inflate(a,n):r===Ui&&(r=Si));a.avail_in>0&&r===Ii&&a.state.wrap>0&&0!==e[a.next_in];)bi.inflateReset(a),r=bi.inflate(a,n);switch(r){case Ti:case Ui:case Si:case Oi:return this.onEnd(r),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||r===Ii))if("string"===this.options.to){var u=jn(a.output,a.next_out),f=a.next_out-u,l=Gn(a.output,u);a.next_out=f,a.avail_out=o-f,f&&a.output.set(a.output.subarray(u,u+f),0),this.onData(l)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==_i||0!==i){if(r===Ii)return r=bi.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Di.prototype.onData=function(e){this.chunks.push(e)},Di.prototype.onEnd=function(e){e===_i&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Bn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ri={Inflate:Di,inflate:Ei,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Ei(e,t)},ungzip:Ei,constants:En}.inflate;function Mi(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var Bi=function(e){h(r,e);var t=Mi(r);function r(){return b(this,r),t.apply(this,arguments)}return l(r,[{key:"decodeBlock",value:function(e){return Ri(new Uint8Array(e)).buffer}}]),r}(tn),Ci=Object.freeze({__proto__:null,default:Bi});function Li(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var Fi=function(e){h(r,e);var t=Li(r);function r(){return b(this,r),t.apply(this,arguments)}return l(r,[{key:"decodeBlock",value:function(e){for(var t=new DataView(e),r=[],n=0;n<e.byteLength;++n){var i=t.getInt8(n);if(i<0){var a=t.getUint8(n+1);i=-i;for(var o=0;o<=i;++o)r.push(a);n+=1}else{for(var s=0;s<=i;++s)r.push(t.getUint8(n+s+1));n+=i+1}}return new Uint8Array(r).buffer}}]),r}(tn),Vi=Object.freeze({__proto__:null,default:Fi}),Gi={exports:{}};!function(e){
|
|
/* 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 */
|
|
!function(){var t,r,n,i,a,o,s,u,f=(t={defaultNoDataValue:-34027999387901484e22,decode:function(e,o){var s=(o=o||{}).encodedMaskData||null===o.encodedMaskData,u=a(e,o.inputOffset||0,s),f=null!==o.noDataValue?o.noDataValue:t.defaultNoDataValue,l=r(u,o.pixelType||Float32Array,o.encodedMaskData,f,o.returnMask),c={width:u.width,height:u.height,pixelData:l.resultPixels,minValue:l.minValue,maxValue:u.pixels.maxValue,noDataValue:f};return l.resultMask&&(c.maskData=l.resultMask),o.returnEncodedMask&&u.mask&&(c.encodedMaskData=u.mask.bitset?u.mask.bitset:null),o.returnFileInfo&&(c.fileInfo=n(u),o.computeUsedBitDepths&&(c.fileInfo.bitDepths=i(u))),c}},r=function(e,t,r,n,i){var a,s,u,f=0,l=e.pixels.numBlocksX,c=e.pixels.numBlocksY,h=Math.floor(e.width/l),d=Math.floor(e.height/c),p=2*e.maxZError,v=Number.MAX_VALUE;r=r||(e.mask?e.mask.bitset:null),s=new t(e.width*e.height),i&&r&&(u=new Uint8Array(e.width*e.height));for(var m,g,y=new Float32Array(h*d),w=0;w<=c;w++){var b=w!==c?d:e.height%c;if(0!==b)for(var k=0;k<=l;k++){var x=k!==l?h:e.width%l;if(0!==x){var A,P,_,I,S=w*e.width*d+k*h,T=e.width-x,U=e.pixels.blocks[f];if(U.encoding<2?(0===U.encoding?A=U.rawData:(o(U.stuffedData,U.bitsPerPixel,U.numValidPixels,U.offset,p,y,e.pixels.maxValue),A=y),P=0):_=2===U.encoding?0:U.offset,r)for(g=0;g<b;g++){for(7&S&&(I=r[S>>3],I<<=7&S),m=0;m<x;m++)7&S||(I=r[S>>3]),128&I?(u&&(u[S]=1),v=v>(a=U.encoding<2?A[P++]:_)?a:v,s[S++]=a):(u&&(u[S]=0),s[S++]=n),I<<=1;S+=T}else if(U.encoding<2)for(g=0;g<b;g++){for(m=0;m<x;m++)v=v>(a=A[P++])?a:v,s[S++]=a;S+=T}else for(v=v>_?_:v,g=0;g<b;g++){for(m=0;m<x;m++)s[S++]=_;S+=T}if(1===U.encoding&&P!==U.numValidPixels)throw"Block and Mask do not match";f++}}}return{resultPixels:s,resultMask:u,minValue:v}},n=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}}},i=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,r={},n=0;n<t;n++){var i=e.pixels.blocks[n];0===i.encoding?r.float32=!0:1===i.encoding?r[i.bitsPerPixel]=!0:r[0]=!0}return Object.keys(r)},a=function(e,t,r){var n={},i=new Uint8Array(e,t,10);if(n.fileIdentifierString=String.fromCharCode.apply(null,i),"CntZImage"!==n.fileIdentifierString.trim())throw"Unexpected file identifier string: "+n.fileIdentifierString;t+=10;var a=new DataView(e,t,24);if(n.fileVersion=a.getInt32(0,!0),n.imageType=a.getInt32(4,!0),n.height=a.getUint32(8,!0),n.width=a.getUint32(12,!0),n.maxZError=a.getFloat64(16,!0),t+=24,!r)if(a=new DataView(e,t,16),n.mask={},n.mask.numBlocksY=a.getUint32(0,!0),n.mask.numBlocksX=a.getUint32(4,!0),n.mask.numBytes=a.getUint32(8,!0),n.mask.maxValue=a.getFloat32(12,!0),t+=16,n.mask.numBytes>0){var o=new Uint8Array(Math.ceil(n.width*n.height/8)),s=(a=new DataView(e,t,n.mask.numBytes)).getInt16(0,!0),u=2,f=0;do{if(s>0)for(;s--;)o[f++]=a.getUint8(u++);else{var l=a.getUint8(u++);for(s=-s;s--;)o[f++]=l}s=a.getInt16(u,!0),u+=2}while(u<n.mask.numBytes);if(-32768!==s||f<o.length)throw"Unexpected end of mask RLE encoding";n.mask.bitset=o,t+=n.mask.numBytes}else 0==(n.mask.numBytes|n.mask.numBlocksY|n.mask.maxValue)&&(n.mask.bitset=new Uint8Array(Math.ceil(n.width*n.height/8)));a=new DataView(e,t,16),n.pixels={},n.pixels.numBlocksY=a.getUint32(0,!0),n.pixels.numBlocksX=a.getUint32(4,!0),n.pixels.numBytes=a.getUint32(8,!0),n.pixels.maxValue=a.getFloat32(12,!0),t+=16;var c=n.pixels.numBlocksX,h=n.pixels.numBlocksY,d=c+(n.width%c>0?1:0),p=h+(n.height%h>0?1:0);n.pixels.blocks=new Array(d*p);for(var v=0,m=0;m<p;m++)for(var g=0;g<d;g++){var y=0,w=e.byteLength-t;a=new DataView(e,t,Math.min(10,w));var b={};n.pixels.blocks[v++]=b;var k=a.getUint8(0);if(y++,b.encoding=63&k,b.encoding>3)throw"Invalid block encoding ("+b.encoding+")";if(2!==b.encoding){if(0!==k&&2!==k){if(k>>=6,b.offsetType=k,2===k)b.offset=a.getInt8(1),y++;else if(1===k)b.offset=a.getInt16(1,!0),y+=2;else{if(0!==k)throw"Invalid block offset type";b.offset=a.getFloat32(1,!0),y+=4}if(1===b.encoding)if(k=a.getUint8(y),y++,b.bitsPerPixel=63&k,k>>=6,b.numValidPixelsType=k,2===k)b.numValidPixels=a.getUint8(y),y++;else if(1===k)b.numValidPixels=a.getUint16(y,!0),y+=2;else{if(0!==k)throw"Invalid valid pixel count type";b.numValidPixels=a.getUint32(y,!0),y+=4}}var x;if(t+=y,3!==b.encoding)if(0===b.encoding){var A=(n.pixels.numBytes-1)/4;if(A!==Math.floor(A))throw"uncompressed block has invalid length";x=new ArrayBuffer(4*A),new Uint8Array(x).set(new Uint8Array(e,t,4*A));var P=new Float32Array(x);b.rawData=P,t+=4*A}else if(1===b.encoding){var _=Math.ceil(b.numValidPixels*b.bitsPerPixel/8),I=Math.ceil(_/4);x=new ArrayBuffer(4*I),new Uint8Array(x).set(new Uint8Array(e,t,_)),b.stuffedData=new Uint32Array(x),t+=_}}else t++}return n.eofOffset=t,n},o=function(e,t,r,n,i,a,o){var s,u,f,l=(1<<t)-1,c=0,h=0,d=Math.ceil((o-n)/i),p=4*e.length-Math.ceil(t*r/8);for(e[e.length-1]<<=8*p,s=0;s<r;s++){if(0===h&&(f=e[c++],h=32),h>=t)u=f>>>h-t&l,h-=t;else{var v=t-h;u=(f&l)<<v&l,u+=(f=e[c++])>>>(h=32-v)}a[s]=u<d?n+u*i:o}return a},t),l=function(){var e=function(e,t,r,n,i,a,o,s){var u,f,l,c,h,d=(1<<r)-1,p=0,v=0,m=4*e.length-Math.ceil(r*n/8);if(e[e.length-1]<<=8*m,i)for(u=0;u<n;u++)0===v&&(l=e[p++],v=32),v>=r?(f=l>>>v-r&d,v-=r):(f=(l&d)<<(c=r-v)&d,f+=(l=e[p++])>>>(v=32-c)),t[u]=i[f];else for(h=Math.ceil((s-a)/o),u=0;u<n;u++)0===v&&(l=e[p++],v=32),v>=r?(f=l>>>v-r&d,v-=r):(f=(l&d)<<(c=r-v)&d,f+=(l=e[p++])>>>(v=32-c)),t[u]=f<h?a+f*o:s},t=function(e,t,r,n,i,a){var o,s=(1<<t)-1,u=0,f=0,l=0,c=0,h=0,d=[],p=4*e.length-Math.ceil(t*r/8);e[e.length-1]<<=8*p;var v=Math.ceil((a-n)/i);for(f=0;f<r;f++)0===c&&(o=e[u++],c=32),c>=t?(h=o>>>c-t&s,c-=t):(h=(o&s)<<(l=t-c)&s,h+=(o=e[u++])>>>(c=32-l)),d[f]=h<v?n+h*i:a;return d.unshift(n),d},r=function(e,t,r,n,i,a,o,s){var u,f,l,c,h=(1<<r)-1,d=0,p=0,v=0;if(i)for(u=0;u<n;u++)0===p&&(l=e[d++],p=32,v=0),p>=r?(f=l>>>v&h,p-=r,v+=r):(f=l>>>v&h,p=32-(c=r-p),f|=((l=e[d++])&(1<<c)-1)<<r-c,v=c),t[u]=i[f];else{var m=Math.ceil((s-a)/o);for(u=0;u<n;u++)0===p&&(l=e[d++],p=32,v=0),p>=r?(f=l>>>v&h,p-=r,v+=r):(f=l>>>v&h,p=32-(c=r-p),f|=((l=e[d++])&(1<<c)-1)<<r-c,v=c),t[u]=f<m?a+f*o:s}return t},n=function(e,t,r,n,i,a){var o,s=(1<<t)-1,u=0,f=0,l=0,c=0,h=0,d=0,p=[],v=Math.ceil((a-n)/i);for(f=0;f<r;f++)0===c&&(o=e[u++],c=32,d=0),c>=t?(h=o>>>d&s,c-=t,d+=t):(h=o>>>d&s,c=32-(l=t-c),h|=((o=e[u++])&(1<<l)-1)<<t-l,d=l),p[f]=h<v?n+h*i:a;return p.unshift(n),p},i=function(e,t,r,n){var i,a,o,s,u=(1<<r)-1,f=0,l=0,c=4*e.length-Math.ceil(r*n/8);for(e[e.length-1]<<=8*c,i=0;i<n;i++)0===l&&(o=e[f++],l=32),l>=r?(a=o>>>l-r&u,l-=r):(a=(o&u)<<(s=r-l)&u,a+=(o=e[f++])>>>(l=32-s)),t[i]=a;return t},a=function(e,t,r,n){var i,a,o,s,u=(1<<r)-1,f=0,l=0,c=0;for(i=0;i<n;i++)0===l&&(o=e[f++],l=32,c=0),l>=r?(a=o>>>c&u,l-=r,c+=r):(a=o>>>c&u,l=32-(s=r-l),a|=((o=e[f++])&(1<<s)-1)<<r-s,c=s),t[i]=a;return t},o={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(e){for(var t=65535,r=65535,n=e.length,i=Math.floor(n/2),a=0;i;){var o=i>=359?359:i;i-=o;do{t+=e[a++]<<8,r+=t+=e[a++]}while(--o);t=(65535&t)+(t>>>16),r=(65535&r)+(r>>>16)}return 1&n&&(r+=t+=e[a]<<8),((r=(65535&r)+(r>>>16))<<16|(t=(65535&t)+(t>>>16)))>>>0},readHeaderInfo:function(e,t){var r=t.ptr,n=new Uint8Array(e,r,6),i={};if(i.fileIdentifierString=String.fromCharCode.apply(null,n),0!==i.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+i.fileIdentifierString;r+=6;var a,o=new DataView(e,r,8),s=o.getInt32(0,!0);if(i.fileVersion=s,r+=4,s>=3&&(i.checksum=o.getUint32(4,!0),r+=4),o=new DataView(e,r,12),i.height=o.getUint32(0,!0),i.width=o.getUint32(4,!0),r+=8,s>=4?(i.numDims=o.getUint32(8,!0),r+=4):i.numDims=1,o=new DataView(e,r,40),i.numValidPixel=o.getUint32(0,!0),i.microBlockSize=o.getInt32(4,!0),i.blobSize=o.getInt32(8,!0),i.imageType=o.getInt32(12,!0),i.maxZError=o.getFloat64(16,!0),i.zMin=o.getFloat64(24,!0),i.zMax=o.getFloat64(32,!0),r+=40,t.headerInfo=i,t.ptr=r,s>=3&&(a=s>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(e,r-a,i.blobSize-14))!==i.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var r=t.headerInfo,n=this.getDataTypeArray(r.imageType),i=r.numDims*this.getDataTypeSize(r.imageType),a=this.readSubArray(e,t.ptr,n,i),o=this.readSubArray(e,t.ptr+i,n,i);t.ptr+=2*i;var s,u=!0;for(s=0;s<r.numDims;s++)if(a[s]!==o[s]){u=!1;break}return r.minValues=a,r.maxValues=o,u},readSubArray:function(e,t,r,n){var i;if(r===Uint8Array)i=new Uint8Array(e,t,n);else{var a=new ArrayBuffer(n);new Uint8Array(a).set(new Uint8Array(e,t,n)),i=new r(a)}return i},readMask:function(e,t){var r,n,i=t.ptr,a=t.headerInfo,o=a.width*a.height,s=a.numValidPixel,u=new DataView(e,i,4),f={};if(f.numBytes=u.getUint32(0,!0),i+=4,(0===s||o===s)&&0!==f.numBytes)throw"invalid mask";if(0===s)r=new Uint8Array(Math.ceil(o/8)),f.bitset=r,n=new Uint8Array(o),t.pixels.resultMask=n,i+=f.numBytes;else if(f.numBytes>0){r=new Uint8Array(Math.ceil(o/8));var l=(u=new DataView(e,i,f.numBytes)).getInt16(0,!0),c=2,h=0,d=0;do{if(l>0)for(;l--;)r[h++]=u.getUint8(c++);else for(d=u.getUint8(c++),l=-l;l--;)r[h++]=d;l=u.getInt16(c,!0),c+=2}while(c<f.numBytes);if(-32768!==l||h<r.length)throw"Unexpected end of mask RLE encoding";n=new Uint8Array(o);var p=0,v=0;for(v=0;v<o;v++)7&v?(p=r[v>>3],p<<=7&v):p=r[v>>3],128&p&&(n[v]=1);t.pixels.resultMask=n,f.bitset=r,i+=f.numBytes}return t.ptr=i,t.mask=f,!0},readDataOneSweep:function(e,t,r,n){var i,a=t.ptr,s=t.headerInfo,u=s.numDims,f=s.width*s.height,l=s.imageType,c=s.numValidPixel*o.getDataTypeSize(l)*u,h=t.pixels.resultMask;if(r===Uint8Array)i=new Uint8Array(e,a,c);else{var d=new ArrayBuffer(c);new Uint8Array(d).set(new Uint8Array(e,a,c)),i=new r(d)}if(i.length===f*u)t.pixels.resultPixels=n?o.swapDimensionOrder(i,f,u,r,!0):i;else{t.pixels.resultPixels=new r(f*u);var p=0,v=0,m=0,g=0;if(u>1){if(n){for(v=0;v<f;v++)if(h[v])for(g=v,m=0;m<u;m++,g+=f)t.pixels.resultPixels[g]=i[p++]}else for(v=0;v<f;v++)if(h[v])for(g=v*u,m=0;m<u;m++)t.pixels.resultPixels[g+m]=i[p++]}else for(v=0;v<f;v++)h[v]&&(t.pixels.resultPixels[v]=i[p++])}return a+=c,t.ptr=a,!0},readHuffmanTree:function(e,t){var r=this.HUFFMAN_LUT_BITS_MAX,n=new DataView(e,t.ptr,16);if(t.ptr+=16,n.getInt32(0,!0)<2)throw"unsupported Huffman version";var i=n.getInt32(4,!0),a=n.getInt32(8,!0),u=n.getInt32(12,!0);if(a>=u)return!1;var f=new Uint32Array(u-a);o.decodeBits(e,t,f);var l,c,h,d,p=[];for(l=a;l<u;l++)p[c=l-(l<i?0:i)]={first:f[l-a],second:null};var v=e.byteLength-t.ptr,m=Math.ceil(v/4),g=new ArrayBuffer(4*m);new Uint8Array(g).set(new Uint8Array(e,t.ptr,v));var y,w=new Uint32Array(g),b=0,k=0;for(y=w[0],l=a;l<u;l++)(d=p[c=l-(l<i?0:i)].first)>0&&(p[c].second=y<<b>>>32-d,32-b>=d?32===(b+=d)&&(b=0,y=w[++k]):(b+=d-32,y=w[++k],p[c].second|=y>>>32-b));var x=0,A=0,P=new s;for(l=0;l<p.length;l++)void 0!==p[l]&&(x=Math.max(x,p[l].first));A=x>=r?r:x;var _,I,S,T,U,O=[];for(l=a;l<u;l++)if((d=p[c=l-(l<i?0:i)].first)>0)if(_=[d,c],d<=A)for(I=p[c].second<<A-d,S=1<<A-d,h=0;h<S;h++)O[I|h]=_;else for(I=p[c].second,U=P,T=d-1;T>=0;T--)I>>>T&1?(U.right||(U.right=new s),U=U.right):(U.left||(U.left=new s),U=U.left),0!==T||U.val||(U.val=_[1]);return{decodeLut:O,numBitsLUTQick:A,numBitsLUT:x,tree:P,stuffedData:w,srcPtr:k,bitPos:b}},readHuffman:function(e,t,r,n){var i,a,s,u,f,l,c,h,d,p=t.headerInfo.numDims,v=t.headerInfo.height,m=t.headerInfo.width,g=m*v,y=this.readHuffmanTree(e,t),w=y.decodeLut,b=y.tree,k=y.stuffedData,x=y.srcPtr,A=y.bitPos,P=y.numBitsLUTQick,_=y.numBitsLUT,I=0===t.headerInfo.imageType?128:0,S=t.pixels.resultMask,T=0;A>0&&(x++,A=0);var U,O=k[x],D=1===t.encodeMode,E=new r(g*p),R=E;if(p<2||D){for(U=0;U<p;U++)if(p>1&&(R=new r(E.buffer,g*U,g),T=0),t.headerInfo.numValidPixel===m*v)for(h=0,l=0;l<v;l++)for(c=0;c<m;c++,h++){if(a=0,f=u=O<<A>>>32-P,32-A<P&&(f=u|=k[x+1]>>>64-A-P),w[f])a=w[f][1],A+=w[f][0];else for(f=u=O<<A>>>32-_,32-A<_&&(f=u|=k[x+1]>>>64-A-_),i=b,d=0;d<_;d++)if(!(i=u>>>_-d-1&1?i.right:i.left).left&&!i.right){a=i.val,A=A+d+1;break}A>=32&&(A-=32,O=k[++x]),s=a-I,D?(s+=c>0?T:l>0?R[h-m]:T,s&=255,R[h]=s,T=s):R[h]=s}else for(h=0,l=0;l<v;l++)for(c=0;c<m;c++,h++)if(S[h]){if(a=0,f=u=O<<A>>>32-P,32-A<P&&(f=u|=k[x+1]>>>64-A-P),w[f])a=w[f][1],A+=w[f][0];else for(f=u=O<<A>>>32-_,32-A<_&&(f=u|=k[x+1]>>>64-A-_),i=b,d=0;d<_;d++)if(!(i=u>>>_-d-1&1?i.right:i.left).left&&!i.right){a=i.val,A=A+d+1;break}A>=32&&(A-=32,O=k[++x]),s=a-I,D?(c>0&&S[h-1]?s+=T:l>0&&S[h-m]?s+=R[h-m]:s+=T,s&=255,R[h]=s,T=s):R[h]=s}}else for(h=0,l=0;l<v;l++)for(c=0;c<m;c++)if(h=l*m+c,!S||S[h])for(U=0;U<p;U++,h+=g){if(a=0,f=u=O<<A>>>32-P,32-A<P&&(f=u|=k[x+1]>>>64-A-P),w[f])a=w[f][1],A+=w[f][0];else for(f=u=O<<A>>>32-_,32-A<_&&(f=u|=k[x+1]>>>64-A-_),i=b,d=0;d<_;d++)if(!(i=u>>>_-d-1&1?i.right:i.left).left&&!i.right){a=i.val,A=A+d+1;break}A>=32&&(A-=32,O=k[++x]),s=a-I,R[h]=s}t.ptr=t.ptr+4*(x+1)+(A>0?4:0),t.pixels.resultPixels=E,p>1&&!n&&(t.pixels.resultPixels=o.swapDimensionOrder(E,g,p,r))},decodeBits:function(o,s,u,f,l){var c=s.headerInfo,h=c.fileVersion,d=0,p=o.byteLength-s.ptr>=5?5:o.byteLength-s.ptr,v=new DataView(o,s.ptr,p),m=v.getUint8(0);d++;var g=m>>6,y=0===g?4:3-g,w=(32&m)>0,b=31&m,k=0;if(1===y)k=v.getUint8(d),d++;else if(2===y)k=v.getUint16(d,!0),d+=2;else{if(4!==y)throw"Invalid valid pixel count type";k=v.getUint32(d,!0),d+=4}var x,A,P,_,I,S,T,U,O,D=2*c.maxZError,E=c.numDims>1?c.maxValues[l]:c.zMax;if(w){for(s.counter.lut++,U=v.getUint8(d),d++,_=Math.ceil((U-1)*b/8),I=Math.ceil(_/4),A=new ArrayBuffer(4*I),P=new Uint8Array(A),s.ptr+=d,P.set(new Uint8Array(o,s.ptr,_)),T=new Uint32Array(A),s.ptr+=_,O=0;U-1>>>O;)O++;_=Math.ceil(k*O/8),I=Math.ceil(_/4),A=new ArrayBuffer(4*I),(P=new Uint8Array(A)).set(new Uint8Array(o,s.ptr,_)),x=new Uint32Array(A),s.ptr+=_,S=h>=3?n(T,b,U-1,f,D,E):t(T,b,U-1,f,D,E),h>=3?r(x,u,O,k,S):e(x,u,O,k,S)}else s.counter.bitstuffer++,O=b,s.ptr+=d,O>0&&(_=Math.ceil(k*O/8),I=Math.ceil(_/4),A=new ArrayBuffer(4*I),(P=new Uint8Array(A)).set(new Uint8Array(o,s.ptr,_)),x=new Uint32Array(A),s.ptr+=_,h>=3?null==f?a(x,u,O,k):r(x,u,O,k,!1,f,D,E):null==f?i(x,u,O,k):e(x,u,O,k,!1,f,D,E))},readTiles:function(e,t,r,n){var i=t.headerInfo,a=i.width,s=i.height,u=a*s,f=i.microBlockSize,l=i.imageType,c=o.getDataTypeSize(l),h=Math.ceil(a/f),d=Math.ceil(s/f);t.pixels.numBlocksY=d,t.pixels.numBlocksX=h,t.pixels.ptr=0;var p,v,m,g,y,w,b,k,x,A,P=0,_=0,I=0,S=0,T=0,U=0,O=0,D=0,E=0,R=0,M=0,B=0,C=0,L=0,F=0,V=new r(f*f),G=s%f||f,j=a%f||f,N=i.numDims,z=t.pixels.resultMask,K=t.pixels.resultPixels,Z=i.fileVersion>=5?14:15,H=i.zMax;for(I=0;I<d;I++)for(T=I!==d-1?f:G,S=0;S<h;S++)for(R=I*a*f+S*f,M=a-(U=S!==h-1?f:j),k=0;k<N;k++){if(N>1?(A=K,R=I*a*f+S*f,K=new r(t.pixels.resultPixels.buffer,u*k*c,u),H=i.maxValues[k]):A=null,O=e.byteLength-t.ptr,v={},F=0,D=(p=new DataView(e,t.ptr,Math.min(10,O))).getUint8(0),F++,x=i.fileVersion>=5?4&D:0,E=D>>6&255,(D>>2&Z)!==(S*f>>3&Z))throw"integrity issue";if(x&&0===k)throw"integrity issue";if((y=3&D)>3)throw t.ptr+=F,"Invalid block encoding ("+y+")";if(2!==y)if(0===y){if(x)throw"integrity issue";if(t.counter.uncompressed++,t.ptr+=F,B=(B=T*U*c)<(C=e.byteLength-t.ptr)?B:C,m=new ArrayBuffer(B%c==0?B:B+c-B%c),new Uint8Array(m).set(new Uint8Array(e,t.ptr,B)),g=new r(m),L=0,z)for(P=0;P<T;P++){for(_=0;_<U;_++)z[R]&&(K[R]=g[L++]),R++;R+=M}else for(P=0;P<T;P++){for(_=0;_<U;_++)K[R++]=g[L++];R+=M}t.ptr+=L*c}else if(w=o.getDataTypeUsed(x&&l<6?4:l,E),b=o.getOnePixel(v,F,w,p),F+=o.getDataTypeSize(w),3===y)if(t.ptr+=F,t.counter.constantoffset++,z)for(P=0;P<T;P++){for(_=0;_<U;_++)z[R]&&(K[R]=x?Math.min(H,A[R]+b):b),R++;R+=M}else for(P=0;P<T;P++){for(_=0;_<U;_++)K[R]=x?Math.min(H,A[R]+b):b,R++;R+=M}else if(t.ptr+=F,o.decodeBits(e,t,V,b,k),F=0,x)if(z)for(P=0;P<T;P++){for(_=0;_<U;_++)z[R]&&(K[R]=V[F++]+A[R]),R++;R+=M}else for(P=0;P<T;P++){for(_=0;_<U;_++)K[R]=V[F++]+A[R],R++;R+=M}else if(z)for(P=0;P<T;P++){for(_=0;_<U;_++)z[R]&&(K[R]=V[F++]),R++;R+=M}else for(P=0;P<T;P++){for(_=0;_<U;_++)K[R++]=V[F++];R+=M}else{if(x)if(z)for(P=0;P<T;P++)for(_=0;_<U;_++)z[R]&&(K[R]=A[R]),R++;else for(P=0;P<T;P++)for(_=0;_<U;_++)K[R]=A[R],R++;t.counter.constant++,t.ptr+=F}}N>1&&!n&&(t.pixels.resultPixels=o.swapDimensionOrder(t.pixels.resultPixels,u,N,r))},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:o.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 r=e.headerInfo.zMax,n=e.headerInfo.zMin,i=e.headerInfo.maxValues,a=e.headerInfo.numDims,o=e.headerInfo.height*e.headerInfo.width,s=0,u=0,f=0,l=e.pixels.resultMask,c=e.pixels.resultPixels;if(l)if(a>1){if(t)for(s=0;s<a;s++)for(f=s*o,r=i[s],u=0;u<o;u++)l[u]&&(c[f+u]=r);else for(u=0;u<o;u++)if(l[u])for(f=u*a,s=0;s<a;s++)c[f+a]=i[s]}else for(u=0;u<o;u++)l[u]&&(c[u]=r);else if(a>1&&n!==r)if(t)for(s=0;s<a;s++)for(f=s*o,r=i[s],u=0;u<o;u++)c[f+u]=r;else for(u=0;u<o;u++)for(f=u*a,s=0;s<a;s++)c[f+s]=i[s];else for(u=0;u<o*a;u++)c[u]=r},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 r;switch(e){case 0:r=t>=-128&&t<=127;break;case 1:r=t>=0&&t<=255;break;case 2:r=t>=-32768&&t<=32767;break;case 3:r=t>=0&&t<=65536;break;case 4:r=t>=-2147483648&&t<=2147483647;break;case 5:r=t>=0&&t<=4294967296;break;case 6:r=t>=-34027999387901484e22&&t<=34027999387901484e22;break;case 7:r=t>=-17976931348623157e292&&t<=17976931348623157e292;break;default:r=!1}return r},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 r=e;switch(e){case 2:case 4:r=e-t;break;case 3:case 5:r=e-2*t;break;case 6:r=0===t?e:1===t?2:1;break;case 7:r=0===t?e:e-2*t+1;break;default:r=e}return r},getOnePixel:function(e,t,r,n){var i=0;switch(r){case 0:i=n.getInt8(t);break;case 1:i=n.getUint8(t);break;case 2:i=n.getInt16(t,!0);break;case 3:i=n.getUint16(t,!0);break;case 4:i=n.getInt32(t,!0);break;case 5:i=n.getUInt32(t,!0);break;case 6:i=n.getFloat32(t,!0);break;case 7:i=n.getFloat64(t,!0);break;default:throw"the decoder does not understand this pixel type"}return i},swapDimensionOrder:function(e,t,r,n,i){var a=0,o=0,s=0,u=0,f=e;if(r>1)if(f=new n(t*r),i)for(a=0;a<t;a++)for(u=a,s=0;s<r;s++,u+=t)f[u]=e[o++];else for(a=0;a<t;a++)for(u=a,s=0;s<r;s++,u+=t)f[o++]=e[u];return f}},s=function(e,t,r){this.val=e,this.left=t,this.right=r},u={decode:function(e,t){var r=(t=t||{}).noDataValue,n=0,i={};i.ptr=t.inputOffset||0,i.pixels={},o.readHeaderInfo(e,i);var a=i.headerInfo,s=a.fileVersion,u=o.getDataTypeArray(a.imageType);if(s>5)throw"unsupported lerc version 2."+s;o.readMask(e,i),a.numValidPixel===a.width*a.height||i.pixels.resultMask||(i.pixels.resultMask=t.maskData);var f=a.width*a.height;i.pixels.resultPixels=new u(f*a.numDims),i.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var l,c=!t.returnPixelInterleavedDims;if(0!==a.numValidPixel)if(a.zMax===a.zMin)o.constructConstantSurface(i,c);else if(s>=4&&o.checkMinMaxRanges(e,i))o.constructConstantSurface(i,c);else{var h=new DataView(e,i.ptr,2),d=h.getUint8(0);if(i.ptr++,d)o.readDataOneSweep(e,i,u,c);else if(s>1&&a.imageType<=1&&Math.abs(a.maxZError-.5)<1e-5){var p=h.getUint8(1);if(i.ptr++,i.encodeMode=p,p>2||s<4&&p>1)throw"Invalid Huffman flag "+p;p?o.readHuffman(e,i,u,c):o.readTiles(e,i,u,c)}else o.readTiles(e,i,u,c)}i.eofOffset=i.ptr,t.inputOffset?(l=i.headerInfo.blobSize+t.inputOffset-i.ptr,Math.abs(l)>=1&&(i.eofOffset=t.inputOffset+i.headerInfo.blobSize)):(l=i.headerInfo.blobSize-i.ptr,Math.abs(l)>=1&&(i.eofOffset=i.headerInfo.blobSize));var v={width:a.width,height:a.height,pixelData:i.pixels.resultPixels,minValue:a.zMin,maxValue:a.zMax,validPixelCount:a.numValidPixel,dimCount:a.numDims,dimStats:{minValues:a.minValues,maxValues:a.maxValues},maskData:i.pixels.resultMask};if(i.pixels.resultMask&&o.isValidPixelValue(a.imageType,r)){var m=i.pixels.resultMask;for(n=0;n<f;n++)m[n]||(v.pixelData[n]=r);v.noDataValue=r}return i.noDataValue=r,t.returnFileInfo&&(v.fileInfo=o.formatFileInfo(i)),v},getBandCount:function(e){for(var t=0,r=0,n={ptr:0,pixels:{}};r<e.byteLength-58;)o.readHeaderInfo(e,n),r+=n.headerInfo.blobSize,t++,n.ptr=r;return t}};return u}(),c=(s=new ArrayBuffer(4),u=new Uint8Array(s),new Uint32Array(s)[0]=1,1===u[0]),h={decode:function(e,t){if(!c)throw"Big endian system is not supported.";var r,n,i=(t=t||{}).inputOffset||0,a=new Uint8Array(e,i,10),o=String.fromCharCode.apply(null,a);if("CntZImage"===o.trim())r=f,n=1;else{if("Lerc2"!==o.substring(0,5))throw"Unexpected file identifier string: "+o;r=l,n=2}for(var s,u,h,d,p,v,m=0,g=e.byteLength-10,y=[],w={width:0,height:0,pixels:[],pixelType:t.pixelType,mask:null,statistics:[]},b=0;i<g;){var k=r.decode(e,{inputOffset:i,encodedMaskData:s,maskData:h,returnMask:0===m,returnEncodedMask:0===m,returnFileInfo:!0,returnPixelInterleavedDims:t.returnPixelInterleavedDims,pixelType:t.pixelType||null,noDataValue:t.noDataValue||null});i=k.fileInfo.eofOffset,h=k.maskData,0===m&&(s=k.encodedMaskData,w.width=k.width,w.height=k.height,w.dimCount=k.dimCount||1,w.pixelType=k.pixelType||k.fileInfo.pixelType,w.mask=h),n>1&&(h&&y.push(h),k.fileInfo.mask&&k.fileInfo.mask.numBytes>0&&b++),m++,w.pixels.push(k.pixelData),w.statistics.push({minValue:k.minValue,maxValue:k.maxValue,noDataValue:k.noDataValue,dimStats:k.dimStats})}if(n>1&&b>1){for(v=w.width*w.height,w.bandMasks=y,(h=new Uint8Array(v)).set(y[0]),d=1;d<y.length;d++)for(u=y[d],p=0;p<v;p++)h[p]=h[p]&u[p];w.maskData=h}return w}};e.exports?e.exports=h:this.Lerc=h}()}(Gi);var ji=Gi.exports;function Ni(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var zi=function(e){h(r,e);var t=Ni(r);function r(e){var n;return b(this,r),(n=t.call(this)).planarConfiguration=void 0!==e.PlanarConfiguration?e.PlanarConfiguration:1,n.samplesPerPixel=void 0!==e.SamplesPerPixel?e.SamplesPerPixel:1,n.addCompression=e.LercParameters[oe.AddCompression],n}return l(r,[{key:"decodeBlock",value:function(e){switch(this.addCompression){case se.None:break;case se.Deflate:e=Ri(new Uint8Array(e)).buffer;break;default:throw new Error("Unsupported LERC additional compression method identifier: ".concat(this.addCompression))}return ji.decode(e,{returnPixelInterleavedDims:1===this.planarConfiguration}).pixels[0].buffer}}]),r}(tn),Ki=Object.freeze({__proto__:null,default:zi});function Zi(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=m(e);if(t){var i=m(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}var Hi=function(e){h(n,e);var t,r=Zi(n);function n(){var e;if(b(this,n),e=r.call(this),"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");return e}return l(n,[{key:"decode",value:(t=u(x.mark((function e(t,r){var n,i,a,o;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Blob([r]),e.next=3,createImageBitmap(n);case 3:return i=e.sent,"undefined"!=typeof document?((a=document.createElement("canvas")).width=i.width,a.height=i.height):a=new OffscreenCanvas(i.width,i.height),(o=a.getContext("2d")).drawImage(i,0,0),e.abrupt("return",o.getImageData(0,0,i.width,i.height).data.buffer);case 8:case"end":return e.stop()}}),e)}))),function(e,r){return t.apply(this,arguments)})}]),n}(tn),Yi=Object.freeze({__proto__:null,default:Hi}),qi=Worker;var Xi=Object.freeze({__proto__:null,create:function(){var e='function e(e,t,r,n,i,a,o){try{var s=e[a](o),f=s.value}catch(e){return void r(e)}s.done?t(f):Promise.resolve(f).then(n,i)}function t(t){return function(){var r=this,n=arguments;return new Promise((function(i,a){var o=t.apply(r,n);function s(t){e(o,i,a,s,f,"next",t)}function f(t){e(o,i,a,s,f,"throw",t)}s(void 0)}))}}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}var n={exports:{}};!function(e){var t=function(e){var t,n=Object.prototype,i=n.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof y?t:y,a=Object.create(i.prototype),o=new T(n||[]);return a._invoke=function(e,t,r){var n=h;return function(i,a){if(n===p)throw new Error("Generator is already running");if(n===m){if("throw"===i)throw a;return E()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=I(o,r);if(s){if(s===v)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var f=c(e,t,r);if("normal"===f.type){if(n=r.done?m:d,f.arg===v)continue;return{value:f.arg,done:r.done}}"throw"===f.type&&(n=m,r.method="throw",r.arg=f.arg)}}}(e,r,o),a}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var h="suspendedStart",d="suspendedYield",p="executing",m="completed",v={};function y(){}function w(){}function g(){}var b={};l(b,o,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(D([])));x&&x!==n&&i.call(x,o)&&(b=x);var _=g.prototype=y.prototype=Object.create(b);function A(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function P(e,t){function n(a,o,s,f){var l=c(e[a],e,o);if("throw"!==l.type){var u=l.arg,h=u.value;return h&&"object"===r(h)&&i.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,s,f)}),(function(e){n("throw",e,s,f)})):t.resolve(h).then((function(e){u.value=e,s(u)}),(function(e){return n("throw",e,s,f)}))}f(l.arg)}var a;this._invoke=function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}}function I(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a \'throw\' method")}return v}var i=c(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function U(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(U,this),this.reset(!0)}function D(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function r(){for(;++n<e.length;)if(i.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:E}}function E(){return{value:t,done:!0}}return w.prototype=g,l(_,"constructor",g),l(g,"constructor",w),w.displayName=l(g,f,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,f,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},A(P.prototype),l(P.prototype,s,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new P(u(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},A(_),l(_,f,"Generator"),l(_,o,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=D,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(S),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var f=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(f&&l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(f){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:D(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"===("undefined"==typeof globalThis?"undefined":r(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(n);var i=n.exports,a=new Map;function o(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){return a.set(e,t)}))}function s(e){return f.apply(this,arguments)}function f(){return(f=t(i.mark((function e(t){var r,n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.get(t.Compression)){e.next=3;break}throw new Error("Unknown compression method identifier: ".concat(t.Compression));case 3:return e.next=5,r();case 5:return n=e.sent,e.abrupt("return",new n(t));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}o([void 0,1],(function(){return Promise.resolve().then((function(){return _})).then((function(e){return e.default}))})),o(5,(function(){return Promise.resolve().then((function(){return S})).then((function(e){return e.default}))})),o(6,(function(){throw new Error("old style JPEG compression is not supported.")})),o(7,(function(){return Promise.resolve().then((function(){return L})).then((function(e){return e.default}))})),o([8,32946],(function(){return Promise.resolve().then((function(){return Ne})).then((function(e){return e.default}))})),o(32773,(function(){return Promise.resolve().then((function(){return Ye})).then((function(e){return e.default}))})),o(34887,(function(){return Promise.resolve().then((function(){return ut})).then((function(e){return e.default}))})),o(50001,(function(){return Promise.resolve().then((function(){return dt})).then((function(e){return e.default}))}));var l=globalThis;function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function h(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),e}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}function m(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called");return e}(e)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function y(e,t){var r=e.length-t,n=0;do{for(var i=t;i>0;i--)e[n+t]+=e[n],n++;r-=t}while(r>0)}function w(e,t,r){for(var n=0,i=e.length,a=i/r;i>t;){for(var o=t;o>0;--o)e[n+t]+=e[n],++n;i-=t}for(var s=e.slice(),f=0;f<a;++f)for(var l=0;l<r;++l)e[r*f+l]=s[(r-l-1)*a+f]}function g(e,t,r,n,i,a){if(!t||1===t)return e;for(var o=0;o<i.length;++o){if(i[o]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(i[o]!==i[0])throw new Error("When decoding with predictor, all samples must have the same size.")}for(var s=i[0]/8,f=2===a?1:i.length,l=0;l<n&&!(l*f*r*s>=e.byteLength);++l){var u=void 0;if(2===t){switch(i[0]){case 8:u=new Uint8Array(e,l*f*r*s,f*r*s);break;case 16:u=new Uint16Array(e,l*f*r*s,f*r*s/2);break;case 32:u=new Uint32Array(e,l*f*r*s,f*r*s/4);break;default:throw new Error("Predictor 2 not allowed with ".concat(i[0]," bits per sample."))}y(u,f)}else 3===t&&w(u=new Uint8Array(e,l*f*r*s,f*r*s),f,s)}return e}l.addEventListener("message",function(){var e=t(i.mark((function e(t){var r,n,a,o,f,u;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.data,n=r.id,a=r.fileDirectory,o=r.buffer,e.next=3,s(a);case 3:return f=e.sent,e.next=6,f.decode(a,o);case 6:u=e.sent,l.postMessage({decoded:u,id:n},[u]);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());var b=function(){function e(){u(this,e)}var r;return h(e,[{key:"decode",value:(r=t(i.mark((function e(t,r){var n,a,o,s,f;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.decodeBlock(r);case 2:if(n=e.sent,1===(a=t.Predictor||1)){e.next=9;break}return o=!t.StripOffsets,s=o?t.TileWidth:t.ImageWidth,f=o?t.TileLength:t.RowsPerStrip||t.ImageLength,e.abrupt("return",g(n,a,s,f,t.BitsPerSample,t.PlanarConfiguration));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})}]),e}();function k(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var x=function(e){p(r,b);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return e}}]),r}(),_=Object.freeze({__proto__:null,default:x});function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}function P(e,t){for(var r=t.length-1;r>=0;r--)e.push(t[r]);return e}function I(e){for(var t=new Uint16Array(4093),r=new Uint8Array(4093),n=0;n<=257;n++)t[n]=4096,r[n]=n;var i=258,a=9,o=0;function s(){i=258,a=9}function f(e){var t=function(e,t,r){var n=t%8,i=Math.floor(t/8),a=8-n,o=t+r-8*(i+1),s=8*(i+2)-(t+r),f=8*(i+2)-t;if(s=Math.max(0,s),i>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),257;var l=e[i]&Math.pow(2,8-n)-1,u=l<<=r-a;if(i+1<e.length){var c=e[i+1]>>>s;u+=c<<=Math.max(0,r-f)}if(o>8&&i+2<e.length){var h=8*(i+3)-(t+r);u+=e[i+2]>>>h}return u}(e,o,a);return o+=a,t}function l(e,n){return r[i]=n,t[i]=e,++i-1}function u(e){for(var n=[],i=e;4096!==i;i=t[i])n.push(r[i]);return n}var c=[];s();for(var h,d=new Uint8Array(e),p=f(d);257!==p;){if(256===p){for(s(),p=f(d);256===p;)p=f(d);if(257===p)break;if(p>256)throw new Error("corrupted code at scanline ".concat(p));P(c,u(p)),h=p}else if(p<i){var m=u(p);P(c,m),l(h,m[m.length-1]),h=p}else{var v=u(h);if(!v)throw new Error("Bogus entry. Not in dictionary, ".concat(h," / ").concat(i,", position: ").concat(o));P(c,v),c.push(v[v.length-1]),l(h,v[v.length-1]),h=p}i+1>=Math.pow(2,a)&&(12===a?h=void 0:a++),p=f(d)}return new Uint8Array(c)}var U=function(e){p(r,b);var t=A(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return I(e).buffer}}]),r}(),S=Object.freeze({__proto__:null,default:U});function T(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var D=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 E(e,t){for(var r=0,n=[],i=16;i>0&&!e[i-1];)--i;n.push({children:[],index:0});for(var a,o=n[0],s=0;s<i;s++){for(var f=0;f<e[s];f++){for((o=n.pop()).children[o.index]=t[r];o.index>0;)o=n.pop();for(o.index++,n.push(o);n.length<=s;)n.push(a={children:[],index:0}),o.children[o.index]=a.children,o=a;r++}s+1<i&&(n.push(a={children:[],index:0}),o.children[o.index]=a.children,o=a)}return n[0].children}function B(e,t,n,i,a,o,s,f,l){var u=n.mcusPerLine,c=n.progressive,h=t,d=t,p=0,m=0;function v(){if(m>0)return m--,p>>m&1;if(255===(p=e[d++])){var t=e[d++];if(t)throw new Error("unexpected marker: ".concat((p<<8|t).toString(16)))}return m=7,p>>>7}function y(e){for(var t,n=e;null!==(t=v());){if("number"==typeof(n=n[t]))return n;if("object"!==r(n))throw new Error("invalid huffman sequence")}return null}function w(e){for(var t=e,r=0;t>0;){var n=v();if(null===n)return;r=r<<1|n,--t}return r}function g(e){var t=w(e);return t>=1<<e-1?t:t+(-1<<e)+1}var b=0;var k,x=0;function _(e,t,r,n,i){var a=r%u,o=(r/u|0)*e.v+n,s=a*e.h+i;t(e,e.blocks[o][s])}function A(e,t,r){var n=r/e.blocksPerLine|0,i=r%e.blocksPerLine;t(e,e.blocks[n][i])}var P,I,U,S,T,E,B=i.length;E=c?0===o?0===f?function(e,t){var r=y(e.huffmanTableDC),n=0===r?0:g(r)<<l;e.pred+=n,t[0]=e.pred}:function(e,t){t[0]|=v()<<l}:0===f?function(e,t){if(b>0)b--;else for(var r=o,n=s;r<=n;){var i=y(e.huffmanTableAC),a=15&i,f=i>>4;if(0===a){if(f<15){b=w(f)+(1<<f)-1;break}r+=16}else t[D[r+=f]]=g(a)*(1<<l),r++}}:function(e,t){for(var r=o,n=s,i=0;r<=n;){var a=D[r],f=t[a]<0?-1:1;switch(x){case 0:var u=y(e.huffmanTableAC),c=15&u;if(i=u>>4,0===c)i<15?(b=w(i)+(1<<i),x=4):(i=16,x=1);else{if(1!==c)throw new Error("invalid ACn encoding");k=g(c),x=i?2:3}continue;case 1:case 2:t[a]?t[a]+=(v()<<l)*f:0==--i&&(x=2===x?3:0);break;case 3:t[a]?t[a]+=(v()<<l)*f:(t[a]=k<<l,x=0);break;case 4:t[a]&&(t[a]+=(v()<<l)*f)}r++}4===x&&0==--b&&(x=0)}:function(e,t){var r=y(e.huffmanTableDC),n=0===r?0:g(r);e.pred+=n,t[0]=e.pred;for(var i=1;i<64;){var a=y(e.huffmanTableAC),o=15&a,s=a>>4;if(0===o){if(s<15)break;i+=16}else t[D[i+=s]]=g(o),i++}};var O,M,C=0;M=1===B?i[0].blocksPerLine*i[0].blocksPerColumn:u*n.mcusPerColumn;for(var L=a||M;C<M;){for(I=0;I<B;I++)i[I].pred=0;if(b=0,1===B)for(P=i[0],T=0;T<L;T++)A(P,E,C),C++;else for(T=0;T<L;T++){for(I=0;I<B;I++){var R=P=i[I],V=R.h,G=R.v;for(U=0;U<G;U++)for(S=0;S<V;S++)_(P,E,C,U,S)}if(++C===M)break}if(m=0,(O=e[d]<<8|e[d+1])<65280)throw new Error("marker was not found");if(!(O>=65488&&O<=65495))break;d+=2}return d-h}function O(e,t){var r=[],n=t.blocksPerLine,i=t.blocksPerColumn,a=n<<3,o=new Int32Array(64),s=new Uint8Array(64);function f(e,r,n){var i,a,o,s,f,l,u,c,h,d,p=t.quantizationTable,m=n;for(d=0;d<64;d++)m[d]=e[d]*p[d];for(d=0;d<8;++d){var v=8*d;0!==m[1+v]||0!==m[2+v]||0!==m[3+v]||0!==m[4+v]||0!==m[5+v]||0!==m[6+v]||0!==m[7+v]?(i=5793*m[0+v]+128>>8,a=5793*m[4+v]+128>>8,o=m[2+v],s=m[6+v],f=2896*(m[1+v]-m[7+v])+128>>8,c=2896*(m[1+v]+m[7+v])+128>>8,l=m[3+v]<<4,h=i-a+1>>1,i=i+a+1>>1,a=h,h=3784*o+1567*s+128>>8,o=1567*o-3784*s+128>>8,s=h,h=f-(u=m[5+v]<<4)+1>>1,f=f+u+1>>1,u=h,h=c+l+1>>1,l=c-l+1>>1,c=h,h=i-s+1>>1,i=i+s+1>>1,s=h,h=a-o+1>>1,a=a+o+1>>1,o=h,h=2276*f+3406*c+2048>>12,f=3406*f-2276*c+2048>>12,c=h,h=799*l+4017*u+2048>>12,l=4017*l-799*u+2048>>12,u=h,m[0+v]=i+c,m[7+v]=i-c,m[1+v]=a+u,m[6+v]=a-u,m[2+v]=o+l,m[5+v]=o-l,m[3+v]=s+f,m[4+v]=s-f):(h=5793*m[0+v]+512>>10,m[0+v]=h,m[1+v]=h,m[2+v]=h,m[3+v]=h,m[4+v]=h,m[5+v]=h,m[6+v]=h,m[7+v]=h)}for(d=0;d<8;++d){var y=d;0!==m[8+y]||0!==m[16+y]||0!==m[24+y]||0!==m[32+y]||0!==m[40+y]||0!==m[48+y]||0!==m[56+y]?(i=5793*m[0+y]+2048>>12,a=5793*m[32+y]+2048>>12,o=m[16+y],s=m[48+y],f=2896*(m[8+y]-m[56+y])+2048>>12,c=2896*(m[8+y]+m[56+y])+2048>>12,l=m[24+y],h=i-a+1>>1,i=i+a+1>>1,a=h,h=3784*o+1567*s+2048>>12,o=1567*o-3784*s+2048>>12,s=h,h=f-(u=m[40+y])+1>>1,f=f+u+1>>1,u=h,h=c+l+1>>1,l=c-l+1>>1,c=h,h=i-s+1>>1,i=i+s+1>>1,s=h,h=a-o+1>>1,a=a+o+1>>1,o=h,h=2276*f+3406*c+2048>>12,f=3406*f-2276*c+2048>>12,c=h,h=799*l+4017*u+2048>>12,l=4017*l-799*u+2048>>12,u=h,m[0+y]=i+c,m[56+y]=i-c,m[8+y]=a+u,m[48+y]=a-u,m[16+y]=o+l,m[40+y]=o-l,m[24+y]=s+f,m[32+y]=s-f):(h=5793*n[d+0]+8192>>14,m[0+y]=h,m[8+y]=h,m[16+y]=h,m[24+y]=h,m[32+y]=h,m[40+y]=h,m[48+y]=h,m[56+y]=h)}for(d=0;d<64;++d){var w=128+(m[d]+8>>4);r[d]=w<0?0:w>255?255:w}}for(var l=0;l<i;l++){for(var u=l<<3,c=0;c<8;c++)r.push(new Uint8Array(a));for(var h=0;h<n;h++){f(t.blocks[l][h],s,o);for(var d=0,p=h<<3,m=0;m<8;m++)for(var v=r[u+m],y=0;y<8;y++)v[p+y]=s[d++]}}return r}var M=function(){function e(){u(this,e),this.jfif=null,this.adobe=null,this.quantizationTables=[],this.huffmanTablesAC=[],this.huffmanTablesDC=[],this.resetFrames()}return h(e,[{key:"resetFrames",value:function(){this.frames=[]}},{key:"parse",value:function(e){var t=0;function r(){var r=e[t]<<8|e[t+1];return t+=2,r}function n(e){var t,r,n=0,i=0;for(r in e.components)e.components.hasOwnProperty(r)&&(n<(t=e.components[r]).h&&(n=t.h),i<t.v&&(i=t.v));var a=Math.ceil(e.samplesPerLine/8/n),o=Math.ceil(e.scanLines/8/i);for(r in e.components)if(e.components.hasOwnProperty(r)){t=e.components[r];for(var s=Math.ceil(Math.ceil(e.samplesPerLine/8)*t.h/n),f=Math.ceil(Math.ceil(e.scanLines/8)*t.v/i),l=a*t.h,u=o*t.v,c=[],h=0;h<u;h++){for(var d=[],p=0;p<l;p++)d.push(new Int32Array(64));c.push(d)}t.blocksPerLine=s,t.blocksPerColumn=f,t.blocks=c}e.maxH=n,e.maxV=i,e.mcusPerLine=a,e.mcusPerColumn=o}var i,a,o=r();if(65496!==o)throw new Error("SOI not found");for(o=r();65497!==o;){switch(o){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:var s=(i=void 0,a=void 0,i=r(),a=e.subarray(t,t+i-2),t+=a.length,a);65504===o&&74===s[0]&&70===s[1]&&73===s[2]&&70===s[3]&&0===s[4]&&(this.jfif={version:{major:s[5],minor:s[6]},densityUnits:s[7],xDensity:s[8]<<8|s[9],yDensity:s[10]<<8|s[11],thumbWidth:s[12],thumbHeight:s[13],thumbData:s.subarray(14,14+3*s[12]*s[13])}),65518===o&&65===s[0]&&100===s[1]&&111===s[2]&&98===s[3]&&101===s[4]&&0===s[5]&&(this.adobe={version:s[6],flags0:s[7]<<8|s[8],flags1:s[9]<<8|s[10],transformCode:s[11]});break;case 65499:for(var f=r()+t-2;t<f;){var l=e[t++],u=new Int32Array(64);if(l>>4==0)for(var c=0;c<64;c++){u[D[c]]=e[t++]}else{if(l>>4!=1)throw new Error("DQT: invalid table spec");for(var h=0;h<64;h++){u[D[h]]=r()}}this.quantizationTables[15&l]=u}break;case 65472:case 65473:case 65474:r();for(var d={extended:65473===o,progressive:65474===o,precision:e[t++],scanLines:r(),samplesPerLine:r(),components:{},componentsOrder:[]},p=e[t++],m=void 0,v=0;v<p;v++){m=e[t];var y=e[t+1]>>4,w=15&e[t+1],g=e[t+2];d.componentsOrder.push(m),d.components[m]={h:y,v:w,quantizationIdx:g},t+=3}n(d),this.frames.push(d);break;case 65476:for(var b=r(),k=2;k<b;){for(var x=e[t++],_=new Uint8Array(16),A=0,P=0;P<16;P++,t++)_[P]=e[t],A+=_[P];for(var I=new Uint8Array(A),U=0;U<A;U++,t++)I[U]=e[t];k+=17+A,x>>4==0?this.huffmanTablesDC[15&x]=E(_,I):this.huffmanTablesAC[15&x]=E(_,I)}break;case 65501:r(),this.resetInterval=r();break;case 65498:r();for(var S=e[t++],T=[],O=this.frames[0],M=0;M<S;M++){var C=O.components[e[t++]],L=e[t++];C.huffmanTableDC=this.huffmanTablesDC[L>>4],C.huffmanTableAC=this.huffmanTablesAC[15&L],T.push(C)}var R=e[t++],V=e[t++],G=e[t++],F=B(e,t,O,T,this.resetInterval,R,V,G>>4,15&G);t+=F;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 ".concat(o.toString(16)))}o=r()}}},{key:"getResult",value:function(){var e=this.frames;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(var t=0;t<this.frames.length;t++)for(var r=this.frames[t].components,n=0,i=Object.keys(r);n<i.length;n++){var a=i[n];r[a].quantizationTable=this.quantizationTables[r[a].quantizationIdx],delete r[a].quantizationIdx}for(var o=e[0],s=o.components,f=o.componentsOrder,l=[],u=o.samplesPerLine,c=o.scanLines,h=0;h<f.length;h++){var d=s[f[h]];l.push({lines:O(0,d),scaleX:d.h/o.maxH,scaleY:d.v/o.maxV})}for(var p=new Uint8Array(u*c*l.length),m=0,v=0;v<c;++v)for(var y=0;y<u;++y)for(var w=0;w<l.length;++w){var g=l[w];p[m]=g.lines[0|v*g.scaleY][0|y*g.scaleX],++m}return p}}]),e}(),C=function(e){p(r,b);var t=T(r);function r(e){var n;return u(this,r),(n=t.call(this)).reader=new M,e.JPEGTables&&n.reader.parse(e.JPEGTables),n}return h(r,[{key:"decodeBlock",value:function(e){return this.reader.resetFrames(),this.reader.parse(new Uint8Array(e)),this.reader.getResult().buffer}}]),r}(),L=Object.freeze({__proto__:null,default:C});function R(e){for(var t=e.length;--t>=0;)e[t]=0}R(new Array(576)),R(new Array(60)),R(new Array(512)),R(new Array(256)),R(new Array(29)),R(new Array(30));var V=function(e,t,r,n){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0},G=new Uint32Array(function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}()),F=function(e,t,r,n){var i=G,a=n+r;e^=-1;for(var o=n;o<a;o++)e=e>>>8^i[255&(e^t[o])];return-1^e},z={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"},j={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},N=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},Z=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==r(n))throw new TypeError(n+"must be non-object");for(var i in n)N(n,i)&&(e[i]=n[i])}}return e},K=function(e){for(var t=0,r=0,n=e.length;r<n;r++)t+=e[r].length;for(var i=new Uint8Array(t),a=0,o=0,s=e.length;a<s;a++){var f=e[a];i.set(f,o),o+=f.length}return i},H=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){H=!1}for(var Y=new Uint8Array(256),X=0;X<256;X++)Y[X]=X>=252?6:X>=248?5:X>=240?4:X>=224?3:X>=192?2:1;Y[254]=Y[254]=1;var W=function(e){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,r,n,i,a,o=e.length,s=0;for(i=0;i<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[a++]=r:r<2048?(t[a++]=192|r>>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},q=function(e,t){var r,n,i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var a=new Array(2*i);for(n=0,r=0;r<i;){var o=e[r++];if(o<128)a[n++]=o;else{var s=Y[o];if(s>4)a[n++]=65533,r+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&r<i;)o=o<<6|63&e[r++],s--;s>1?a[n++]=65533:o<65536?a[n++]=o:(o-=65536,a[n++]=55296|o>>10&1023,a[n++]=56320|1023&o)}}}return function(e,t){if(t<65534&&e.subarray&&H)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}(a,n)},J=function(e,t){(t=t||e.length)>e.length&&(t=e.length);for(var r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Y[e[r]]>t?r:t};var Q=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},$=function(e,t){var r,n,i,a,o,s,f,l,u,c,h,d,p,m,v,y,w,g,b,k,x,_,A,P,I=e.state;r=e.next_in,A=e.input,n=r+(e.avail_in-5),i=e.next_out,P=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=I.dmax,f=I.wsize,l=I.whave,u=I.wnext,c=I.window,h=I.hold,d=I.bits,p=I.lencode,m=I.distcode,v=(1<<I.lenbits)-1,y=(1<<I.distbits)-1;e:do{d<15&&(h+=A[r++]<<d,d+=8,h+=A[r++]<<d,d+=8),w=p[h&v];t:for(;;){if(h>>>=g=w>>>24,d-=g,0===(g=w>>>16&255))P[i++]=65535&w;else{if(!(16&g)){if(0==(64&g)){w=p[(65535&w)+(h&(1<<g)-1)];continue t}if(32&g){I.mode=12;break e}e.msg="invalid literal/length code",I.mode=30;break e}b=65535&w,(g&=15)&&(d<g&&(h+=A[r++]<<d,d+=8),b+=h&(1<<g)-1,h>>>=g,d-=g),d<15&&(h+=A[r++]<<d,d+=8,h+=A[r++]<<d,d+=8),w=m[h&y];r:for(;;){if(h>>>=g=w>>>24,d-=g,!(16&(g=w>>>16&255))){if(0==(64&g)){w=m[(65535&w)+(h&(1<<g)-1)];continue r}e.msg="invalid distance code",I.mode=30;break e}if(k=65535&w,d<(g&=15)&&(h+=A[r++]<<d,(d+=8)<g&&(h+=A[r++]<<d,d+=8)),(k+=h&(1<<g)-1)>s){e.msg="invalid distance too far back",I.mode=30;break e}if(h>>>=g,d-=g,k>(g=i-a)){if((g=k-g)>l&&I.sane){e.msg="invalid distance too far back",I.mode=30;break e}if(x=0,_=c,0===u){if(x+=f-g,g<b){b-=g;do{P[i++]=c[x++]}while(--g);x=i-k,_=P}}else if(u<g){if(x+=f+u-g,(g-=u)<b){b-=g;do{P[i++]=c[x++]}while(--g);if(x=0,u<b){b-=g=u;do{P[i++]=c[x++]}while(--g);x=i-k,_=P}}}else if(x+=u-g,g<b){b-=g;do{P[i++]=c[x++]}while(--g);x=i-k,_=P}for(;b>2;)P[i++]=_[x++],P[i++]=_[x++],P[i++]=_[x++],b-=3;b&&(P[i++]=_[x++],b>1&&(P[i++]=_[x++]))}else{x=i-k;do{P[i++]=P[x++],P[i++]=P[x++],P[i++]=P[x++],b-=3}while(b>2);b&&(P[i++]=P[x++],b>1&&(P[i++]=P[x++]))}break}}break}}while(r<n&&i<o);r-=b=d>>3,h&=(1<<(d-=b<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r<n?n-r+5:5-(r-n),e.avail_out=i<o?o-i+257:257-(i-o),I.hold=h,I.bits=d},ee=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]),te=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]),re=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]),ne=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]),ie=function(e,t,r,n,i,a,o,s){var f,l,u,c,h,d,p,m,v,y=s.bits,w=0,g=0,b=0,k=0,x=0,_=0,A=0,P=0,I=0,U=0,S=null,T=0,D=new Uint16Array(16),E=new Uint16Array(16),B=null,O=0;for(w=0;w<=15;w++)D[w]=0;for(g=0;g<n;g++)D[t[r+g]]++;for(x=y,k=15;k>=1&&0===D[k];k--);if(x>k&&(x=k),0===k)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(b=1;b<k&&0===D[b];b++);for(x<b&&(x=b),P=1,w=1;w<=15;w++)if(P<<=1,(P-=D[w])<0)return-1;if(P>0&&(0===e||1!==k))return-1;for(E[1]=0,w=1;w<15;w++)E[w+1]=E[w]+D[w];for(g=0;g<n;g++)0!==t[r+g]&&(o[E[t[r+g]]++]=g);if(0===e?(S=B=o,d=19):1===e?(S=ee,T-=257,B=te,O-=257,d=256):(S=re,B=ne,d=-1),U=0,g=0,w=b,h=a,_=x,A=0,u=-1,c=(I=1<<x)-1,1===e&&I>852||2===e&&I>592)return 1;for(;;){p=w-A,o[g]<d?(m=0,v=o[g]):o[g]>d?(m=B[O+o[g]],v=S[T+o[g]]):(m=96,v=0),f=1<<w-A,b=l=1<<_;do{i[h+(U>>A)+(l-=f)]=p<<24|m<<16|v|0}while(0!==l);for(f=1<<w-1;U&f;)f>>=1;if(0!==f?(U&=f-1,U+=f):U=0,g++,0==--D[w]){if(w===k)break;w=t[r+o[g]]}if(w>x&&(U&c)!==u){for(0===A&&(A=x),h+=b,P=1<<(_=w-A);_+A<k&&!((P-=D[_+A])<=0);)_++,P<<=1;if(I+=1<<_,1===e&&I>852||2===e&&I>592)return 1;i[u=U&c]=x<<24|_<<16|h-a|0}}return 0!==U&&(i[h+U]=w-A<<24|64<<16|0),s.bits=x,0},ae=j.Z_FINISH,oe=j.Z_BLOCK,se=j.Z_TREES,fe=j.Z_OK,le=j.Z_STREAM_END,ue=j.Z_NEED_DICT,ce=j.Z_STREAM_ERROR,he=j.Z_DATA_ERROR,de=j.Z_MEM_ERROR,pe=j.Z_BUF_ERROR,me=j.Z_DEFLATED,ve=function(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)};function ye(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var we,ge,be=function(e){if(!e||!e.state)return ce;var 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,fe},ke=function(e){if(!e||!e.state)return ce;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,be(e)},xe=function(e,t){var r;if(!e||!e.state)return ce;var n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ce:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ke(e))},_e=function(e,t){if(!e)return ce;var r=new ye;e.state=r,r.window=null;var n=xe(e,t);return n!==fe&&(e.state=null),n},Ae=!0,Pe=function(e){if(Ae){we=new Int32Array(512),ge=new Int32Array(32);for(var t=0;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(ie(1,e.lens,0,288,we,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ie(2,e.lens,0,32,ge,0,e.work,{bits:5}),Ae=!1}e.lencode=we,e.lenbits=9,e.distcode=ge,e.distbits=5},Ie=function(e,t,r,n){var i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},Ue={inflateReset:ke,inflateReset2:xe,inflateResetKeep:be,inflateInit:function(e){return _e(e,15)},inflateInit2:_e,inflate:function(e,t){var r,n,i,a,o,s,f,l,u,c,h,d,p,m,v,y,w,g,b,k,x,_,A,P,I=0,U=new Uint8Array(4),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 ce;12===(r=e.state).mode&&(r.mode=13),o=e.next_out,i=e.output,f=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,l=r.hold,u=r.bits,c=s,h=f,_=fe;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(2&r.wrap&&35615===l){r.check=0,U[0]=255&l,U[1]=l>>>8&255,r.check=F(r.check,U,2,0),l=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&l)!==me){e.msg="unknown compression method",r.mode=30;break}if(u-=4,x=8+(15&(l>>>=4)),0===r.wbits)r.wbits=x;else if(x>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<r.wbits,e.adler=r.check=1,r.mode=512&l?10:12,l=0,u=0;break;case 2:for(;u<16;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(r.flags=l,(255&r.flags)!==me){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=l>>8&1),512&r.flags&&(U[0]=255&l,U[1]=l>>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}r.head&&(r.head.time=l),512&r.flags&&(U[0]=255&l,U[1]=l>>>8&255,U[2]=l>>>16&255,U[3]=l>>>24&255,r.check=F(r.check,U,4,0)),l=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}r.head&&(r.head.xflags=255&l,r.head.os=l>>8),512&r.flags&&(U[0]=255&l,U[1]=l>>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}r.length=l,r.head&&(r.head.extra_len=l),512&r.flags&&(U[0]=255&l,U[1]=l>>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>s&&(d=s),d&&(r.head&&(x=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+d),x)),512&r.flags&&(r.check=F(r.check,n,d,a)),s-=d,a+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;d=0;do{x=n[a+d++],r.head&&x&&r.length<65536&&(r.head.name+=String.fromCharCode(x))}while(x&&d<s);if(512&r.flags&&(r.check=F(r.check,n,d,a)),s-=d,a+=d,x)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===s)break e;d=0;do{x=n[a+d++],r.head&&x&&r.length<65536&&(r.head.comment+=String.fromCharCode(x))}while(x&&d<s);if(512&r.flags&&(r.check=F(r.check,n,d,a)),s-=d,a+=d,x)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;u<16;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(l!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}l=0,u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}e.adler=r.check=ve(l),l=0,u=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=o,e.avail_out=f,e.next_in=a,e.avail_in=s,r.hold=l,r.bits=u,ue;e.adler=r.check=1,r.mode=12;case 12:if(t===oe||t===se)break e;case 13:if(r.last){l>>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}switch(r.last=1&l,u-=1,3&(l>>>=1)){case 0:r.mode=14;break;case 1:if(Pe(r),r.mode=20,t===se){l>>>=2,u-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}l>>>=2,u-=2;break;case 14:for(l>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&l,l=0,u=0,r.mode=15,t===se)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>s&&(d=s),d>f&&(d=f),0===d)break e;i.set(n.subarray(a,a+d),o),s-=d,a+=d,f-=d,o+=d,r.length-=d;break}r.mode=12;break;case 17:for(;u<14;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(r.nlen=257+(31&l),l>>>=5,u-=5,r.ndist=1+(31&l),l>>>=5,u-=5,r.ncode=4+(15&l),l>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;u<3;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}r.lens[S[r.have++]]=7&l,l>>>=3,u-=3}for(;r.have<19;)r.lens[S[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},_=ie(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,_){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;y=(I=r.lencode[l&(1<<r.lenbits)-1])>>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(w<16)l>>>=v,u-=v,r.lens[r.have++]=w;else{if(16===w){for(P=v+2;u<P;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(l>>>=v,u-=v,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}x=r.lens[r.have-1],d=3+(3&l),l>>>=2,u-=2}else if(17===w){for(P=v+3;u<P;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}u-=v,x=0,d=3+(7&(l>>>=v)),l>>>=3,u-=3}else{for(P=v+7;u<P;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}u-=v,x=0,d=11+(127&(l>>>=v)),l>>>=7,u-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=x}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,A={bits:r.lenbits},_=ie(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,_){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},_=ie(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,_){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===se)break e;case 20:r.mode=21;case 21:if(s>=6&&f>=258){e.next_out=o,e.avail_out=f,e.next_in=a,e.avail_in=s,r.hold=l,r.bits=u,$(e,h),o=e.next_out,i=e.output,f=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,l=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;y=(I=r.lencode[l&(1<<r.lenbits)-1])>>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(y&&0==(240&y)){for(g=v,b=y,k=w;y=(I=r.lencode[k+((l&(1<<g+b)-1)>>g)])>>>16&255,w=65535&I,!(g+(v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}l>>>=g,u-=g,r.back+=g}if(l>>>=v,u-=v,r.back+=v,r.length=w,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=12;break}if(64&y){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(P=r.extra;u<P;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;y=(I=r.distcode[l&(1<<r.distbits)-1])>>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(0==(240&y)){for(g=v,b=y,k=w;y=(I=r.distcode[k+((l&(1<<g+b)-1)>>g)])>>>16&255,w=65535&I,!(g+(v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}l>>>=g,u-=g,r.back+=g}if(l>>>=v,u-=v,r.back+=v,64&y){e.msg="invalid distance code",r.mode=30;break}r.offset=w,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(P=r.extra;u<P;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===f)break e;if(d=h-f,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=o-r.offset,d=r.length;d>f&&(d=f),f-=d,r.length-=d;do{i[o++]=m[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===f)break e;i[o++]=r.length,f--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===s)break e;s--,l|=n[a++]<<u,u+=8}if(h-=f,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=r.flags?F(r.check,i,h,o-h):V(r.check,i,h,o-h)),h=f,(r.flags?l:ve(l))!==r.check){e.msg="incorrect data check",r.mode=30;break}l=0,u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;u<32;){if(0===s)break e;s--,l+=n[a++]<<u,u+=8}if(l!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}l=0,u=0}r.mode=29;case 29:_=le;break e;case 30:_=he;break e;case 31:return de;default:return ce}return e.next_out=o,e.avail_out=f,e.next_in=a,e.avail_in=s,r.hold=l,r.bits=u,(r.wsize||h!==e.avail_out&&r.mode<30&&(r.mode<27||t!==ae))&&Ie(e,e.output,e.next_out,h-e.avail_out),c-=e.avail_in,h-=e.avail_out,e.total_in+=c,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=r.flags?F(r.check,i,h,e.next_out-h):V(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0===c&&0===h||t===ae)&&_===fe&&(_=pe),_},inflateEnd:function(e){if(!e||!e.state)return ce;var t=e.state;return t.window&&(t.window=null),e.state=null,fe},inflateGetHeader:function(e,t){if(!e||!e.state)return ce;var r=e.state;return 0==(2&r.wrap)?ce:(r.head=t,t.done=!1,fe)},inflateSetDictionary:function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?ce:11===r.mode&&V(1,t,n,0)!==r.check?he:Ie(e,t,n,n)?(r.mode=31,de):(r.havedict=1,fe):ce},inflateInfo:"pako inflate (from Nodeca project)"};var Se=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},Te=Object.prototype.toString,De=j.Z_NO_FLUSH,Ee=j.Z_FINISH,Be=j.Z_OK,Oe=j.Z_STREAM_END,Me=j.Z_NEED_DICT,Ce=j.Z_STREAM_ERROR,Le=j.Z_DATA_ERROR,Re=j.Z_MEM_ERROR;function Ve(e){this.options=Z({chunkSize:65536,windowBits:15,to:""},e||{});var 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 Q,this.strm.avail_out=0;var r=Ue.inflateInit2(this.strm,t.windowBits);if(r!==Be)throw new Error(z[r]);if(this.header=new Se,Ue.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=W(t.dictionary):"[object ArrayBuffer]"===Te.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Ue.inflateSetDictionary(this.strm,t.dictionary))!==Be))throw new Error(z[r])}function Ge(e,t){var r=new Ve(t);if(r.push(e),r.err)throw r.msg||z[r.err];return r.result}Ve.prototype.push=function(e,t){var r,n,i,a=this.strm,o=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?Ee:De,"[object ArrayBuffer]"===Te.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(o),a.next_out=0,a.avail_out=o),(r=Ue.inflate(a,n))===Me&&s&&((r=Ue.inflateSetDictionary(a,s))===Be?r=Ue.inflate(a,n):r===Le&&(r=Me));a.avail_in>0&&r===Oe&&a.state.wrap>0&&0!==e[a.next_in];)Ue.inflateReset(a),r=Ue.inflate(a,n);switch(r){case Ce:case Le:case Me:case Re:return this.onEnd(r),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||r===Oe))if("string"===this.options.to){var f=J(a.output,a.next_out),l=a.next_out-f,u=q(a.output,f);a.next_out=l,a.avail_out=o-l,l&&a.output.set(a.output.subarray(f,f+l),0),this.onData(u)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==Be||0!==i){if(r===Oe)return r=Ue.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Ve.prototype.onData=function(e){this.chunks.push(e)},Ve.prototype.onEnd=function(e){e===Be&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=K(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Fe={Inflate:Ve,inflate:Ge,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Ge(e,t)},ungzip:Ge,constants:j}.inflate;function ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var je=function(e){p(r,b);var t=ze(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return Fe(new Uint8Array(e)).buffer}}]),r}(),Ne=Object.freeze({__proto__:null,default:je});function Ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var Ke,He=function(e){p(r,b);var t=Ze(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){for(var t=new DataView(e),r=[],n=0;n<e.byteLength;++n){var i=t.getInt8(n);if(i<0){var a=t.getUint8(n+1);i=-i;for(var o=0;o<=i;++o)r.push(a);n+=1}else{for(var s=0;s<=i;++s)r.push(t.getUint8(n+s+1));n+=i+1}}return new Uint8Array(r).buffer}}]),r}(),Ye=Object.freeze({__proto__:null,default:He}),Xe={exports:{}};Ke=Xe,\n/* 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 */\nfunction(){var e,t,r,n,i,a,o,s,f,l,u,c,h,d,p,m,v=(e={defaultNoDataValue:-34027999387901484e22,decode:function(a,o){var s=(o=o||{}).encodedMaskData||null===o.encodedMaskData,f=i(a,o.inputOffset||0,s),l=null!==o.noDataValue?o.noDataValue:e.defaultNoDataValue,u=t(f,o.pixelType||Float32Array,o.encodedMaskData,l,o.returnMask),c={width:f.width,height:f.height,pixelData:u.resultPixels,minValue:u.minValue,maxValue:f.pixels.maxValue,noDataValue:l};return u.resultMask&&(c.maskData=u.resultMask),o.returnEncodedMask&&f.mask&&(c.encodedMaskData=f.mask.bitset?f.mask.bitset:null),o.returnFileInfo&&(c.fileInfo=r(f),o.computeUsedBitDepths&&(c.fileInfo.bitDepths=n(f))),c}},t=function(e,t,r,n,i){var o,s,f,l=0,u=e.pixels.numBlocksX,c=e.pixels.numBlocksY,h=Math.floor(e.width/u),d=Math.floor(e.height/c),p=2*e.maxZError,m=Number.MAX_VALUE;r=r||(e.mask?e.mask.bitset:null),s=new t(e.width*e.height),i&&r&&(f=new Uint8Array(e.width*e.height));for(var v,y,w=new Float32Array(h*d),g=0;g<=c;g++){var b=g!==c?d:e.height%c;if(0!==b)for(var k=0;k<=u;k++){var x=k!==u?h:e.width%u;if(0!==x){var _,A,P,I,U=g*e.width*d+k*h,S=e.width-x,T=e.pixels.blocks[l];if(T.encoding<2?(0===T.encoding?_=T.rawData:(a(T.stuffedData,T.bitsPerPixel,T.numValidPixels,T.offset,p,w,e.pixels.maxValue),_=w),A=0):P=2===T.encoding?0:T.offset,r)for(y=0;y<b;y++){for(7&U&&(I=r[U>>3],I<<=7&U),v=0;v<x;v++)7&U||(I=r[U>>3]),128&I?(f&&(f[U]=1),m=m>(o=T.encoding<2?_[A++]:P)?o:m,s[U++]=o):(f&&(f[U]=0),s[U++]=n),I<<=1;U+=S}else if(T.encoding<2)for(y=0;y<b;y++){for(v=0;v<x;v++)m=m>(o=_[A++])?o:m,s[U++]=o;U+=S}else for(m=m>P?P:m,y=0;y<b;y++){for(v=0;v<x;v++)s[U++]=P;U+=S}if(1===T.encoding&&A!==T.numValidPixels)throw"Block and Mask do not match";l++}}}return{resultPixels:s,resultMask:f,minValue:m}},r=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}}},n=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,r={},n=0;n<t;n++){var i=e.pixels.blocks[n];0===i.encoding?r.float32=!0:1===i.encoding?r[i.bitsPerPixel]=!0:r[0]=!0}return Object.keys(r)},i=function(e,t,r){var n={},i=new Uint8Array(e,t,10);if(n.fileIdentifierString=String.fromCharCode.apply(null,i),"CntZImage"!==n.fileIdentifierString.trim())throw"Unexpected file identifier string: "+n.fileIdentifierString;t+=10;var a=new DataView(e,t,24);if(n.fileVersion=a.getInt32(0,!0),n.imageType=a.getInt32(4,!0),n.height=a.getUint32(8,!0),n.width=a.getUint32(12,!0),n.maxZError=a.getFloat64(16,!0),t+=24,!r)if(a=new DataView(e,t,16),n.mask={},n.mask.numBlocksY=a.getUint32(0,!0),n.mask.numBlocksX=a.getUint32(4,!0),n.mask.numBytes=a.getUint32(8,!0),n.mask.maxValue=a.getFloat32(12,!0),t+=16,n.mask.numBytes>0){var o=new Uint8Array(Math.ceil(n.width*n.height/8)),s=(a=new DataView(e,t,n.mask.numBytes)).getInt16(0,!0),f=2,l=0;do{if(s>0)for(;s--;)o[l++]=a.getUint8(f++);else{var u=a.getUint8(f++);for(s=-s;s--;)o[l++]=u}s=a.getInt16(f,!0),f+=2}while(f<n.mask.numBytes);if(-32768!==s||l<o.length)throw"Unexpected end of mask RLE encoding";n.mask.bitset=o,t+=n.mask.numBytes}else 0==(n.mask.numBytes|n.mask.numBlocksY|n.mask.maxValue)&&(n.mask.bitset=new Uint8Array(Math.ceil(n.width*n.height/8)));a=new DataView(e,t,16),n.pixels={},n.pixels.numBlocksY=a.getUint32(0,!0),n.pixels.numBlocksX=a.getUint32(4,!0),n.pixels.numBytes=a.getUint32(8,!0),n.pixels.maxValue=a.getFloat32(12,!0),t+=16;var c=n.pixels.numBlocksX,h=n.pixels.numBlocksY,d=c+(n.width%c>0?1:0),p=h+(n.height%h>0?1:0);n.pixels.blocks=new Array(d*p);for(var m=0,v=0;v<p;v++)for(var y=0;y<d;y++){var w=0,g=e.byteLength-t;a=new DataView(e,t,Math.min(10,g));var b={};n.pixels.blocks[m++]=b;var k=a.getUint8(0);if(w++,b.encoding=63&k,b.encoding>3)throw"Invalid block encoding ("+b.encoding+")";if(2!==b.encoding){if(0!==k&&2!==k){if(k>>=6,b.offsetType=k,2===k)b.offset=a.getInt8(1),w++;else if(1===k)b.offset=a.getInt16(1,!0),w+=2;else{if(0!==k)throw"Invalid block offset type";b.offset=a.getFloat32(1,!0),w+=4}if(1===b.encoding)if(k=a.getUint8(w),w++,b.bitsPerPixel=63&k,k>>=6,b.numValidPixelsType=k,2===k)b.numValidPixels=a.getUint8(w),w++;else if(1===k)b.numValidPixels=a.getUint16(w,!0),w+=2;else{if(0!==k)throw"Invalid valid pixel count type";b.numValidPixels=a.getUint32(w,!0),w+=4}}var x;if(t+=w,3!==b.encoding)if(0===b.encoding){var _=(n.pixels.numBytes-1)/4;if(_!==Math.floor(_))throw"uncompressed block has invalid length";x=new ArrayBuffer(4*_),new Uint8Array(x).set(new Uint8Array(e,t,4*_));var A=new Float32Array(x);b.rawData=A,t+=4*_}else if(1===b.encoding){var P=Math.ceil(b.numValidPixels*b.bitsPerPixel/8),I=Math.ceil(P/4);x=new ArrayBuffer(4*I),new Uint8Array(x).set(new Uint8Array(e,t,P)),b.stuffedData=new Uint32Array(x),t+=P}}else t++}return n.eofOffset=t,n},a=function(e,t,r,n,i,a,o){var s,f,l,u=(1<<t)-1,c=0,h=0,d=Math.ceil((o-n)/i),p=4*e.length-Math.ceil(t*r/8);for(e[e.length-1]<<=8*p,s=0;s<r;s++){if(0===h&&(l=e[c++],h=32),h>=t)f=l>>>h-t&u,h-=t;else{var m=t-h;f=(l&u)<<m&u,f+=(l=e[c++])>>>(h=32-m)}a[s]=f<d?n+f*i:o}return a},e),y=(o=function(e,t,r,n,i,a,o,s){var f,l,u,c,h,d=(1<<r)-1,p=0,m=0,v=4*e.length-Math.ceil(r*n/8);if(e[e.length-1]<<=8*v,i)for(f=0;f<n;f++)0===m&&(u=e[p++],m=32),m>=r?(l=u>>>m-r&d,m-=r):(l=(u&d)<<(c=r-m)&d,l+=(u=e[p++])>>>(m=32-c)),t[f]=i[l];else for(h=Math.ceil((s-a)/o),f=0;f<n;f++)0===m&&(u=e[p++],m=32),m>=r?(l=u>>>m-r&d,m-=r):(l=(u&d)<<(c=r-m)&d,l+=(u=e[p++])>>>(m=32-c)),t[f]=l<h?a+l*o:s},s=function(e,t,r,n,i,a){var o,s=(1<<t)-1,f=0,l=0,u=0,c=0,h=0,d=[],p=4*e.length-Math.ceil(t*r/8);e[e.length-1]<<=8*p;var m=Math.ceil((a-n)/i);for(l=0;l<r;l++)0===c&&(o=e[f++],c=32),c>=t?(h=o>>>c-t&s,c-=t):(h=(o&s)<<(u=t-c)&s,h+=(o=e[f++])>>>(c=32-u)),d[l]=h<m?n+h*i:a;return d.unshift(n),d},f=function(e,t,r,n,i,a,o,s){var f,l,u,c,h=(1<<r)-1,d=0,p=0,m=0;if(i)for(f=0;f<n;f++)0===p&&(u=e[d++],p=32,m=0),p>=r?(l=u>>>m&h,p-=r,m+=r):(l=u>>>m&h,p=32-(c=r-p),l|=((u=e[d++])&(1<<c)-1)<<r-c,m=c),t[f]=i[l];else{var v=Math.ceil((s-a)/o);for(f=0;f<n;f++)0===p&&(u=e[d++],p=32,m=0),p>=r?(l=u>>>m&h,p-=r,m+=r):(l=u>>>m&h,p=32-(c=r-p),l|=((u=e[d++])&(1<<c)-1)<<r-c,m=c),t[f]=l<v?a+l*o:s}return t},l=function(e,t,r,n,i,a){var o,s=(1<<t)-1,f=0,l=0,u=0,c=0,h=0,d=0,p=[],m=Math.ceil((a-n)/i);for(l=0;l<r;l++)0===c&&(o=e[f++],c=32,d=0),c>=t?(h=o>>>d&s,c-=t,d+=t):(h=o>>>d&s,c=32-(u=t-c),h|=((o=e[f++])&(1<<u)-1)<<t-u,d=u),p[l]=h<m?n+h*i:a;return p.unshift(n),p},u=function(e,t,r,n){var i,a,o,s,f=(1<<r)-1,l=0,u=0,c=4*e.length-Math.ceil(r*n/8);for(e[e.length-1]<<=8*c,i=0;i<n;i++)0===u&&(o=e[l++],u=32),u>=r?(a=o>>>u-r&f,u-=r):(a=(o&f)<<(s=r-u)&f,a+=(o=e[l++])>>>(u=32-s)),t[i]=a;return t},c=function(e,t,r,n){var i,a,o,s,f=(1<<r)-1,l=0,u=0,c=0;for(i=0;i<n;i++)0===u&&(o=e[l++],u=32,c=0),u>=r?(a=o>>>c&f,u-=r,c+=r):(a=o>>>c&f,u=32-(s=r-u),a|=((o=e[l++])&(1<<s)-1)<<r-s,c=s),t[i]=a;return t},h={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(e){for(var t=65535,r=65535,n=e.length,i=Math.floor(n/2),a=0;i;){var o=i>=359?359:i;i-=o;do{t+=e[a++]<<8,r+=t+=e[a++]}while(--o);t=(65535&t)+(t>>>16),r=(65535&r)+(r>>>16)}return 1&n&&(r+=t+=e[a]<<8),((r=(65535&r)+(r>>>16))<<16|(t=(65535&t)+(t>>>16)))>>>0},readHeaderInfo:function(e,t){var r=t.ptr,n=new Uint8Array(e,r,6),i={};if(i.fileIdentifierString=String.fromCharCode.apply(null,n),0!==i.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+i.fileIdentifierString;r+=6;var a,o=new DataView(e,r,8),s=o.getInt32(0,!0);if(i.fileVersion=s,r+=4,s>=3&&(i.checksum=o.getUint32(4,!0),r+=4),o=new DataView(e,r,12),i.height=o.getUint32(0,!0),i.width=o.getUint32(4,!0),r+=8,s>=4?(i.numDims=o.getUint32(8,!0),r+=4):i.numDims=1,o=new DataView(e,r,40),i.numValidPixel=o.getUint32(0,!0),i.microBlockSize=o.getInt32(4,!0),i.blobSize=o.getInt32(8,!0),i.imageType=o.getInt32(12,!0),i.maxZError=o.getFloat64(16,!0),i.zMin=o.getFloat64(24,!0),i.zMax=o.getFloat64(32,!0),r+=40,t.headerInfo=i,t.ptr=r,s>=3&&(a=s>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(e,r-a,i.blobSize-14))!==i.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var r=t.headerInfo,n=this.getDataTypeArray(r.imageType),i=r.numDims*this.getDataTypeSize(r.imageType),a=this.readSubArray(e,t.ptr,n,i),o=this.readSubArray(e,t.ptr+i,n,i);t.ptr+=2*i;var s,f=!0;for(s=0;s<r.numDims;s++)if(a[s]!==o[s]){f=!1;break}return r.minValues=a,r.maxValues=o,f},readSubArray:function(e,t,r,n){var i;if(r===Uint8Array)i=new Uint8Array(e,t,n);else{var a=new ArrayBuffer(n);new Uint8Array(a).set(new Uint8Array(e,t,n)),i=new r(a)}return i},readMask:function(e,t){var r,n,i=t.ptr,a=t.headerInfo,o=a.width*a.height,s=a.numValidPixel,f=new DataView(e,i,4),l={};if(l.numBytes=f.getUint32(0,!0),i+=4,(0===s||o===s)&&0!==l.numBytes)throw"invalid mask";if(0===s)r=new Uint8Array(Math.ceil(o/8)),l.bitset=r,n=new Uint8Array(o),t.pixels.resultMask=n,i+=l.numBytes;else if(l.numBytes>0){r=new Uint8Array(Math.ceil(o/8));var u=(f=new DataView(e,i,l.numBytes)).getInt16(0,!0),c=2,h=0,d=0;do{if(u>0)for(;u--;)r[h++]=f.getUint8(c++);else for(d=f.getUint8(c++),u=-u;u--;)r[h++]=d;u=f.getInt16(c,!0),c+=2}while(c<l.numBytes);if(-32768!==u||h<r.length)throw"Unexpected end of mask RLE encoding";n=new Uint8Array(o);var p=0,m=0;for(m=0;m<o;m++)7&m?(p=r[m>>3],p<<=7&m):p=r[m>>3],128&p&&(n[m]=1);t.pixels.resultMask=n,l.bitset=r,i+=l.numBytes}return t.ptr=i,t.mask=l,!0},readDataOneSweep:function(e,t,r,n){var i,a=t.ptr,o=t.headerInfo,s=o.numDims,f=o.width*o.height,l=o.imageType,u=o.numValidPixel*h.getDataTypeSize(l)*s,c=t.pixels.resultMask;if(r===Uint8Array)i=new Uint8Array(e,a,u);else{var d=new ArrayBuffer(u);new Uint8Array(d).set(new Uint8Array(e,a,u)),i=new r(d)}if(i.length===f*s)t.pixels.resultPixels=n?h.swapDimensionOrder(i,f,s,r,!0):i;else{t.pixels.resultPixels=new r(f*s);var p=0,m=0,v=0,y=0;if(s>1){if(n){for(m=0;m<f;m++)if(c[m])for(y=m,v=0;v<s;v++,y+=f)t.pixels.resultPixels[y]=i[p++]}else for(m=0;m<f;m++)if(c[m])for(y=m*s,v=0;v<s;v++)t.pixels.resultPixels[y+v]=i[p++]}else for(m=0;m<f;m++)c[m]&&(t.pixels.resultPixels[m]=i[p++])}return a+=u,t.ptr=a,!0},readHuffmanTree:function(e,t){var r=this.HUFFMAN_LUT_BITS_MAX,n=new DataView(e,t.ptr,16);if(t.ptr+=16,n.getInt32(0,!0)<2)throw"unsupported Huffman version";var i=n.getInt32(4,!0),a=n.getInt32(8,!0),o=n.getInt32(12,!0);if(a>=o)return!1;var s=new Uint32Array(o-a);h.decodeBits(e,t,s);var f,l,u,c,p=[];for(f=a;f<o;f++)p[l=f-(f<i?0:i)]={first:s[f-a],second:null};var m=e.byteLength-t.ptr,v=Math.ceil(m/4),y=new ArrayBuffer(4*v);new Uint8Array(y).set(new Uint8Array(e,t.ptr,m));var w,g=new Uint32Array(y),b=0,k=0;for(w=g[0],f=a;f<o;f++)(c=p[l=f-(f<i?0:i)].first)>0&&(p[l].second=w<<b>>>32-c,32-b>=c?32===(b+=c)&&(b=0,w=g[++k]):(b+=c-32,w=g[++k],p[l].second|=w>>>32-b));var x=0,_=0,A=new d;for(f=0;f<p.length;f++)void 0!==p[f]&&(x=Math.max(x,p[f].first));_=x>=r?r:x;var P,I,U,S,T,D=[];for(f=a;f<o;f++)if((c=p[l=f-(f<i?0:i)].first)>0)if(P=[c,l],c<=_)for(I=p[l].second<<_-c,U=1<<_-c,u=0;u<U;u++)D[I|u]=P;else for(I=p[l].second,T=A,S=c-1;S>=0;S--)I>>>S&1?(T.right||(T.right=new d),T=T.right):(T.left||(T.left=new d),T=T.left),0!==S||T.val||(T.val=P[1]);return{decodeLut:D,numBitsLUTQick:_,numBitsLUT:x,tree:A,stuffedData:g,srcPtr:k,bitPos:b}},readHuffman:function(e,t,r,n){var i,a,o,s,f,l,u,c,d,p=t.headerInfo.numDims,m=t.headerInfo.height,v=t.headerInfo.width,y=v*m,w=this.readHuffmanTree(e,t),g=w.decodeLut,b=w.tree,k=w.stuffedData,x=w.srcPtr,_=w.bitPos,A=w.numBitsLUTQick,P=w.numBitsLUT,I=0===t.headerInfo.imageType?128:0,U=t.pixels.resultMask,S=0;_>0&&(x++,_=0);var T,D=k[x],E=1===t.encodeMode,B=new r(y*p),O=B;if(p<2||E){for(T=0;T<p;T++)if(p>1&&(O=new r(B.buffer,y*T,y),S=0),t.headerInfo.numValidPixel===v*m)for(c=0,l=0;l<m;l++)for(u=0;u<v;u++,c++){if(a=0,f=s=D<<_>>>32-A,32-_<A&&(f=s|=k[x+1]>>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_<P&&(f=s|=k[x+1]>>>64-_-P),i=b,d=0;d<P;d++)if(!(i=s>>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,E?(o+=u>0?S:l>0?O[c-v]:S,o&=255,O[c]=o,S=o):O[c]=o}else for(c=0,l=0;l<m;l++)for(u=0;u<v;u++,c++)if(U[c]){if(a=0,f=s=D<<_>>>32-A,32-_<A&&(f=s|=k[x+1]>>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_<P&&(f=s|=k[x+1]>>>64-_-P),i=b,d=0;d<P;d++)if(!(i=s>>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,E?(u>0&&U[c-1]?o+=S:l>0&&U[c-v]?o+=O[c-v]:o+=S,o&=255,O[c]=o,S=o):O[c]=o}}else for(c=0,l=0;l<m;l++)for(u=0;u<v;u++)if(c=l*v+u,!U||U[c])for(T=0;T<p;T++,c+=y){if(a=0,f=s=D<<_>>>32-A,32-_<A&&(f=s|=k[x+1]>>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_<P&&(f=s|=k[x+1]>>>64-_-P),i=b,d=0;d<P;d++)if(!(i=s>>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,O[c]=o}t.ptr=t.ptr+4*(x+1)+(_>0?4:0),t.pixels.resultPixels=B,p>1&&!n&&(t.pixels.resultPixels=h.swapDimensionOrder(B,y,p,r))},decodeBits:function(e,t,r,n,i){var a=t.headerInfo,h=a.fileVersion,d=0,p=e.byteLength-t.ptr>=5?5:e.byteLength-t.ptr,m=new DataView(e,t.ptr,p),v=m.getUint8(0);d++;var y=v>>6,w=0===y?4:3-y,g=(32&v)>0,b=31&v,k=0;if(1===w)k=m.getUint8(d),d++;else if(2===w)k=m.getUint16(d,!0),d+=2;else{if(4!==w)throw"Invalid valid pixel count type";k=m.getUint32(d,!0),d+=4}var x,_,A,P,I,U,S,T,D,E=2*a.maxZError,B=a.numDims>1?a.maxValues[i]:a.zMax;if(g){for(t.counter.lut++,T=m.getUint8(d),d++,P=Math.ceil((T-1)*b/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),A=new Uint8Array(_),t.ptr+=d,A.set(new Uint8Array(e,t.ptr,P)),S=new Uint32Array(_),t.ptr+=P,D=0;T-1>>>D;)D++;P=Math.ceil(k*D/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),(A=new Uint8Array(_)).set(new Uint8Array(e,t.ptr,P)),x=new Uint32Array(_),t.ptr+=P,U=h>=3?l(S,b,T-1,n,E,B):s(S,b,T-1,n,E,B),h>=3?f(x,r,D,k,U):o(x,r,D,k,U)}else t.counter.bitstuffer++,D=b,t.ptr+=d,D>0&&(P=Math.ceil(k*D/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),(A=new Uint8Array(_)).set(new Uint8Array(e,t.ptr,P)),x=new Uint32Array(_),t.ptr+=P,h>=3?null==n?c(x,r,D,k):f(x,r,D,k,!1,n,E,B):null==n?u(x,r,D,k):o(x,r,D,k,!1,n,E,B))},readTiles:function(e,t,r,n){var i=t.headerInfo,a=i.width,o=i.height,s=a*o,f=i.microBlockSize,l=i.imageType,u=h.getDataTypeSize(l),c=Math.ceil(a/f),d=Math.ceil(o/f);t.pixels.numBlocksY=d,t.pixels.numBlocksX=c,t.pixels.ptr=0;var p,m,v,y,w,g,b,k,x,_,A=0,P=0,I=0,U=0,S=0,T=0,D=0,E=0,B=0,O=0,M=0,C=0,L=0,R=0,V=0,G=new r(f*f),F=o%f||f,z=a%f||f,j=i.numDims,N=t.pixels.resultMask,Z=t.pixels.resultPixels,K=i.fileVersion>=5?14:15,H=i.zMax;for(I=0;I<d;I++)for(S=I!==d-1?f:F,U=0;U<c;U++)for(O=I*a*f+U*f,M=a-(T=U!==c-1?f:z),k=0;k<j;k++){if(j>1?(_=Z,O=I*a*f+U*f,Z=new r(t.pixels.resultPixels.buffer,s*k*u,s),H=i.maxValues[k]):_=null,D=e.byteLength-t.ptr,m={},V=0,E=(p=new DataView(e,t.ptr,Math.min(10,D))).getUint8(0),V++,x=i.fileVersion>=5?4&E:0,B=E>>6&255,(E>>2&K)!=(U*f>>3&K))throw"integrity issue";if(x&&0===k)throw"integrity issue";if((w=3&E)>3)throw t.ptr+=V,"Invalid block encoding ("+w+")";if(2!==w)if(0===w){if(x)throw"integrity issue";if(t.counter.uncompressed++,t.ptr+=V,C=(C=S*T*u)<(L=e.byteLength-t.ptr)?C:L,v=new ArrayBuffer(C%u==0?C:C+u-C%u),new Uint8Array(v).set(new Uint8Array(e,t.ptr,C)),y=new r(v),R=0,N)for(A=0;A<S;A++){for(P=0;P<T;P++)N[O]&&(Z[O]=y[R++]),O++;O+=M}else for(A=0;A<S;A++){for(P=0;P<T;P++)Z[O++]=y[R++];O+=M}t.ptr+=R*u}else if(g=h.getDataTypeUsed(x&&l<6?4:l,B),b=h.getOnePixel(m,V,g,p),V+=h.getDataTypeSize(g),3===w)if(t.ptr+=V,t.counter.constantoffset++,N)for(A=0;A<S;A++){for(P=0;P<T;P++)N[O]&&(Z[O]=x?Math.min(H,_[O]+b):b),O++;O+=M}else for(A=0;A<S;A++){for(P=0;P<T;P++)Z[O]=x?Math.min(H,_[O]+b):b,O++;O+=M}else if(t.ptr+=V,h.decodeBits(e,t,G,b,k),V=0,x)if(N)for(A=0;A<S;A++){for(P=0;P<T;P++)N[O]&&(Z[O]=G[V++]+_[O]),O++;O+=M}else for(A=0;A<S;A++){for(P=0;P<T;P++)Z[O]=G[V++]+_[O],O++;O+=M}else if(N)for(A=0;A<S;A++){for(P=0;P<T;P++)N[O]&&(Z[O]=G[V++]),O++;O+=M}else for(A=0;A<S;A++){for(P=0;P<T;P++)Z[O++]=G[V++];O+=M}else{if(x)if(N)for(A=0;A<S;A++)for(P=0;P<T;P++)N[O]&&(Z[O]=_[O]),O++;else for(A=0;A<S;A++)for(P=0;P<T;P++)Z[O]=_[O],O++;t.counter.constant++,t.ptr+=V}}j>1&&!n&&(t.pixels.resultPixels=h.swapDimensionOrder(t.pixels.resultPixels,s,j,r))},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:h.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 r=e.headerInfo.zMax,n=e.headerInfo.zMin,i=e.headerInfo.maxValues,a=e.headerInfo.numDims,o=e.headerInfo.height*e.headerInfo.width,s=0,f=0,l=0,u=e.pixels.resultMask,c=e.pixels.resultPixels;if(u)if(a>1){if(t)for(s=0;s<a;s++)for(l=s*o,r=i[s],f=0;f<o;f++)u[f]&&(c[l+f]=r);else for(f=0;f<o;f++)if(u[f])for(l=f*a,s=0;s<a;s++)c[l+a]=i[s]}else for(f=0;f<o;f++)u[f]&&(c[f]=r);else if(a>1&&n!==r)if(t)for(s=0;s<a;s++)for(l=s*o,r=i[s],f=0;f<o;f++)c[l+f]=r;else for(f=0;f<o;f++)for(l=f*a,s=0;s<a;s++)c[l+s]=i[s];else for(f=0;f<o*a;f++)c[f]=r},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 r;switch(e){case 0:r=t>=-128&&t<=127;break;case 1:r=t>=0&&t<=255;break;case 2:r=t>=-32768&&t<=32767;break;case 3:r=t>=0&&t<=65536;break;case 4:r=t>=-2147483648&&t<=2147483647;break;case 5:r=t>=0&&t<=4294967296;break;case 6:r=t>=-34027999387901484e22&&t<=34027999387901484e22;break;case 7:r=t>=-17976931348623157e292&&t<=17976931348623157e292;break;default:r=!1}return r},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 r=e;switch(e){case 2:case 4:r=e-t;break;case 3:case 5:r=e-2*t;break;case 6:r=0===t?e:1===t?2:1;break;case 7:r=0===t?e:e-2*t+1;break;default:r=e}return r},getOnePixel:function(e,t,r,n){var i=0;switch(r){case 0:i=n.getInt8(t);break;case 1:i=n.getUint8(t);break;case 2:i=n.getInt16(t,!0);break;case 3:i=n.getUint16(t,!0);break;case 4:i=n.getInt32(t,!0);break;case 5:i=n.getUInt32(t,!0);break;case 6:i=n.getFloat32(t,!0);break;case 7:i=n.getFloat64(t,!0);break;default:throw"the decoder does not understand this pixel type"}return i},swapDimensionOrder:function(e,t,r,n,i){var a=0,o=0,s=0,f=0,l=e;if(r>1)if(l=new n(t*r),i)for(a=0;a<t;a++)for(f=a,s=0;s<r;s++,f+=t)l[f]=e[o++];else for(a=0;a<t;a++)for(f=a,s=0;s<r;s++,f+=t)l[o++]=e[f];return l}},d=function(e,t,r){this.val=e,this.left=t,this.right=r},{decode:function(e,t){var r=(t=t||{}).noDataValue,n=0,i={};i.ptr=t.inputOffset||0,i.pixels={},h.readHeaderInfo(e,i);var a=i.headerInfo,o=a.fileVersion,s=h.getDataTypeArray(a.imageType);if(o>5)throw"unsupported lerc version 2."+o;h.readMask(e,i),a.numValidPixel===a.width*a.height||i.pixels.resultMask||(i.pixels.resultMask=t.maskData);var f=a.width*a.height;i.pixels.resultPixels=new s(f*a.numDims),i.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var l,u=!t.returnPixelInterleavedDims;if(0!==a.numValidPixel)if(a.zMax===a.zMin)h.constructConstantSurface(i,u);else if(o>=4&&h.checkMinMaxRanges(e,i))h.constructConstantSurface(i,u);else{var c=new DataView(e,i.ptr,2),d=c.getUint8(0);if(i.ptr++,d)h.readDataOneSweep(e,i,s,u);else if(o>1&&a.imageType<=1&&Math.abs(a.maxZError-.5)<1e-5){var p=c.getUint8(1);if(i.ptr++,i.encodeMode=p,p>2||o<4&&p>1)throw"Invalid Huffman flag "+p;p?h.readHuffman(e,i,s,u):h.readTiles(e,i,s,u)}else h.readTiles(e,i,s,u)}i.eofOffset=i.ptr,t.inputOffset?(l=i.headerInfo.blobSize+t.inputOffset-i.ptr,Math.abs(l)>=1&&(i.eofOffset=t.inputOffset+i.headerInfo.blobSize)):(l=i.headerInfo.blobSize-i.ptr,Math.abs(l)>=1&&(i.eofOffset=i.headerInfo.blobSize));var m={width:a.width,height:a.height,pixelData:i.pixels.resultPixels,minValue:a.zMin,maxValue:a.zMax,validPixelCount:a.numValidPixel,dimCount:a.numDims,dimStats:{minValues:a.minValues,maxValues:a.maxValues},maskData:i.pixels.resultMask};if(i.pixels.resultMask&&h.isValidPixelValue(a.imageType,r)){var v=i.pixels.resultMask;for(n=0;n<f;n++)v[n]||(m.pixelData[n]=r);m.noDataValue=r}return i.noDataValue=r,t.returnFileInfo&&(m.fileInfo=h.formatFileInfo(i)),m},getBandCount:function(e){for(var t=0,r=0,n={ptr:0,pixels:{}};r<e.byteLength-58;)h.readHeaderInfo(e,n),r+=n.headerInfo.blobSize,t++,n.ptr=r;return t}}),w=(p=new ArrayBuffer(4),m=new Uint8Array(p),new Uint32Array(p)[0]=1,1===m[0]),g={decode:function(e,t){if(!w)throw"Big endian system is not supported.";var r,n,i=(t=t||{}).inputOffset||0,a=new Uint8Array(e,i,10),o=String.fromCharCode.apply(null,a);if("CntZImage"===o.trim())r=v,n=1;else{if("Lerc2"!==o.substring(0,5))throw"Unexpected file identifier string: "+o;r=y,n=2}for(var s,f,l,u,c,h,d=0,p=e.byteLength-10,m=[],g={width:0,height:0,pixels:[],pixelType:t.pixelType,mask:null,statistics:[]},b=0;i<p;){var k=r.decode(e,{inputOffset:i,encodedMaskData:s,maskData:l,returnMask:0===d,returnEncodedMask:0===d,returnFileInfo:!0,returnPixelInterleavedDims:t.returnPixelInterleavedDims,pixelType:t.pixelType||null,noDataValue:t.noDataValue||null});i=k.fileInfo.eofOffset,l=k.maskData,0===d&&(s=k.encodedMaskData,g.width=k.width,g.height=k.height,g.dimCount=k.dimCount||1,g.pixelType=k.pixelType||k.fileInfo.pixelType,g.mask=l),n>1&&(l&&m.push(l),k.fileInfo.mask&&k.fileInfo.mask.numBytes>0&&b++),d++,g.pixels.push(k.pixelData),g.statistics.push({minValue:k.minValue,maxValue:k.maxValue,noDataValue:k.noDataValue,dimStats:k.dimStats})}if(n>1&&b>1){for(h=g.width*g.height,g.bandMasks=m,(l=new Uint8Array(h)).set(m[0]),u=1;u<m.length;u++)for(f=m[u],c=0;c<h;c++)l[c]=l[c]&f[c];g.maskData=l}return g}};Ke.exports?Ke.exports=g:this.Lerc=g}();var We=Xe.exports,qe={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"},Je={};for(var Qe in qe)qe.hasOwnProperty(Qe)&&(Je[qe[Qe]]=parseInt(Qe,10));Je.BitsPerSample,Je.ExtraSamples,Je.SampleFormat,Je.StripByteCounts,Je.StripOffsets,Je.StripRowCounts,Je.TileByteCounts,Je.TileOffsets,Je.SubIFDs;var $e={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"},et={};for(var tt in $e)$e.hasOwnProperty(tt)&&(et[$e[tt]]=parseInt(tt,10));var rt=1,nt=0,it=1,at={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"},ot={};for(var st in at)at.hasOwnProperty(st)&&(ot[at[st]]=parseInt(st,10));function ft(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var lt=function(e){p(r,b);var t=ft(r);function r(e){var n;return u(this,r),(n=t.call(this)).planarConfiguration=void 0!==e.PlanarConfiguration?e.PlanarConfiguration:1,n.samplesPerPixel=void 0!==e.SamplesPerPixel?e.SamplesPerPixel:1,n.addCompression=e.LercParameters[rt],n}return h(r,[{key:"decodeBlock",value:function(e){switch(this.addCompression){case nt:break;case it:e=Fe(new Uint8Array(e)).buffer;break;default:throw new Error("Unsupported LERC additional compression method identifier: ".concat(this.addCompression))}return We.decode(e,{returnPixelInterleavedDims:1===this.planarConfiguration}).pixels[0].buffer}}]),r}(),ut=Object.freeze({__proto__:null,default:lt});function ct(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var ht=function(e){p(a,b);var r,n=ct(a);function a(){var e;if(u(this,a),e=n.call(this),"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");return e}return h(a,[{key:"decode",value:(r=t(i.mark((function e(t,r){var n,a,o,s;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Blob([r]),e.next=3,createImageBitmap(n);case 3:return a=e.sent,"undefined"!=typeof document?((o=document.createElement("canvas")).width=a.width,o.height=a.height):o=new OffscreenCanvas(a.width,a.height),(s=o.getContext("2d")).drawImage(a,0,0),e.abrupt("return",s.getImageData(0,0,a.width,a.height).data.buffer);case 8:case"end":return e.stop()}}),e)}))),function(e,t){return r.apply(this,arguments)})}]),a}(),dt=Object.freeze({__proto__:null,default:ht});';return new qi("undefined"==typeof Blob?"data:application/javascript;base64,"+Buffer.from(e,"binary").toString("base64"):URL.createObjectURL(new Blob([e],{type:"application/javascript"})))}});e.GeoTIFF=Zr,e.GeoTIFFImage=Ce,e.MultiGeoTIFF=Hr,e.Pool=je,e.addDecoder=be,e.default=Zr,e.fromArrayBuffer=function(e,t){return qr.apply(this,arguments)},e.fromBlob=function(e,t){return Wr.apply(this,arguments)},e.fromFile=function(e,t){return Xr.apply(this,arguments)},e.fromUrl=function(e){return Yr.apply(this,arguments)},e.fromUrls=function(e){return Jr.apply(this,arguments)},e.getDecoder=ke,e.globals=ce,e.rgb=ye,e.setLogger=function(){arguments.length>0&&void 0!==arguments[0]||new Br},e.writeArrayBuffer=function(e,t){return Mr(e,t)},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
//# sourceMappingURL=geotiff.js.map
|