unpkg.com Open in urlscan Pro
2606:4700::6811:f9cb  Public Scan

Submitted URL: https://unpkg.com/lerc@latest/LercDecode.min.js
Effective URL: https://unpkg.com/lerc@4.0.4/LercDecode.min.js
Submission Tags: falconsandbox
Submission: On November 20 via api from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

/*! Lerc 4.0
Copyright 2015 - 2023 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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
A local copy of the license and additional notices are located with the
source distribution at:
http://github.com/Esri/lerc/
Contributors:  Thomas Maurer, Wenxue Ju
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Lerc={})}(this,(function(t){"use strict";var e,n=(e="undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("LercDecode.js",document.baseURI).href,function(t){var n,r;(t=void 0!==(t=t||{})?t:{}).ready=new Promise((function(t,e){n=t,r=e}));var i,o,a,s,u,c,f=Object.assign({},t),l="object"==typeof window,p="function"==typeof importScripts,d="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,h="";d?(h=p?require("path").dirname(h)+"/":__dirname+"/",c=()=>{u||(s=require("fs"),u=require("path"))},i=function(t,e){return c(),t=u.normalize(t),s.readFileSync(t,e?void 0:"utf8")},a=t=>{var e=i(t,!0);return e.buffer||(e=new Uint8Array(e)),e},o=(t,e,n)=>{c(),t=u.normalize(t),s.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof X))throw t})),process.on("unhandledRejection",(function(t){throw t})),t.inspect=function(){return"[Emscripten Module object]"}):(l||p)&&(p?h=self.location.href:"undefined"!=typeof document&&document.currentScript&&(h=document.currentScript.src),e&&(h=e),h=0!==h.indexOf("blob:")?h.substr(0,h.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},p&&(a=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),o=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)}),t.print||console.log.bind(console);var y,m,g=t.printErr||console.warn.bind(console);Object.assign(t,f),f=null,t.arguments,t.thisProgram,t.quit,t.wasmBinary&&(y=t.wasmBinary),t.noExitRuntime,"object"!=typeof WebAssembly&&B("no native wasm support detected");var _,w,b,A,v,U,x=!1,R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function I(t,e){return t?function(t,e,n){for(var r=e+n,i=e;t[i]&&!(i>=r);)++i;if(i-e>16&&t.buffer&&R)return R.decode(t.subarray(e,i));for(var o="";e<i;){var a=t[e++];if(128&a){var s=63&t[e++];if(192!=(224&a)){var u=63&t[e++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<6|63&t[e++])<65536)o+=String.fromCharCode(a);else{var c=a-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|s)}else o+=String.fromCharCode(a)}return o}(b,t,e):""}function S(e){_=e,t.HEAP8=w=new Int8Array(e),t.HEAP16=new Int16Array(e),t.HEAP32=A=new Int32Array(e),t.HEAPU8=b=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=v=new Uint32Array(e),t.HEAPF32=new Float32Array(e),t.HEAPF64=new Float64Array(e)}t.INITIAL_MEMORY;var T,C,D=[],E=[],P=[],F=0,j=null;function B(e){t.onAbort&&t.onAbort(e),g(e="Aborted("+e+")"),x=!0,e+=". Build with -sASSERTIONS for more info.";var n=new WebAssembly.RuntimeError(e);throw r(n),n}function L(t){return t.startsWith("data:application/octet-stream;base64,")}function z(t){return t.startsWith("file://")}function M(t){try{if(t==T&&y)return new Uint8Array(y);if(a)return a(t);throw"both async and sync fetching of the wasm failed"}catch(t){B(t)}}function V(e){for(;e.length>0;){var n=e.shift();if("function"!=typeof n){var r=n.func;"number"==typeof r?void 0===n.arg?W(r)():W(r)(n.arg):r(void 0===n.arg?null:n.arg)}else n(t)}}t.locateFile?L(T="lerc-wasm.wasm")||(C=T,T=t.locateFile?t.locateFile(C,h):h+C):T=new URL("lerc-wasm.wasm","undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("LercDecode.js",document.baseURI).href).toString();var k=[];function W(t){var e=k[t];return e||(t>=k.length&&(k.length=t+1),k[t]=e=U.get(t)),e}function H(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){v[this.ptr+4>>2]=t},this.get_type=function(){return v[this.ptr+4>>2]},this.set_destructor=function(t){v[this.ptr+8>>2]=t},this.get_destructor=function(){return v[this.ptr+8>>2]},this.set_refcount=function(t){A[this.ptr>>2]=t},this.set_caught=function(t){t=t?1:0,w[this.ptr+12>>0]=t},this.get_caught=function(){return 0!=w[this.ptr+12>>0]},this.set_rethrown=function(t){t=t?1:0,w[this.ptr+13>>0]=t},this.get_rethrown=function(){return 0!=w[this.ptr+13>>0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var t=A[this.ptr>>2];A[this.ptr>>2]=t+1},this.release_ref=function(){var t=A[this.ptr>>2];return A[this.ptr>>2]=t-1,1===t},this.set_adjusted_ptr=function(t){v[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return v[this.ptr+16>>2]},this.get_exception_ptr=function(){if(G(this.get_type()))return v[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function O(t){try{return m.grow(t-_.byteLength+65535>>>16),S(m.buffer),1}catch(t){}}var q={a:function(t,e,n,r){B("Assertion failed: "+I(t)+", at: "+[e?I(e):"unknown filename",n,r?I(r):"unknown function"])},c:function(t){return $(t+24)+24},b:function(t,e,n){throw new H(t).init(e,n),t},d:function(){B("")},f:function(t,e,n){b.copyWithin(t,e,e+n)},e:function(t){var e,n,r=b.length,i=2147483648;if((t>>>=0)>i)return!1;for(var o=1;o<=4;o*=2){var a=r*(1+.2/o);if(a=Math.min(a,t+100663296),O(Math.min(i,(e=Math.max(t,a))+((n=65536)-e%n)%n)))return!0}return!1}};!function(){var e={a:q};function n(e,n){var r,i=e.exports;t.asm=i,S((m=t.asm.g).buffer),U=t.asm.m,r=t.asm.h,E.unshift(r),function(e){if(F--,t.monitorRunDependencies&&t.monitorRunDependencies(F),0==F&&j){var n=j;j=null,n()}}()}function i(t){n(t.instance)}function a(t){return function(){if(!y&&(l||p)){if("function"==typeof fetch&&!z(T))return fetch(T,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+T+"'";return t.arrayBuffer()})).catch((function(){return M(T)}));if(o)return new Promise((function(t,e){o(T,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return M(T)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(t,(function(t){g("failed to asynchronously prepare wasm: "+t),B(t)}))}if(F++,t.monitorRunDependencies&&t.monitorRunDependencies(F),t.instantiateWasm)try{return t.instantiateWasm(e,n)}catch(t){return g("Module.instantiateWasm callback failed with error: "+t),!1}(y||"function"!=typeof WebAssembly.instantiateStreaming||L(T)||z(T)||d||"function"!=typeof fetch?a(i):fetch(T,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(i,(function(t){return g("wasm streaming compile failed: "+t),g("falling back to ArrayBuffer instantiation"),a(i)}))}))).catch(r)}(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.h).apply(null,arguments)},t._lerc_getBlobInfo=function(){return(t._lerc_getBlobInfo=t.asm.i).apply(null,arguments)},t._lerc_getDataRanges=function(){return(t._lerc_getDataRanges=t.asm.j).apply(null,arguments)},t._lerc_decode=function(){return(t._lerc_decode=t.asm.k).apply(null,arguments)},t._lerc_decode_4D=function(){return(t._lerc_decode_4D=t.asm.l).apply(null,arguments)};var $=t._malloc=function(){return($=t._malloc=t.asm.n).apply(null,arguments)};t._free=function(){return(t._free=t.asm.o).apply(null,arguments)};var N,G=t.___cxa_is_pointer_type=function(){return(G=t.___cxa_is_pointer_type=t.asm.p).apply(null,arguments)};function X(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function Y(e){function r(){N||(N=!0,t.calledRun=!0,x||(V(E),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),function(){if(t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;)e=t.postRun.shift(),P.unshift(e);var e;V(P)}()))}F>0||(function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)e=t.preRun.shift(),D.unshift(e);var e;V(D)}(),F>0||(t.setStatus?(t.setStatus("Running..."),setTimeout((function(){setTimeout((function(){t.setStatus("")}),1),r()}),1)):r()))}if(j=function t(){N||Y(),N||(j=t)},t.run=Y,t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Y(),t.ready});const r=[{pixelType:"S8",size:1,ctor:Int8Array,range:[-128,128]},{pixelType:"U8",size:1,ctor:Uint8Array,range:[0,255]},{pixelType:"S16",size:2,ctor:Int16Array,range:[-32768,32767]},{pixelType:"U16",size:2,ctor:Uint16Array,range:[0,65536]},{pixelType:"S32",size:4,ctor:Int32Array,range:[-2147483648,2147483647]},{pixelType:"U32",size:4,ctor:Uint32Array,range:[0,4294967296]},{pixelType:"F32",size:4,ctor:Float32Array,range:[-34027999387901484e22,34027999387901484e22]},{pixelType:"F64",size:8,ctor:Float64Array,range:[-17976931348623157e292,17976931348623157e292]}];let i=null,o=!1;const a={getBlobInfo:null,decode:null};function s(t,e,n){n.set(t.slice(e,e+n.length))}function u(t,e,n,r,i){if(n<2)return t;const o=new r(e*n);if(i)for(let r=0,i=0;r<e;r++)for(let a=0,s=r;a<n;a++,s+=e)o[s]=t[i++];else for(let r=0,i=0;r<e;r++)for(let a=0,s=r;a<n;a++,s+=e)o[i++]=t[s];return o}function c(t,e={}){var n;const r=null!==(n=e.inputOffset)&&void 0!==n?n:0,i=t instanceof Uint8Array?t.subarray(r):new Uint8Array(t,r);return a.getBlobInfo(i)}t.decode=function(t,e={}){var n,i;const o=null!==(n=e.inputOffset)&&void 0!==n?n:0,s=t instanceof Uint8Array?t.subarray(o):new Uint8Array(t,o),c=a.getBlobInfo(s),{data:f,maskData:l}=a.decode(s,c),{width:p,height:d,bandCount:h,dimCount:y,depthCount:m,dataType:g,maskCount:_,statistics:w}=c,b=r[g],A=new b.ctor(f.buffer),v=[],U=[],x=p*d,R=x*m,I=null!==(i=e.returnInterleaved)&&void 0!==i?i:e.returnPixelInterleavedDims;for(let t=0;t<h;t++){const e=A.subarray(t*R,(t+1)*R);if(I)v.push(e);else{const t=u(e,x,m,b.ctor,!0);v.push(t)}U.push(l.subarray(t*R,(t+1)*R))}const S=0===_?null:1===_?U[0]:new Uint8Array(x);if(_>1){S.set(U[0]);for(let t=1;t<U.length;t++){const e=U[t];for(let t=0;t<x;t++)S[t]=S[t]&e[t]}}const{noDataValue:T}=e,C=null!=T&&b.range[0]<=T&&b.range[1]>=T;if(_>0&&C)for(let t=0;t<h;t++){const e=v[t],n=U[t]||S;for(let t=0;t<x;t++)0===n[t]&&(e[t]=T)}const D=_===h&&h>1?U:null,{pixelType:E}=b;return{width:p,height:d,pixelType:E,statistics:w,pixels:v,mask:S,dimCount:y,depthCount:m,bandMasks:D}},t.getBandCount=function(t,e={}){return c(t,e).bandCount},t.getBlobInfo=c,t.isLoaded=function(){return o},t.load=function(t={}){if(i)return i;const e=t.locateFile||((t,e)=>`${e}${t}`);return i=n({locateFile:e}).then((t=>t.ready.then((()=>{!function(t){const{_malloc:e,_free:n,_lerc_getBlobInfo:i,_lerc_getDataRanges:o,_lerc_decode_4D:u,asm:c}=t;let f;const l=Object.values(c).find((e=>e&&"buffer"in e&&e.buffer===t.HEAPU8.buffer)),p=t=>{const n=t.map((t=>16+(t>>3<<3))),r=n.reduce(((t,e)=>t+e)),i=e(r);f=new Uint8Array(l.buffer);let o=n[0];n[0]=i;for(let t=1;t<n.length;t++){const e=n[t];n[t]=n[t-1]+o,o=e}return n};a.getBlobInfo=t=>{const e=12,r=3,a=new Uint8Array(4*e),u=new Uint8Array(8*r),[c,d,h]=p([t.length,a.length,u.length]);f.set(t,c),f.set(a,d),f.set(u,h);let y=i(c,t.length,d,h,e,r);if(y)throw n(c),`lerc-getBlobInfo: error code is ${y}`;f=new Uint8Array(l.buffer),s(f,d,a),s(f,h,u);const m=new Uint32Array(a.buffer),g=new Float64Array(u.buffer),[_,w,b,A,v,U,x,R,I,S,T]=m,C={version:_,dimCount:b,width:A,height:v,validPixelCount:x,bandCount:U,blobSize:R,maskCount:I,depthCount:S,dataType:w,minValue:g[0],maxValue:g[1],maxZerror:g[2],statistics:[],bandCountWithNoData:T};if(T)return n(c),C;if(1===S&&1===U)return n(c),C.statistics.push({minValue:g[0],maxValue:g[1]}),C;const D=S*U*8,E=new Uint8Array(D),P=new Uint8Array(D);let F=c,j=0,B=0,L=!1;if(f.byteLength<c+2*D?(n(c),L=!0,[F,j,B]=p([t.length,D,D]),f.set(t,F)):[j,B]=p([D,D]),f.set(E,j),f.set(P,B),y=o(F,t.length,S,U,j,B),y)throw n(F),L||n(j),`lerc-getDataRanges: error code is ${y}`;f=new Uint8Array(l.buffer),s(f,j,E),s(f,B,P);const z=new Float64Array(E.buffer),M=new Float64Array(P.buffer),V=C.statistics;for(let t=0;t<U;t++)if(S>1){const e=z.slice(t*S,(t+1)*S),n=M.slice(t*S,(t+1)*S),r=Math.min.apply(null,e),i=Math.max.apply(null,n);V.push({minValue:r,maxValue:i,dimStats:{minValues:e,maxValues:n},depthStats:{minValues:e,maxValues:n}})}else V.push({minValue:z[t],maxValue:M[t]});return n(F),L||n(j),C},a.decode=(t,e)=>{const{maskCount:i,depthCount:o,bandCount:a,width:c,height:d,dataType:h,bandCountWithNoData:y}=e,m=r[h],g=c*d,_=new Uint8Array(g*a),w=g*o*a*m.size,b=new Uint8Array(w),A=new Uint8Array(a),v=new Uint8Array(8*a),[U,x,R,I,S]=p([t.length,_.length,b.length,A.length,v.length]);f.set(t,U),f.set(_,x),f.set(b,R),f.set(A,I),f.set(v,S);const T=u(U,t.length,i,x,o,c,d,a,h,R,I,S);if(T)throw n(U),`lerc-decode: error code is ${T}`;f=new Uint8Array(l.buffer),s(f,R,b),s(f,x,_);let C=null;if(y){s(f,I,A),s(f,S,v),C=[];const t=new Float64Array(v.buffer);for(let e=0;e<A.length;e++)C.push(A[e]?t[e]:null)}return n(U),{data:b,maskData:_,noDataValues:C}}}(t),o=!0})))),i},Object.defineProperty(t,"__esModule",{value:!0})}));