@keeratita/heic-converter 0.6.1 → 0.6.2-prerelease

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";var t,e="undefined"!=typeof document?document.currentScript:null,r=(t="undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("heic-decoder-2EERQO7N.js",document.baseURI).href,async function(r={}){var n,i,a=r;a.ready=new Promise((t,e)=>{n=t,i=e});var o,s,u=Object.assign({},a),c="./this.program",f="object"==typeof window,h="function"==typeof importScripts,p="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,l="";if(p){const{createRequire:t}=await(import("module"));var d=t("undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("heic-decoder-2EERQO7N.js",document.baseURI).href),v=d("fs"),m=d("path");l=h?m.dirname(l)+"/":d("url").fileURLToPath(new URL("./","undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("heic-decoder-2EERQO7N.js",document.baseURI).href)),o=(t,e)=>(t=W(t)?new URL(t):m.normalize(t),v.readFileSync(t,e?void 0:"utf8")),s=t=>{var e=o(t,!0);return e.buffer||(e=new Uint8Array(e)),e},!a.thisProgram&&process.argv.length>1&&(c=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(f||h)&&(h?l=self.location.href:"undefined"!=typeof document&&document.currentScript&&(l=document.currentScript.src),t&&(l=t),l=l.startsWith("blob:")?"":l.substr(0,l.replace(/[?#].*/,"").lastIndexOf("/")+1),o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},h&&(s=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}));var g,y,_=a.print||console.log.bind(console),w=a.printErr||console.error.bind(console);Object.assign(a,u),u=null,a.arguments&&a.arguments,a.thisProgram&&(c=a.thisProgram),a.quit&&a.quit,a.wasmBinary&&(g=a.wasmBinary);var R,b,A,U=!1;function E(){var t=y.buffer;a.HEAP8=R=new Int8Array(t),a.HEAP16=new Int16Array(t),a.HEAPU8=b=new Uint8Array(t),a.HEAPU16=new Uint16Array(t),a.HEAP32=new Int32Array(t),a.HEAPU32=A=new Uint32Array(t),a.HEAPF32=new Float32Array(t),a.HEAPF64=new Float64Array(t)}var P=[],C=[],S=[];function j(t){P.unshift(t)}function I(t){S.unshift(t)}var T=0,x=null;function L(t){a.onAbort?.(t),w(t="Aborted("+t+")"),U=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw i(e),e}var F,H,N=t=>t.startsWith("data:application/octet-stream;base64,"),W=t=>t.startsWith("file://");function O(t){if(t==F&&g)return new Uint8Array(g);if(s)return s(t);throw"both async and sync fetching of the wasm failed"}function q(t,e,r){return function(t){return g||!f&&!h||"function"!=typeof fetch?Promise.resolve().then(()=>O(t)):fetch(t,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw`failed to load wasm binary file at '${t}'`;return e.arrayBuffer()}).catch(()=>O(t))}(t).then(t=>WebAssembly.instantiate(t,e)).then(r,t=>{w(`failed to asynchronously prepare wasm: ${t}`),L(t)})}a.locateFile?N(F="heic-decoder.wasm")||(H=F,F=a.locateFile?a.locateFile(H,l):l+H):F=new URL("heic-decoder.wasm","undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("heic-decoder-2EERQO7N.js",document.baseURI).href).href;var M=t=>{for(;t.length>0;)t.shift()(a)};a.noExitRuntime;var k="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,$=(t,e,r)=>{for(var n=e+r,i=e;t[i]&&!(i>=n);)++i;if(i-e>16&&t.buffer&&k)return k.decode(t.subarray(e,i));for(var a="";e<i;){var o=t[e++];if(128&o){var s=63&t[e++];if(192!=(224&o)){var u=63&t[e++];if((o=224==(240&o)?(15&o)<<12|s<<6|u:(7&o)<<18|s<<12|u<<6|63&t[e++])<65536)a+=String.fromCharCode(o);else{var c=o-65536;a+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a},B=(t,e)=>t?$(b,t,e):"",D=[],G=0,Q=0;class z{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){A[this.ptr+4>>2]=t}get_type(){return A[this.ptr+4>>2]}set_destructor(t){A[this.ptr+8>>2]=t}get_destructor(){return A[this.ptr+8>>2]}set_caught(t){t=t?1:0,R[this.ptr+12]=t}get_caught(){return 0!=R[this.ptr+12]}set_rethrown(t){t=t?1:0,R[this.ptr+13]=t}get_rethrown(){return 0!=R[this.ptr+13]}init(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)}set_adjusted_ptr(t){A[this.ptr+16>>2]=t}get_adjusted_ptr(){return A[this.ptr+16>>2]}get_exception_ptr(){if(lt(this.get_type()))return A[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}var X,J=t=>{var e=Q;if(!e)return st(0),0;var r=new z(e);r.set_adjusted_ptr(e);var n=r.get_type();if(!n)return st(0),e;for(var i in t){var a=t[i];if(0===a||a===n)break;var o=r.ptr+16;if(pt(a,n,o))return st(a),e}return st(n),e},K=t=>{var e=(t-y.buffer.byteLength+65535)/65536;try{return y.grow(e),E(),1}catch(t){}},V={},Y=()=>{if(!Y.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(var e in V)void 0===V[e]?delete t[e]:t[e]=V[e];var r=[];for(var e in t)r.push(`${e}=${t[e]}`);Y.strings=r}return Y.strings},Z=[null,[],[]],tt=(t,e)=>{var r=Z[t];0===e||10===e?((1===t?_:w)($(r,0)),r.length=0):r.push(e)},et=[],rt=t=>{var e=et[t];return e||(t>=et.length&&(et.length=t+1),et[t]=e=X.get(t)),e},nt={a:(t,e,r,n)=>{L(`Assertion failed: ${B(t)}, at: `+[e?B(e):"unknown filename",r,n?B(n):"unknown function"])},l:t=>{var e=new z(t);return e.get_caught()||(e.set_caught(!0),G--),e.set_rethrown(!1),D.push(e),ht(e.excPtr),e.get_exception_ptr()},m:()=>{ot(0,0);var t=D.pop();ft(t.excPtr),Q=0},b:()=>J([]),c:t=>J([t]),r:()=>{var t=D.pop();t||L("no exception to throw");var e=t.excPtr;throw t.get_rethrown()||(D.push(t),t.set_rethrown(!0),t.set_caught(!1),G++),Q=e},j:(t,e,r)=>{throw new z(t).init(e,r),G++,Q=t},x:()=>G,f:t=>{throw Q||(Q=t),Q},z:(t,e,r)=>{},p:()=>{L("")},o:function(t){try{a.__progressCb&&a.__progressCb(t)}catch(t){}},D:(t,e,r)=>b.copyWithin(t,e,e+r),y:t=>{var e=b.length,r=2147483648;if((t>>>=0)>r)return!1;for(var n=(t,e)=>t+(e-t%e)%e,i=1;i<=4;i*=2){var a=e*(1+.2/i);a=Math.min(a,t+100663296);var o=Math.min(r,n(Math.max(t,a),65536));if(K(o))return!0}return!1},B:(t,e)=>{var r=0;return Y().forEach((n,i)=>{var a=e+r;A[t+4*i>>2]=a,((t,e)=>{for(var r=0;r<t.length;++r)R[e++]=t.charCodeAt(r);R[e]=0})(n,a),r+=n.length+1}),0},C:(t,e)=>{var r=Y();A[t>>2]=r.length;var n=0;return r.forEach(t=>n+=t.length+1),A[e>>2]=n,0},A:t=>52,v:function(t,e,r,n,i){return 70},s:(t,e,r,n)=>{for(var i=0,a=0;a<r;a++){var o=A[e>>2],s=A[e+4>>2];e+=8;for(var u=0;u<s;u++)tt(t,b[o+u]);i+=s}return A[n>>2]=i,0},d:function(t,e){var r=ut();try{return rt(t)(e)}catch(t){if(ct(r),t!==t+0)throw t;ot(1,0)}},e:function(t,e,r){var n=ut();try{return rt(t)(e,r)}catch(t){if(ct(n),t!==t+0)throw t;ot(1,0)}},i:function(t,e,r,n){var i=ut();try{return rt(t)(e,r,n)}catch(t){if(ct(i),t!==t+0)throw t;ot(1,0)}},n:function(t,e,r,n,i,a){var o=ut();try{return rt(t)(e,r,n,i,a)}catch(t){if(ct(o),t!==t+0)throw t;ot(1,0)}},u:function(t,e,r,n,i,a,o){var s=ut();try{return vt(t,e,r,n,i,a,o)}catch(t){if(ct(s),t!==t+0)throw t;ot(1,0)}},k:function(t){var e=ut();try{rt(t)()}catch(t){if(ct(e),t!==t+0)throw t;ot(1,0)}},E:function(t,e){var r=ut();try{rt(t)(e)}catch(t){if(ct(r),t!==t+0)throw t;ot(1,0)}},h:function(t,e){var r=ut();try{rt(t)(e)}catch(t){if(ct(r),t!==t+0)throw t;ot(1,0)}},g:function(t,e,r){var n=ut();try{rt(t)(e,r)}catch(t){if(ct(n),t!==t+0)throw t;ot(1,0)}},q:function(t,e,r,n){var i=ut();try{rt(t)(e,r,n)}catch(t){if(ct(i),t!==t+0)throw t;ot(1,0)}},t:function(t,e,r,n,i){var a=ut();try{rt(t)(e,r,n,i)}catch(t){if(ct(a),t!==t+0)throw t;ot(1,0)}},w:function(t,e,r,n){var i=ut();try{dt(t,e,r,n)}catch(t){if(ct(i),t!==t+0)throw t;ot(1,0)}}},it=function(){var t,e,r,n,o={a:nt};function s(t,e){var r;return it=t.exports,y=it.F,E(),X=it.J,r=it.G,C.unshift(r),function(){if(T--,a.monitorRunDependencies?.(T),0==T&&x){var t=x;x=null,t()}}(),it}if(T++,a.monitorRunDependencies?.(T),a.instantiateWasm)try{return a.instantiateWasm(o,s)}catch(t){w(`Module.instantiateWasm callback failed with error: ${t}`),i(t)}return(t=g,e=F,r=o,n=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||N(e)||p||"function"!=typeof fetch?q(e,r,n):fetch(e,{credentials:"same-origin"}).then(t=>WebAssembly.instantiateStreaming(t,r).then(n,function(t){return w(`wasm streaming compile failed: ${t}`),w("falling back to ArrayBuffer instantiation"),q(e,r,n)}))).catch(i),{}}();a._heic_decode=(t,e)=>(a._heic_decode=it.H)(t,e),a._heic_result_free=t=>(a._heic_result_free=it.I)(t),a._free=t=>(a._free=it.K)(t),a._malloc=t=>(a._malloc=it.L)(t);var at,ot=(t,e)=>(ot=it.M)(t,e),st=t=>(st=it.N)(t),ut=()=>(ut=it.O)(),ct=t=>(ct=it.P)(t),ft=t=>(ft=it.Q)(t),ht=t=>(ht=it.R)(t),pt=(t,e,r)=>(pt=it.S)(t,e,r),lt=t=>(lt=it.T)(t),dt=a.dynCall_vij=(t,e,r,n)=>(dt=a.dynCall_vij=it.U)(t,e,r,n),vt=a.dynCall_iiiiij=(t,e,r,n,i,o,s)=>(vt=a.dynCall_iiiiij=it.V)(t,e,r,n,i,o,s);function mt(){function t(){at||(at=!0,a.calledRun=!0,U||(M(C),n(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),function(){if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;)I(a.postRun.shift());M(S)}()))}T>0||(function(){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)j(a.preRun.shift());M(P)}(),T>0||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),t()},1)):t()))}if(a.___start_em_js=91680,a.___stop_em_js=91784,x=function t(){at||mt(),at||(x=t)},a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return mt(),r.ready});module.exports=r;
@@ -0,0 +1 @@
1
+ var t,r=(t=import.meta.url,async function(r={}){var e,n,i=r;i.ready=new Promise((t,r)=>{e=t,n=r});var a,o,s=Object.assign({},i),u="./this.program",c="object"==typeof window,f="function"==typeof importScripts,h="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,p="";if(h){const{createRequire:t}=await(import("module"));var l=t(import.meta.url),v=l("fs"),d=l("path");p=f?d.dirname(p)+"/":l("url").fileURLToPath(new URL("./",import.meta.url)),a=(t,r)=>(t=L(t)?new URL(t):d.normalize(t),v.readFileSync(t,r?void 0:"utf8")),o=t=>{var r=a(t,!0);return r.buffer||(r=new Uint8Array(r)),r},!i.thisProgram&&process.argv.length>1&&(u=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(c||f)&&(f?p=self.location.href:"undefined"!=typeof document&&document.currentScript&&(p=document.currentScript.src),t&&(p=t),p=p.startsWith("blob:")?"":p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1),a=t=>{var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(null),r.responseText},f&&(o=t=>{var r=new XMLHttpRequest;return r.open("GET",t,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}));var g,y,m=i.print||console.log.bind(console),_=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(u=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(g=i.wasmBinary);var w,b,A,R=!1;function P(){var t=y.buffer;i.HEAP8=w=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAPU8=b=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU32=A=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}var E=[],j=[],x=[];function S(t){E.unshift(t)}function C(t){x.unshift(t)}var U=0,I=null;function H(t){i.onAbort?.(t),_(t="Aborted("+t+")"),R=!0,t+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(t);throw n(r),r}var T,W,F=t=>t.startsWith("data:application/octet-stream;base64,"),L=t=>t.startsWith("file://");function M(t){if(t==T&&g)return new Uint8Array(g);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}function k(t,r,e){return function(t){return g||!c&&!f||"function"!=typeof fetch?Promise.resolve().then(()=>M(t)):fetch(t,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw`failed to load wasm binary file at '${t}'`;return r.arrayBuffer()}).catch(()=>M(t))}(t).then(t=>WebAssembly.instantiate(t,r)).then(e,t=>{_(`failed to asynchronously prepare wasm: ${t}`),H(t)})}i.locateFile?F(T="heic-decoder.wasm")||(W=T,T=i.locateFile?i.locateFile(W,p):p+W):T=new URL("heic-decoder.wasm",import.meta.url).href;var O=t=>{for(;t.length>0;)t.shift()(i)};i.noExitRuntime;var $="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,q=(t,r,e)=>{for(var n=r+e,i=r;t[i]&&!(i>=n);)++i;if(i-r>16&&t.buffer&&$)return $.decode(t.subarray(r,i));for(var a="";r<i;){var o=t[r++];if(128&o){var s=63&t[r++];if(192!=(224&o)){var u=63&t[r++];if((o=224==(240&o)?(15&o)<<12|s<<6|u:(7&o)<<18|s<<12|u<<6|63&t[r++])<65536)a+=String.fromCharCode(o);else{var c=o-65536;a+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a},B=(t,r)=>t?q(b,t,r):"",D=[],G=0,z=0;class N{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){A[this.ptr+4>>2]=t}get_type(){return A[this.ptr+4>>2]}set_destructor(t){A[this.ptr+8>>2]=t}get_destructor(){return A[this.ptr+8>>2]}set_caught(t){t=t?1:0,w[this.ptr+12]=t}get_caught(){return 0!=w[this.ptr+12]}set_rethrown(t){t=t?1:0,w[this.ptr+13]=t}get_rethrown(){return 0!=w[this.ptr+13]}init(t,r){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(r)}set_adjusted_ptr(t){A[this.ptr+16>>2]=t}get_adjusted_ptr(){return A[this.ptr+16>>2]}get_exception_ptr(){if(pt(this.get_type()))return A[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}var X,J=t=>{var r=z;if(!r)return ot(0),0;var e=new N(r);e.set_adjusted_ptr(r);var n=e.get_type();if(!n)return ot(0),r;for(var i in t){var a=t[i];if(0===a||a===n)break;var o=e.ptr+16;if(ht(a,n,o))return ot(a),r}return ot(n),r},K=t=>{var r=(t-y.buffer.byteLength+65535)/65536;try{return y.grow(r),P(),1}catch(t){}},Q={},V=()=>{if(!V.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:u||"./this.program"};for(var r in Q)void 0===Q[r]?delete t[r]:t[r]=Q[r];var e=[];for(var r in t)e.push(`${r}=${t[r]}`);V.strings=e}return V.strings},Y=[null,[],[]],Z=(t,r)=>{var e=Y[t];0===r||10===r?((1===t?m:_)(q(e,0)),e.length=0):e.push(r)},tt=[],rt=t=>{var r=tt[t];return r||(t>=tt.length&&(tt.length=t+1),tt[t]=r=X.get(t)),r},et={a:(t,r,e,n)=>{H(`Assertion failed: ${B(t)}, at: `+[r?B(r):"unknown filename",e,n?B(n):"unknown function"])},l:t=>{var r=new N(t);return r.get_caught()||(r.set_caught(!0),G--),r.set_rethrown(!1),D.push(r),ft(r.excPtr),r.get_exception_ptr()},m:()=>{at(0,0);var t=D.pop();ct(t.excPtr),z=0},b:()=>J([]),c:t=>J([t]),r:()=>{var t=D.pop();t||H("no exception to throw");var r=t.excPtr;throw t.get_rethrown()||(D.push(t),t.set_rethrown(!0),t.set_caught(!1),G++),z=r},j:(t,r,e)=>{throw new N(t).init(r,e),G++,z=t},x:()=>G,f:t=>{throw z||(z=t),z},z:(t,r,e)=>{},p:()=>{H("")},o:function(t){try{i.__progressCb&&i.__progressCb(t)}catch(t){}},D:(t,r,e)=>b.copyWithin(t,r,r+e),y:t=>{var r=b.length,e=2147483648;if((t>>>=0)>e)return!1;for(var n=(t,r)=>t+(r-t%r)%r,i=1;i<=4;i*=2){var a=r*(1+.2/i);a=Math.min(a,t+100663296);var o=Math.min(e,n(Math.max(t,a),65536));if(K(o))return!0}return!1},B:(t,r)=>{var e=0;return V().forEach((n,i)=>{var a=r+e;A[t+4*i>>2]=a,((t,r)=>{for(var e=0;e<t.length;++e)w[r++]=t.charCodeAt(e);w[r]=0})(n,a),e+=n.length+1}),0},C:(t,r)=>{var e=V();A[t>>2]=e.length;var n=0;return e.forEach(t=>n+=t.length+1),A[r>>2]=n,0},A:t=>52,v:function(t,r,e,n,i){return 70},s:(t,r,e,n)=>{for(var i=0,a=0;a<e;a++){var o=A[r>>2],s=A[r+4>>2];r+=8;for(var u=0;u<s;u++)Z(t,b[o+u]);i+=s}return A[n>>2]=i,0},d:function(t,r){var e=st();try{return rt(t)(r)}catch(t){if(ut(e),t!==t+0)throw t;at(1,0)}},e:function(t,r,e){var n=st();try{return rt(t)(r,e)}catch(t){if(ut(n),t!==t+0)throw t;at(1,0)}},i:function(t,r,e,n){var i=st();try{return rt(t)(r,e,n)}catch(t){if(ut(i),t!==t+0)throw t;at(1,0)}},n:function(t,r,e,n,i,a){var o=st();try{return rt(t)(r,e,n,i,a)}catch(t){if(ut(o),t!==t+0)throw t;at(1,0)}},u:function(t,r,e,n,i,a,o){var s=st();try{return vt(t,r,e,n,i,a,o)}catch(t){if(ut(s),t!==t+0)throw t;at(1,0)}},k:function(t){var r=st();try{rt(t)()}catch(t){if(ut(r),t!==t+0)throw t;at(1,0)}},E:function(t,r){var e=st();try{rt(t)(r)}catch(t){if(ut(e),t!==t+0)throw t;at(1,0)}},h:function(t,r){var e=st();try{rt(t)(r)}catch(t){if(ut(e),t!==t+0)throw t;at(1,0)}},g:function(t,r,e){var n=st();try{rt(t)(r,e)}catch(t){if(ut(n),t!==t+0)throw t;at(1,0)}},q:function(t,r,e,n){var i=st();try{rt(t)(r,e,n)}catch(t){if(ut(i),t!==t+0)throw t;at(1,0)}},t:function(t,r,e,n,i){var a=st();try{rt(t)(r,e,n,i)}catch(t){if(ut(a),t!==t+0)throw t;at(1,0)}},w:function(t,r,e,n){var i=st();try{lt(t,r,e,n)}catch(t){if(ut(i),t!==t+0)throw t;at(1,0)}}},nt=function(){var t,r,e,a,o={a:et};function s(t,r){var e;return nt=t.exports,y=nt.F,P(),X=nt.J,e=nt.G,j.unshift(e),function(){if(U--,i.monitorRunDependencies?.(U),0==U&&I){var t=I;I=null,t()}}(),nt}if(U++,i.monitorRunDependencies?.(U),i.instantiateWasm)try{return i.instantiateWasm(o,s)}catch(t){_(`Module.instantiateWasm callback failed with error: ${t}`),n(t)}return(t=g,r=T,e=o,a=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||F(r)||h||"function"!=typeof fetch?k(r,e,a):fetch(r,{credentials:"same-origin"}).then(t=>WebAssembly.instantiateStreaming(t,e).then(a,function(t){return _(`wasm streaming compile failed: ${t}`),_("falling back to ArrayBuffer instantiation"),k(r,e,a)}))).catch(n),{}}();i._heic_decode=(t,r)=>(i._heic_decode=nt.H)(t,r),i._heic_result_free=t=>(i._heic_result_free=nt.I)(t),i._free=t=>(i._free=nt.K)(t),i._malloc=t=>(i._malloc=nt.L)(t);var it,at=(t,r)=>(at=nt.M)(t,r),ot=t=>(ot=nt.N)(t),st=()=>(st=nt.O)(),ut=t=>(ut=nt.P)(t),ct=t=>(ct=nt.Q)(t),ft=t=>(ft=nt.R)(t),ht=(t,r,e)=>(ht=nt.S)(t,r,e),pt=t=>(pt=nt.T)(t),lt=i.dynCall_vij=(t,r,e,n)=>(lt=i.dynCall_vij=nt.U)(t,r,e,n),vt=i.dynCall_iiiiij=(t,r,e,n,a,o,s)=>(vt=i.dynCall_iiiiij=nt.V)(t,r,e,n,a,o,s);function dt(){function t(){it||(it=!0,i.calledRun=!0,R||(O(j),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)C(i.postRun.shift());O(x)}()))}U>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)S(i.preRun.shift());O(E)}(),U>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),t()},1)):t()))}if(i.___start_em_js=91680,i.___stop_em_js=91784,I=function t(){it||dt(),it||(I=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return dt(),r.ready});export{r as default};
Binary file
Binary file
Binary file
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("./chunk-TND3VERK.js"),t=require("./chunk-N2LCVW2Q.js"),r=new WeakSet,n=/[\u0000-\u001f\u007f-\u009f]+/g,i=class{options;module=null;decoderInstance=null;initPromise=null;initGeneration=0;constructor(e){this.options=e}async initialize(){if(!this.initPromise){const r=++this.initGeneration,n={};this.options?.moduleOverrides&&Object.assign(n,this.options.moduleOverrides),this.options?.locateFile&&(n.locateFile=this.options.locateFile),this.options?.wasmBinary&&(n.wasmBinary=this.options.wasmBinary);const i=import("./heic-decoder-7MDF76JS.js").then(({default:e})=>e(n)).then(n=>{const i=new n.HeicDecoder;if(r!==this.initGeneration)return i.delete(),null;const o=["function"==typeof i.decodeFromPointer?null:"decodeFromPointer","function"==typeof n._malloc?null:"_malloc","function"==typeof n._free?null:"_free",n.HEAPU8 instanceof Uint8Array?null:"HEAPU8"].filter(e=>null!==e);if(o.length>0)throw i.delete(),new t.HeicConverterError("decoder_init_failed",e.Messages.GlueApiMissing(o.join(", ")));return this.module=n,this.decoderInstance=i,n}).catch(e=>{throw this.initPromise===i&&(this.initPromise=null),e});this.initPromise=i}await this.initPromise}async decode(i,o){if(this.module&&this.decoderInstance||await this.initialize(),!this.module||!this.decoderInstance)throw new t.HeicConverterError("decode_failed",e.Messages.DecoderFreedDuringDecode);let a;const s=o?t=>{try{o(e.clampPercent(t))}catch(e){a=a??e}}:null,c=this.module,d=this.decoderInstance,f=c.HEAPU8.buffer;let u;try{const r=i.buffer===f?new Uint8Array(i):i,n=c._malloc(r.byteLength);if(0===n)throw new t.HeicConverterError("decode_failed",e.Messages.DecodeInputAllocFailed(r.byteLength));try{c.HEAPU8.set(r,n),u=d.decodeFromPointer(n,r.byteLength,s)}finally{c._free(n)}}catch(n){if(n instanceof t.HeicConverterError)throw n;throw r.add(this),new t.HeicConverterError("decode_failed",e.Messages.DecodeFaulted(i.byteLength),{cause:n})}if("string"==typeof u)throw new t.HeicConverterError("decode_failed",e.Messages.DecodeFailedWithDetail(function(e){const t=e.replace(n," ").trim();return t.length>200?`${t.slice(0,197)}...`:t}(u),i.byteLength));if(!u)throw new t.HeicConverterError("decode_failed",e.Messages.DecodeFailed(i.byteLength));if(void 0!==a)throw e.progressCallbackError(a);const l=u.width,h=u.height,w=u.orientation,g="number"==typeof w&&Number.isInteger(w)&&w>=1&&w<=8?w:1,p=c.HEAPU8.buffer,v={width:l,height:h,data:u.data.buffer!==p?new Uint8ClampedArray(u.data.buffer,u.data.byteOffset,u.data.byteLength):new Uint8ClampedArray(u.data)};g>1&&(v.orientation=g);const y=u.exif;return y instanceof Uint8Array&&y.length>=14&&(v.exif=y.buffer!==p?new Uint8Array(y.buffer,y.byteOffset,y.byteLength):new Uint8Array(y)),v}free(){this.initGeneration+=1,this.decoderInstance&&(this.decoderInstance.delete(),this.decoderInstance=null),this.module=null,r.delete(this),this.initPromise=null}},o=16384;function a(){if("undefined"==typeof OffscreenCanvas&&"undefined"==typeof document)throw new t.HeicConverterError("unsupported_environment",e.Messages.CanvasUnsupported)}var s=null,c=0;function d(){if(null===s){if(Date.now()<c)return Promise.resolve(void 0);const e=async function(){let e;try{e=w(1,1)}catch{return}const t=h(e,"image/avif");let r;const n=new Promise(e=>{r=setTimeout(()=>e("timeout"),5e3)});try{const e=await Promise.race([t,n]);return"timeout"===e?void 0:"image/avif"===e.type&&e.size>0}finally{void 0!==r&&clearTimeout(r),g(e)}}().catch(()=>{});s=e,e.then(t=>{void 0===t&&s===e&&(s=null,c=Date.now()+1e4)})}return s}async function f(r){if(e.validateFormat(r),"avif"===String(r).toLowerCase()&&!1===await d())throw new t.HeicConverterError("format_unsupported",e.Messages.FormatUnsupported("avif"))}function u(r,n){if(!Number.isFinite(r)||!Number.isFinite(n)||r>o||n>o)throw new t.HeicConverterError("invalid_resize",e.Messages.TargetSizeTooLarge(r,n,o))}async function l(r){try{const e=await r.arrayBuffer(),t=new Uint8Array(e);let n="";const i=32768;for(let e=0;e<t.length;e+=i)n+=String.fromCharCode(...t.subarray(e,e+i));const o=btoa(n);return`data:${r.type};base64,${o}`}catch(r){throw new t.HeicConverterError("render_encode_failed",e.Messages.BlobToBase64FailedWithCause(r instanceof Error?r.message:String(r)),{cause:r})}}function h(r,n,i){return"convertToBlob"in r?r.convertToBlob({type:n,quality:i}):new Promise((o,a)=>{r.toBlob(r=>{r?o(r):a(new t.HeicConverterError("render_encode_failed",e.Messages.CanvasToBlobFailed(n)))},n,i)})}function w(r,n){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(r,n);if("undefined"!=typeof document){const e=document.createElement("canvas");return e.width=r,e.height=n,e}throw new t.HeicConverterError("unsupported_environment",e.Messages.CanvasUnsupported)}function g(e){const t=e;"function"==typeof t.close?t.close():e.width=0}function p(e,t,r,n){if("undefined"!=typeof ImageData)e.putImageData(new ImageData(t,r,n),0,0);else{const i=e.createImageData(r,n);i.data.set(t),e.putImageData(i,0,0)}}var v=!1;async function y(t,r,n,i,o){const a=r.exif;if(!n||!a||0===a.length)return t;const s=await import("./exif-H2Q7BO7Y.js").catch(()=>null);if(!s)return v||(v=!0,console.warn(e.Messages.ExifChunkLoadWarning)),t;const{injectExifIntoJpeg:c,injectExifIntoPng:d,normalizeOrientationTag:f}=s,u=o?f(a):a,l=new Uint8Array(await t.arrayBuffer()),h="jpeg"===i?c(l,u):d(l,u);return h===l?t:new Blob([h.buffer],{type:t.type})}function m(){return import("./worker-DISSAV3W.js").catch(r=>{const n=r instanceof Error?r.message:String(r);throw new t.HeicConverterError("worker_load_failed",e.Messages.WorkerChunkLoadFailed(n),{cause:r})})}function b(e){return!0===e?.nativeDecode&&!0!==e?.preserveExif&&!1!==e?.applyOrientation}var E=!1;async function C(r,n){const o=n?.to??"jpeg";e.validateConvertOptions(n),a(),await f(o);const s=n?.signal;e.throwIfAborted(s);const c=n,v=await async function(r){if(r instanceof Uint8Array)return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if("undefined"!=typeof Blob&&r instanceof Blob)return new Uint8Array(await r.arrayBuffer());if(null!==r&&"object"==typeof r&&"function"==typeof r.arrayBuffer){const e=await r.arrayBuffer();if(e instanceof ArrayBuffer)return new Uint8Array(e)}if(ArrayBuffer.isView(r)){const e=r;return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}throw new t.HeicConverterError("invalid_input",e.Messages.UnsupportedInputType(Object.prototype.toString.call(r)))}(r);let m,C;e.throwIfAborted(s);let I,_=!1;if(n?.decoder)m=n.decoder,C=!1;else if(b(n)){try{I=await(import("./native-JFFONPCS.js"))}catch(t){M=t instanceof Error?t.message:String(t),E||(E=!0,console.warn(e.Messages.NativeChunkLoadWarning(M)))}void 0===I||I.isNativeHeicRefused()?m=new i:(m=new I.NativeHeicDecoder,_=!0),C=!0}else m=new i,C=!0;var M;let H=!1;const A=()=>{if(C&&!H){H=!0;try{m.free()}catch{}}};try{const r=e.progressGateFor(n?.onProgress),a=async n=>{try{await n.initialize()}catch(r){throw new t.HeicConverterError("decoder_init_failed",e.Messages.DecoderInitFailed(r instanceof Error?r.message:String(r)),{cause:r})}return e.throwIfAborted(s),n.decode(v,r?r.report:void 0)};let f;try{f=await a(m)}catch(r){if(!_)throw r;if(r instanceof t.HeicConverterError&&"aborted"===r.code)throw r;r instanceof t.HeicConverterError&&"decoder_init_failed"===r.code&&I.markNativeHeicRefused(),e.throwIfAborted(s),A(),m=new i,H=!1,_=!1,f=await a(m)}A(),e.throwIfAborted(s);const b=void 0!==n?.quality?n.quality:e.DEFAULT_QUALITY;let E;try{E=await async function(r,n,i,o,a=!0,s,c=!1){e.validateFormat(n),e.validateCrop(s);const f=n.toLowerCase();if("avif"===f&&!1===await d())throw new t.HeicConverterError("format_unsupported",e.Messages.FormatUnsupported("avif"));const{width:v,height:m,data:b}=r;if(!Number.isInteger(v)||v<=0||!Number.isInteger(m)||m<=0)throw new t.HeicConverterError("render_encode_failed",e.Messages.InvalidDimensions(v,m));const E=v*m*4;if(b.length!==E)throw new t.HeicConverterError("render_encode_failed",e.Messages.DataLengthMismatch(E,v,m,b.length));const C=function(e,t){return t&&"number"==typeof e&&Number.isInteger(e)&&e>=1&&e<=8?e:1}(r.orientation,a),I=!(void 0!==r.orientation&&r.orientation>=2&&r.orientation<=8)||a,_=function(e,t,r){switch(e){case 2:return[-1,0,0,1,t,0];case 3:return[-1,0,0,-1,t,r];case 4:return[1,0,0,-1,0,r];case 5:return[0,1,1,0,0,0];case 6:return[0,1,-1,0,r,0];case 7:return[0,-1,-1,0,r,t];case 8:return[0,-1,1,0,0,t];default:return null}}(C,v,m),M=C>=5,H=M?m:v,A=M?v:m,F=s?.x??0,U=s?.y??0,P=s?s.width:H,O=s?s.height:A;if(s&&(F+P>H||U+O>A))throw new t.HeicConverterError("invalid_crop",e.Messages.CropOutOfBounds(F,U,P,O,H,A));const x=function(t,r,n){if(e.validateResize(n),!n)return{width:t,height:r};const{maxWidth:i,maxHeight:o,scale:a}=n;if(void 0!==a){const e=Math.max(1,Math.round(t*a)),n=Math.max(1,Math.round(r*a));return u(e,n),{width:e,height:n}}if(void 0===i&&void 0===o)return{width:t,height:r};const s=Math.min(void 0!==i?i/t:Number.POSITIVE_INFINITY,void 0!==o?o/r:Number.POSITIVE_INFINITY);if(s>=1)return{width:t,height:r};const c=Math.min(Math.max(1,Math.round(t*s)),void 0!==i?Math.floor(i):Number.POSITIVE_INFINITY),d=Math.min(Math.max(1,Math.round(r*s)),void 0!==o?Math.floor(o):Number.POSITIVE_INFINITY);return u(c,d),{width:c,height:d}}(P,O,o),D=x.width!==P||x.height!==O,B=null!==_||void 0!==s,T=w(x.width,x.height),N=T.getContext("2d");if(!N)throw new t.HeicConverterError("render_encode_failed",e.Messages.ContextUnavailable);if(B||D){const r=w(v,m),n=r.getContext("2d");if(!n)throw new t.HeicConverterError("render_encode_failed",e.Messages.ContextUnavailable);if(p(n,b,v,m),B){const e=x.width/P,t=x.height/O,n=_?_[0]:1,i=_?_[1]:0,o=_?_[2]:0,a=_?_[3]:1,s=_?_[4]:0,c=_?_[5]:0;N.setTransform(n*e,i*t,o*e,a*t,e*(s-F),t*(c-U)),N.drawImage(r,0,0)}else N.drawImage(r,0,0,x.width,x.height);g(r)}else p(N,b,v,m);if("png"===f){const e=await h(T,"image/png");return g(T),y(e,r,c,"png",I)}if("jpeg"===f||"jpg"===f){const e=await h(T,"image/jpeg",i);return g(T),y(e,r,c,"jpeg",I)}if("webp"===f){const e=await h(T,"image/webp",i);return g(T),e}if("avif"===f){const r=await h(T,"image/avif",i);if(g(T),"image/avif"!==r.type)throw new t.HeicConverterError("format_unsupported",e.Messages.FormatUnsupported("avif"));return r}if("svg"===f){const e=await h(T,"image/png");g(T);const t=await l(e),r=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${x.width} ${x.height}" width="${x.width}" height="${x.height}">\n <image width="${x.width}" height="${x.height}" href="`;return new Blob([r,t,'" />\n</svg>'],{type:"image/svg+xml"})}throw new t.HeicConverterError("invalid_format",e.Messages.UnsupportedFormat(String(n)))}(f,o,b,c,n?.applyOrientation??!0,n?.crop,n?.preserveExif??!1)}catch(r){if(r instanceof t.HeicConverterError)throw r;throw new t.HeicConverterError("render_encode_failed",e.Messages.RenderEncodeFailed(o,r instanceof Error?r.message:String(r)),{cause:r})}return e.throwIfAborted(s),r?.complete(),async function(e,t){return"dataUrl"===t?await l(e):"arrayBuffer"===t?await e.arrayBuffer():e}(E,n?.output??"blob")}finally{A()}}var I=class{idle=[];disposed=!1;acquire(){return this.idle.pop()??new i}release(e){if(this.disposed||function(e){return r.has(e)}(e))try{e.free()}catch{}else this.idle.push(e)}dispose(){this.disposed=!0;for(const e of this.idle)try{e.free()}catch{}this.idle.length=0}};Object.defineProperty(exports,"DEFAULT_QUALITY",{enumerable:!0,get:function(){return e.DEFAULT_QUALITY}}),Object.defineProperty(exports,"SUPPORTED_FORMATS",{enumerable:!0,get:function(){return e.SUPPORTED_FORMATS}}),Object.defineProperty(exports,"HeicConverterError",{enumerable:!0,get:function(){return t.HeicConverterError}}),exports.LibheifDecoder=i,exports.convertHeic=C,exports.convertHeicInWorker=function(e,t){return m().then(r=>r.convertHeicInWorker(e,t))},exports.convertMany=async function(r,n){if(!Array.isArray(r))throw new t.HeicConverterError("invalid_input",e.Messages.InputsMustBeArray);const i=n?.concurrency??4;e.validateConcurrency(i),e.validateConvertOptions(n),e.validateBatchOptions(n),a(),await f(n?.to??"jpeg");const{concurrency:o,onProgress:s,continueOnError:c,reuseDecoders:d,...u}=n??{},l=e.progressCallbackFor(s),h=!0!==d||void 0!==n?.decoder||b(n)?null:new I;try{return await e.runBoundedBatch(r,i,async(e,t)=>{const r=h?h.acquire():null;try{return await C(e,{...u,...r?{decoder:r}:{},onProgress:l?e=>l(t,e):void 0})}finally{r&&h.release(r)}},{continueOnError:!0===n?.continueOnError,signal:n?.signal})}finally{h?.dispose()}},exports.convertManyInWorker=function(e,t){return m().then(r=>r.convertManyInWorker(e,t))},exports.freeSharedDecoder=function(){};
1
+ "use strict";var e=require("./chunk-TND3VERK.js"),t=require("./chunk-N2LCVW2Q.js"),r=new WeakSet,n=/[\u0000-\u001f\u007f-\u009f]+/g,i=class{options;module=null;initPromise=null;initGeneration=0;constructor(e){this.options=e}async initialize(){if(!this.initPromise){const r=++this.initGeneration,n={};this.options?.moduleOverrides&&Object.assign(n,this.options.moduleOverrides),this.options?.locateFile&&(n.locateFile=this.options.locateFile),this.options?.wasmBinary&&(n.wasmBinary=this.options.wasmBinary);const i=import("./heic-decoder-2EERQO7N.js").then(({default:e})=>e(n)).then(n=>{if(r!==this.initGeneration)return null;const i=["function"==typeof n._heic_decode?null:"_heic_decode","function"==typeof n._heic_result_free?null:"_heic_result_free","function"==typeof n._malloc?null:"_malloc","function"==typeof n._free?null:"_free",n.HEAPU8 instanceof Uint8Array?null:"HEAPU8"].filter(e=>null!==e);if(i.length>0)throw new t.HeicConverterError("decoder_init_failed",e.Messages.GlueApiMissing(i.join(", ")));return this.module=n,n}).catch(e=>{throw this.initPromise===i&&(this.initPromise=null),e});this.initPromise=i}await this.initPromise}async decode(i,o){this.module||await this.initialize();const a=this.module;if(!a)throw new t.HeicConverterError("decode_failed",e.Messages.DecoderFreedDuringDecode);let s;const c=o?t=>{try{o(e.clampPercent(t))}catch(e){s=s??e,a.__progressCb=null}}:null,u=i.buffer===a.HEAPU8.buffer?new Uint8Array(i):i;let f,d=0,l=0;try{if(d=a._malloc(u.byteLength),0===d)throw new t.HeicConverterError("decode_failed",e.Messages.DecodeInputAllocFailed(u.byteLength));a.HEAPU8.set(u,d);const r=a.__progressCb??null;a.__progressCb=c;try{l=a._heic_decode(d,u.byteLength)}finally{a.__progressCb=r}const o=a.HEAPU8;if(0===l)throw new TypeError("heic_decode returned a null result");const s=new DataView(o.buffer,l,36),h=s.getInt32(0,!0);if(0===h){const r=s.getUint32(28,!0),a=s.getUint32(32,!0),c=0!==r?(new TextDecoder).decode(o.subarray(r,r+a)):"";throw new t.HeicConverterError("decode_failed",c?e.Messages.DecodeFailedWithDetail(function(e){const t=e.replace(n," ").trim();return t.length>200?`${t.slice(0,197)}...`:t}(c),i.byteLength):e.Messages.DecodeFailed(i.byteLength))}const w=s.getInt32(4,!0),g=s.getInt32(8,!0),p=g>=1&&g<=8?g:1,v=s.getUint32(12,!0),y=s.getUint32(16,!0),m=4*h,_=new Uint8ClampedArray(m*w);if(y===m)_.set(o.subarray(v,v+m*w));else for(let e=0;e<w;e++)_.set(o.subarray(v+e*y,v+e*y+m),e*m);f={width:h,height:w,data:_},p>1&&(f.orientation=p);const b=s.getUint32(20,!0),E=s.getUint32(24,!0);0!==b&&E>=14&&(f.exif=o.slice(b,b+E))}catch(n){if(n instanceof t.HeicConverterError)throw n;throw r.add(this),new t.HeicConverterError("decode_failed",e.Messages.DecodeFaulted(i.byteLength),{cause:n})}finally{a.__progressCb=null;try{0!==l&&a._heic_result_free(l),0!==d&&a._free(d)}catch{}}if(void 0!==s)throw e.progressCallbackError(s);return f}free(){this.initGeneration+=1,this.module=null,r.delete(this),this.initPromise=null}},o=16384;function a(){if("undefined"==typeof OffscreenCanvas&&"undefined"==typeof document)throw new t.HeicConverterError("unsupported_environment",e.Messages.CanvasUnsupported)}var s=null,c=0;function u(){if(null===s){if(Date.now()<c)return Promise.resolve(void 0);const e=async function(){let e;try{e=w(1,1)}catch{return}const t=h(e,"image/avif");let r;const n=new Promise(e=>{r=setTimeout(()=>e("timeout"),5e3)});try{const e=await Promise.race([t,n]);return"timeout"===e?void 0:"image/avif"===e.type&&e.size>0}finally{void 0!==r&&clearTimeout(r),g(e)}}().catch(()=>{});s=e,e.then(t=>{void 0===t&&s===e&&(s=null,c=Date.now()+1e4)})}return s}async function f(r){if(e.validateFormat(r),"avif"===String(r).toLowerCase()&&!1===await u())throw new t.HeicConverterError("format_unsupported",e.Messages.FormatUnsupported("avif"))}function d(r,n){if(!Number.isFinite(r)||!Number.isFinite(n)||r>o||n>o)throw new t.HeicConverterError("invalid_resize",e.Messages.TargetSizeTooLarge(r,n,o))}async function l(r){try{const e=await r.arrayBuffer(),t=new Uint8Array(e);let n="";const i=32768;for(let e=0;e<t.length;e+=i)n+=String.fromCharCode(...t.subarray(e,e+i));const o=btoa(n);return`data:${r.type};base64,${o}`}catch(r){throw new t.HeicConverterError("render_encode_failed",e.Messages.BlobToBase64FailedWithCause(r instanceof Error?r.message:String(r)),{cause:r})}}function h(r,n,i){return"convertToBlob"in r?r.convertToBlob({type:n,quality:i}):new Promise((o,a)=>{r.toBlob(r=>{r?o(r):a(new t.HeicConverterError("render_encode_failed",e.Messages.CanvasToBlobFailed(n)))},n,i)})}function w(r,n){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(r,n);if("undefined"!=typeof document){const e=document.createElement("canvas");return e.width=r,e.height=n,e}throw new t.HeicConverterError("unsupported_environment",e.Messages.CanvasUnsupported)}function g(e){const t=e;"function"==typeof t.close?t.close():e.width=0}function p(e,t,r,n){if("undefined"!=typeof ImageData)e.putImageData(new ImageData(t,r,n),0,0);else{const i=e.createImageData(r,n);i.data.set(t),e.putImageData(i,0,0)}}var v=!1;async function y(t,r,n,i,o){const a=r.exif;if(!n||!a||0===a.length)return t;const s=await import("./exif-H2Q7BO7Y.js").catch(()=>null);if(!s)return v||(v=!0,console.warn(e.Messages.ExifChunkLoadWarning)),t;const{injectExifIntoJpeg:c,injectExifIntoPng:u,normalizeOrientationTag:f}=s,d=o?f(a):a,l=new Uint8Array(await t.arrayBuffer()),h="jpeg"===i?c(l,d):u(l,d);return h===l?t:new Blob([h.buffer],{type:t.type})}function m(){return import("./worker-DISSAV3W.js").catch(r=>{const n=r instanceof Error?r.message:String(r);throw new t.HeicConverterError("worker_load_failed",e.Messages.WorkerChunkLoadFailed(n),{cause:r})})}function _(e){return!0===e?.nativeDecode&&!0!==e?.preserveExif&&!1!==e?.applyOrientation}var b=!1;async function E(r,n){const o=n?.to??"jpeg";e.validateConvertOptions(n),a(),await f(o);const s=n?.signal;e.throwIfAborted(s);const c=n,v=await async function(r){if(r instanceof Uint8Array)return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if("undefined"!=typeof Blob&&r instanceof Blob)return new Uint8Array(await r.arrayBuffer());if(null!==r&&"object"==typeof r&&"function"==typeof r.arrayBuffer){const e=await r.arrayBuffer();if(e instanceof ArrayBuffer)return new Uint8Array(e)}if(ArrayBuffer.isView(r)){const e=r;return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}throw new t.HeicConverterError("invalid_input",e.Messages.UnsupportedInputType(Object.prototype.toString.call(r)))}(r);let m,E;e.throwIfAborted(s);let C,I=!1;if(n?.decoder)m=n.decoder,E=!1;else if(_(n)){try{C=await(import("./native-JFFONPCS.js"))}catch(t){M=t instanceof Error?t.message:String(t),b||(b=!0,console.warn(e.Messages.NativeChunkLoadWarning(M)))}void 0===C||C.isNativeHeicRefused()?m=new i:(m=new C.NativeHeicDecoder,I=!0),E=!0}else m=new i,E=!0;var M;let H=!1;const U=()=>{if(E&&!H){H=!0;try{m.free()}catch{}}};try{const r=e.progressGateFor(n?.onProgress),a=async n=>{try{await n.initialize()}catch(r){throw new t.HeicConverterError("decoder_init_failed",e.Messages.DecoderInitFailed(r instanceof Error?r.message:String(r)),{cause:r})}return e.throwIfAborted(s),n.decode(v,r?r.report:void 0)};let f;try{f=await a(m)}catch(r){if(!I)throw r;if(r instanceof t.HeicConverterError&&"aborted"===r.code)throw r;r instanceof t.HeicConverterError&&"decoder_init_failed"===r.code&&C.markNativeHeicRefused(),e.throwIfAborted(s),U(),m=new i,H=!1,I=!1,f=await a(m)}U(),e.throwIfAborted(s);const _=void 0!==n?.quality?n.quality:e.DEFAULT_QUALITY;let b;try{b=await async function(r,n,i,o,a=!0,s,c=!1){e.validateFormat(n),e.validateCrop(s);const f=n.toLowerCase();if("avif"===f&&!1===await u())throw new t.HeicConverterError("format_unsupported",e.Messages.FormatUnsupported("avif"));const{width:v,height:m,data:_}=r;if(!Number.isInteger(v)||v<=0||!Number.isInteger(m)||m<=0)throw new t.HeicConverterError("render_encode_failed",e.Messages.InvalidDimensions(v,m));const b=v*m*4;if(_.length!==b)throw new t.HeicConverterError("render_encode_failed",e.Messages.DataLengthMismatch(b,v,m,_.length));const E=function(e,t){return t&&"number"==typeof e&&Number.isInteger(e)&&e>=1&&e<=8?e:1}(r.orientation,a),C=!(void 0!==r.orientation&&r.orientation>=2&&r.orientation<=8)||a,I=function(e,t,r){switch(e){case 2:return[-1,0,0,1,t,0];case 3:return[-1,0,0,-1,t,r];case 4:return[1,0,0,-1,0,r];case 5:return[0,1,1,0,0,0];case 6:return[0,1,-1,0,r,0];case 7:return[0,-1,-1,0,r,t];case 8:return[0,-1,1,0,0,t];default:return null}}(E,v,m),M=E>=5,H=M?m:v,U=M?v:m,A=s?.x??0,F=s?.y??0,O=s?s.width:H,P=s?s.height:U;if(s&&(A+O>H||F+P>U))throw new t.HeicConverterError("invalid_crop",e.Messages.CropOutOfBounds(A,F,O,P,H,U));const x=function(t,r,n){if(e.validateResize(n),!n)return{width:t,height:r};const{maxWidth:i,maxHeight:o,scale:a}=n;if(void 0!==a){const e=Math.max(1,Math.round(t*a)),n=Math.max(1,Math.round(r*a));return d(e,n),{width:e,height:n}}if(void 0===i&&void 0===o)return{width:t,height:r};const s=Math.min(void 0!==i?i/t:Number.POSITIVE_INFINITY,void 0!==o?o/r:Number.POSITIVE_INFINITY);if(s>=1)return{width:t,height:r};const c=Math.min(Math.max(1,Math.round(t*s)),void 0!==i?Math.floor(i):Number.POSITIVE_INFINITY),u=Math.min(Math.max(1,Math.round(r*s)),void 0!==o?Math.floor(o):Number.POSITIVE_INFINITY);return d(c,u),{width:c,height:u}}(O,P,o),D=x.width!==O||x.height!==P,T=null!==I||void 0!==s,B=w(x.width,x.height),N=B.getContext("2d");if(!N)throw new t.HeicConverterError("render_encode_failed",e.Messages.ContextUnavailable);if(T||D){const r=w(v,m),n=r.getContext("2d");if(!n)throw new t.HeicConverterError("render_encode_failed",e.Messages.ContextUnavailable);if(p(n,_,v,m),T){const e=x.width/O,t=x.height/P,n=I?I[0]:1,i=I?I[1]:0,o=I?I[2]:0,a=I?I[3]:1,s=I?I[4]:0,c=I?I[5]:0;N.setTransform(n*e,i*t,o*e,a*t,e*(s-A),t*(c-F)),N.drawImage(r,0,0)}else N.drawImage(r,0,0,x.width,x.height);g(r)}else p(N,_,v,m);if("png"===f){const e=await h(B,"image/png");return g(B),y(e,r,c,"png",C)}if("jpeg"===f||"jpg"===f){const e=await h(B,"image/jpeg",i);return g(B),y(e,r,c,"jpeg",C)}if("webp"===f){const e=await h(B,"image/webp",i);return g(B),e}if("avif"===f){const r=await h(B,"image/avif",i);if(g(B),"image/avif"!==r.type)throw new t.HeicConverterError("format_unsupported",e.Messages.FormatUnsupported("avif"));return r}if("svg"===f){const e=await h(B,"image/png");g(B);const t=await l(e),r=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${x.width} ${x.height}" width="${x.width}" height="${x.height}">\n <image width="${x.width}" height="${x.height}" href="`;return new Blob([r,t,'" />\n</svg>'],{type:"image/svg+xml"})}throw new t.HeicConverterError("invalid_format",e.Messages.UnsupportedFormat(String(n)))}(f,o,_,c,n?.applyOrientation??!0,n?.crop,n?.preserveExif??!1)}catch(r){if(r instanceof t.HeicConverterError)throw r;throw new t.HeicConverterError("render_encode_failed",e.Messages.RenderEncodeFailed(o,r instanceof Error?r.message:String(r)),{cause:r})}return e.throwIfAborted(s),r?.complete(),async function(e,t){return"dataUrl"===t?await l(e):"arrayBuffer"===t?await e.arrayBuffer():e}(b,n?.output??"blob")}finally{U()}}var C=class{idle=[];disposed=!1;acquire(){return this.idle.pop()??new i}release(e){if(this.disposed||function(e){return r.has(e)}(e))try{e.free()}catch{}else this.idle.push(e)}dispose(){this.disposed=!0;for(const e of this.idle)try{e.free()}catch{}this.idle.length=0}};Object.defineProperty(exports,"DEFAULT_QUALITY",{enumerable:!0,get:function(){return e.DEFAULT_QUALITY}}),Object.defineProperty(exports,"SUPPORTED_FORMATS",{enumerable:!0,get:function(){return e.SUPPORTED_FORMATS}}),Object.defineProperty(exports,"HeicConverterError",{enumerable:!0,get:function(){return t.HeicConverterError}}),exports.LibheifDecoder=i,exports.convertHeic=E,exports.convertHeicInWorker=function(e,t){return m().then(r=>r.convertHeicInWorker(e,t))},exports.convertMany=async function(r,n){if(!Array.isArray(r))throw new t.HeicConverterError("invalid_input",e.Messages.InputsMustBeArray);const i=n?.concurrency??4;e.validateConcurrency(i),e.validateConvertOptions(n),e.validateBatchOptions(n),a(),await f(n?.to??"jpeg");const{concurrency:o,onProgress:s,continueOnError:c,reuseDecoders:u,...d}=n??{},l=e.progressCallbackFor(s),h=!0!==u||void 0!==n?.decoder||_(n)?null:new C;try{return await e.runBoundedBatch(r,i,async(e,t)=>{const r=h?h.acquire():null;try{return await E(e,{...d,...r?{decoder:r}:{},onProgress:l?e=>l(t,e):void 0})}finally{r&&h.release(r)}},{continueOnError:!0===n?.continueOnError,signal:n?.signal})}finally{h?.dispose()}},exports.convertManyInWorker=function(e,t){return m().then(r=>r.convertManyInWorker(e,t))},exports.freeSharedDecoder=function(){};
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{Messages as e,validateConvertOptions as t,throwIfAborted as n,progressGateFor as i,DEFAULT_QUALITY as r,validateConcurrency as o,validateBatchOptions as a,progressCallbackFor as s,runBoundedBatch as c,clampPercent as d,progressCallbackError as f,validateFormat as u,validateCrop as l,validateResize as h}from"./chunk-BTAX2PFV.mjs";export{DEFAULT_QUALITY,SUPPORTED_FORMATS}from"./chunk-BTAX2PFV.mjs";import{HeicConverterError as w}from"./chunk-AROQBV5T.mjs";export{HeicConverterError}from"./chunk-AROQBV5T.mjs";var m=new WeakSet,p=/[\u0000-\u001f\u007f-\u009f]+/g,g=class{options;module=null;decoderInstance=null;initPromise=null;initGeneration=0;constructor(e){this.options=e}async initialize(){if(!this.initPromise){const t=++this.initGeneration,n={};this.options?.moduleOverrides&&Object.assign(n,this.options.moduleOverrides),this.options?.locateFile&&(n.locateFile=this.options.locateFile),this.options?.wasmBinary&&(n.wasmBinary=this.options.wasmBinary);const i=import("./heic-decoder-6NSMO57O.mjs").then(({default:e})=>e(n)).then(n=>{const i=new n.HeicDecoder;if(t!==this.initGeneration)return i.delete(),null;const r=["function"==typeof i.decodeFromPointer?null:"decodeFromPointer","function"==typeof n._malloc?null:"_malloc","function"==typeof n._free?null:"_free",n.HEAPU8 instanceof Uint8Array?null:"HEAPU8"].filter(e=>null!==e);if(r.length>0)throw i.delete(),new w("decoder_init_failed",e.GlueApiMissing(r.join(", ")));return this.module=n,this.decoderInstance=i,n}).catch(e=>{throw this.initPromise===i&&(this.initPromise=null),e});this.initPromise=i}await this.initPromise}async decode(t,n){if(this.module&&this.decoderInstance||await this.initialize(),!this.module||!this.decoderInstance)throw new w("decode_failed",e.DecoderFreedDuringDecode);let i;const r=n?e=>{try{n(d(e))}catch(e){i=i??e}}:null,o=this.module,a=this.decoderInstance,s=o.HEAPU8.buffer;let c;try{const n=t.buffer===s?new Uint8Array(t):t,i=o._malloc(n.byteLength);if(0===i)throw new w("decode_failed",e.DecodeInputAllocFailed(n.byteLength));try{o.HEAPU8.set(n,i),c=a.decodeFromPointer(i,n.byteLength,r)}finally{o._free(i)}}catch(n){if(n instanceof w)throw n;throw m.add(this),new w("decode_failed",e.DecodeFaulted(t.byteLength),{cause:n})}if("string"==typeof c)throw new w("decode_failed",e.DecodeFailedWithDetail(function(e){const t=e.replace(p," ").trim();return t.length>200?`${t.slice(0,197)}...`:t}(c),t.byteLength));if(!c)throw new w("decode_failed",e.DecodeFailed(t.byteLength));if(void 0!==i)throw f(i);const u=c.width,l=c.height,h=c.orientation,g="number"==typeof h&&Number.isInteger(h)&&h>=1&&h<=8?h:1,y=o.HEAPU8.buffer,v={width:u,height:l,data:c.data.buffer!==y?new Uint8ClampedArray(c.data.buffer,c.data.byteOffset,c.data.byteLength):new Uint8ClampedArray(c.data)};g>1&&(v.orientation=g);const b=c.exif;return b instanceof Uint8Array&&b.length>=14&&(v.exif=b.buffer!==y?new Uint8Array(b.buffer,b.byteOffset,b.byteLength):new Uint8Array(b)),v}free(){this.initGeneration+=1,this.decoderInstance&&(this.decoderInstance.delete(),this.decoderInstance=null),this.module=null,m.delete(this),this.initPromise=null}},y=16384;function v(){if("undefined"==typeof OffscreenCanvas&&"undefined"==typeof document)throw new w("unsupported_environment",e.CanvasUnsupported)}var b=null,I=0;function _(){if(null===b){if(Date.now()<I)return Promise.resolve(void 0);const e=async function(){let e;try{e=P(1,1)}catch{return}const t=F(e,"image/avif");let n;const i=new Promise(e=>{n=setTimeout(()=>e("timeout"),5e3)});try{const e=await Promise.race([t,i]);return"timeout"===e?void 0:"image/avif"===e.type&&e.size>0}finally{void 0!==n&&clearTimeout(n),E(e)}}().catch(()=>{});b=e,e.then(t=>{void 0===t&&b===e&&(b=null,I=Date.now()+1e4)})}return b}async function A(t){if(u(t),"avif"===String(t).toLowerCase()&&!1===await _())throw new w("format_unsupported",e.FormatUnsupported("avif"))}function U(t,n){if(!Number.isFinite(t)||!Number.isFinite(n)||t>y||n>y)throw new w("invalid_resize",e.TargetSizeTooLarge(t,n,y))}async function B(t){try{const e=await t.arrayBuffer(),n=new Uint8Array(e);let i="";const r=32768;for(let e=0;e<n.length;e+=r)i+=String.fromCharCode(...n.subarray(e,e+r));const o=btoa(i);return`data:${t.type};base64,${o}`}catch(t){throw new w("render_encode_failed",e.BlobToBase64FailedWithCause(t instanceof Error?t.message:String(t)),{cause:t})}}function F(t,n,i){return"convertToBlob"in t?t.convertToBlob({type:n,quality:i}):new Promise((r,o)=>{t.toBlob(t=>{t?r(t):o(new w("render_encode_failed",e.CanvasToBlobFailed(n)))},n,i)})}function P(t,n){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,n);if("undefined"!=typeof document){const e=document.createElement("canvas");return e.width=t,e.height=n,e}throw new w("unsupported_environment",e.CanvasUnsupported)}function E(e){const t=e;"function"==typeof t.close?t.close():e.width=0}function O(e,t,n,i){if("undefined"!=typeof ImageData)e.putImageData(new ImageData(t,n,i),0,0);else{const r=e.createImageData(n,i);r.data.set(t),e.putImageData(r,0,0)}}var T=!1;async function x(t,n,i,r,o){const a=n.exif;if(!i||!a||0===a.length)return t;const s=await import("./exif-MBEKII5G.mjs").catch(()=>null);if(!s)return T||(T=!0,console.warn(e.ExifChunkLoadWarning)),t;const{injectExifIntoJpeg:c,injectExifIntoPng:d,normalizeOrientationTag:f}=s,u=o?f(a):a,l=new Uint8Array(await t.arrayBuffer()),h="jpeg"===r?c(l,u):d(l,u);return h===l?t:new Blob([h.buffer],{type:t.type})}function D(){return import("./worker-VA6WQF25.mjs").catch(t=>{const n=t instanceof Error?t.message:String(t);throw new w("worker_load_failed",e.WorkerChunkLoadFailed(n),{cause:t})})}function N(e,t){return D().then(n=>n.convertHeicInWorker(e,t))}function C(e,t){return D().then(n=>n.convertManyInWorker(e,t))}function j(){}function M(e){return!0===e?.nativeDecode&&!0!==e?.preserveExif&&!1!==e?.applyOrientation}var L=!1;async function S(o,a){const s=a?.to??"jpeg";t(a),v(),await A(s);const c=a?.signal;n(c);const d=a,f=await async function(t){if(t instanceof Uint8Array)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if("undefined"!=typeof Blob&&t instanceof Blob)return new Uint8Array(await t.arrayBuffer());if(null!==t&&"object"==typeof t&&"function"==typeof t.arrayBuffer){const e=await t.arrayBuffer();if(e instanceof ArrayBuffer)return new Uint8Array(e)}if(ArrayBuffer.isView(t)){const e=t;return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}throw new w("invalid_input",e.UnsupportedInputType(Object.prototype.toString.call(t)))}(o);let m,p;n(c);let y,b=!1;if(a?.decoder)m=a.decoder,p=!1;else if(M(a)){try{y=await(import("./native-IGARV2W7.mjs"))}catch(t){I=t instanceof Error?t.message:String(t),L||(L=!0,console.warn(e.NativeChunkLoadWarning(I)))}void 0===y||y.isNativeHeicRefused()?m=new g:(m=new y.NativeHeicDecoder,b=!0),p=!0}else m=new g,p=!0;var I;let T=!1;const D=()=>{if(p&&!T){T=!0;try{m.free()}catch{}}};try{const t=i(a?.onProgress),o=async i=>{try{await i.initialize()}catch(t){throw new w("decoder_init_failed",e.DecoderInitFailed(t instanceof Error?t.message:String(t)),{cause:t})}return n(c),i.decode(f,t?t.report:void 0)};let p;try{p=await o(m)}catch(e){if(!b)throw e;if(e instanceof w&&"aborted"===e.code)throw e;e instanceof w&&"decoder_init_failed"===e.code&&y.markNativeHeicRefused(),n(c),D(),m=new g,T=!1,b=!1,p=await o(m)}D(),n(c);const v=void 0!==a?.quality?a.quality:r;let I;try{I=await async function(t,n,i,r,o=!0,a,s=!1){u(n),l(a);const c=n.toLowerCase();if("avif"===c&&!1===await _())throw new w("format_unsupported",e.FormatUnsupported("avif"));const{width:d,height:f,data:m}=t;if(!Number.isInteger(d)||d<=0||!Number.isInteger(f)||f<=0)throw new w("render_encode_failed",e.InvalidDimensions(d,f));const p=d*f*4;if(m.length!==p)throw new w("render_encode_failed",e.DataLengthMismatch(p,d,f,m.length));const g=function(e,t){return t&&"number"==typeof e&&Number.isInteger(e)&&e>=1&&e<=8?e:1}(t.orientation,o),y=!(void 0!==t.orientation&&t.orientation>=2&&t.orientation<=8)||o,v=function(e,t,n){switch(e){case 2:return[-1,0,0,1,t,0];case 3:return[-1,0,0,-1,t,n];case 4:return[1,0,0,-1,0,n];case 5:return[0,1,1,0,0,0];case 6:return[0,1,-1,0,n,0];case 7:return[0,-1,-1,0,n,t];case 8:return[0,-1,1,0,0,t];default:return null}}(g,d,f),b=g>=5,I=b?f:d,A=b?d:f,T=a?.x??0,D=a?.y??0,N=a?a.width:I,C=a?a.height:A;if(a&&(T+N>I||D+C>A))throw new w("invalid_crop",e.CropOutOfBounds(T,D,N,C,I,A));const j=function(e,t,n){if(h(n),!n)return{width:e,height:t};const{maxWidth:i,maxHeight:r,scale:o}=n;if(void 0!==o){const n=Math.max(1,Math.round(e*o)),i=Math.max(1,Math.round(t*o));return U(n,i),{width:n,height:i}}if(void 0===i&&void 0===r)return{width:e,height:t};const a=Math.min(void 0!==i?i/e:Number.POSITIVE_INFINITY,void 0!==r?r/t:Number.POSITIVE_INFINITY);if(a>=1)return{width:e,height:t};const s=Math.min(Math.max(1,Math.round(e*a)),void 0!==i?Math.floor(i):Number.POSITIVE_INFINITY),c=Math.min(Math.max(1,Math.round(t*a)),void 0!==r?Math.floor(r):Number.POSITIVE_INFINITY);return U(s,c),{width:s,height:c}}(N,C,r),M=j.width!==N||j.height!==C,L=null!==v||void 0!==a,S=P(j.width,j.height),k=S.getContext("2d");if(!k)throw new w("render_encode_failed",e.ContextUnavailable);if(L||M){const t=P(d,f),n=t.getContext("2d");if(!n)throw new w("render_encode_failed",e.ContextUnavailable);if(O(n,m,d,f),L){const e=j.width/N,n=j.height/C,i=v?v[0]:1,r=v?v[1]:0,o=v?v[2]:0,a=v?v[3]:1,s=v?v[4]:0,c=v?v[5]:0;k.setTransform(i*e,r*n,o*e,a*n,e*(s-T),n*(c-D)),k.drawImage(t,0,0)}else k.drawImage(t,0,0,j.width,j.height);E(t)}else O(k,m,d,f);if("png"===c){const e=await F(S,"image/png");return E(S),x(e,t,s,"png",y)}if("jpeg"===c||"jpg"===c){const e=await F(S,"image/jpeg",i);return E(S),x(e,t,s,"jpeg",y)}if("webp"===c){const e=await F(S,"image/webp",i);return E(S),e}if("avif"===c){const t=await F(S,"image/avif",i);if(E(S),"image/avif"!==t.type)throw new w("format_unsupported",e.FormatUnsupported("avif"));return t}if("svg"===c){const e=await F(S,"image/png");E(S);const t=await B(e),n=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${j.width} ${j.height}" width="${j.width}" height="${j.height}">\n <image width="${j.width}" height="${j.height}" href="`;return new Blob([n,t,'" />\n</svg>'],{type:"image/svg+xml"})}throw new w("invalid_format",e.UnsupportedFormat(String(n)))}(p,s,v,d,a?.applyOrientation??!0,a?.crop,a?.preserveExif??!1)}catch(t){if(t instanceof w)throw t;throw new w("render_encode_failed",e.RenderEncodeFailed(s,t instanceof Error?t.message:String(t)),{cause:t})}return n(c),t?.complete(),async function(e,t){return"dataUrl"===t?await B(e):"arrayBuffer"===t?await e.arrayBuffer():e}(I,a?.output??"blob")}finally{D()}}var k=class{idle=[];disposed=!1;acquire(){return this.idle.pop()??new g}release(e){if(this.disposed||function(e){return m.has(e)}(e))try{e.free()}catch{}else this.idle.push(e)}dispose(){this.disposed=!0;for(const e of this.idle)try{e.free()}catch{}this.idle.length=0}};async function H(n,i){if(!Array.isArray(n))throw new w("invalid_input",e.InputsMustBeArray);const r=i?.concurrency??4;o(r),t(i),a(i),v(),await A(i?.to??"jpeg");const{concurrency:d,onProgress:f,continueOnError:u,reuseDecoders:l,...h}=i??{},m=s(f),p=!0!==l||void 0!==i?.decoder||M(i)?null:new k;try{return await c(n,r,async(e,t)=>{const n=p?p.acquire():null;try{return await S(e,{...h,...n?{decoder:n}:{},onProgress:m?e=>m(t,e):void 0})}finally{n&&p.release(n)}},{continueOnError:!0===i?.continueOnError,signal:i?.signal})}finally{p?.dispose()}}export{g as LibheifDecoder,S as convertHeic,N as convertHeicInWorker,H as convertMany,C as convertManyInWorker,j as freeSharedDecoder};
1
+ import{Messages as e,validateConvertOptions as t,throwIfAborted as n,progressGateFor as i,DEFAULT_QUALITY as r,validateConcurrency as o,validateBatchOptions as a,progressCallbackFor as s,runBoundedBatch as c,clampPercent as u,progressCallbackError as f,validateFormat as d,validateCrop as l,validateResize as h}from"./chunk-BTAX2PFV.mjs";export{DEFAULT_QUALITY,SUPPORTED_FORMATS}from"./chunk-BTAX2PFV.mjs";import{HeicConverterError as w}from"./chunk-AROQBV5T.mjs";export{HeicConverterError}from"./chunk-AROQBV5T.mjs";var g=new WeakSet,p=/[\u0000-\u001f\u007f-\u009f]+/g,m=class{options;module=null;initPromise=null;initGeneration=0;constructor(e){this.options=e}async initialize(){if(!this.initPromise){const t=++this.initGeneration,n={};this.options?.moduleOverrides&&Object.assign(n,this.options.moduleOverrides),this.options?.locateFile&&(n.locateFile=this.options.locateFile),this.options?.wasmBinary&&(n.wasmBinary=this.options.wasmBinary);const i=import("./heic-decoder-IZMSMJZ7.mjs").then(({default:e})=>e(n)).then(n=>{if(t!==this.initGeneration)return null;const i=["function"==typeof n._heic_decode?null:"_heic_decode","function"==typeof n._heic_result_free?null:"_heic_result_free","function"==typeof n._malloc?null:"_malloc","function"==typeof n._free?null:"_free",n.HEAPU8 instanceof Uint8Array?null:"HEAPU8"].filter(e=>null!==e);if(i.length>0)throw new w("decoder_init_failed",e.GlueApiMissing(i.join(", ")));return this.module=n,n}).catch(e=>{throw this.initPromise===i&&(this.initPromise=null),e});this.initPromise=i}await this.initPromise}async decode(t,n){this.module||await this.initialize();const i=this.module;if(!i)throw new w("decode_failed",e.DecoderFreedDuringDecode);let r;const o=n?e=>{try{n(u(e))}catch(e){r=r??e,i.__progressCb=null}}:null,a=t.buffer===i.HEAPU8.buffer?new Uint8Array(t):t;let s,c=0,d=0;try{if(c=i._malloc(a.byteLength),0===c)throw new w("decode_failed",e.DecodeInputAllocFailed(a.byteLength));i.HEAPU8.set(a,c);const n=i.__progressCb??null;i.__progressCb=o;try{d=i._heic_decode(c,a.byteLength)}finally{i.__progressCb=n}const r=i.HEAPU8;if(0===d)throw new TypeError("heic_decode returned a null result");const u=new DataView(r.buffer,d,36),f=u.getInt32(0,!0);if(0===f){const n=u.getUint32(28,!0),i=u.getUint32(32,!0),o=0!==n?(new TextDecoder).decode(r.subarray(n,n+i)):"";throw new w("decode_failed",o?e.DecodeFailedWithDetail(function(e){const t=e.replace(p," ").trim();return t.length>200?`${t.slice(0,197)}...`:t}(o),t.byteLength):e.DecodeFailed(t.byteLength))}const l=u.getInt32(4,!0),h=u.getInt32(8,!0),g=h>=1&&h<=8?h:1,m=u.getUint32(12,!0),y=u.getUint32(16,!0),v=4*f,_=new Uint8ClampedArray(v*l);if(y===v)_.set(r.subarray(m,m+v*l));else for(let e=0;e<l;e++)_.set(r.subarray(m+e*y,m+e*y+v),e*v);s={width:f,height:l,data:_},g>1&&(s.orientation=g);const b=u.getUint32(20,!0),I=u.getUint32(24,!0);0!==b&&I>=14&&(s.exif=r.slice(b,b+I))}catch(n){if(n instanceof w)throw n;throw g.add(this),new w("decode_failed",e.DecodeFaulted(t.byteLength),{cause:n})}finally{i.__progressCb=null;try{0!==d&&i._heic_result_free(d),0!==c&&i._free(c)}catch{}}if(void 0!==r)throw f(r);return s}free(){this.initGeneration+=1,this.module=null,g.delete(this),this.initPromise=null}},y=16384;function v(){if("undefined"==typeof OffscreenCanvas&&"undefined"==typeof document)throw new w("unsupported_environment",e.CanvasUnsupported)}var _=null,b=0;function I(){if(null===_){if(Date.now()<b)return Promise.resolve(void 0);const e=async function(){let e;try{e=T(1,1)}catch{return}const t=E(e,"image/avif");let n;const i=new Promise(e=>{n=setTimeout(()=>e("timeout"),5e3)});try{const e=await Promise.race([t,i]);return"timeout"===e?void 0:"image/avif"===e.type&&e.size>0}finally{void 0!==n&&clearTimeout(n),F(e)}}().catch(()=>{});_=e,e.then(t=>{void 0===t&&_===e&&(_=null,b=Date.now()+1e4)})}return _}async function U(t){if(d(t),"avif"===String(t).toLowerCase()&&!1===await I())throw new w("format_unsupported",e.FormatUnsupported("avif"))}function A(t,n){if(!Number.isFinite(t)||!Number.isFinite(n)||t>y||n>y)throw new w("invalid_resize",e.TargetSizeTooLarge(t,n,y))}async function B(t){try{const e=await t.arrayBuffer(),n=new Uint8Array(e);let i="";const r=32768;for(let e=0;e<n.length;e+=r)i+=String.fromCharCode(...n.subarray(e,e+r));const o=btoa(i);return`data:${t.type};base64,${o}`}catch(t){throw new w("render_encode_failed",e.BlobToBase64FailedWithCause(t instanceof Error?t.message:String(t)),{cause:t})}}function E(t,n,i){return"convertToBlob"in t?t.convertToBlob({type:n,quality:i}):new Promise((r,o)=>{t.toBlob(t=>{t?r(t):o(new w("render_encode_failed",e.CanvasToBlobFailed(n)))},n,i)})}function T(t,n){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,n);if("undefined"!=typeof document){const e=document.createElement("canvas");return e.width=t,e.height=n,e}throw new w("unsupported_environment",e.CanvasUnsupported)}function F(e){const t=e;"function"==typeof t.close?t.close():e.width=0}function P(e,t,n,i){if("undefined"!=typeof ImageData)e.putImageData(new ImageData(t,n,i),0,0);else{const r=e.createImageData(n,i);r.data.set(t),e.putImageData(r,0,0)}}var x=!1;async function C(t,n,i,r,o){const a=n.exif;if(!i||!a||0===a.length)return t;const s=await import("./exif-MBEKII5G.mjs").catch(()=>null);if(!s)return x||(x=!0,console.warn(e.ExifChunkLoadWarning)),t;const{injectExifIntoJpeg:c,injectExifIntoPng:u,normalizeOrientationTag:f}=s,d=o?f(a):a,l=new Uint8Array(await t.arrayBuffer()),h="jpeg"===r?c(l,d):u(l,d);return h===l?t:new Blob([h.buffer],{type:t.type})}function D(){return import("./worker-VA6WQF25.mjs").catch(t=>{const n=t instanceof Error?t.message:String(t);throw new w("worker_load_failed",e.WorkerChunkLoadFailed(n),{cause:t})})}function O(e,t){return D().then(n=>n.convertHeicInWorker(e,t))}function j(e,t){return D().then(n=>n.convertManyInWorker(e,t))}function M(){}function N(e){return!0===e?.nativeDecode&&!0!==e?.preserveExif&&!1!==e?.applyOrientation}var S=!1;async function L(o,a){const s=a?.to??"jpeg";t(a),v(),await U(s);const c=a?.signal;n(c);const u=a,f=await async function(t){if(t instanceof Uint8Array)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if("undefined"!=typeof Blob&&t instanceof Blob)return new Uint8Array(await t.arrayBuffer());if(null!==t&&"object"==typeof t&&"function"==typeof t.arrayBuffer){const e=await t.arrayBuffer();if(e instanceof ArrayBuffer)return new Uint8Array(e)}if(ArrayBuffer.isView(t)){const e=t;return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}throw new w("invalid_input",e.UnsupportedInputType(Object.prototype.toString.call(t)))}(o);let g,p;n(c);let y,_=!1;if(a?.decoder)g=a.decoder,p=!1;else if(N(a)){try{y=await(import("./native-IGARV2W7.mjs"))}catch(t){b=t instanceof Error?t.message:String(t),S||(S=!0,console.warn(e.NativeChunkLoadWarning(b)))}void 0===y||y.isNativeHeicRefused()?g=new m:(g=new y.NativeHeicDecoder,_=!0),p=!0}else g=new m,p=!0;var b;let x=!1;const D=()=>{if(p&&!x){x=!0;try{g.free()}catch{}}};try{const t=i(a?.onProgress),o=async i=>{try{await i.initialize()}catch(t){throw new w("decoder_init_failed",e.DecoderInitFailed(t instanceof Error?t.message:String(t)),{cause:t})}return n(c),i.decode(f,t?t.report:void 0)};let p;try{p=await o(g)}catch(e){if(!_)throw e;if(e instanceof w&&"aborted"===e.code)throw e;e instanceof w&&"decoder_init_failed"===e.code&&y.markNativeHeicRefused(),n(c),D(),g=new m,x=!1,_=!1,p=await o(g)}D(),n(c);const v=void 0!==a?.quality?a.quality:r;let b;try{b=await async function(t,n,i,r,o=!0,a,s=!1){d(n),l(a);const c=n.toLowerCase();if("avif"===c&&!1===await I())throw new w("format_unsupported",e.FormatUnsupported("avif"));const{width:u,height:f,data:g}=t;if(!Number.isInteger(u)||u<=0||!Number.isInteger(f)||f<=0)throw new w("render_encode_failed",e.InvalidDimensions(u,f));const p=u*f*4;if(g.length!==p)throw new w("render_encode_failed",e.DataLengthMismatch(p,u,f,g.length));const m=function(e,t){return t&&"number"==typeof e&&Number.isInteger(e)&&e>=1&&e<=8?e:1}(t.orientation,o),y=!(void 0!==t.orientation&&t.orientation>=2&&t.orientation<=8)||o,v=function(e,t,n){switch(e){case 2:return[-1,0,0,1,t,0];case 3:return[-1,0,0,-1,t,n];case 4:return[1,0,0,-1,0,n];case 5:return[0,1,1,0,0,0];case 6:return[0,1,-1,0,n,0];case 7:return[0,-1,-1,0,n,t];case 8:return[0,-1,1,0,0,t];default:return null}}(m,u,f),_=m>=5,b=_?f:u,U=_?u:f,x=a?.x??0,D=a?.y??0,O=a?a.width:b,j=a?a.height:U;if(a&&(x+O>b||D+j>U))throw new w("invalid_crop",e.CropOutOfBounds(x,D,O,j,b,U));const M=function(e,t,n){if(h(n),!n)return{width:e,height:t};const{maxWidth:i,maxHeight:r,scale:o}=n;if(void 0!==o){const n=Math.max(1,Math.round(e*o)),i=Math.max(1,Math.round(t*o));return A(n,i),{width:n,height:i}}if(void 0===i&&void 0===r)return{width:e,height:t};const a=Math.min(void 0!==i?i/e:Number.POSITIVE_INFINITY,void 0!==r?r/t:Number.POSITIVE_INFINITY);if(a>=1)return{width:e,height:t};const s=Math.min(Math.max(1,Math.round(e*a)),void 0!==i?Math.floor(i):Number.POSITIVE_INFINITY),c=Math.min(Math.max(1,Math.round(t*a)),void 0!==r?Math.floor(r):Number.POSITIVE_INFINITY);return A(s,c),{width:s,height:c}}(O,j,r),N=M.width!==O||M.height!==j,S=null!==v||void 0!==a,L=T(M.width,M.height),k=L.getContext("2d");if(!k)throw new w("render_encode_failed",e.ContextUnavailable);if(S||N){const t=T(u,f),n=t.getContext("2d");if(!n)throw new w("render_encode_failed",e.ContextUnavailable);if(P(n,g,u,f),S){const e=M.width/O,n=M.height/j,i=v?v[0]:1,r=v?v[1]:0,o=v?v[2]:0,a=v?v[3]:1,s=v?v[4]:0,c=v?v[5]:0;k.setTransform(i*e,r*n,o*e,a*n,e*(s-x),n*(c-D)),k.drawImage(t,0,0)}else k.drawImage(t,0,0,M.width,M.height);F(t)}else P(k,g,u,f);if("png"===c){const e=await E(L,"image/png");return F(L),C(e,t,s,"png",y)}if("jpeg"===c||"jpg"===c){const e=await E(L,"image/jpeg",i);return F(L),C(e,t,s,"jpeg",y)}if("webp"===c){const e=await E(L,"image/webp",i);return F(L),e}if("avif"===c){const t=await E(L,"image/avif",i);if(F(L),"image/avif"!==t.type)throw new w("format_unsupported",e.FormatUnsupported("avif"));return t}if("svg"===c){const e=await E(L,"image/png");F(L);const t=await B(e),n=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${M.width} ${M.height}" width="${M.width}" height="${M.height}">\n <image width="${M.width}" height="${M.height}" href="`;return new Blob([n,t,'" />\n</svg>'],{type:"image/svg+xml"})}throw new w("invalid_format",e.UnsupportedFormat(String(n)))}(p,s,v,u,a?.applyOrientation??!0,a?.crop,a?.preserveExif??!1)}catch(t){if(t instanceof w)throw t;throw new w("render_encode_failed",e.RenderEncodeFailed(s,t instanceof Error?t.message:String(t)),{cause:t})}return n(c),t?.complete(),async function(e,t){return"dataUrl"===t?await B(e):"arrayBuffer"===t?await e.arrayBuffer():e}(b,a?.output??"blob")}finally{D()}}var k=class{idle=[];disposed=!1;acquire(){return this.idle.pop()??new m}release(e){if(this.disposed||function(e){return g.has(e)}(e))try{e.free()}catch{}else this.idle.push(e)}dispose(){this.disposed=!0;for(const e of this.idle)try{e.free()}catch{}this.idle.length=0}};async function V(n,i){if(!Array.isArray(n))throw new w("invalid_input",e.InputsMustBeArray);const r=i?.concurrency??4;o(r),t(i),a(i),v(),await U(i?.to??"jpeg");const{concurrency:u,onProgress:f,continueOnError:d,reuseDecoders:l,...h}=i??{},g=s(f),p=!0!==l||void 0!==i?.decoder||N(i)?null:new k;try{return await c(n,r,async(e,t)=>{const n=p?p.acquire():null;try{return await L(e,{...h,...n?{decoder:n}:{},onProgress:g?e=>g(t,e):void 0})}finally{n&&p.release(n)}},{continueOnError:!0===i?.continueOnError,signal:i?.signal})}finally{p?.dispose()}}export{m as LibheifDecoder,L as convertHeic,O as convertHeicInWorker,V as convertMany,j as convertManyInWorker,M as freeSharedDecoder};
@@ -23,22 +23,21 @@ export interface LibheifDecoderOptions {
23
23
  export declare class LibheifDecoder implements IHeicDecoder {
24
24
  private options?;
25
25
  private module;
26
- private decoderInstance;
27
26
  /**
28
27
  * Memoized module-loading promise so concurrent initialize()/decode() calls
29
28
  * on the same instance never instantiate (or mutate) the module twice.
30
- * Resolves null when a concurrent free() discarded the freshly created
31
- * instance (see initGeneration).
29
+ * Resolves null when a concurrent free() discarded the freshly loaded
30
+ * module (see initGeneration).
32
31
  */
33
32
  private initPromise;
34
33
  /**
35
34
  * Generation counter for init/free races: a load that finishes after a
36
- * concurrent free() must not resurrect module/decoderInstance.
35
+ * concurrent free() must not resurrect module.
37
36
  */
38
37
  private initGeneration;
39
38
  constructor(options?: LibheifDecoderOptions);
40
39
  /**
41
- * Initializes the WebAssembly module and instantiates the HEIC decoder.
40
+ * Initializes the WebAssembly module (the raw C-ABI decoder surface).
42
41
  * Safe to call concurrently: the module is loaded at most once per instance.
43
42
  */
44
43
  initialize(): Promise<void>;
@@ -50,13 +49,13 @@ export declare class LibheifDecoder implements IHeicDecoder {
50
49
  */
51
50
  decode(data: Uint8Array, onProgress?: (percent: number) => void): Promise<DecodedImage>;
52
51
  /**
53
- * Cleans up the WebAssembly decoder instance and resources.
52
+ * Cleans up the WebAssembly decoder resources.
54
53
  * Idempotent: safe to call multiple times. After free(), the next
55
54
  * initialize() — or decode() directly, which re-initializes transparently
56
55
  * — loads a fresh module.
57
56
  *
58
57
  * free() is also safe to call while initialize() is in flight: a load that
59
- * completes after free() discards its fresh instance instead of leaking it.
58
+ * completes after free() discards itself instead of resurrecting state.
60
59
  */
61
60
  free(): void;
62
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keeratita/heic-converter",
3
- "version": "0.6.1",
3
+ "version": "0.6.2-prerelease",
4
4
  "description": "Convert HEIC images to standard web formats (JPEG, PNG, WebP, AVIF, SVG) without breaking CSP",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1 +0,0 @@
1
- var t,e=(t=import.meta.url,async function(e={}){var r,n,a=e;a.ready=new Promise((t,e)=>{r=t,n=e});var o,i,s=Object.assign({},a),u="./this.program",l="object"==typeof window,c="function"==typeof importScripts,h="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,p="";if(h){const{createRequire:t}=await(import("module"));var f=t(import.meta.url),d=f("fs"),v=f("path");p=c?v.dirname(p)+"/":f("url").fileURLToPath(new URL("./",import.meta.url)),o=(t,e)=>(t=L(t)?new URL(t):v.normalize(t),d.readFileSync(t,e?void 0:"utf8")),i=t=>{var e=o(t,!0);return e.buffer||(e=new Uint8Array(e)),e},!a.thisProgram&&process.argv.length>1&&(u=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(l||c)&&(c?p=self.location.href:"undefined"!=typeof document&&document.currentScript&&(p=document.currentScript.src),t&&(p=t),p=p.startsWith("blob:")?"":p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1),o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},c&&(i=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}));var y,$,g=a.print||console.log.bind(console),m=a.printErr||console.error.bind(console);Object.assign(a,s),s=null,a.arguments&&a.arguments,a.thisProgram&&(u=a.thisProgram),a.quit&&a.quit,a.wasmBinary&&(y=a.wasmBinary);var b,w,C,P,T,_,A,j,S=!1;function E(){var t=$.buffer;a.HEAP8=b=new Int8Array(t),a.HEAP16=C=new Int16Array(t),a.HEAPU8=w=new Uint8Array(t),a.HEAPU16=P=new Uint16Array(t),a.HEAP32=T=new Int32Array(t),a.HEAPU32=_=new Uint32Array(t),a.HEAPF32=A=new Float32Array(t),a.HEAPF64=j=new Float64Array(t)}var W=[],k=[],F=[];function O(t){W.unshift(t)}function R(t){F.unshift(t)}var x=0,U=null;function D(t){a.onAbort?.(t),m(t="Aborted("+t+")"),S=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}var I,H,V=t=>t.startsWith("data:application/octet-stream;base64,"),L=t=>t.startsWith("file://");function M(t){if(t==I&&y)return new Uint8Array(y);if(i)return i(t);throw"both async and sync fetching of the wasm failed"}function B(t,e,r){return function(t){return y||!l&&!c||"function"!=typeof fetch?Promise.resolve().then(()=>M(t)):fetch(t,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw`failed to load wasm binary file at '${t}'`;return e.arrayBuffer()}).catch(()=>M(t))}(t).then(t=>WebAssembly.instantiate(t,e)).then(r,t=>{m(`failed to asynchronously prepare wasm: ${t}`),D(t)})}a.locateFile?V(I="heic-decoder.wasm")||(H=I,I=a.locateFile?a.locateFile(H,p):p+H):I=new URL("heic-decoder.wasm",import.meta.url).href;var q=t=>{for(;t.length>0;)t.shift()(a)};a.noExitRuntime;var z="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,G=(t,e,r)=>{for(var n=e+r,a=e;t[a]&&!(a>=n);)++a;if(a-e>16&&t.buffer&&z)return z.decode(t.subarray(e,a));for(var o="";e<a;){var i=t[e++];if(128&i){var s=63&t[e++];if(192!=(224&i)){var u=63&t[e++];if((i=224==(240&i)?(15&i)<<12|s<<6|u:(7&i)<<18|s<<12|u<<6|63&t[e++])<65536)o+=String.fromCharCode(i);else{var l=i-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|s)}else o+=String.fromCharCode(i)}return o},N=(t,e)=>t?G(w,t,e):"",X=[],Z=0,J=0;class K{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){_[this.ptr+4>>2]=t}get_type(){return _[this.ptr+4>>2]}set_destructor(t){_[this.ptr+8>>2]=t}get_destructor(){return _[this.ptr+8>>2]}set_caught(t){t=t?1:0,b[this.ptr+12]=t}get_caught(){return 0!=b[this.ptr+12]}set_rethrown(t){t=t?1:0,b[this.ptr+13]=t}get_rethrown(){return 0!=b[this.ptr+13]}init(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)}set_adjusted_ptr(t){_[this.ptr+16>>2]=t}get_adjusted_ptr(){return _[this.ptr+16>>2]}get_exception_ptr(){if(Se(this.get_type()))return _[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}var Q,Y,tt,et=t=>{var e=J;if(!e)return Ce(0),0;var r=new K(e);r.set_adjusted_ptr(e);var n=r.get_type();if(!n)return Ce(0),e;for(var a in t){var o=t[a];if(0===o||o===n)break;var i=r.ptr+16;if(je(o,n,i))return Ce(o),e}return Ce(n),e},rt=t=>{for(var e="",r=t;w[r];)e+=Q[w[r++]];return e},nt={},at={},ot={},it=t=>{throw new Y(t)},st=t=>{throw new tt(t)},ut=(t,e,r)=>{function n(e){var n=r(e);n.length!==t.length&&st("Mismatched type converter count");for(var a=0;a<t.length;++a)lt(t[a],n[a])}t.forEach(function(t){ot[t]=e});var a=new Array(e.length),o=[],i=0;e.forEach((t,e)=>{at.hasOwnProperty(t)?a[e]=at[t]:(o.push(t),nt.hasOwnProperty(t)||(nt[t]=[]),nt[t].push(()=>{a[e]=at[t],++i===o.length&&n(a)}))}),0===o.length&&n(a)};function lt(t,e,r={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(t,e,r={}){var n=e.name;if(t||it(`type "${n}" must have a positive integer typeid pointer`),at.hasOwnProperty(t)){if(r.ignoreDuplicateRegistrations)return;it(`Cannot register type '${n}' twice`)}if(at[t]=e,delete ot[t],nt.hasOwnProperty(t)){var a=nt[t];delete nt[t],a.forEach(t=>t())}}(t,e,r)}var ct,ht=t=>{it(t.$$.ptrType.registeredClass.name+" instance already deleted")},pt=!1,ft=t=>{},dt=t=>{t.count.value-=1,0===t.count.value&&(t=>{t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)})(t)},vt=(t,e,r)=>{if(e===r)return t;if(void 0===r.baseClass)return null;var n=vt(t,e,r.baseClass);return null===n?null:r.downcast(n)},yt={},$t=[],gt=()=>{for(;$t.length;){var t=$t.pop();t.$$.deleteScheduled=!1,t.delete()}},mt={},bt=(t,e)=>(e.ptrType&&e.ptr||st("makeClassHandle requires ptr and ptrType"),!!e.smartPtrType!=!!e.smartPtr&&st("Both smartPtrType and smartPtr must be specified"),e.count={value:1},wt(Object.create(t,{$$:{value:e,writable:!0}}))),wt=t=>"undefined"==typeof FinalizationRegistry?(wt=t=>t,t):(pt=new FinalizationRegistry(t=>{dt(t.$$)}),ft=t=>pt.unregister(t),(wt=t=>{var e=t.$$;if(e.smartPtr){var r={$$:e};pt.register(t,r,t)}return t})(t));function Ct(){}var Pt=(t,e)=>Object.defineProperty(e,"name",{value:t}),Tt=(t,e,r)=>{if(void 0===t[e].overloadTable){var n=t[e];t[e]=function(...n){return t[e].overloadTable.hasOwnProperty(n.length)||it(`Function '${r}' called with an invalid number of arguments (${n.length}) - expects one of (${t[e].overloadTable})!`),t[e].overloadTable[n.length].apply(this,n)},t[e].overloadTable=[],t[e].overloadTable[n.argCount]=n}};function _t(t,e,r,n,a,o,i,s){this.name=t,this.constructor=e,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=a,this.getActualType=o,this.upcast=i,this.downcast=s,this.pureVirtualFunctions=[]}var At=(t,e,r)=>{for(;e!==r;)e.upcast||it(`Expected null or instance of ${r.name}, got an instance of ${e.name}`),t=e.upcast(t),e=e.baseClass;return t};function jt(t,e){if(null===e)return this.isReference&&it(`null is not a valid ${this.name}`),0;e.$$||it(`Cannot pass "${Zt(e)}" as a ${this.name}`),e.$$.ptr||it(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=e.$$.ptrType.registeredClass;return At(e.$$.ptr,r,this.registeredClass)}function St(t,e){var r;if(null===e)return this.isReference&&it(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),null!==t&&t.push(this.rawDestructor,r),r):0;e&&e.$$||it(`Cannot pass "${Zt(e)}" as a ${this.name}`),e.$$.ptr||it(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&it(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var n=e.$$.ptrType.registeredClass;if(r=At(e.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===e.$$.smartPtr&&it("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?r=e.$$.smartPtr:it(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)r=e.$$.smartPtr;else{var a=e.clone();r=this.rawShare(r,Nt.toHandle(()=>a.delete())),null!==t&&t.push(this.rawDestructor,r)}break;default:it("Unsupporting sharing policy")}return r}function Et(t,e){if(null===e)return this.isReference&&it(`null is not a valid ${this.name}`),0;e.$$||it(`Cannot pass "${Zt(e)}" as a ${this.name}`),e.$$.ptr||it(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&it(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var r=e.$$.ptrType.registeredClass;return At(e.$$.ptr,r,this.registeredClass)}function Wt(t){return this.fromWireType(_[t>>2])}function kt(t,e,r,n,a,o,i,s,u,l,c){this.name=t,this.registeredClass=e,this.isReference=r,this.isConst=n,this.isSmartPointer=a,this.pointeeType=o,this.sharingPolicy=i,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=l,this.rawDestructor=c,a||void 0!==e.baseClass?this.toWireType=St:n?(this.toWireType=jt,this.destructorFunction=null):(this.toWireType=Et,this.destructorFunction=null)}var Ft,Ot,Rt=[],xt=t=>{var e=Rt[t];return e||(t>=Rt.length&&(Rt.length=t+1),Rt[t]=e=Ft.get(t)),e},Ut=(t,e)=>{var r,n,o=(t=rt(t)).includes("j")?(r=t,n=e,(...t)=>((t,e,r=[])=>t.includes("j")?((t,e,r)=>(0,a["dynCall_"+t])(e,...r))(t,e,r):xt(e)(...r))(r,n,t)):xt(e);return"function"!=typeof o&&it(`unknown function pointer with signature ${t}: ${e}`),o},Dt=t=>{var e=be(t),r=rt(e);return me(e),r},It=(t,e)=>{var r=[],n={};throw e.forEach(function t(e){n[e]||at[e]||(ot[e]?ot[e].forEach(t):(r.push(e),n[e]=!0))}),new Ot(`${t}: `+r.map(Dt).join([", "]))},Ht=(t,e)=>{for(var r=[],n=0;n<t;n++)r.push(_[e+4*n>>2]);return r},Vt=t=>{for(;t.length;){var e=t.pop();t.pop()(e)}};function Lt(t,e,r,n,a,o){var i=e.length;i<2&&it("argTypes array size mismatch! Must at least get return value and 'this' types!");var s=null!==e[1]&&null!==r,u=function(t){for(var e=1;e<t.length;++e)if(null!==t[e]&&void 0===t[e].destructorFunction)return!0;return!1}(e),l="void"!==e[0].name,c=i-2,h=new Array(c),p=[],f=[];return Pt(t,function(...r){var o;r.length!==c&&it(`function ${t} called with ${r.length} arguments, expected ${c}`),f.length=0,p.length=s?2:1,p[0]=a,s&&(o=e[1].toWireType(f,this),p[1]=o);for(var i=0;i<c;++i)h[i]=e[i+2].toWireType(f,r[i]),p.push(h[i]);return function(t){if(u)Vt(f);else for(var r=s?1:2;r<e.length;r++){var n=1===r?o:h[r-2];null!==e[r].destructorFunction&&e[r].destructorFunction(n)}if(l)return e[0].fromWireType(t)}(n(...p))})}var Mt,Bt,qt=[],zt=[],Gt=t=>{t>9&&0===--zt[t+1]&&(zt[t]=void 0,qt.push(t))},Nt={toValue:t=>(t||it("Cannot use deleted val. handle = "+t),zt[t]),toHandle:t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const e=qt.pop()||zt.length;return zt[e]=t,zt[e+1]=1,e}}}},Xt={name:"emscripten::val",fromWireType:t=>{var e=Nt.toValue(t);return Gt(t),e},toWireType:(t,e)=>Nt.toHandle(e),argPackAdvance:8,readValueFromPointer:Wt,destructorFunction:null},Zt=t=>{if(null===t)return"null";var e=typeof t;return"object"===e||"array"===e||"function"===e?t.toString():""+t},Jt=(t,e)=>{switch(e){case 4:return function(t){return this.fromWireType(A[t>>2])};case 8:return function(t){return this.fromWireType(j[t>>3])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}},Kt=(t,e,r)=>{switch(e){case 1:return r?t=>b[t]:t=>w[t];case 2:return r?t=>C[t>>1]:t=>P[t>>1];case 4:return r?t=>T[t>>2]:t=>_[t>>2];default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},Qt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,Yt=(t,e)=>{for(var r=t,n=r>>1,a=n+e/2;!(n>=a)&&P[n];)++n;if((r=n<<1)-t>32&&Qt)return Qt.decode(w.subarray(t,r));for(var o="",i=0;!(i>=e/2);++i){var s=C[t+2*i>>1];if(0==s)break;o+=String.fromCharCode(s)}return o},te=(t,e,r)=>{if(r??=2147483647,r<2)return 0;for(var n=e,a=(r-=2)<2*t.length?r/2:t.length,o=0;o<a;++o){var i=t.charCodeAt(o);C[e>>1]=i,e+=2}return C[e>>1]=0,e-n},ee=t=>2*t.length,re=(t,e)=>{for(var r=0,n="";!(r>=e/4);){var a=T[t+4*r>>2];if(0==a)break;if(++r,a>=65536){var o=a-65536;n+=String.fromCharCode(55296|o>>10,56320|1023&o)}else n+=String.fromCharCode(a)}return n},ne=(t,e,r)=>{if(r??=2147483647,r<4)return 0;for(var n=e,a=n+r-4,o=0;o<t.length;++o){var i=t.charCodeAt(o);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&t.charCodeAt(++o)),T[e>>2]=i,(e+=4)+4>a)break}return T[e>>2]=0,e-n},ae=t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n>=55296&&n<=57343&&++r,e+=4}return e},oe=[],ie={},se=t=>{var e=ie[t];return void 0===e?rt(t):e},ue=()=>{if("object"==typeof globalThis)return globalThis;function t(t){t.$$$embind_global$$$=t;var e="object"==typeof $$$embind_global$$$&&t.$$$embind_global$$$==t;return e||delete t.$$$embind_global$$$,e}if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;if("object"==typeof global&&t(global)?$$$embind_global$$$=global:"object"==typeof self&&t(self)&&($$$embind_global$$$=self),"object"==typeof $$$embind_global$$$)return $$$embind_global$$$;throw Error("unable to get global object.")},le=(t,e)=>{var r=at[t];return void 0===r&&it(`${e} has unknown type ${Dt(t)}`),r},ce=Reflect.construct,he=t=>{var e=(t-$.buffer.byteLength+65535)/65536;try{return $.grow(e),E(),1}catch(t){}},pe={},fe=()=>{if(!fe.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:u||"./this.program"};for(var e in pe)void 0===pe[e]?delete t[e]:t[e]=pe[e];var r=[];for(var e in t)r.push(`${e}=${t[e]}`);fe.strings=r}return fe.strings},de=[null,[],[]],ve=(t,e)=>{var r=de[t];0===e||10===e?((1===t?g:m)(G(r,0)),r.length=0):r.push(e)};(()=>{for(var t=new Array(256),e=0;e<256;++e)t[e]=String.fromCharCode(e);Q=t})(),Y=a.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},tt=a.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}},Object.assign(Ct.prototype,{isAliasOf(t){if(!(this instanceof Ct))return!1;if(!(t instanceof Ct))return!1;var e=this.$$.ptrType.registeredClass,r=this.$$.ptr;t.$$=t.$$;for(var n=t.$$.ptrType.registeredClass,a=t.$$.ptr;e.baseClass;)r=e.upcast(r),e=e.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return e===n&&r===a},clone(){if(this.$$.ptr||ht(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t,e=wt(Object.create(Object.getPrototypeOf(this),{$$:{value:(t=this.$$,{count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType})}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},delete(){this.$$.ptr||ht(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&it("Object already scheduled for deletion"),ft(this),dt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||ht(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&it("Object already scheduled for deletion"),$t.push(this),1===$t.length&&ct&&ct(gt),this.$$.deleteScheduled=!0,this}}),a.getInheritedInstanceCount=()=>Object.keys(mt).length,a.getLiveInheritedInstances=()=>{var t=[];for(var e in mt)mt.hasOwnProperty(e)&&t.push(mt[e]);return t},a.flushPendingDeletes=gt,a.setDelayFunction=t=>{ct=t,$t.length&&ct&&ct(gt)},Object.assign(kt.prototype,{getPointee(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t},destructor(t){this.rawDestructor?.(t)},argPackAdvance:8,readValueFromPointer:Wt,fromWireType:function(t){var e=this.getPointee(t);if(!e)return this.destructor(t),null;var r=((t,e)=>(e=((t,e)=>{for(void 0===e&&it("ptr should not be undefined");t.baseClass;)e=t.upcast(e),t=t.baseClass;return e})(t,e),mt[e]))(this.registeredClass,e);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=e,r.$$.smartPtr=t,r.clone();var n=r.clone();return this.destructor(t),n}function a(){return this.isSmartPointer?bt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:t}):bt(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var o,i=this.registeredClass.getActualType(e),s=yt[i];if(!s)return a.call(this);o=this.isConst?s.constPointerType:s.pointerType;var u=vt(e,this.registeredClass,o.registeredClass);return null===u?a.call(this):this.isSmartPointer?bt(o.registeredClass.instancePrototype,{ptrType:o,ptr:u,smartPtrType:this,smartPtr:t}):bt(o.registeredClass.instancePrototype,{ptrType:o,ptr:u})}}),Ot=a.UnboundTypeError=(Mt=Error,(Bt=Pt("UnboundTypeError",function(t){this.name="UnboundTypeError",this.message=t;var e=new Error(t).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))})).prototype=Object.create(Mt.prototype),Bt.prototype.constructor=Bt,Bt.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},Bt),zt.push(0,1,void 0,1,null,1,!0,1,!1,1),a.count_emval_handles=()=>zt.length/2-5-qt.length;var ye={a:(t,e,r,n)=>{D(`Assertion failed: ${N(t)}, at: `+[e?N(e):"unknown filename",r,n?N(n):"unknown function"])},o:t=>{var e=new K(t);return e.get_caught()||(e.set_caught(!0),Z--),e.set_rethrown(!1),X.push(e),Ae(e.excPtr),e.get_exception_ptr()},q:()=>{we(0,0);var t=X.pop();_e(t.excPtr),J=0},b:()=>et([]),c:t=>et([t]),A:()=>{var t=X.pop();t||D("no exception to throw");var e=t.excPtr;throw t.get_rethrown()||(X.push(t),t.set_rethrown(!0),t.set_caught(!1),Z++),J=e},m:(t,e,r)=>{throw new K(t).init(e,r),Z++,J=t},P:()=>Z,f:t=>{throw J||(J=t),J},R:(t,e,r)=>{},N:(t,e,r,n,a)=>{},X:(t,e,r,n)=>{lt(t,{name:e=rt(e),fromWireType:function(t){return!!t},toWireType:function(t,e){return e?r:n},argPackAdvance:8,readValueFromPointer:function(t){return this.fromWireType(w[t])},destructorFunction:null})},J:(t,e,r,n,o,i,s,u,l,c,h,p,f)=>{h=rt(h),i=Ut(o,i),u&&=Ut(s,u),c&&=Ut(l,c),f=Ut(p,f);var d=(t=>{if(void 0===t)return"_unknown";var e=(t=t.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return e>=48&&e<=57?`_${t}`:t})(h);((t,e)=>{a.hasOwnProperty(t)?(it(`Cannot register public name '${t}' twice`),Tt(a,t,t),a.hasOwnProperty(void 0)&&it("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),a[t].overloadTable[void 0]=e):a[t]=e})(d,function(){It(`Cannot construct ${h} due to unbound types`,[n])}),ut([t,e,r],n?[n]:[],e=>{var r,o;e=e[0],o=n?(r=e.registeredClass).instancePrototype:Ct.prototype;var s=Pt(h,function(...t){if(Object.getPrototypeOf(this)!==l)throw new Y("Use 'new' to construct "+h);if(void 0===p.constructor_body)throw new Y(h+" has no accessible constructor");var e=p.constructor_body[t.length];if(void 0===e)throw new Y(`Tried to invoke ctor of ${h} with invalid number of parameters (${t.length}) - expected (${Object.keys(p.constructor_body).toString()}) parameters instead!`);return e.apply(this,t)}),l=Object.create(o,{constructor:{value:s}});s.prototype=l;var p=new _t(h,s,l,f,r,i,u,c);p.baseClass&&(p.baseClass.__derivedClasses??=[],p.baseClass.__derivedClasses.push(p));var v=new kt(h,p,!0,!1,!1),y=new kt(h+"*",p,!1,!1,!1),$=new kt(h+" const*",p,!1,!0,!1);return yt[t]={pointerType:y,constPointerType:$},((t,e)=>{a.hasOwnProperty(t)||st("Replacing nonexistent public symbol"),a[t].overloadTable,a[t]=e,a[t].argCount=void 0})(d,s),[v,y,$]})},I:(t,e,r,n,a,o)=>{var i=Ht(e,r);a=Ut(n,a),ut([],[t],t=>{var r=`constructor ${(t=t[0]).name}`;if(void 0===t.registeredClass.constructor_body&&(t.registeredClass.constructor_body=[]),void 0!==t.registeredClass.constructor_body[e-1])throw new Y(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${t.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return t.registeredClass.constructor_body[e-1]=()=>{It(`Cannot construct ${t.name} due to unbound types`,i)},ut([],i,n=>(n.splice(1,0,null),t.registeredClass.constructor_body[e-1]=Lt(r,n,null,a,o),[])),[]})},s:(t,e,r,n,a,o,i,s,u)=>{var l=Ht(r,n);e=(t=>{const e=(t=t.trim()).indexOf("(");return-1!==e?t.substr(0,e):t})(e=rt(e)),o=Ut(a,o),ut([],[t],t=>{var n=`${(t=t[0]).name}.${e}`;function a(){It(`Cannot call ${n} due to unbound types`,l)}e.startsWith("@@")&&(e=Symbol[e.substring(2)]),s&&t.registeredClass.pureVirtualFunctions.push(e);var u=t.registeredClass.instancePrototype,c=u[e];return void 0===c||void 0===c.overloadTable&&c.className!==t.name&&c.argCount===r-2?(a.argCount=r-2,a.className=t.name,u[e]=a):(Tt(u,e,n),u[e].overloadTable[r-2]=a),ut([],l,a=>{var s=Lt(n,a,t,o,i);return void 0===u[e].overloadTable?(s.argCount=r-2,u[e]=s):u[e].overloadTable[r-2]=s,[]}),[]})},W:t=>lt(t,Xt),D:(t,e,r)=>{lt(t,{name:e=rt(e),fromWireType:t=>t,toWireType:(t,e)=>e,argPackAdvance:8,readValueFromPointer:Jt(e,r),destructorFunction:null})},n:(t,e,r,n,a)=>{e=rt(e);var o=t=>t;if(0===n){var i=32-8*r;o=t=>t<<i>>>i}var s=e.includes("unsigned");lt(t,{name:e,fromWireType:o,toWireType:s?function(t,e){return this.name,e>>>0}:function(t,e){return this.name,e},argPackAdvance:8,readValueFromPointer:Kt(e,r,0!==n),destructorFunction:null})},g:(t,e,r)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function a(t){var e=_[t>>2],r=_[t+4>>2];return new n(b.buffer,r,e)}lt(t,{name:r=rt(r),fromWireType:a,argPackAdvance:8,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},C:(t,e)=>{var r="std::string"===(e=rt(e));lt(t,{name:e,fromWireType(t){var e,n=_[t>>2],a=t+4;if(r)for(var o=a,i=0;i<=n;++i){var s=a+i;if(i==n||0==w[s]){var u=N(o,s-o);void 0===e?e=u:(e+=String.fromCharCode(0),e+=u),o=s+1}}else{var l=new Array(n);for(i=0;i<n;++i)l[i]=String.fromCharCode(w[a+i]);e=l.join("")}return me(t),e},toWireType(t,e){var n;e instanceof ArrayBuffer&&(e=new Uint8Array(e));var a="string"==typeof e;a||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||it("Cannot pass non-string to std::string"),n=r&&a?(t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++r):e+=3}return e})(e):e.length;var o=ge(4+n+1),i=o+4;if(_[o>>2]=n,r&&a)((t,e,r,n)=>{if(!(n>0))return 0;for(var a=r+n-1,o=0;o<t.length;++o){var i=t.charCodeAt(o);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&t.charCodeAt(++o)),i<=127){if(r>=a)break;e[r++]=i}else if(i<=2047){if(r+1>=a)break;e[r++]=192|i>>6,e[r++]=128|63&i}else if(i<=65535){if(r+2>=a)break;e[r++]=224|i>>12,e[r++]=128|i>>6&63,e[r++]=128|63&i}else{if(r+3>=a)break;e[r++]=240|i>>18,e[r++]=128|i>>12&63,e[r++]=128|i>>6&63,e[r++]=128|63&i}}e[r]=0})(e,w,i,n+1);else if(a)for(var s=0;s<n;++s){var u=e.charCodeAt(s);u>255&&(me(i),it("String has UTF-16 code units that do not fit in 8 bits")),w[i+s]=u}else for(s=0;s<n;++s)w[i+s]=e[s];return null!==t&&t.push(me,o),o},argPackAdvance:8,readValueFromPointer:Wt,destructorFunction(t){me(t)}})},v:(t,e,r)=>{var n,a,o,i;r=rt(r),2===e?(n=Yt,a=te,i=ee,o=t=>P[t>>1]):4===e&&(n=re,a=ne,i=ae,o=t=>_[t>>2]),lt(t,{name:r,fromWireType:t=>{for(var r,a=_[t>>2],i=t+4,s=0;s<=a;++s){var u=t+4+s*e;if(s==a||0==o(u)){var l=n(i,u-i);void 0===r?r=l:(r+=String.fromCharCode(0),r+=l),i=u+e}}return me(t),r},toWireType:(t,n)=>{"string"!=typeof n&&it(`Cannot pass non-string to C++ string type ${r}`);var o=i(n),s=ge(4+o+e);return _[s>>2]=o/e,a(n,s+4,o+e),null!==t&&t.push(me,s),s},argPackAdvance:8,readValueFromPointer:Wt,destructorFunction(t){me(t)}})},Y:(t,e)=>{lt(t,{isVoid:!0,name:e=rt(e),argPackAdvance:0,fromWireType:()=>{},toWireType:(t,e)=>{}})},x:(t,e,r,n)=>(t=oe[t])(null,e=Nt.toValue(e),r,n),E:(t,e,r,n,a)=>(t=oe[t])(e=Nt.toValue(e),e[r=se(r)],n,a),K:Gt,$:t=>0===t?Nt.toHandle(ue()):(t=se(t),Nt.toHandle(ue()[t])),r:(t,e,r)=>{var n=((t,e)=>{for(var r=new Array(t),n=0;n<t;++n)r[n]=le(_[e+4*n>>2],"parameter "+n);return r})(t,e),a=n.shift();t--;var o,i,s=new Array(t),u=`methodCaller<(${n.map(t=>t.name).join(", ")}) => ${a.name}>`;return o=Pt(u,(e,o,i,u)=>{for(var l=0,c=0;c<t;++c)s[c]=n[c].readValueFromPointer(u+l),l+=n[c].argPackAdvance;var h=1===r?ce(o,s):o.apply(e,s);return((t,e,r)=>{var n=[],a=t.toWireType(n,r);return n.length&&(_[e>>2]=Nt.toHandle(n)),a})(a,i,h)}),i=oe.length,oe.push(o),i},F:t=>{t>9&&(zt[t+1]+=1)},p:t=>Nt.toHandle(se(t)),_:()=>Nt.toHandle({}),ba:t=>{var e=Nt.toValue(t);Vt(e),Gt(t)},Z:(t,e,r)=>{t=Nt.toValue(t),e=Nt.toValue(e),r=Nt.toValue(r),t[e]=r},y:(t,e)=>{var r=(t=le(t,"_emval_take_value")).readValueFromPointer(e);return Nt.toHandle(r)},u:()=>{D("")},V:(t,e,r)=>w.copyWithin(t,e,e+r),Q:t=>{var e=w.length,r=2147483648;if((t>>>=0)>r)return!1;for(var n=(t,e)=>t+(e-t%e)%e,a=1;a<=4;a*=2){var o=e*(1+.2/a);o=Math.min(o,t+100663296);var i=Math.min(r,n(Math.max(t,o),65536));if(he(i))return!0}return!1},T:(t,e)=>{var r=0;return fe().forEach((n,a)=>{var o=e+r;_[t+4*a>>2]=o,((t,e)=>{for(var r=0;r<t.length;++r)b[e++]=t.charCodeAt(r);b[e]=0})(n,o),r+=n.length+1}),0},U:(t,e)=>{var r=fe();_[t>>2]=r.length;var n=0;return r.forEach(t=>n+=t.length+1),_[e>>2]=n,0},S:t=>52,M:function(t,e,r,n,a){return 70},B:(t,e,r,n)=>{for(var a=0,o=0;o<r;o++){var i=_[e>>2],s=_[e+4>>2];e+=8;for(var u=0;u<s;u++)ve(t,w[i+u]);a+=s}return _[n>>2]=a,0},G:function(t,e,r,n,a){var o=Pe();try{return xt(t)(e,r,n,a)}catch(t){if(Te(o),t!==t+0)throw t;we(1,0)}},H:function(t){var e=Pe();try{return xt(t)()}catch(t){if(Te(e),t!==t+0)throw t;we(1,0)}},i:function(t,e){var r=Pe();try{return xt(t)(e)}catch(t){if(Te(r),t!==t+0)throw t;we(1,0)}},e:function(t,e,r){var n=Pe();try{return xt(t)(e,r)}catch(t){if(Te(n),t!==t+0)throw t;we(1,0)}},k:function(t,e,r,n){var a=Pe();try{return xt(t)(e,r,n)}catch(t){if(Te(a),t!==t+0)throw t;we(1,0)}},w:function(t,e,r,n,a,o){var i=Pe();try{return xt(t)(e,r,n,a,o)}catch(t){if(Te(i),t!==t+0)throw t;we(1,0)}},L:function(t,e,r,n,a,o,i){var s=Pe();try{return ke(t,e,r,n,a,o,i)}catch(t){if(Te(s),t!==t+0)throw t;we(1,0)}},l:function(t){var e=Pe();try{xt(t)()}catch(t){if(Te(e),t!==t+0)throw t;we(1,0)}},d:function(t,e){var r=Pe();try{xt(t)(e)}catch(t){if(Te(r),t!==t+0)throw t;we(1,0)}},j:function(t,e,r){var n=Pe();try{xt(t)(e,r)}catch(t){if(Te(n),t!==t+0)throw t;we(1,0)}},h:function(t,e,r,n){var a=Pe();try{xt(t)(e,r,n)}catch(t){if(Te(a),t!==t+0)throw t;we(1,0)}},z:function(t,e,r,n,a){var o=Pe();try{xt(t)(e,r,n,a)}catch(t){if(Te(o),t!==t+0)throw t;we(1,0)}},t:function(t,e,r,n,a,o){var i=Pe();try{xt(t)(e,r,n,a,o)}catch(t){if(Te(i),t!==t+0)throw t;we(1,0)}},aa:function(t,e,r,n,a,o,i){var s=Pe();try{xt(t)(e,r,n,a,o,i)}catch(t){if(Te(s),t!==t+0)throw t;we(1,0)}},O:function(t,e,r,n){var a=Pe();try{Ee(t,e,r,n)}catch(t){if(Te(a),t!==t+0)throw t;we(1,0)}}},$e=function(){var t,e,r,o,i={a:ye};function s(t,e){var r;return $e=t.exports,$=$e.ca,E(),Ft=$e.fa,r=$e.da,k.unshift(r),function(){if(x--,a.monitorRunDependencies?.(x),0==x&&U){var t=U;U=null,t()}}(),$e}if(x++,a.monitorRunDependencies?.(x),a.instantiateWasm)try{return a.instantiateWasm(i,s)}catch(t){m(`Module.instantiateWasm callback failed with error: ${t}`),n(t)}return(t=y,e=I,r=i,o=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||V(e)||h||"function"!=typeof fetch?B(e,r,o):fetch(e,{credentials:"same-origin"}).then(t=>WebAssembly.instantiateStreaming(t,r).then(o,function(t){return m(`wasm streaming compile failed: ${t}`),m("falling back to ArrayBuffer instantiation"),B(e,r,o)}))).catch(n),{}}(),ge=a._malloc=t=>(ge=a._malloc=$e.ea)(t),me=a._free=t=>(me=a._free=$e.ga)(t),be=t=>(be=$e.ha)(t),we=(t,e)=>(we=$e.ia)(t,e),Ce=t=>(Ce=$e.ja)(t),Pe=()=>(Pe=$e.ka)(),Te=t=>(Te=$e.la)(t),_e=t=>(_e=$e.ma)(t),Ae=t=>(Ae=$e.na)(t),je=(t,e,r)=>(je=$e.oa)(t,e,r),Se=t=>(Se=$e.pa)(t),Ee=a.dynCall_vij=(t,e,r,n)=>(Ee=a.dynCall_vij=$e.qa)(t,e,r,n);a.dynCall_ji=(t,e)=>(a.dynCall_ji=$e.ra)(t,e),a.dynCall_iij=(t,e,r,n)=>(a.dynCall_iij=$e.sa)(t,e,r,n),a.dynCall_jijj=(t,e,r,n,o,i)=>(a.dynCall_jijj=$e.ta)(t,e,r,n,o,i),a.dynCall_vijj=(t,e,r,n,o,i)=>(a.dynCall_vijj=$e.ua)(t,e,r,n,o,i),a.dynCall_jiji=(t,e,r,n,o)=>(a.dynCall_jiji=$e.va)(t,e,r,n,o);var We,ke=a.dynCall_iiiiij=(t,e,r,n,o,i,s)=>(ke=a.dynCall_iiiiij=$e.wa)(t,e,r,n,o,i,s);function Fe(){function t(){We||(We=!0,a.calledRun=!0,S||(q(k),r(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),function(){if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;)R(a.postRun.shift());q(F)}()))}x>0||(function(){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)O(a.preRun.shift());q(W)}(),x>0||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),t()},1)):t()))}if(U=function t(){We||Fe(),We||(U=t)},a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return Fe(),e.ready});export{e as default};
@@ -1 +0,0 @@
1
- var e,r="undefined"!=typeof document?document.currentScript:null,t=(e="undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("heic-decoder-7MDF76JS.js",document.baseURI).href,async function(t={}){var n,a,o=t;o.ready=new Promise((e,r)=>{n=e,a=r});var i,s,u=Object.assign({},o),l="./this.program",c="object"==typeof window,h="function"==typeof importScripts,p="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,f="";if(p){const{createRequire:e}=await(import("module"));var d=e("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("heic-decoder-7MDF76JS.js",document.baseURI).href),v=d("fs"),y=d("path");f=h?y.dirname(f)+"/":d("url").fileURLToPath(new URL("./","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("heic-decoder-7MDF76JS.js",document.baseURI).href)),i=(e,r)=>(e=M(e)?new URL(e):y.normalize(e),v.readFileSync(e,r?void 0:"utf8")),s=e=>{var r=i(e,!0);return r.buffer||(r=new Uint8Array(r)),r},!o.thisProgram&&process.argv.length>1&&(l=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(c||h)&&(h?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),e&&(f=e),f=f.startsWith("blob:")?"":f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1),i=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},h&&(s=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}));var m,$,g=o.print||console.log.bind(console),b=o.printErr||console.error.bind(console);Object.assign(o,u),u=null,o.arguments&&o.arguments,o.thisProgram&&(l=o.thisProgram),o.quit&&o.quit,o.wasmBinary&&(m=o.wasmBinary);var w,C,P,T,_,A,j,R,S=!1;function F(){var e=$.buffer;o.HEAP8=w=new Int8Array(e),o.HEAP16=P=new Int16Array(e),o.HEAPU8=C=new Uint8Array(e),o.HEAPU16=T=new Uint16Array(e),o.HEAP32=_=new Int32Array(e),o.HEAPU32=A=new Uint32Array(e),o.HEAPF32=j=new Float32Array(e),o.HEAPF64=R=new Float64Array(e)}var U=[],E=[],W=[];function k(e){U.unshift(e)}function O(e){W.unshift(e)}var I=0,D=null;function x(e){o.onAbort?.(e),b(e="Aborted("+e+")"),S=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw a(r),r}var H,V,L=e=>e.startsWith("data:application/octet-stream;base64,"),M=e=>e.startsWith("file://");function q(e){if(e==H&&m)return new Uint8Array(m);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}function B(e,r,t){return function(e){return m||!c&&!h||"function"!=typeof fetch?Promise.resolve().then(()=>q(e)):fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw`failed to load wasm binary file at '${e}'`;return r.arrayBuffer()}).catch(()=>q(e))}(e).then(e=>WebAssembly.instantiate(e,r)).then(t,e=>{b(`failed to asynchronously prepare wasm: ${e}`),x(e)})}o.locateFile?L(H="heic-decoder.wasm")||(V=H,H=o.locateFile?o.locateFile(V,f):f+V):H=new URL("heic-decoder.wasm","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("heic-decoder-7MDF76JS.js",document.baseURI).href).href;var N=e=>{for(;e.length>0;)e.shift()(o)};o.noExitRuntime;var z="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,G=(e,r,t)=>{for(var n=r+t,a=r;e[a]&&!(a>=n);)++a;if(a-r>16&&e.buffer&&z)return z.decode(e.subarray(r,a));for(var o="";r<a;){var i=e[r++];if(128&i){var s=63&e[r++];if(192!=(224&i)){var u=63&e[r++];if((i=224==(240&i)?(15&i)<<12|s<<6|u:(7&i)<<18|s<<12|u<<6|63&e[r++])<65536)o+=String.fromCharCode(i);else{var l=i-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|s)}else o+=String.fromCharCode(i)}return o},J=(e,r)=>e?G(C,e,r):"",X=[],Z=0,K=0;class Q{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){A[this.ptr+4>>2]=e}get_type(){return A[this.ptr+4>>2]}set_destructor(e){A[this.ptr+8>>2]=e}get_destructor(){return A[this.ptr+8>>2]}set_caught(e){e=e?1:0,w[this.ptr+12]=e}get_caught(){return 0!=w[this.ptr+12]}set_rethrown(e){e=e?1:0,w[this.ptr+13]=e}get_rethrown(){return 0!=w[this.ptr+13]}init(e,r){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(r)}set_adjusted_ptr(e){A[this.ptr+16>>2]=e}get_adjusted_ptr(){return A[this.ptr+16>>2]}get_exception_ptr(){if(Sr(this.get_type()))return A[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var Y,ee,re,te=e=>{var r=K;if(!r)return Pr(0),0;var t=new Q(r);t.set_adjusted_ptr(r);var n=t.get_type();if(!n)return Pr(0),r;for(var a in e){var o=e[a];if(0===o||o===n)break;var i=t.ptr+16;if(Rr(o,n,i))return Pr(o),r}return Pr(n),r},ne=e=>{for(var r="",t=e;C[t];)r+=Y[C[t++]];return r},ae={},oe={},ie={},se=e=>{throw new ee(e)},ue=e=>{throw new re(e)},le=(e,r,t)=>{function n(r){var n=t(r);n.length!==e.length&&ue("Mismatched type converter count");for(var a=0;a<e.length;++a)ce(e[a],n[a])}e.forEach(function(e){ie[e]=r});var a=new Array(r.length),o=[],i=0;r.forEach((e,r)=>{oe.hasOwnProperty(e)?a[r]=oe[e]:(o.push(e),ae.hasOwnProperty(e)||(ae[e]=[]),ae[e].push(()=>{a[r]=oe[e],++i===o.length&&n(a)}))}),0===o.length&&n(a)};function ce(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,r,t={}){var n=r.name;if(e||se(`type "${n}" must have a positive integer typeid pointer`),oe.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;se(`Cannot register type '${n}' twice`)}if(oe[e]=r,delete ie[e],ae.hasOwnProperty(e)){var a=ae[e];delete ae[e],a.forEach(e=>e())}}(e,r,t)}var he,pe=e=>{se(e.$$.ptrType.registeredClass.name+" instance already deleted")},fe=!1,de=e=>{},ve=e=>{e.count.value-=1,0===e.count.value&&(e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)})(e)},ye=(e,r,t)=>{if(r===t)return e;if(void 0===t.baseClass)return null;var n=ye(e,r,t.baseClass);return null===n?null:t.downcast(n)},me={},$e=[],ge=()=>{for(;$e.length;){var e=$e.pop();e.$$.deleteScheduled=!1,e.delete()}},be={},we=(e,r)=>(r.ptrType&&r.ptr||ue("makeClassHandle requires ptr and ptrType"),!!r.smartPtrType!=!!r.smartPtr&&ue("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ce(Object.create(e,{$$:{value:r,writable:!0}}))),Ce=e=>"undefined"==typeof FinalizationRegistry?(Ce=e=>e,e):(fe=new FinalizationRegistry(e=>{ve(e.$$)}),de=e=>fe.unregister(e),(Ce=e=>{var r=e.$$;if(r.smartPtr){var t={$$:r};fe.register(e,t,e)}return e})(e));function Pe(){}var Te=(e,r)=>Object.defineProperty(r,"name",{value:e}),_e=(e,r,t)=>{if(void 0===e[r].overloadTable){var n=e[r];e[r]=function(...n){return e[r].overloadTable.hasOwnProperty(n.length)||se(`Function '${t}' called with an invalid number of arguments (${n.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[n.length].apply(this,n)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}};function Ae(e,r,t,n,a,o,i,s){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=a,this.getActualType=o,this.upcast=i,this.downcast=s,this.pureVirtualFunctions=[]}var je=(e,r,t)=>{for(;r!==t;)r.upcast||se(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function Re(e,r){if(null===r)return this.isReference&&se(`null is not a valid ${this.name}`),0;r.$$||se(`Cannot pass "${Ze(r)}" as a ${this.name}`),r.$$.ptr||se(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass;return je(r.$$.ptr,t,this.registeredClass)}function Se(e,r){var t;if(null===r)return this.isReference&&se(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,t),t):0;r&&r.$$||se(`Cannot pass "${Ze(r)}" as a ${this.name}`),r.$$.ptr||se(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&se(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=je(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===r.$$.smartPtr&&se("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:se(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var a=r.clone();t=this.rawShare(t,Je.toHandle(()=>a.delete())),null!==e&&e.push(this.rawDestructor,t)}break;default:se("Unsupporting sharing policy")}return t}function Fe(e,r){if(null===r)return this.isReference&&se(`null is not a valid ${this.name}`),0;r.$$||se(`Cannot pass "${Ze(r)}" as a ${this.name}`),r.$$.ptr||se(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&se(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass;return je(r.$$.ptr,t,this.registeredClass)}function Ue(e){return this.fromWireType(A[e>>2])}function Ee(e,r,t,n,a,o,i,s,u,l,c){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=a,this.pointeeType=o,this.sharingPolicy=i,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=l,this.rawDestructor=c,a||void 0!==r.baseClass?this.toWireType=Se:n?(this.toWireType=Re,this.destructorFunction=null):(this.toWireType=Fe,this.destructorFunction=null)}var We,ke,Oe=[],Ie=e=>{var r=Oe[e];return r||(e>=Oe.length&&(Oe.length=e+1),Oe[e]=r=We.get(e)),r},De=(e,r)=>{var t,n,a=(e=ne(e)).includes("j")?(t=e,n=r,(...e)=>((e,r,t=[])=>e.includes("j")?((e,r,t)=>(0,o["dynCall_"+e])(r,...t))(e,r,t):Ie(r)(...t))(t,n,e)):Ie(r);return"function"!=typeof a&&se(`unknown function pointer with signature ${e}: ${r}`),a},xe=e=>{var r=wr(e),t=ne(r);return br(r),t},He=(e,r)=>{var t=[],n={};throw r.forEach(function e(r){n[r]||oe[r]||(ie[r]?ie[r].forEach(e):(t.push(r),n[r]=!0))}),new ke(`${e}: `+t.map(xe).join([", "]))},Ve=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(A[r+4*n>>2]);return t},Le=e=>{for(;e.length;){var r=e.pop();e.pop()(r)}};function Me(e,r,t,n,a,o){var i=r.length;i<2&&se("argTypes array size mismatch! Must at least get return value and 'this' types!");var s=null!==r[1]&&null!==t,u=function(e){for(var r=1;r<e.length;++r)if(null!==e[r]&&void 0===e[r].destructorFunction)return!0;return!1}(r),l="void"!==r[0].name,c=i-2,h=new Array(c),p=[],f=[];return Te(e,function(...t){var o;t.length!==c&&se(`function ${e} called with ${t.length} arguments, expected ${c}`),f.length=0,p.length=s?2:1,p[0]=a,s&&(o=r[1].toWireType(f,this),p[1]=o);for(var i=0;i<c;++i)h[i]=r[i+2].toWireType(f,t[i]),p.push(h[i]);return function(e){if(u)Le(f);else for(var t=s?1:2;t<r.length;t++){var n=1===t?o:h[t-2];null!==r[t].destructorFunction&&r[t].destructorFunction(n)}if(l)return r[0].fromWireType(e)}(n(...p))})}var qe,Be,Ne=[],ze=[],Ge=e=>{e>9&&0===--ze[e+1]&&(ze[e]=void 0,Ne.push(e))},Je={toValue:e=>(e||se("Cannot use deleted val. handle = "+e),ze[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const r=Ne.pop()||ze.length;return ze[r]=e,ze[r+1]=1,r}}}},Xe={name:"emscripten::val",fromWireType:e=>{var r=Je.toValue(e);return Ge(e),r},toWireType:(e,r)=>Je.toHandle(r),argPackAdvance:8,readValueFromPointer:Ue,destructorFunction:null},Ze=e=>{if(null===e)return"null";var r=typeof e;return"object"===r||"array"===r||"function"===r?e.toString():""+e},Ke=(e,r)=>{switch(r){case 4:return function(e){return this.fromWireType(j[e>>2])};case 8:return function(e){return this.fromWireType(R[e>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},Qe=(e,r,t)=>{switch(r){case 1:return t?e=>w[e]:e=>C[e];case 2:return t?e=>P[e>>1]:e=>T[e>>1];case 4:return t?e=>_[e>>2]:e=>A[e>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},Ye="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,er=(e,r)=>{for(var t=e,n=t>>1,a=n+r/2;!(n>=a)&&T[n];)++n;if((t=n<<1)-e>32&&Ye)return Ye.decode(C.subarray(e,t));for(var o="",i=0;!(i>=r/2);++i){var s=P[e+2*i>>1];if(0==s)break;o+=String.fromCharCode(s)}return o},rr=(e,r,t)=>{if(t??=2147483647,t<2)return 0;for(var n=r,a=(t-=2)<2*e.length?t/2:e.length,o=0;o<a;++o){var i=e.charCodeAt(o);P[r>>1]=i,r+=2}return P[r>>1]=0,r-n},tr=e=>2*e.length,nr=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var a=_[e+4*t>>2];if(0==a)break;if(++t,a>=65536){var o=a-65536;n+=String.fromCharCode(55296|o>>10,56320|1023&o)}else n+=String.fromCharCode(a)}return n},ar=(e,r,t)=>{if(t??=2147483647,t<4)return 0;for(var n=r,a=n+t-4,o=0;o<e.length;++o){var i=e.charCodeAt(o);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),_[r>>2]=i,(r+=4)+4>a)break}return _[r>>2]=0,r-n},or=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4}return r},ir=[],sr={},ur=e=>{var r=sr[e];return void 0===r?ne(e):r},lr=()=>{if("object"==typeof globalThis)return globalThis;function e(e){e.$$$embind_global$$$=e;var r="object"==typeof $$$embind_global$$$&&e.$$$embind_global$$$==e;return r||delete e.$$$embind_global$$$,r}if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;if("object"==typeof global&&e(global)?$$$embind_global$$$=global:"object"==typeof self&&e(self)&&($$$embind_global$$$=self),"object"==typeof $$$embind_global$$$)return $$$embind_global$$$;throw Error("unable to get global object.")},cr=(e,r)=>{var t=oe[e];return void 0===t&&se(`${r} has unknown type ${xe(e)}`),t},hr=Reflect.construct,pr=e=>{var r=(e-$.buffer.byteLength+65535)/65536;try{return $.grow(r),F(),1}catch(e){}},fr={},dr=()=>{if(!dr.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:l||"./this.program"};for(var r in fr)void 0===fr[r]?delete e[r]:e[r]=fr[r];var t=[];for(var r in e)t.push(`${r}=${e[r]}`);dr.strings=t}return dr.strings},vr=[null,[],[]],yr=(e,r)=>{var t=vr[e];0===r||10===r?((1===e?g:b)(G(t,0)),t.length=0):t.push(r)};(()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Y=e})(),ee=o.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},re=o.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},Object.assign(Pe.prototype,{isAliasOf(e){if(!(this instanceof Pe))return!1;if(!(e instanceof Pe))return!1;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,a=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return r===n&&t===a},clone(){if(this.$$.ptr||pe(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,r=Ce(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return r.$$.count.value+=1,r.$$.deleteScheduled=!1,r},delete(){this.$$.ptr||pe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&se("Object already scheduled for deletion"),de(this),ve(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||pe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&se("Object already scheduled for deletion"),$e.push(this),1===$e.length&&he&&he(ge),this.$$.deleteScheduled=!0,this}}),o.getInheritedInstanceCount=()=>Object.keys(be).length,o.getLiveInheritedInstances=()=>{var e=[];for(var r in be)be.hasOwnProperty(r)&&e.push(be[r]);return e},o.flushPendingDeletes=ge,o.setDelayFunction=e=>{he=e,$e.length&&he&&he(ge)},Object.assign(Ee.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e)},argPackAdvance:8,readValueFromPointer:Ue,fromWireType:function(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=((e,r)=>(r=((e,r)=>{for(void 0===r&&se("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r})(e,r),be[r]))(this.registeredClass,r);if(void 0!==t){if(0===t.$$.count.value)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function a(){return this.isSmartPointer?we(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):we(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o,i=this.registeredClass.getActualType(r),s=me[i];if(!s)return a.call(this);o=this.isConst?s.constPointerType:s.pointerType;var u=ye(r,this.registeredClass,o.registeredClass);return null===u?a.call(this):this.isSmartPointer?we(o.registeredClass.instancePrototype,{ptrType:o,ptr:u,smartPtrType:this,smartPtr:e}):we(o.registeredClass.instancePrototype,{ptrType:o,ptr:u})}}),ke=o.UnboundTypeError=(qe=Error,(Be=Te("UnboundTypeError",function(e){this.name="UnboundTypeError",this.message=e;var r=new Error(e).stack;void 0!==r&&(this.stack=this.toString()+"\n"+r.replace(/^Error(:[^\n]*)?\n/,""))})).prototype=Object.create(qe.prototype),Be.prototype.constructor=Be,Be.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},Be),ze.push(0,1,void 0,1,null,1,!0,1,!1,1),o.count_emval_handles=()=>ze.length/2-5-Ne.length;var mr={a:(e,r,t,n)=>{x(`Assertion failed: ${J(e)}, at: `+[r?J(r):"unknown filename",t,n?J(n):"unknown function"])},o:e=>{var r=new Q(e);return r.get_caught()||(r.set_caught(!0),Z--),r.set_rethrown(!1),X.push(r),jr(r.excPtr),r.get_exception_ptr()},q:()=>{Cr(0,0);var e=X.pop();Ar(e.excPtr),K=0},b:()=>te([]),c:e=>te([e]),A:()=>{var e=X.pop();e||x("no exception to throw");var r=e.excPtr;throw e.get_rethrown()||(X.push(e),e.set_rethrown(!0),e.set_caught(!1),Z++),K=r},m:(e,r,t)=>{throw new Q(e).init(r,t),Z++,K=e},P:()=>Z,f:e=>{throw K||(K=e),K},R:(e,r,t)=>{},N:(e,r,t,n,a)=>{},X:(e,r,t,n)=>{ce(e,{name:r=ne(r),fromWireType:function(e){return!!e},toWireType:function(e,r){return r?t:n},argPackAdvance:8,readValueFromPointer:function(e){return this.fromWireType(C[e])},destructorFunction:null})},J:(e,r,t,n,a,i,s,u,l,c,h,p,f)=>{h=ne(h),i=De(a,i),u&&=De(s,u),c&&=De(l,c),f=De(p,f);var d=(e=>{if(void 0===e)return"_unknown";var r=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return r>=48&&r<=57?`_${e}`:e})(h);((e,r)=>{o.hasOwnProperty(e)?(se(`Cannot register public name '${e}' twice`),_e(o,e,e),o.hasOwnProperty(void 0)&&se("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[e].overloadTable[void 0]=r):o[e]=r})(d,function(){He(`Cannot construct ${h} due to unbound types`,[n])}),le([e,r,t],n?[n]:[],r=>{var t,a;r=r[0],a=n?(t=r.registeredClass).instancePrototype:Pe.prototype;var s=Te(h,function(...e){if(Object.getPrototypeOf(this)!==l)throw new ee("Use 'new' to construct "+h);if(void 0===p.constructor_body)throw new ee(h+" has no accessible constructor");var r=p.constructor_body[e.length];if(void 0===r)throw new ee(`Tried to invoke ctor of ${h} with invalid number of parameters (${e.length}) - expected (${Object.keys(p.constructor_body).toString()}) parameters instead!`);return r.apply(this,e)}),l=Object.create(a,{constructor:{value:s}});s.prototype=l;var p=new Ae(h,s,l,f,t,i,u,c);p.baseClass&&(p.baseClass.__derivedClasses??=[],p.baseClass.__derivedClasses.push(p));var v=new Ee(h,p,!0,!1,!1),y=new Ee(h+"*",p,!1,!1,!1),m=new Ee(h+" const*",p,!1,!0,!1);return me[e]={pointerType:y,constPointerType:m},((e,r)=>{o.hasOwnProperty(e)||ue("Replacing nonexistent public symbol"),o[e].overloadTable,o[e]=r,o[e].argCount=void 0})(d,s),[v,y,m]})},I:(e,r,t,n,a,o)=>{var i=Ve(r,t);a=De(n,a),le([],[e],e=>{var t=`constructor ${(e=e[0]).name}`;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[r-1])throw new ee(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[r-1]=()=>{He(`Cannot construct ${e.name} due to unbound types`,i)},le([],i,n=>(n.splice(1,0,null),e.registeredClass.constructor_body[r-1]=Me(t,n,null,a,o),[])),[]})},s:(e,r,t,n,a,o,i,s,u)=>{var l=Ve(t,n);r=(e=>{const r=(e=e.trim()).indexOf("(");return-1!==r?e.substr(0,r):e})(r=ne(r)),o=De(a,o),le([],[e],e=>{var n=`${(e=e[0]).name}.${r}`;function a(){He(`Cannot call ${n} due to unbound types`,l)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(r);var u=e.registeredClass.instancePrototype,c=u[r];return void 0===c||void 0===c.overloadTable&&c.className!==e.name&&c.argCount===t-2?(a.argCount=t-2,a.className=e.name,u[r]=a):(_e(u,r,n),u[r].overloadTable[t-2]=a),le([],l,a=>{var s=Me(n,a,e,o,i);return void 0===u[r].overloadTable?(s.argCount=t-2,u[r]=s):u[r].overloadTable[t-2]=s,[]}),[]})},W:e=>ce(e,Xe),D:(e,r,t)=>{ce(e,{name:r=ne(r),fromWireType:e=>e,toWireType:(e,r)=>r,argPackAdvance:8,readValueFromPointer:Ke(r,t),destructorFunction:null})},n:(e,r,t,n,a)=>{r=ne(r);var o=e=>e;if(0===n){var i=32-8*t;o=e=>e<<i>>>i}var s=r.includes("unsigned");ce(e,{name:r,fromWireType:o,toWireType:s?function(e,r){return this.name,r>>>0}:function(e,r){return this.name,r},argPackAdvance:8,readValueFromPointer:Qe(r,t,0!==n),destructorFunction:null})},g:(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][r];function a(e){var r=A[e>>2],t=A[e+4>>2];return new n(w.buffer,t,r)}ce(e,{name:t=ne(t),fromWireType:a,argPackAdvance:8,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},C:(e,r)=>{var t="std::string"===(r=ne(r));ce(e,{name:r,fromWireType(e){var r,n=A[e>>2],a=e+4;if(t)for(var o=a,i=0;i<=n;++i){var s=a+i;if(i==n||0==C[s]){var u=J(o,s-o);void 0===r?r=u:(r+=String.fromCharCode(0),r+=u),o=s+1}}else{var l=new Array(n);for(i=0;i<n;++i)l[i]=String.fromCharCode(C[a+i]);r=l.join("")}return br(e),r},toWireType(e,r){var n;r instanceof ArrayBuffer&&(r=new Uint8Array(r));var a="string"==typeof r;a||r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Int8Array||se("Cannot pass non-string to std::string"),n=t&&a?(e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r})(r):r.length;var o=gr(4+n+1),i=o+4;if(A[o>>2]=n,t&&a)((e,r,t,n)=>{if(!(n>0))return 0;for(var a=t+n-1,o=0;o<e.length;++o){var i=e.charCodeAt(o);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),i<=127){if(t>=a)break;r[t++]=i}else if(i<=2047){if(t+1>=a)break;r[t++]=192|i>>6,r[t++]=128|63&i}else if(i<=65535){if(t+2>=a)break;r[t++]=224|i>>12,r[t++]=128|i>>6&63,r[t++]=128|63&i}else{if(t+3>=a)break;r[t++]=240|i>>18,r[t++]=128|i>>12&63,r[t++]=128|i>>6&63,r[t++]=128|63&i}}r[t]=0})(r,C,i,n+1);else if(a)for(var s=0;s<n;++s){var u=r.charCodeAt(s);u>255&&(br(i),se("String has UTF-16 code units that do not fit in 8 bits")),C[i+s]=u}else for(s=0;s<n;++s)C[i+s]=r[s];return null!==e&&e.push(br,o),o},argPackAdvance:8,readValueFromPointer:Ue,destructorFunction(e){br(e)}})},v:(e,r,t)=>{var n,a,o,i;t=ne(t),2===r?(n=er,a=rr,i=tr,o=e=>T[e>>1]):4===r&&(n=nr,a=ar,i=or,o=e=>A[e>>2]),ce(e,{name:t,fromWireType:e=>{for(var t,a=A[e>>2],i=e+4,s=0;s<=a;++s){var u=e+4+s*r;if(s==a||0==o(u)){var l=n(i,u-i);void 0===t?t=l:(t+=String.fromCharCode(0),t+=l),i=u+r}}return br(e),t},toWireType:(e,n)=>{"string"!=typeof n&&se(`Cannot pass non-string to C++ string type ${t}`);var o=i(n),s=gr(4+o+r);return A[s>>2]=o/r,a(n,s+4,o+r),null!==e&&e.push(br,s),s},argPackAdvance:8,readValueFromPointer:Ue,destructorFunction(e){br(e)}})},Y:(e,r)=>{ce(e,{isVoid:!0,name:r=ne(r),argPackAdvance:0,fromWireType:()=>{},toWireType:(e,r)=>{}})},x:(e,r,t,n)=>(e=ir[e])(null,r=Je.toValue(r),t,n),E:(e,r,t,n,a)=>(e=ir[e])(r=Je.toValue(r),r[t=ur(t)],n,a),K:Ge,$:e=>0===e?Je.toHandle(lr()):(e=ur(e),Je.toHandle(lr()[e])),r:(e,r,t)=>{var n=((e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=cr(A[r+4*n>>2],"parameter "+n);return t})(e,r),a=n.shift();e--;var o,i,s=new Array(e),u=`methodCaller<(${n.map(e=>e.name).join(", ")}) => ${a.name}>`;return o=Te(u,(r,o,i,u)=>{for(var l=0,c=0;c<e;++c)s[c]=n[c].readValueFromPointer(u+l),l+=n[c].argPackAdvance;var h=1===t?hr(o,s):o.apply(r,s);return((e,r,t)=>{var n=[],a=e.toWireType(n,t);return n.length&&(A[r>>2]=Je.toHandle(n)),a})(a,i,h)}),i=ir.length,ir.push(o),i},F:e=>{e>9&&(ze[e+1]+=1)},p:e=>Je.toHandle(ur(e)),_:()=>Je.toHandle({}),ba:e=>{var r=Je.toValue(e);Le(r),Ge(e)},Z:(e,r,t)=>{e=Je.toValue(e),r=Je.toValue(r),t=Je.toValue(t),e[r]=t},y:(e,r)=>{var t=(e=cr(e,"_emval_take_value")).readValueFromPointer(r);return Je.toHandle(t)},u:()=>{x("")},V:(e,r,t)=>C.copyWithin(e,r,r+t),Q:e=>{var r=C.length,t=2147483648;if((e>>>=0)>t)return!1;for(var n=(e,r)=>e+(r-e%r)%r,a=1;a<=4;a*=2){var o=r*(1+.2/a);o=Math.min(o,e+100663296);var i=Math.min(t,n(Math.max(e,o),65536));if(pr(i))return!0}return!1},T:(e,r)=>{var t=0;return dr().forEach((n,a)=>{var o=r+t;A[e+4*a>>2]=o,((e,r)=>{for(var t=0;t<e.length;++t)w[r++]=e.charCodeAt(t);w[r]=0})(n,o),t+=n.length+1}),0},U:(e,r)=>{var t=dr();A[e>>2]=t.length;var n=0;return t.forEach(e=>n+=e.length+1),A[r>>2]=n,0},S:e=>52,M:function(e,r,t,n,a){return 70},B:(e,r,t,n)=>{for(var a=0,o=0;o<t;o++){var i=A[r>>2],s=A[r+4>>2];r+=8;for(var u=0;u<s;u++)yr(e,C[i+u]);a+=s}return A[n>>2]=a,0},G:function(e,r,t,n,a){var o=Tr();try{return Ie(e)(r,t,n,a)}catch(e){if(_r(o),e!==e+0)throw e;Cr(1,0)}},H:function(e){var r=Tr();try{return Ie(e)()}catch(e){if(_r(r),e!==e+0)throw e;Cr(1,0)}},i:function(e,r){var t=Tr();try{return Ie(e)(r)}catch(e){if(_r(t),e!==e+0)throw e;Cr(1,0)}},e:function(e,r,t){var n=Tr();try{return Ie(e)(r,t)}catch(e){if(_r(n),e!==e+0)throw e;Cr(1,0)}},k:function(e,r,t,n){var a=Tr();try{return Ie(e)(r,t,n)}catch(e){if(_r(a),e!==e+0)throw e;Cr(1,0)}},w:function(e,r,t,n,a,o){var i=Tr();try{return Ie(e)(r,t,n,a,o)}catch(e){if(_r(i),e!==e+0)throw e;Cr(1,0)}},L:function(e,r,t,n,a,o,i){var s=Tr();try{return Er(e,r,t,n,a,o,i)}catch(e){if(_r(s),e!==e+0)throw e;Cr(1,0)}},l:function(e){var r=Tr();try{Ie(e)()}catch(e){if(_r(r),e!==e+0)throw e;Cr(1,0)}},d:function(e,r){var t=Tr();try{Ie(e)(r)}catch(e){if(_r(t),e!==e+0)throw e;Cr(1,0)}},j:function(e,r,t){var n=Tr();try{Ie(e)(r,t)}catch(e){if(_r(n),e!==e+0)throw e;Cr(1,0)}},h:function(e,r,t,n){var a=Tr();try{Ie(e)(r,t,n)}catch(e){if(_r(a),e!==e+0)throw e;Cr(1,0)}},z:function(e,r,t,n,a){var o=Tr();try{Ie(e)(r,t,n,a)}catch(e){if(_r(o),e!==e+0)throw e;Cr(1,0)}},t:function(e,r,t,n,a,o){var i=Tr();try{Ie(e)(r,t,n,a,o)}catch(e){if(_r(i),e!==e+0)throw e;Cr(1,0)}},aa:function(e,r,t,n,a,o,i){var s=Tr();try{Ie(e)(r,t,n,a,o,i)}catch(e){if(_r(s),e!==e+0)throw e;Cr(1,0)}},O:function(e,r,t,n){var a=Tr();try{Fr(e,r,t,n)}catch(e){if(_r(a),e!==e+0)throw e;Cr(1,0)}}},$r=function(){var e,r,t,n,i={a:mr};function s(e,r){var t;return $r=e.exports,$=$r.ca,F(),We=$r.fa,t=$r.da,E.unshift(t),function(){if(I--,o.monitorRunDependencies?.(I),0==I&&D){var e=D;D=null,e()}}(),$r}if(I++,o.monitorRunDependencies?.(I),o.instantiateWasm)try{return o.instantiateWasm(i,s)}catch(e){b(`Module.instantiateWasm callback failed with error: ${e}`),a(e)}return(e=m,r=H,t=i,n=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||L(r)||p||"function"!=typeof fetch?B(r,t,n):fetch(r,{credentials:"same-origin"}).then(e=>WebAssembly.instantiateStreaming(e,t).then(n,function(e){return b(`wasm streaming compile failed: ${e}`),b("falling back to ArrayBuffer instantiation"),B(r,t,n)}))).catch(a),{}}(),gr=o._malloc=e=>(gr=o._malloc=$r.ea)(e),br=o._free=e=>(br=o._free=$r.ga)(e),wr=e=>(wr=$r.ha)(e),Cr=(e,r)=>(Cr=$r.ia)(e,r),Pr=e=>(Pr=$r.ja)(e),Tr=()=>(Tr=$r.ka)(),_r=e=>(_r=$r.la)(e),Ar=e=>(Ar=$r.ma)(e),jr=e=>(jr=$r.na)(e),Rr=(e,r,t)=>(Rr=$r.oa)(e,r,t),Sr=e=>(Sr=$r.pa)(e),Fr=o.dynCall_vij=(e,r,t,n)=>(Fr=o.dynCall_vij=$r.qa)(e,r,t,n);o.dynCall_ji=(e,r)=>(o.dynCall_ji=$r.ra)(e,r),o.dynCall_iij=(e,r,t,n)=>(o.dynCall_iij=$r.sa)(e,r,t,n),o.dynCall_jijj=(e,r,t,n,a,i)=>(o.dynCall_jijj=$r.ta)(e,r,t,n,a,i),o.dynCall_vijj=(e,r,t,n,a,i)=>(o.dynCall_vijj=$r.ua)(e,r,t,n,a,i),o.dynCall_jiji=(e,r,t,n,a)=>(o.dynCall_jiji=$r.va)(e,r,t,n,a);var Ur,Er=o.dynCall_iiiiij=(e,r,t,n,a,i,s)=>(Er=o.dynCall_iiiiij=$r.wa)(e,r,t,n,a,i,s);function Wr(){function e(){Ur||(Ur=!0,o.calledRun=!0,S||(N(E),n(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)O(o.postRun.shift());N(W)}()))}I>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)k(o.preRun.shift());N(U)}(),I>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),e()},1)):e()))}if(D=function e(){Ur||Wr(),Ur||(D=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Wr(),t.ready});module.exports=t;