@keeratita/heic-converter 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +298 -42
- package/dist/heic-decoder-7BA7NJOA.js +5 -0
- package/dist/heic-decoder-WNTZ4MAN.mjs +5 -0
- package/dist/heic-decoder.wasm +0 -0
- package/dist/heic-decoder.wasm.br +0 -0
- package/dist/heic-decoder.wasm.gz +0 -0
- package/dist/index.d.mts +361 -36
- package/dist/index.d.ts +361 -36
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +16 -12
- package/dist/heic-decoder-AAMWPCW2.mjs +0 -5
- package/dist/heic-decoder-L3ME46HT.js +0 -5
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var i={QualityInvalid:e=>`Quality must be a number between 0.0 and 1.0, got: ${e}`,UnsupportedInputType:e=>`Unsupported input type. Expected Blob, File, ArrayBuffer, or Uint8Array. Got: ${e}`,DecoderInitFailed:e=>`Failed to initialize HEIC decoder: ${e}`,RenderEncodeFailed:(e,r)=>`Failed to render and encode image as ${e}: ${r}`,ConcurrencyInvalid:e=>`Concurrency must be a positive integer, got: ${e}`,ScaleInvalid:e=>`Scale must be a positive finite number, got: ${e}`,MaxWidthInvalid:e=>`maxWidth must be a positive finite number, got: ${e}`,MaxHeightInvalid:e=>`maxHeight must be a positive finite number, got: ${e}`,TargetSizeTooLarge:(e,r,n)=>`Target image size ${e}x${r} exceeds the maximum supported dimension of ${n}px`,BlobToBase64Failed:"Failed to convert Blob to base64 string",BlobToBase64FailedWithCause:e=>`Failed to convert Blob to base64 string: ${e}`,CanvasToBlobFailed:e=>`Failed to convert canvas to blob (type: ${e})`,CanvasUnsupported:"Canvas is not supported in the current environment. Conversion requires a browser environment or canvas polyfills.",InvalidDimensions:(e,r)=>`Invalid image dimensions: ${e}x${r}. Width and height must be positive integers.`,DataLengthMismatch:(e,r,n,t)=>`Image data length mismatch. Expected ${e} bytes for ${r}x${n}, got ${t}`,ContextUnavailable:"Failed to acquire 2D rendering context from canvas",UnsupportedFormat:e=>`Unsupported output format: ${e}`,DecodeFailed:"HEIC decoding failed",DecodeFailedWithDetail:e=>`HEIC decoding failed: ${e}`,WorkerUnsupported:"Web Worker is not supported in the current environment",WorkerCreateFailed:e=>`Failed to create Web Worker: ${e}`,WorkerPostFailed:e=>`Failed to post message to Web Worker: ${e}`,WorkerConversionFailed:"Worker conversion failed",WorkerFailed:"Worker failed",WorkerTimeout:"Web Worker conversion timed out",InputsMustBeArray:"Inputs must be an array of HEIC images",ConvertManyItemFailed:(e,r,n)=>`Conversion of item ${e} of ${r} failed: ${n}`};var y=class{options;module=null;decoderInstance=null;initPromise=null;constructor(r){this.options=r;}async initialize(){if(!this.initPromise){let r={};this.options?.locateFile&&(r.locateFile=this.options.locateFile),this.options?.wasmBinary&&(r.wasmBinary=this.options.wasmBinary),this.initPromise=import('./heic-decoder-AAMWPCW2.mjs').then(({default:n})=>n(r)).then(n=>(this.module=n,this.decoderInstance=new n.HeicDecoder,n)).catch(n=>{throw this.initPromise=null,n});}await this.initPromise;}async decode(r,n){(!this.module||!this.decoderInstance)&&await this.initialize();let t=this.decoderInstance.decode(r,n??null);if(!t)throw new Error(i.DecodeFailed);if(typeof t=="string")throw new Error(i.DecodeFailedWithDetail(t));let o=t.width,a=t.height,s=new Uint8ClampedArray(t.data);return {width:o,height:a,data:s}}free(){this.decoderInstance&&(this.decoderInstance.delete(),this.decoderInstance=null),this.module=null,this.initPromise=null;}};var E=16384;function C(e){if(!e)return;let{maxWidth:r,maxHeight:n,scale:t}=e;if(t!==void 0&&(typeof t!="number"||!Number.isFinite(t)||t<=0))throw new Error(i.ScaleInvalid(t));if(r!==void 0&&(typeof r!="number"||!Number.isFinite(r)||r<=0))throw new Error(i.MaxWidthInvalid(r));if(n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<=0))throw new Error(i.MaxHeightInvalid(n))}function B(e,r,n){if(C(n),!n)return {width:e,height:r};let{maxWidth:t,maxHeight:o,scale:a}=n;if(a!==void 0){let g=Math.max(1,Math.round(e*a)),c=Math.max(1,Math.round(r*a));return F(g,c),{width:g,height:c}}if(t===void 0&&o===void 0)return {width:e,height:r};let s=Math.min(t!==void 0?t/e:Number.POSITIVE_INFINITY,o!==void 0?o/r:Number.POSITIVE_INFINITY);if(s>=1)return {width:e,height:r};let l=Math.min(Math.max(1,Math.round(e*s)),t!==void 0?Math.floor(t):Number.POSITIVE_INFINITY),d=Math.min(Math.max(1,Math.round(r*s)),o!==void 0?Math.floor(o):Number.POSITIVE_INFINITY);return F(l,d),{width:l,height:d}}function F(e,r){if(!Number.isFinite(e)||!Number.isFinite(r)||e>E||r>E)throw new Error(i.TargetSizeTooLarge(e,r,E))}async function W(e){if(typeof FileReader<"u")return new Promise((r,n)=>{let t=new FileReader;t.onloadend=()=>{typeof t.result=="string"?r(t.result):n(new Error(i.BlobToBase64Failed));},t.onerror=()=>n(t.error),t.readAsDataURL(e);});try{let r=await e.arrayBuffer(),n=new Uint8Array(r),t="",o=32768;for(let s=0;s<n.length;s+=o)t+=String.fromCharCode(...n.subarray(s,s+o));let a=btoa(t);return `data:${e.type};base64,${a}`}catch(r){throw new Error(i.BlobToBase64FailedWithCause(r instanceof Error?r.message:String(r)),{cause:r})}}function I(e,r,n){return "convertToBlob"in e?e.convertToBlob({type:r,quality:n}):new Promise((t,o)=>{e.toBlob(a=>{a?t(a):o(new Error(i.CanvasToBlobFailed(r)));},r,n);})}function M(e,r){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,r);if(typeof document<"u"){let n=document.createElement("canvas");return n.width=e,n.height=r,n}throw new Error(i.CanvasUnsupported)}function T(e){typeof e.close=="function"?e.close():e.width=0;}function D(e,r,n,t){if(typeof ImageData<"u")e.putImageData(new ImageData(r,n,t),0,0);else {let o=e.createImageData(n,t);o.data.set(r),e.putImageData(o,0,0);}}async function x(e,r,n,t){let{width:o,height:a,data:s}=e;if(!Number.isInteger(o)||o<=0||!Number.isInteger(a)||a<=0)throw new Error(i.InvalidDimensions(o,a));let l=o*a*4;if(s.length!==l)throw new Error(i.DataLengthMismatch(l,o,a,s.length));let d=B(o,a,t),g=d.width!==o||d.height!==a,c=M(d.width,d.height),m=c.getContext("2d");if(!m)throw new Error(i.ContextUnavailable);if(g){let w=M(o,a),f=w.getContext("2d");if(!f)throw new Error(i.ContextUnavailable);D(f,s,o,a),m.drawImage(w,0,0,d.width,d.height),T(w);}else D(m,s,o,a);let p=r.toLowerCase();if(p==="png")return I(c,"image/png");if(p==="jpeg"||p==="jpg")return I(c,"image/jpeg",n);if(p==="webp")return I(c,"image/webp",n);if(p==="svg"){let w=await I(c,"image/png"),f=await W(w),b=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${d.width} ${d.height}" width="${d.width}" height="${d.height}">
|
|
2
|
-
<image width="${
|
|
3
|
-
</svg>`;return new Blob([
|
|
1
|
+
var s={QualityInvalid:e=>`Quality must be a number between 0.0 and 1.0, got: ${e}`,ApplyOrientationInvalid:e=>`applyOrientation must be a boolean, got: ${e}`,UnsupportedInputType:e=>`Unsupported input type. Expected Blob, File, ArrayBuffer, or Uint8Array. Got: ${e}`,DecoderInitFailed:e=>`Failed to initialize HEIC decoder: ${e} \u2014 verify heic-decoder.wasm is served (dist/heic-decoder.wasm; see the README "Serving and Locating WASM" section / locateFile option) and that your CSP allows 'wasm-unsafe-eval'`,RenderEncodeFailed:(e,r)=>`Failed to render and encode image as ${e}: ${r}`,ConcurrencyInvalid:e=>`Concurrency must be a positive integer, got: ${e}`,MaxConcurrentWorkersInvalid:e=>`maxConcurrentWorkers must be a positive integer, got: ${e}`,TimeoutInvalid:e=>`timeoutMs must be a finite number >= 0 (0 disables the timeout), got: ${e}`,InputsMustBeArray:"Inputs must be an array of HEIC images",OutputShapeInvalid:e=>`output must be one of 'blob', 'dataUrl', 'arrayBuffer', got: ${e}`,ReuseDecodersInvalid:e=>`reuseDecoders must be a boolean, got: ${e}`,ContinueOnErrorInvalid:e=>`continueOnError must be a boolean, got: ${e}`,PreserveExifInvalid:e=>`preserveExif must be a boolean, got: ${e}`,SignalInvalid:e=>`signal must be an AbortSignal, got: ${e}`,Aborted:"Conversion aborted (AbortSignal was aborted)",ConvertManyItemFailed:(e,r,t)=>`Conversion of item ${e} of ${r} failed: ${t}`,ConvertManyExtraFailures:(e,r)=>` (${e} of ${r} items failed in total)`,ConvertManyOtherErrors:e=>`; other errors: ${e.join(" | ")}`,BatchItemProducedNoResult:e=>`Item ${String(e)} produced no result`,BatchEndedWithoutResult:"Batch ended without a result",ScaleInvalid:e=>`Scale must be a positive finite number, got: ${e}`,MaxWidthInvalid:e=>`maxWidth must be a positive finite number, got: ${e}`,MaxHeightInvalid:e=>`maxHeight must be a positive finite number, got: ${e}`,TargetSizeTooLarge:(e,r,t)=>`Target image size ${e}x${r} exceeds the maximum supported dimension of ${t}px`,BlobToBase64Failed:"Failed to convert Blob to base64 string",BlobToBase64FailedWithCause:e=>`Failed to convert Blob to base64 string: ${e}`,CanvasToBlobFailed:e=>`Failed to convert canvas to blob (type: ${e})`,CanvasUnsupported:"Canvas is not supported in the current environment. In a browser this requires OffscreenCanvas or HTMLCanvasElement. In Node.js there is no canvas: decode raw RGBA with LibheifDecoder and encode externally (see the Node.js section of the README).",InvalidDimensions:(e,r)=>`Invalid image dimensions: ${e}x${r}. Width and height must be positive integers.`,DataLengthMismatch:(e,r,t,n)=>`Image data length mismatch. Expected ${e} bytes for ${r}x${t}, got ${n}`,ContextUnavailable:"Failed to acquire 2D rendering context from canvas",UnsupportedFormat:e=>`Unsupported output format: ${e}`,FormatUnsupported:e=>`The current environment cannot encode '${e}' \u2014 canvas encoding produced no '${e}' image (e.g. AVIF encoding is not supported in this browser). Try 'jpeg', 'png', or 'webp' instead.`,CropInvalid:(e,r)=>`crop.${e} must be ${e==="width"||e==="height"?"a positive integer":"a non-negative integer"}, got: ${r}`,CropOutOfBounds:(e,r,t,n,o,i)=>`crop ${t}x${n} at (${e}, ${r}) exceeds the ${o}x${i} image (crop coordinates are in post-orientation display pixels)`,DecoderFreedDuringDecode:"Decoder was freed before decoding completed; call initialize() again.",DecodeInputAllocFailed:e=>`Failed to allocate ${e} bytes in the WASM heap for decode input`,DecodeFailed:e=>`HEIC decoding failed (no result returned; input: ${e} bytes \u2014 is the file truncated or empty?)`,DecodeFailedWithDetail:(e,r)=>`HEIC decoding failed: ${e} (input: ${r} bytes)`,ProgressCallbackThrew:e=>`onProgress callback threw during decode: ${e}`,WorkerUnsupported:"Web Worker is not supported in the current environment",WorkerCreateFailed:e=>`Failed to create Web Worker: ${e}`,WorkerPostFailed:e=>`Failed to post message to Web Worker: ${e}`,WorkerConversionFailed:"Worker conversion failed",WorkerDecoderUnsupported:"The decoder option is not supported by convertHeicInWorker: the worker creates its own decoder (functions and class instances cannot cross the worker boundary). Use convertHeic with an injected decoder instead.",WorkerFailed:e=>"Worker failed"+(e!==void 0?` (could not load worker script at ${String(e)}; check the path resolves and the script is served as JavaScript, e.g. Content-Type: text/javascript)`:""),WorkerTimeout:(e,r)=>{let t=[`${r.progressMessages} progress message(s) received`];return r.lastPercent!==void 0&&t.push(`last percent ${r.lastPercent}`),r.unknownType!==void 0&&t.push(`last unknown message type '${r.unknownType}' (worker may not implement the progress/result protocol)`),r.workerUrl!==void 0&&t.push(`worker ${String(r.workerUrl)}`),`Web Worker conversion timed out after ${e}ms (${t.join("; ")}). Increase timeoutMs for large images, set timeoutMs to 0 to disable the timeout, and verify the worker script implements the { type: "progress" | "result" } protocol.`}};function T(e){let r=Number(e);return Number.isFinite(r)?Math.min(100,Math.max(0,r)):0}var a=class extends Error{code;itemIndex;itemTotal;failedCount;constructor(r,t,n){super(t,{cause:n?.cause}),this.name="HeicConverterError",this.code=r,n?.itemIndex!==void 0&&(this.itemIndex=n.itemIndex),n?.itemTotal!==void 0&&(this.itemTotal=n.itemTotal),n?.failedCount!==void 0&&(this.failedCount=n.failedCount);}};var _=class{options;module=null;decoderInstance=null;initPromise=null;initGeneration=0;constructor(r){this.options=r;}async initialize(){if(!this.initPromise){let r=++this.initGeneration,t={};this.options?.moduleOverrides&&Object.assign(t,this.options.moduleOverrides),this.options?.locateFile&&(t.locateFile=this.options.locateFile),this.options?.wasmBinary&&(t.wasmBinary=this.options.wasmBinary);let n=import('./heic-decoder-WNTZ4MAN.mjs').then(({default:o})=>o(t)).then(o=>{let i=new o.HeicDecoder;return r!==this.initGeneration?(i.delete(),null):(this.module=o,this.decoderInstance=i,o)}).catch(o=>{throw this.initPromise===n&&(this.initPromise=null),o});this.initPromise=n;}await this.initPromise;}async decode(r,t){if((!this.module||!this.decoderInstance)&&await this.initialize(),!this.module||!this.decoderInstance)throw new a("decode_failed",s.DecoderFreedDuringDecode);let n,o=t?O=>{try{t(T(O));}catch(k){n=n??k;}}:null,i=this.module,c=this.decoderInstance,u;if(typeof c.decodeFromPointer=="function"&&typeof i._malloc=="function"&&typeof i._free=="function"&&i.HEAPU8 instanceof Uint8Array&&r.buffer!==i.HEAPU8.buffer){let O=i._malloc(r.byteLength);if(O===0)throw new a("decode_failed",s.DecodeInputAllocFailed(r.byteLength));try{i.HEAPU8.set(r,O),u=c.decodeFromPointer(O,r.byteLength,o);}finally{i._free(O);}}else u=c.decode(r,o);if(typeof u=="string")throw new a("decode_failed",s.DecodeFailedWithDetail(u,r.byteLength));if(!u)throw new a("decode_failed",s.DecodeFailed(r.byteLength));if(n!==void 0)throw new a("progress_callback_failed",s.ProgressCallbackThrew(n instanceof Error?n.message:String(n)),{cause:n});let d=u.width,l=u.height,m=u.orientation,y=typeof m=="number"&&Number.isInteger(m)&&m>=1&&m<=8?m:1,h=i.HEAPU8 instanceof Uint8Array?i.HEAPU8.buffer:void 0,w=h!==void 0&&u.data.buffer!==h?new Uint8ClampedArray(u.data.buffer,u.data.byteOffset,u.data.byteLength):new Uint8ClampedArray(u.data),g={width:d,height:l,data:w};y>1&&(g.orientation=y);let p=u.exif;return p instanceof Uint8Array&&p.length>=14&&(g.exif=h!==void 0&&p.buffer!==h?new Uint8Array(p.buffer,p.byteOffset,p.byteLength):new Uint8Array(p)),g}free(){this.initGeneration+=1,this.decoderInstance&&(this.decoderInstance.delete(),this.decoderInstance=null),this.module=null,this.initPromise=null;}};var ie=["jpeg","jpg","png","svg","webp","avif"],Se=.92;function R(e){$(e?.to??"jpeg"),e?.quality!==void 0&&ke(e.quality),Ae(e?.applyOrientation),_e(e?.output),Te(e?.signal),X(e?.crop),Me(e?.preserveExif),Q(e?.maxWidth!==void 0||e?.maxHeight!==void 0||e?.scale!==void 0?e:void 0);}function ae(e){Y(e?.continueOnError),Pe(e?.reuseDecoders);}function ke(e){if(typeof e!="number"||!Number.isFinite(e)||e<0||e>1)throw new a("invalid_quality",s.QualityInvalid(e))}function Ae(e){if(e!==void 0&&typeof e!="boolean")throw new a("invalid_input",s.ApplyOrientationInvalid(e))}function _e(e){if(e!==void 0&&e!=="blob"&&e!=="dataUrl"&&e!=="arrayBuffer")throw new a("invalid_input",s.OutputShapeInvalid(e))}function Pe(e){if(e!==void 0&&typeof e!="boolean")throw new a("invalid_input",s.ReuseDecodersInvalid(e))}function Y(e){if(e!==void 0&&typeof e!="boolean")throw new a("invalid_input",s.ContinueOnErrorInvalid(e))}function Me(e){if(e!==void 0&&typeof e!="boolean")throw new a("invalid_input",s.PreserveExifInvalid(e))}function Te(e){if(e!==void 0&&(typeof e!="object"||e===null||typeof e.addEventListener!="function"))throw new a("invalid_input",s.SignalInvalid(e))}function U(e){if(e?.aborted)throw new a("aborted",s.Aborted)}function $(e){let r=String(e).toLowerCase();if(!ie.includes(r))throw new a("invalid_format",s.UnsupportedFormat(String(e)))}function Q(e){if(!e)return;let{maxWidth:r,maxHeight:t,scale:n}=e;if(n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<=0))throw new a("invalid_resize",s.ScaleInvalid(n));if(r!==void 0&&(typeof r!="number"||!Number.isFinite(r)||r<=0))throw new a("invalid_resize",s.MaxWidthInvalid(r));if(t!==void 0&&(typeof t!="number"||!Number.isFinite(t)||t<=0))throw new a("invalid_resize",s.MaxHeightInvalid(t))}function X(e){if(!e)return;let{x:r=0,y:t=0,width:n,height:o}=e;if(!Number.isInteger(n)||n<=0)throw new a("invalid_crop",s.CropInvalid("width",n));if(!Number.isInteger(o)||o<=0)throw new a("invalid_crop",s.CropInvalid("height",o));if(!Number.isInteger(r)||r<0)throw new a("invalid_crop",s.CropInvalid("x",r));if(!Number.isInteger(t)||t<0)throw new a("invalid_crop",s.CropInvalid("y",t))}function J(e){if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new a("invalid_concurrency",s.MaxConcurrentWorkersInvalid(e))}function K(e){if(e!==void 0&&(typeof e!="number"||!Number.isFinite(e)||e<0))throw new a("invalid_input",s.TimeoutInvalid(e))}var B=new Uint8Array([69,120,105,102,0,0]),se=new Uint8Array([137,80,78,71,13,10,26,10]);function Z(e){if(e.length<B.length+8)return false;for(let r=0;r<B.length;r++)if(e[r]!==B[r])return false;return Re(e,B.length)}function Re(e,r){if(r+8>e.length)return false;let t=e[r]===73&&e[r+1]===73,n=e[r]===77&&e[r+1]===77;return !t&&!n?false:(t?e[r+2]|e[r+3]<<8:e[r+2]<<8|e[r+3])===42}function Ue(e,r){return e[r]<<8|e[r+1]}function ue(e,r){return (e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0}function de(e){try{if(!Z(e))return e;let r=B.length,t=e[r]===73,n=d=>t?e[d]|e[d+1]<<8:e[d]<<8|e[d+1],o=d=>t?(e[d+3]<<24|e[d+2]<<16|e[d+1]<<8|e[d])>>>0:(e[d]<<24|e[d+1]<<16|e[d+2]<<8|e[d+3])>>>0,i=o(r+4);if(i<8||r+i+2>e.length)return e;let c=r+i,u=n(c);for(let d=0;d<u;d++){let l=c+2+d*12;if(l+12>e.length)return e;if(n(l)!==274)continue;let m=n(l+2),y=o(l+4);if(m!==3||y!==1||(t?e[l+8]|e[l+9]<<8:e[l+8]<<8|e[l+9])===1)return e;let w=e.slice();return w[l+8]=t?1:0,w[l+9]=t?0:1,w[l+10]=0,w[l+11]=0,w}return e}catch{return e}}function ce(e,r){try{if(e.length<4||e[0]!==255||e[1]!==216||!Z(r))return e;let t=r.length+2;if(t>65535)return e;let n=2;for(;n<e.length;){if(n+4>e.length||e[n]!==255)return e;let i=e[n+1];if(i===255){n+=1;continue}if(!(i>=224&&i<=239||i===254))break;let u=Ue(e,n+2);if(u<2||n+2+u>e.length)return e;n+=2+u;}let o=new Uint8Array(e.length+4+r.length);return o.set(e.subarray(0,n),0),o[n]=255,o[n+1]=225,o[n+2]=t>>8&255,o[n+3]=t&255,o.set(r,n+4),o.set(e.subarray(n),n+4+r.length),o}catch{return e}}var L;function Be(){if(!L){L=new Uint32Array(256);for(let e=0;e<256;e++){let r=e;for(let t=0;t<8;t++)r=r&1?3988292384^r>>>1:r>>>1;L[e]=r>>>0;}}return L}function Fe(e){let r=Be(),t=4294967295;for(let n=0;n<e.length;n++)t=r[(t^e[n])&255]^t>>>8;return (t^4294967295)>>>0}function N(e,r,t){return e[r]===t.charCodeAt(0)&&e[r+1]===t.charCodeAt(1)&&e[r+2]===t.charCodeAt(2)&&e[r+3]===t.charCodeAt(3)}function le(e,r){try{if(e.length<33)return e;for(let u=0;u<se.length;u++)if(e[u]!==se[u])return e;if(ue(e,8)!==13||!N(e,12,"IHDR")||!Z(r))return e;let t=r.subarray(B.length),n=33;for(;n+8<=e.length;){let u=ue(e,n);if(u>e.length||n+12+u>e.length)return e;if(N(e,n+4,"IDAT")||N(e,n+4,"IEND"))break;if(N(e,n+4,"eXIf"))return e;n+=12+u;}let o=new Uint8Array(12+t.length);o[0]=t.length>>>24&255,o[1]=t.length>>>16&255,o[2]=t.length>>>8&255,o[3]=t.length&255,o.set([101,88,73,102],4),o.set(t,8);let i=Fe(o.subarray(4,8+t.length));o[8+t.length]=i>>>24&255,o[9+t.length]=i>>>16&255,o[10+t.length]=i>>>8&255,o[11+t.length]=i&255;let c=new Uint8Array(e.length+o.length);return c.set(e.subarray(0,n),0),c.set(o,n),c.set(e.subarray(n),n+o.length),c}catch{return e}}var j=16384;function re(){if(typeof OffscreenCanvas>"u"&&typeof document>"u")throw new a("unsupported_environment",s.CanvasUnsupported)}var z=null,De=5e3;async function We(){let e=ee(1,1),r=F(e,"image/avif"),t,n=new Promise(o=>{t=setTimeout(()=>o("timeout"),De);});try{let o=await Promise.race([r,n]);return o==="timeout"?(z=null,!1):o.type==="image/avif"&&o.size>0}finally{t!==void 0&&clearTimeout(t),P(e);}}function ge(){return z===null&&(z=We().catch(()=>false)),z}async function ne(e){if($(e),String(e).toLowerCase()==="avif"&&!await ge())throw new a("format_unsupported",s.FormatUnsupported("avif"))}function He(e,r,t){if(Q(t),!t)return {width:e,height:r};let{maxWidth:n,maxHeight:o,scale:i}=t;if(i!==void 0){let l=Math.max(1,Math.round(e*i)),m=Math.max(1,Math.round(r*i));return fe(l,m),{width:l,height:m}}if(n===void 0&&o===void 0)return {width:e,height:r};let c=Math.min(n!==void 0?n/e:Number.POSITIVE_INFINITY,o!==void 0?o/r:Number.POSITIVE_INFINITY);if(c>=1)return {width:e,height:r};let u=Math.min(Math.max(1,Math.round(e*c)),n!==void 0?Math.floor(n):Number.POSITIVE_INFINITY),d=Math.min(Math.max(1,Math.round(r*c)),o!==void 0?Math.floor(o):Number.POSITIVE_INFINITY);return fe(u,d),{width:u,height:d}}function fe(e,r){if(!Number.isFinite(e)||!Number.isFinite(r)||e>j||r>j)throw new a("invalid_resize",s.TargetSizeTooLarge(e,r,j))}async function te(e){if(typeof FileReader<"u")return new Promise((r,t)=>{let n=new FileReader;n.onloadend=()=>{typeof n.result=="string"?r(n.result):t(new a("render_encode_failed",s.BlobToBase64Failed));},n.onerror=()=>t(new a("render_encode_failed",s.BlobToBase64FailedWithCause(n.error?.message??"FileReader failed"),{cause:n.error??void 0})),n.readAsDataURL(e);});try{let r=await e.arrayBuffer(),t=new Uint8Array(r),n="",o=32768;for(let c=0;c<t.length;c+=o)n+=String.fromCharCode(...t.subarray(c,c+o));let i=btoa(n);return `data:${e.type};base64,${i}`}catch(r){throw new a("render_encode_failed",s.BlobToBase64FailedWithCause(r instanceof Error?r.message:String(r)),{cause:r})}}function F(e,r,t){return "convertToBlob"in e?e.convertToBlob({type:r,quality:t}):new Promise((n,o)=>{e.toBlob(i=>{i?n(i):o(new a("render_encode_failed",s.CanvasToBlobFailed(r)));},r,t);})}function ee(e,r){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,r);if(typeof document<"u"){let t=document.createElement("canvas");return t.width=e,t.height=r,t}throw new a("unsupported_environment",s.CanvasUnsupported)}function P(e){let r=e;typeof r.close=="function"?r.close():e.width=0;}function me(e,r,t,n){if(typeof ImageData<"u")e.putImageData(new ImageData(r,t,n),0,0);else {let o=e.createImageData(t,n);o.data.set(r),e.putImageData(o,0,0);}}function $e(e,r,t){switch(e){case 2:return [-1,0,0,1,r,0];case 3:return [-1,0,0,-1,r,t];case 4:return [1,0,0,-1,0,t];case 5:return [0,1,1,0,0,0];case 6:return [0,1,-1,0,t,0];case 7:return [0,-1,-1,0,t,r];case 8:return [0,-1,1,0,0,r];default:return null}}function Le(e,r){return !r||typeof e!="number"||!Number.isInteger(e)?1:e>=1&&e<=8?e:1}async function pe(e,r,t,n,o){let i=r.exif;if(!t||!i||i.length===0)return e;let c=o?de(i):i,u=new Uint8Array(await e.arrayBuffer()),d=n==="jpeg"?ce(u,c):le(u,c);return d===u?e:new Blob([d.buffer],{type:e.type})}async function he(e,r,t,n,o=true,i,c=false){$(r),X(i);let u=r.toLowerCase();if(u==="avif"&&!await ge())throw new a("format_unsupported",s.FormatUnsupported("avif"));let{width:d,height:l,data:m}=e;if(!Number.isInteger(d)||d<=0||!Number.isInteger(l)||l<=0)throw new a("render_encode_failed",s.InvalidDimensions(d,l));let y=d*l*4;if(m.length!==y)throw new a("render_encode_failed",s.DataLengthMismatch(y,d,l,m.length));let h=Le(e.orientation,o),g=!(e.orientation!==void 0&&e.orientation>=2&&e.orientation<=8)||o,p=$e(h,d,l),O=h>=5,k=O?l:d,M=O?d:l,A=i?.x??0,v=i?.y??0,b=i?i.width:k,E=i?i.height:M;if(i&&(A+b>k||v+E>M))throw new a("invalid_crop",s.CropOutOfBounds(A,v,b,E,k,M));let C=He(b,E,n),q=C.width!==b||C.height!==E,I=p!==null||i!==void 0,f=ee(C.width,C.height),S=f.getContext("2d");if(!S)throw new a("render_encode_failed",s.ContextUnavailable);if(I||q){let x=ee(d,l),H=x.getContext("2d");if(!H)throw new a("render_encode_failed",s.ContextUnavailable);if(me(H,m,d,l),I){let D=C.width/b,W=C.height/E,ye=p?p[0]:1,xe=p?p[1]:0,Ce=p?p[2]:0,Ie=p?p[3]:1,Oe=p?p[4]:0,Ee=p?p[5]:0;S.setTransform(ye*D,xe*W,Ce*D,Ie*W,D*(Oe-A),W*(Ee-v)),S.drawImage(x,0,0);}else S.drawImage(x,0,0,C.width,C.height);P(x);}else me(S,m,d,l);if(u==="png"){let x=await F(f,"image/png");return P(f),pe(x,e,c,"png",g)}if(u==="jpeg"||u==="jpg"){let x=await F(f,"image/jpeg",t);return P(f),pe(x,e,c,"jpeg",g)}if(u==="webp"){let x=await F(f,"image/webp",t);return P(f),x}if(u==="avif"){let x=await F(f,"image/avif",t);if(P(f),x.type!=="image/avif")throw new a("format_unsupported",s.FormatUnsupported("avif"));return x}if(u==="svg"){let x=await F(f,"image/png");P(f);let H=await te(x),D=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${C.width} ${C.height}" width="${C.width}" height="${C.height}">
|
|
2
|
+
<image width="${C.width}" height="${C.height}" href="`,W=`" />
|
|
3
|
+
</svg>`;return new Blob([D,H,W],{type:"image/svg+xml"})}throw new a("invalid_format",s.UnsupportedFormat(String(r)))}async function V(e,r,t,n){let o=n?.continueOnError===true,i=n?.signal,c=new Array(e.length),u=0,d=false,l=0,m=null,y=-1,h=0,w=[],g,p=new Promise(v=>{g=v;}),O=()=>g?.();i&&!o&&i.addEventListener("abort",O,{once:true});let k=async()=>{for(;!d&&!i?.aborted||o;){let v=u;if(u+=1,v>=e.length)return;if(o&&i?.aborted){let b=new a("aborted",s.Aborted);for(let E=v;E<e.length;E++)c[E]={index:E,ok:false,error:b};u=e.length;return}try{let b=await t(e[v],v);c[v]={index:v,ok:!0,result:b},l+=1;}catch(b){if(h+=1,o){c[v]={index:v,ok:false,error:b instanceof Error?b:new Error(String(b))};continue}d?w.length<2&&w.push(b instanceof Error?b.message:String(b)):(d=true,m=b,y=v,g?.());}}},M=Math.min(r,e.length),A=Array.from({length:M},()=>k());try{if(o)return await Promise.all(A),c;if(await Promise.race([Promise.all(A),p]),l===e.length)return c.map(v=>{if(!v||!v.ok)throw new a("batch_item_failed",s.BatchItemProducedNoResult(v?.index));return v.result});if(i?.aborted)throw new a("aborted",s.Aborted);if(d){let v=m instanceof Error?m.message:String(m),b=s.ConvertManyItemFailed(y+1,e.length,v);throw h>1&&(b+=s.ConvertManyExtraFailures(h,e.length),w.length>0&&(b+=s.ConvertManyOtherErrors(w))),new a("batch_item_failed",b,{cause:m,itemIndex:y,itemTotal:e.length,failedCount:h})}throw new a("batch_item_failed",s.BatchEndedWithoutResult)}finally{i?.removeEventListener("abort",O);}}function Ne(){let e=typeof navigator<"u"&&typeof navigator.hardwareConcurrency=="number"?navigator.hardwareConcurrency:4;return Math.max(1,Math.min(e,8))}var G=new Map;function ze(e,r,t){let n=G.get(e);n||(n={active:0,waiters:[]},G.set(e,n));let o={granted:false,released:false},i=()=>{let d=n.waiters.shift();d?d():n.active===0&&n.waiters.length===0&&G.delete(e);},c=()=>{if(!o.released)if(o.released=true,o.granted)o.granted=false,n.active-=1,i();else {let d=n.waiters.indexOf(u);d!==-1&&n.waiters.splice(d,1),n.active===0&&n.waiters.length===0&&G.delete(e);}},u=()=>{o.released||(o.granted=true,n.active+=1,t(c));};return n.active<r?u():n.waiters.push(u),c}function ve(e){return new a("progress_callback_failed",s.ProgressCallbackThrew(e instanceof Error?e.message:String(e)),{cause:e})}function be(e,r){return new Promise((t,n)=>{if(typeof Worker>"u"){n(new a("worker_unsupported",s.WorkerUnsupported));return}if(r.decoder!==void 0){n(new a("invalid_input",s.WorkerDecoderUnsupported));return}try{R(r),J(r?.maxConcurrentWorkers),K(r?.timeoutMs);}catch(I){n(I);return}if(r.signal?.aborted){n(new a("aborted",s.Aborted));return}let o={progressMessages:0},i,c=false,u,d,l=()=>{c||(c=true,u!==void 0&&clearTimeout(u),r.signal?.removeEventListener("abort",m),i&&(i.removeEventListener("message",h),i.removeEventListener("messageerror",g),i.removeEventListener("error",w),i.terminate()),d?.());},m=()=>{l(),n(new a("aborted",s.Aborted));};r.signal?.addEventListener("abort",m,{once:true});let y=r.timeoutMs??6e4;y>0&&(u=setTimeout(()=>{l(),n(new a("worker_timeout",s.WorkerTimeout(y,{progressMessages:o.progressMessages,lastPercent:o.lastPercent,unknownType:o.unknownType,workerUrl:r.workerUrl})));},y));let h=I=>{let f=I.data;if(f?.type==="progress"){o.progressMessages+=1;let S=T(f.percent);if(o.lastPercent=S,S>=100)return;try{r.onProgress?.(S);}catch(x){l(),n(ve(x));}return}if(f?.type!=="result"){typeof f?.type=="string"&&(o.unknownType=f.type);return}if(l(),f.ok&&f.blob!==void 0){try{r.onProgress?.(100);}catch(S){n(ve(S));return}t(f.blob);}else n(new a("worker_failed",f.error??s.WorkerConversionFailed));},w=I=>{l();let f=I.filename?` (${I.filename}:${I.lineno})`:"";n(new a("worker_failed",`${I.message||s.WorkerFailed(r.workerUrl)}${f}`));},g=I=>{l();let f=I.data;n(new a("worker_failed",f instanceof Error?f.message:f!==void 0?String(f):s.WorkerFailed(r.workerUrl),{cause:f}));},{workerUrl:p,onProgress:O,timeoutMs:k,workerType:M,maxConcurrentWorkers:A,signal:v,...b}=r,E=I=>{if(d=I,!c){try{i=new Worker(p,r.workerType==="module"?{type:"module"}:void 0);}catch(f){l(),n(new a("worker_create_failed",s.WorkerCreateFailed(f instanceof Error?f.message:String(f)),{cause:f}));return}i.addEventListener("message",h),i.addEventListener("messageerror",g),i.addEventListener("error",w);try{i.postMessage({input:e,options:b});}catch(f){l(),n(new a("worker_post_failed",s.WorkerPostFailed(f instanceof Error?f.message:String(f)),{cause:f}));}}},C=`${String(p)}|${r.workerType??"classic"}`,q=we(r.maxConcurrentWorkers);d=ze(C,q,E);})}function we(e){return typeof e=="number"&&Number.isInteger(e)?Math.max(1,e):Ne()}async function Ve(e,r){if(!Array.isArray(e))throw new a("invalid_input",s.InputsMustBeArray);if(typeof Worker>"u")throw new a("worker_unsupported",s.WorkerUnsupported);if(r.decoder!==void 0)throw new a("invalid_input",s.WorkerDecoderUnsupported);R(r),Y(r?.continueOnError),J(r?.maxConcurrentWorkers),K(r?.timeoutMs);let{onProgress:t,continueOnError:n,...o}=r??{};return V(e,we(r?.maxConcurrentWorkers),(i,c)=>be(i,{...o,...t!==void 0?{onProgress:u=>t(c,u)}:{}}),{continueOnError:r?.continueOnError===true,signal:r?.signal})}function _r(){}async function Ge(e,r){return r==="dataUrl"?await te(e):r==="arrayBuffer"?await e.arrayBuffer():e}async function qe(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(typeof Blob<"u"&&e instanceof Blob)return new Uint8Array(await e.arrayBuffer());if(e!==null&&typeof e=="object"&&typeof e.arrayBuffer=="function"){let r=await e.arrayBuffer();if(r instanceof ArrayBuffer)return new Uint8Array(r)}if(ArrayBuffer.isView(e)){let r=e;return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}throw new a("invalid_input",s.UnsupportedInputType(Object.prototype.toString.call(e)))}function Ye(e){if(typeof e!="function")return;let r=false,t,n=o=>{try{e(o);}catch(i){throw new a("progress_callback_failed",s.ProgressCallbackThrew(i instanceof Error?i.message:String(i)),{cause:i})}};return {report:o=>{if(r)return;let i=T(o);if(!(i>=100))try{e(i);}catch(c){t=t??c;}},complete:()=>{if(!r){if(r=true,t!==void 0)throw new a("progress_callback_failed",s.ProgressCallbackThrew(t instanceof Error?t.message:String(t)),{cause:t});n(100);}}}}async function Qe(e,r){let t=r?.to??"jpeg";R(r),re(),await ne(t);let n=r?.signal;U(n);let o=r?.maxWidth!==void 0||r?.maxHeight!==void 0||r?.scale!==void 0?r:void 0,i=await qe(e);U(n);let c=r?.decoder??new _,u=!r?.decoder,d=false,l=()=>{if(!(!u||d)){d=true;try{c.free();}catch{}}};try{try{await c.initialize();}catch(g){throw new a("decoder_init_failed",s.DecoderInitFailed(g instanceof Error?g.message:String(g)),{cause:g})}U(n);let m=Ye(r?.onProgress),y=await c.decode(i,m?m.report:void 0);l(),U(n);let h=r?.quality!==void 0?r.quality:.92,w;try{w=await he(y,t,h,o,r?.applyOrientation??!0,r?.crop,r?.preserveExif??!1);}catch(g){throw g instanceof a?g:new a("render_encode_failed",s.RenderEncodeFailed(t,g instanceof Error?g.message:String(g)),{cause:g})}return U(n),m?.complete(),Ge(w,r?.output??"blob")}finally{l();}}var oe=class{max;idle=[];waiters=[];leasedCount=0;disposed=false;constructor(r){this.max=Math.max(1,r);}async acquire(){let r=this.idle.pop();return r||(this.leasedCount<this.max?(this.leasedCount+=1,new _):new Promise(t=>this.waiters.push(t)))}release(r){if(this.disposed){try{r.free();}catch{}return}let t=this.waiters.shift();t?t(r):this.idle.push(r);}dispose(){this.disposed=true;for(let r of this.idle)try{r.free();}catch{}this.idle.length=0;for(let r of this.waiters.splice(0))r(new _);}};async function Pr(e,r){if(!Array.isArray(e))throw new a("invalid_input",s.InputsMustBeArray);let t=r?.concurrency??4;if(!Number.isInteger(t)||t<1)throw new a("invalid_concurrency",s.ConcurrencyInvalid(t));R(r),ae(r),re(),await ne(r?.to??"jpeg");let{concurrency:n,onProgress:o,continueOnError:i,reuseDecoders:c,...u}=r??{},l=c===true&&r?.decoder===void 0?new oe(Math.min(t,e.length)):null;try{return await V(e,t,async(m,y)=>{let h=l?await l.acquire():null;try{return await Qe(m,{...u,...h?{decoder:h}:{},onProgress:o!==void 0?w=>o(y,w):void 0})}finally{h&&l.release(h);}},{continueOnError:r?.continueOnError===!0,signal:r?.signal})}finally{l?.dispose();}}export{Se as DEFAULT_QUALITY,a as HeicConverterError,_ as LibheifDecoder,ie as SUPPORTED_FORMATS,Qe as convertHeic,be as convertHeicInWorker,Pr as convertMany,Ve as convertManyInWorker,_r as freeSharedDecoder};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keeratita/heic-converter",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Convert HEIC images to standard web formats (
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"require": "./dist/index.js",
|
|
13
|
-
"import": "./dist/index.mjs"
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
14
15
|
},
|
|
15
16
|
"./wasm": {
|
|
16
17
|
"require": "./dist/heic-decoder.wasm",
|
|
17
|
-
"import": "./dist/heic-decoder.wasm"
|
|
18
|
+
"import": "./dist/heic-decoder.wasm",
|
|
19
|
+
"default": "./dist/heic-decoder.wasm"
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
22
|
"files": [
|
|
@@ -26,6 +28,8 @@
|
|
|
26
28
|
"scripts": {
|
|
27
29
|
"build": "tsup && node build-scripts/compress-wasm.mjs",
|
|
28
30
|
"build:wasm": "bash build-scripts/build-wasm.sh",
|
|
31
|
+
"verify:wasm": "node build-scripts/verify-wasm-artifacts.mjs",
|
|
32
|
+
"wasm:hashes": "node build-scripts/verify-wasm-artifacts.mjs --write",
|
|
29
33
|
"test": "vitest run",
|
|
30
34
|
"test:watch": "vitest",
|
|
31
35
|
"test:e2e": "node test/browser/test-playwright.mjs",
|
|
@@ -34,7 +38,7 @@
|
|
|
34
38
|
"lint": "eslint .",
|
|
35
39
|
"sonar": "sonar-scanner",
|
|
36
40
|
"prepare": "husky",
|
|
37
|
-
"release": "node build-scripts/release.
|
|
41
|
+
"release": "node build-scripts/release.mjs"
|
|
38
42
|
},
|
|
39
43
|
"keywords": [
|
|
40
44
|
"heic",
|
|
@@ -55,15 +59,15 @@
|
|
|
55
59
|
"homepage": "https://github.com/keeratita/heic-converter#readme",
|
|
56
60
|
"devDependencies": {
|
|
57
61
|
"@eslint/js": "^10.0.1",
|
|
58
|
-
"@vitest/browser": "^
|
|
59
|
-
"@vitest/coverage-v8": "^
|
|
60
|
-
"eslint": "^10.
|
|
61
|
-
"globals": "^17.
|
|
62
|
+
"@vitest/browser": "^5.0.3",
|
|
63
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
64
|
+
"eslint": "^10.12.0",
|
|
65
|
+
"globals": "^17.13.0",
|
|
62
66
|
"husky": "^9.1.7",
|
|
63
|
-
"playwright": "^1.
|
|
67
|
+
"playwright": "^1.63.0",
|
|
64
68
|
"tsup": "^8.0.0",
|
|
65
69
|
"typescript": "^5.0.0",
|
|
66
|
-
"typescript-eslint": "^8.
|
|
67
|
-
"vitest": "^
|
|
70
|
+
"typescript-eslint": "^8.71.0",
|
|
71
|
+
"vitest": "^5.0.3"
|
|
68
72
|
}
|
|
69
73
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var wa=(()=>{var sr=import.meta.url;return(async function(lr={}){var f=lr,ur,me;f.ready=new Promise((e,r)=>{ur=e,me=r;});var fr=Object.assign({},f),je="./this.program",vr=typeof window=="object",Q=typeof importScripts=="function",ye=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",H="";function Kr(e){return f.locateFile?f.locateFile(e,H):H+e}var oe,Oe,ge;if(ye){let{createRequire:e}=await import('module');var we=e(import.meta.url),We=we("fs"),Ue=we("path");Q?H=Ue.dirname(H)+"/":H=we("url").fileURLToPath(new URL("./",import.meta.url)),oe=(r,t)=>(r=br(r)?new URL(r):Ue.normalize(r),We.readFileSync(r,t?void 0:"utf8")),ge=r=>{var t=oe(r,true);return t.buffer||(t=new Uint8Array(t)),t},Oe=(r,t,n,o=true)=>{r=br(r)?new URL(r):Ue.normalize(r),We.readFile(r,o?void 0:"utf8",(i,s)=>{i?n(i):t(o?s.buffer:s);});},!f.thisProgram&&process.argv.length>1&&(je=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2);}else (vr||Q)&&(Q?H=self.location.href:typeof document<"u"&&document.currentScript&&(H=document.currentScript.src),sr&&(H=sr),H.startsWith("blob:")?H="":H=H.substr(0,H.replace(/[?#].*/,"").lastIndexOf("/")+1),oe=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.send(null),r.responseText},Q&&(ge=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Oe=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,true),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t();},n.onerror=t,n.send(null);});var He=f.print||console.log.bind(console),Y=f.printErr||console.error.bind(console);Object.assign(f,fr),fr=null,f.arguments&&(f.arguments),f.thisProgram&&(je=f.thisProgram),f.quit&&(f.quit);var ie;f.wasmBinary&&(ie=f.wasmBinary);var _e,hr=false,M,O,ee,se,_,b,pr,mr;function yr(){var e=_e.buffer;f.HEAP8=M=new Int8Array(e),f.HEAP16=ee=new Int16Array(e),f.HEAPU8=O=new Uint8Array(e),f.HEAPU16=se=new Uint16Array(e),f.HEAP32=_=new Int32Array(e),f.HEAPU32=b=new Uint32Array(e),f.HEAPF32=pr=new Float32Array(e),f.HEAPF64=mr=new Float64Array(e);}var gr=[],wr=[],_r=[];function Qr(){if(f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)tt(f.preRun.shift());xe(gr);}function et(){!f.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=false,xe(wr);}function rt(){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)at(f.postRun.shift());xe(_r);}function tt(e){gr.unshift(e);}function nt(e){wr.unshift(e);}function at(e){_r.unshift(e);}var X=0,le=null;function Le(e){X++,f.monitorRunDependencies?.(X);}function Ee(e){if(X--,f.monitorRunDependencies?.(X),X==0&&(le)){var r=le;le=null,r();}}function re(e){f.onAbort?.(e),e="Aborted("+e+")",Y(e),hr=true,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw me(r),r}var ot="data:application/octet-stream;base64,",Er=e=>e.startsWith(ot),br=e=>e.startsWith("file://"),G;f.locateFile?(G="heic-decoder.wasm",Er(G)||(G=Kr(G))):G=new URL("heic-decoder.wasm",import.meta.url).href;function $r(e){if(e==G&&ie)return new Uint8Array(ie);if(ge)return ge(e);throw "both async and sync fetching of the wasm failed"}function it(e){return !ie&&(vr||Q)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw `failed to load wasm binary file at '${e}'`;return r.arrayBuffer()}).catch(()=>$r(e)):Promise.resolve().then(()=>$r(e))}function kr(e,r,t){return it(e).then(n=>WebAssembly.instantiate(n,r)).then(t,n=>{Y(`failed to asynchronously prepare wasm: ${n}`),re(n);})}function st(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!Er(r)&&!ye&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(o=>{var i=WebAssembly.instantiateStreaming(o,t);return i.then(n,function(s){return Y(`wasm streaming compile failed: ${s}`),Y("falling back to ArrayBuffer instantiation"),kr(r,t,n)})}):kr(r,t,n)}function lt(){var e={a:la};function r(n,o){return A=n.exports,_e=A.R,yr(),Ur=A.U,nt(A.S),Ee(),A}Le();function t(n){r(n.instance);}if(f.instantiateWasm)try{return f.instantiateWasm(e,r)}catch(n){Y(`Module.instantiateWasm callback failed with error: ${n}`),me(n);}return st(ie,G,e,t).catch(me),{}}var E,R,xe=e=>{for(;e.length>0;)e.shift()(f);};f.noExitRuntime||true;var Pr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,te=(e,r,t)=>{for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.buffer&&Pr)return Pr.decode(e.subarray(r,o));for(var i="";r<o;){var s=e[r++];if(!(s&128)){i+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|l);continue}var u=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|u:s=(s&7)<<18|l<<12|u<<6|e[r++]&63,s<65536)i+=String.fromCharCode(s);else {var d=s-65536;i+=String.fromCharCode(55296|d>>10,56320|d&1023);}}return i},K=(e,r)=>e?te(O,e,r):"",ut=(e,r,t,n)=>{re(`Assertion failed: ${K(e)}, at: `+[r?K(r):"unknown filename",t,n?K(n):"unknown function"]);};class ft{constructor(r){this.excPtr=r,this.ptr=r-24;}set_type(r){b[this.ptr+4>>2]=r;}get_type(){return b[this.ptr+4>>2]}set_destructor(r){b[this.ptr+8>>2]=r;}get_destructor(){return b[this.ptr+8>>2]}set_caught(r){r=r?1:0,M[this.ptr+12]=r;}get_caught(){return M[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,M[this.ptr+13]=r;}get_rethrown(){return M[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t);}set_adjusted_ptr(r){b[this.ptr+16>>2]=r;}get_adjusted_ptr(){return b[this.ptr+16>>2]}get_exception_ptr(){var r=qr(this.get_type());if(r)return b[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Cr=0,ct=(e,r,t)=>{var n=new ft(e);throw n.init(r,t),Cr=e,Cr},T={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var o=e[n];o==="."?e.splice(n,1):o===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--);}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=T.isAbs(e),t=e.substr(-1)==="/";return e=T.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=T.splitPath(e),t=r[0],n=r[1];return !t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return "/";e=T.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>T.normalize(e.join("/")),join2:(e,r)=>T.normalize(e+"/"+r)},vt=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return n=>crypto.getRandomValues(n);if(ye)try{var e=we("crypto"),r=e.randomFillSync;if(r)return n=>e.randomFillSync(n);var t=e.randomBytes;return n=>(n.set(t(n.byteLength)),n)}catch{}re("initRandomDevice");},Tr=e=>(Tr=vt())(e),N={resolve:(...e)=>{for(var r="",t=false,n=e.length-1;n>=-1&&!t;n--){var o=n>=0?e[n]:a.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return "";r=o+"/"+r,t=T.isAbs(o);}return r=T.normalizeArray(r.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=N.resolve(e).substr(1),r=N.resolve(r).substr(1);function t(d){for(var v=0;v<d.length&&d[v]==="";v++);for(var y=d.length-1;y>=0&&d[y]==="";y--);return v>y?[]:d.slice(v,y-v+1)}for(var n=t(e.split("/")),o=t(r.split("/")),i=Math.min(n.length,o.length),s=i,l=0;l<i;l++)if(n[l]!==o[l]){s=l;break}for(var u=[],l=s;l<n.length;l++)u.push("..");return u=u.concat(o.slice(s)),u.join("/")}},ze=[],Ne=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},Be=(e,r,t,n)=>{if(!(n>0))return 0;for(var o=t,i=t+n-1,s=0;s<e.length;++s){var l=e.charCodeAt(s);if(l>=55296&&l<=57343){var u=e.charCodeAt(++s);l=65536+((l&1023)<<10)|u&1023;}if(l<=127){if(t>=i)break;r[t++]=l;}else if(l<=2047){if(t+1>=i)break;r[t++]=192|l>>6,r[t++]=128|l&63;}else if(l<=65535){if(t+2>=i)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63;}else {if(t+3>=i)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63;}}return r[t]=0,t-o};function be(e,r,t){var n=Ne(e)+1,o=new Array(n),i=Be(e,o,0,o.length);return r&&(o.length=i),o}var ht=()=>{if(!ze.length){var e=null;if(ye){var r=256,t=Buffer.alloc(r),n=0,o=process.stdin.fd;try{n=We.readSync(o,t);}catch(i){if(i.toString().includes("EOF"))n=0;else throw i}n>0?e=t.slice(0,n).toString("utf-8"):e=null;}else typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
2
|
-
`)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
|
|
3
|
-
`));if(!e)return null;ze=be(e,true);}return ze.shift()},q={ttys:[],init(){},shutdown(){},register(e,r){q.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,q.stream_ops);},stream_ops:{open(e){var r=q.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=false;},close(e){e.tty.ops.fsync(e.tty);},fsync(e){e.tty.ops.fsync(e.tty);},read(e,r,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var i=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty);}catch{throw new a.ErrnoError(29)}if(l===void 0&&i===0)throw new a.ErrnoError(6);if(l==null)break;i++,r[t+s]=l;}return i&&(e.node.timestamp=Date.now()),i},write(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,r[t+i]);}catch{throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char(e){return ht()},put_char(e,r){r===null||r===10?(He(te(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(He(te(e.output,0)),e.output=[]);},ioctl_tcgets(e){return {c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return [24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(Y(te(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(Y(te(e.output,0)),e.output=[]);}}},Fr=e=>{re();},w={ops_table:null,mount(e){return w.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);w.ops_table||={dir:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,lookup:w.node_ops.lookup,mknod:w.node_ops.mknod,rename:w.node_ops.rename,unlink:w.node_ops.unlink,rmdir:w.node_ops.rmdir,readdir:w.node_ops.readdir,symlink:w.node_ops.symlink},stream:{llseek:w.stream_ops.llseek}},file:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:{llseek:w.stream_ops.llseek,read:w.stream_ops.read,write:w.stream_ops.write,allocate:w.stream_ops.allocate,mmap:w.stream_ops.mmap,msync:w.stream_ops.msync}},link:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,readlink:w.node_ops.readlink},stream:{}},chrdev:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:a.chrdev_stream_ops}};var o=a.createNode(e,r,t,n);return a.isDir(o.mode)?(o.node_ops=w.ops_table.dir.node,o.stream_ops=w.ops_table.dir.stream,o.contents={}):a.isFile(o.mode)?(o.node_ops=w.ops_table.file.node,o.stream_ops=w.ops_table.file.stream,o.usedBytes=0,o.contents=null):a.isLink(o.mode)?(o.node_ops=w.ops_table.link.node,o.stream_ops=w.ops_table.link.stream):a.isChrdev(o.mode)&&(o.node_ops=w.ops_table.chrdev.node,o.stream_ops=w.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[r]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var o=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(o.subarray(0,e.usedBytes),0);}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else {var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r;}},node_ops:{getattr(e){var r={};return r.dev=a.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,a.isDir(e.mode)?r.size=4096:a.isFile(e.mode)?r.size=e.usedBytes:a.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&w.resizeFileStorage(e,r.size);},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return w.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t);}catch{}if(n)for(var o in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r;},unlink(e,r){delete e.contents[r],e.timestamp=Date.now();},rmdir(e,r){var t=a.lookupNode(e,r);for(var n in t.contents)throw new a.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now();},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var n=w.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(s>8&&i.subarray)r.set(i.subarray(o,o+s),t);else for(var l=0;l<s;l++)r[t+l]=i[o+l];return s},write(e,r,t,n,o,i){if(r.buffer===M.buffer&&(i=false),!n)return 0;var s=e.node;if(s.timestamp=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=r.subarray(t,t+n),s.usedBytes=n,n;if(s.usedBytes===0&&o===0)return s.contents=r.slice(t,t+n),s.usedBytes=n,n;if(o+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),o),n}if(w.expandFileStorage(s,o+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),o);else for(var l=0;l<n;l++)s.contents[o+l]=r[t+l];return s.usedBytes=Math.max(s.usedBytes,o+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&a.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new a.ErrnoError(28);return n},allocate(e,r,t){w.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t);},mmap(e,r,t,n,o){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var i,s,l=e.node.contents;if(!(o&2)&&l.buffer===M.buffer)s=false,i=l.byteOffset;else {if((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),s=true,i=Fr(),!i)throw new a.ErrnoError(48);M.set(l,i);}return {ptr:i,allocated:s}},msync(e,r,t,n,o){return w.stream_ops.write(e,r,0,n,t,false),0}}},pt=(e,r,t,n)=>{var o=`al ${e}`;Oe(e,i=>{r(new Uint8Array(i)),o&&Ee();},i=>{if(t)t();else throw `Loading data file "${e}" failed.`}),o&&Le();},mt=(e,r,t,n,o,i)=>{a.createDataFile(e,r,t,n,o,i);},yt=f.preloadPlugins||[],gt=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var o=false;return yt.forEach(i=>{o||i.canHandle(r)&&(i.handle(e,r,t,n),o=true);}),o},wt=(e,r,t,n,o,i,s,l,u,d)=>{var v=r?N.resolve(T.join2(e,r)):e;function m(h){function g(C){d?.(),l||mt(e,r,C,n,o,u),i?.(),Ee();}gt(h,v,g,()=>{s?.(),Ee();})||g(h);}Le(),typeof t=="string"?pt(t,m,s):m(t);},_t=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},Ve=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e;}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.shared={};}get object(){return this.node}set object(e){this.node=e;}get isRead(){return (this.flags&2097155)!==1}get isWrite(){return (this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e;}get position(){return this.shared.position}set position(e){this.shared.position=e;}},FSNode:class{constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=a.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146;}get read(){return (this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode;}get write(){return (this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode;}get isFolder(){return a.isDir(this.mode)}get isDevice(){return a.isChrdev(this.mode)}},lookupPath(e,r={}){if(e=N.resolve(e),!e)return {path:"",node:null};var t={follow_mount:true,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(y=>!!y),o=a.root,i="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(o=a.lookupNode(o,n[s]),i=T.join2(i,n[s]),a.isMountpoint(o)&&(!l||l&&r.follow_mount)&&(o=o.mounted.root),!l||r.follow)for(var u=0;a.isLink(o.mode);){var d=a.readlink(i);i=N.resolve(T.dirname(i),d);var v=a.lookupPath(i,{recurse_count:r.recurse_count+1});if(o=v.node,u++>40)throw new a.ErrnoError(32)}}return {path:i,node:o}},getPath(e){for(var r;;){if(a.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent;}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return (e+t>>>0)%a.nameTable.length},hashAddNode(e){var r=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[r],a.nameTable[r]=e;},hashRemoveNode(e){var r=a.hashName(e.parent.id,e.name);if(a.nameTable[r]===e)a.nameTable[r]=e.name_next;else for(var t=a.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next;}},lookupNode(e,r){var t=a.mayLookup(e);if(t)throw new a.ErrnoError(t);for(var n=a.hashName(e.id,r),o=a.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===r)return o}return a.lookup(e,r)},createNode(e,r,t,n){var o=new a.FSNode(e,r,t,n);return a.hashAddNode(o),o},destroyNode(e){a.hashRemoveNode(e);},isRoot(e){return e===e.parent},isMountpoint(e){return !!e.mounted},isFile(e){return (e&61440)===32768},isDir(e){return (e&61440)===16384},isLink(e){return (e&61440)===40960},isChrdev(e){return (e&61440)===8192},isBlkdev(e){return (e&61440)===24576},isFIFO(e){return (e&61440)===4096},isSocket(e){return (e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return a.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!a.isDir(e.mode))return 54;var r=a.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){try{var t=a.lookupNode(e,r);return 20}catch{}return a.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=a.lookupNode(e,r);}catch(i){return i.errno}var o=a.nodePermissions(e,"wx");if(o)return o;if(t){if(!a.isDir(n.mode))return 54;if(a.isRoot(n)||a.getPath(n)===a.cwd())return 10}else if(a.isDir(n.mode))return 31;return 0},mayOpen(e,r){return e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked(e){var r=a.getStream(e);if(!r)throw new a.ErrnoError(8);return r},getStream:e=>a.streams[e],createStream(e,r=-1){return e=Object.assign(new a.FSStream,e),r==-1&&(r=a.nextfd()),e.fd=r,a.streams[r]=e,e},closeStream(e){a.streams[e]=null;},dupStream(e,r=-1){var t=a.createStream(e,r);return t.stream_ops?.dup?.(t),t},chrdev_stream_ops:{open(e){var r=a.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e);},llseek(){throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){a.devices[e]={stream_ops:r};},getDevice:e=>a.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts);}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=false),a.syncFSRequests++,a.syncFSRequests>1&&Y(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=a.getMounts(a.root.mount),n=0;function o(s){return a.syncFSRequests--,r(s)}function i(s){if(s)return i.errored?void 0:(i.errored=true,o(s));++n>=t.length&&o(null);}t.forEach(s=>{if(!s.type.syncfs)return i(null);s.type.syncfs(s,e,i);});},mount(e,r,t){var n=t==="/",o=!t,i;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!o){var s=a.lookupPath(t,{follow_mount:false});if(t=s.path,i=s.node,a.isMountpoint(i))throw new a.ErrnoError(10);if(!a.isDir(i.mode))throw new a.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(l);return u.mount=l,l.root=u,n?a.root=u:i&&(i.mounted=l,i.mount&&i.mount.mounts.push(l)),u},unmount(e){var r=a.lookupPath(e,{follow_mount:false});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,o=a.getMounts(n);Object.keys(a.nameTable).forEach(s=>{for(var l=a.nameTable[s];l;){var u=l.name_next;o.includes(l.mount)&&a.destroyNode(l),l=u;}}),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1);},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=a.lookupPath(e,{parent:true}),o=n.node,i=T.basename(e);if(!i||i==="."||i==="..")throw new a.ErrnoError(28);var s=a.mayCreate(o,i);if(s)throw new a.ErrnoError(s);if(!o.node_ops.mknod)throw new a.ErrnoError(63);return o.node_ops.mknod(o,i,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{a.mkdir(n,r);}catch(i){if(i.errno!=20)throw i}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)},symlink(e,r){if(!N.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:true}),n=t.node;if(!n)throw new a.ErrnoError(44);var o=T.basename(r),i=a.mayCreate(n,o);if(i)throw new a.ErrnoError(i);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,o,e)},rename(e,r){var t=T.dirname(e),n=T.dirname(r),o=T.basename(e),i=T.basename(r),s,l,u;if(s=a.lookupPath(e,{parent:true}),l=s.node,s=a.lookupPath(r,{parent:true}),u=s.node,!l||!u)throw new a.ErrnoError(44);if(l.mount!==u.mount)throw new a.ErrnoError(75);var d=a.lookupNode(l,o),v=N.relative(e,n);if(v.charAt(0)!==".")throw new a.ErrnoError(28);if(v=N.relative(r,t),v.charAt(0)!==".")throw new a.ErrnoError(55);var y;try{y=a.lookupNode(u,i);}catch{}if(d!==y){var m=a.isDir(d.mode),h=a.mayDelete(l,o,m);if(h)throw new a.ErrnoError(h);if(h=y?a.mayDelete(u,i,m):a.mayCreate(u,i),h)throw new a.ErrnoError(h);if(!l.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(d)||y&&a.isMountpoint(y))throw new a.ErrnoError(10);if(u!==l&&(h=a.nodePermissions(l,"w"),h))throw new a.ErrnoError(h);a.hashRemoveNode(d);try{l.node_ops.rename(d,u,i);}catch(g){throw g}finally{a.hashAddNode(d);}}},rmdir(e){var r=a.lookupPath(e,{parent:true}),t=r.node,n=T.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,true);if(i)throw new a.ErrnoError(i);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(o);},readdir(e){var r=a.lookupPath(e,{follow:true}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=a.lookupPath(e,{parent:true}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=T.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,false);if(i)throw new a.ErrnoError(i);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(o);},readlink(e){var r=a.lookupPath(e),t=r.node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return N.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return a.stat(e,true)},chmod(e,r,t){var n;if(typeof e=="string"){var o=a.lookupPath(e,{follow:!t});n=o.node;}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()});},lchmod(e,r){a.chmod(e,r,true);},fchmod(e,r){var t=a.getStreamChecked(e);a.chmod(t.node,r);},chown(e,r,t,n){var o;if(typeof e=="string"){var i=a.lookupPath(e,{follow:!n});o=i.node;}else o=e;if(!o.node_ops.setattr)throw new a.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()});},lchown(e,r,t){a.chown(e,r,t,true);},fchown(e,r,t){var n=a.getStreamChecked(e);a.chown(n.node,r,t);},truncate(e,r){if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:true});t=n.node;}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var o=a.nodePermissions(t,"w");if(o)throw new a.ErrnoError(o);t.node_ops.setattr(t,{size:r,timestamp:Date.now()});},ftruncate(e,r){var t=a.getStreamChecked(e);if((t.flags&2097155)===0)throw new a.ErrnoError(28);a.truncate(t.node,r);},utime(e,r,t){var n=a.lookupPath(e,{follow:true}),o=n.node;o.node_ops.setattr(o,{timestamp:Math.max(r,t)});},open(e,r,t){if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?_t(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else {e=T.normalize(e);try{var o=a.lookupPath(e,{follow:!(r&131072)});n=o.node;}catch{}}var i=false;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),i=true;if(!n)throw new a.ErrnoError(44);if(a.isChrdev(n.mode)&&(r&=-513),r&65536&&!a.isDir(n.mode))throw new a.ErrnoError(54);if(!i){var s=a.mayOpen(n,r);if(s)throw new a.ErrnoError(s)}r&512&&!i&&a.truncate(n,0),r&=-131713;var l=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:true,position:0,stream_ops:n.stream_ops,ungotten:[],error:false});return l.stream_ops.open&&l.stream_ops.open(l),f.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),l},close(e){if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e);}catch(r){throw r}finally{a.closeStream(e.fd);}e.fd=null;},isClosed(e){return e.fd===null},llseek(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,o){if(n<0||o<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var i=typeof o<"u";if(!i)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,o);return i||(e.position+=s),s},write(e,r,t,n,o,i){if(n<0||o<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var s=typeof o<"u";if(!s)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,o,i);return s||(e.position+=l),l},allocate(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t);},mmap(e,r,t,n,o){if((n&2)!==0&&(o&2)===0&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,o)},msync(e,r,t,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new a.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=a.open(e,r.flags),o=a.stat(e),i=o.size,s=new Uint8Array(i);return a.read(n,s,0,i,0),r.encoding==="utf8"?t=te(s,0):r.encoding==="binary"&&(t=s),a.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var o=new Uint8Array(Ne(r)+1),i=Be(r,o,0,o.length);a.write(n,o,0,i,void 0,t.canOwn);}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n);},cwd:()=>a.currentPath,chdir(e){var r=a.lookupPath(e,{follow:true});if(r.node===null)throw new a.ErrnoError(44);if(!a.isDir(r.node.mode))throw new a.ErrnoError(54);var t=a.nodePermissions(r.node,"x");if(t)throw new a.ErrnoError(t);a.currentPath=r.path;},createDefaultDirectories(){a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user");},createDefaultDevices(){a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(n,o,i,s,l)=>s}),a.mkdev("/dev/null",a.makedev(1,3)),q.register(a.makedev(5,0),q.default_tty_ops),q.register(a.makedev(6,0),q.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=Tr(e).byteLength),e[--r]);a.createDevice("/dev","random",t),a.createDevice("/dev","urandom",t),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp");},createSpecialDirectories(){a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount(){var r=a.createNode(e,"fd",16895,73);return r.node_ops={lookup(t,n){var o=+n,i=a.getStreamChecked(o),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return s.parent=s,s}},r}},{},"/proc/self/fd");},createStandardStreams(){f.stdin?a.createDevice("/dev","stdin",f.stdin):a.symlink("/dev/tty","/dev/stdin"),f.stdout?a.createDevice("/dev","stdout",null,f.stdout):a.symlink("/dev/tty","/dev/stdout"),f.stderr?a.createDevice("/dev","stderr",null,f.stderr):a.symlink("/dev/tty1","/dev/stderr");a.open("/dev/stdin",0);a.open("/dev/stdout",1);a.open("/dev/stderr",1);},staticInit(){[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>";}),a.nameTable=new Array(4096),a.mount(w,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:w};},init(e,r,t){a.init.initialized=true,f.stdin=e||f.stdin,f.stdout=r||f.stdout,f.stderr=t||f.stderr,a.createStandardStreams();},quit(){a.init.initialized=false;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r);}},findObject(e,r){var t=a.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=a.lookupPath(e,{follow:!r});e=t.path;}catch{}var n={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var t=a.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=T.basename(e),t=a.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/";}catch(o){n.error=o.errno;}return n},createPath(e,r,t,n){e=typeof e=="string"?e:a.getPath(e);for(var o=r.split("/").reverse();o.length;){var i=o.pop();if(i){var s=T.join2(e,i);try{a.mkdir(s);}catch{}e=s;}}return s},createFile(e,r,t,n,o){var i=T.join2(typeof e=="string"?e:a.getPath(e),r),s=Ve(n,o);return a.create(i,s)},createDataFile(e,r,t,n,o,i){var s=r;e&&(e=typeof e=="string"?e:a.getPath(e),s=r?T.join2(e,r):e);var l=Ve(n,o),u=a.create(s,l);if(t){if(typeof t=="string"){for(var d=new Array(t.length),v=0,y=t.length;v<y;++v)d[v]=t.charCodeAt(v);t=d;}a.chmod(u,l|146);var m=a.open(u,577);a.write(m,t,0,t.length,0,i),a.close(m),a.chmod(u,l);}},createDevice(e,r,t,n){var o=T.join2(typeof e=="string"?e:a.getPath(e),r),i=Ve(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(l){l.seekable=false;},close(l){n?.buffer?.length&&n(10);},read(l,u,d,v,y){for(var m=0,h=0;h<v;h++){var g;try{g=t();}catch{throw new a.ErrnoError(29)}if(g===void 0&&m===0)throw new a.ErrnoError(6);if(g==null)break;m++,u[d+h]=g;}return m&&(l.node.timestamp=Date.now()),m},write(l,u,d,v,y){for(var m=0;m<v;m++)try{n(u[d+m]);}catch{throw new a.ErrnoError(29)}return v&&(l.node.timestamp=Date.now()),m}}),a.mkdev(o,i,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return true;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(oe)try{e.contents=be(oe(e.url),!0),e.usedBytes=e.contents.length;}catch{throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(e,r,t,n,o){class i{constructor(){this.lengthKnown=false,this.chunks=[];}get(h){if(!(h>this.length-1||h<0)){var g=h%this.chunkSize,C=h/this.chunkSize|0;return this.getter(C)[g]}}setDataGetter(h){this.getter=h;}cacheLength(){var h=new XMLHttpRequest;if(h.open("HEAD",t,false),h.send(null),!(h.status>=200&&h.status<300||h.status===304))throw new Error("Couldn't load "+t+". Status: "+h.status);var g=Number(h.getResponseHeader("Content-length")),C,F=(C=h.getResponseHeader("Accept-Ranges"))&&C==="bytes",P=(C=h.getResponseHeader("Content-Encoding"))&&C==="gzip",c=1024*1024;F||(c=g);var p=($,U)=>{if($>U)throw new Error("invalid range ("+$+", "+U+") or no bytes requested!");if(U>g-1)throw new Error("only "+g+" bytes available! programmer error!");var S=new XMLHttpRequest;if(S.open("GET",t,false),g!==c&&S.setRequestHeader("Range","bytes="+$+"-"+U),S.responseType="arraybuffer",S.overrideMimeType&&S.overrideMimeType("text/plain; charset=x-user-defined"),S.send(null),!(S.status>=200&&S.status<300||S.status===304))throw new Error("Couldn't load "+t+". Status: "+S.status);return S.response!==void 0?new Uint8Array(S.response||[]):be(S.responseText||"",true)},D=this;D.setDataGetter($=>{var U=$*c,S=($+1)*c-1;if(S=Math.min(S,g-1),typeof D.chunks[$]>"u"&&(D.chunks[$]=p(U,S)),typeof D.chunks[$]>"u")throw new Error("doXHR failed!");return D.chunks[$]}),(P||!g)&&(c=g=1,g=this.getter(0).length,c=g,He("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=c,this.lengthKnown=true;}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!Q)throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i,l={isDevice:false,contents:s};}else var l={isDevice:false,url:t};var u=a.createFile(e,r,l,n,o);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var d={},v=Object.keys(u.stream_ops);v.forEach(m=>{var h=u.stream_ops[m];d[m]=(...g)=>(a.forceLoadFile(u),h(...g));});function y(m,h,g,C,F){var P=m.node.contents;if(F>=P.length)return 0;var c=Math.min(P.length-F,C);if(P.slice)for(var p=0;p<c;p++)h[g+p]=P[F+p];else for(var p=0;p<c;p++)h[g+p]=P.get(F+p);return c}return d.read=(m,h,g,C,F)=>(a.forceLoadFile(u),y(m,h,g,C,F)),d.mmap=(m,h,g,C,F)=>{a.forceLoadFile(u);var P=Fr();if(!P)throw new a.ErrnoError(48);return y(m,M,P,h,g),{ptr:P,allocated:true}},u.stream_ops=d,u}},L={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(T.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else {var o=L.getStreamFromFD(e);n=o.path;}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return T.join2(n,r)},doStat(e,r,t){var n=e(r);_[t>>2]=n.dev,_[t+4>>2]=n.mode,b[t+8>>2]=n.nlink,_[t+12>>2]=n.uid,_[t+16>>2]=n.gid,_[t+20>>2]=n.rdev,R=[n.size>>>0,(E=n.size,+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+24>>2]=R[0],_[t+28>>2]=R[1],_[t+32>>2]=4096,_[t+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),s=n.ctime.getTime();return R=[Math.floor(o/1e3)>>>0,(E=Math.floor(o/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+40>>2]=R[0],_[t+44>>2]=R[1],b[t+48>>2]=o%1e3*1e3,R=[Math.floor(i/1e3)>>>0,(E=Math.floor(i/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+56>>2]=R[0],_[t+60>>2]=R[1],b[t+64>>2]=i%1e3*1e3,R=[Math.floor(s/1e3)>>>0,(E=Math.floor(s/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+72>>2]=R[0],_[t+76>>2]=R[1],b[t+80>>2]=s%1e3*1e3,R=[n.ino>>>0,(E=n.ino,+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+88>>2]=R[0],_[t+92>>2]=R[1],0},doMsync(e,r,t,n,o){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var i=O.slice(e,e+t);a.msync(r,i,o,t,n);},varargs:void 0,get(){var e=_[+L.varargs>>2];return L.varargs+=4,e},getp(){return L.get()},getStr(e){var r=K(e);return r},getStreamFromFD(e){var r=a.getStreamChecked(e);return r}};function Et(e,r,t){try{return r=L.getStr(r),r=L.calculateAt(e,r),t===0?a.unlink(r):t===512?a.rmdir(r):re("Invalid flags passed to unlinkat"),0}catch(n){if(typeof a>"u"||n.name!=="ErrnoError")throw n;return -n.errno}}var $e={},Ye=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r);}};function ue(e){return this.fromWireType(b[e>>2])}var ne={},J={},ke={},Sr,Pe=e=>{throw new Sr(e)},Z=(e,r,t)=>{e.forEach(function(l){ke[l]=r;});function n(l){var u=t(l);u.length!==e.length&&Pe("Mismatched type converter count");for(var d=0;d<e.length;++d)x(e[d],u[d]);}var o=new Array(r.length),i=[],s=0;r.forEach((l,u)=>{J.hasOwnProperty(l)?o[u]=J[l]:(i.push(l),ne.hasOwnProperty(l)||(ne[l]=[]),ne[l].push(()=>{o[u]=J[l],++s,s===i.length&&n(o);}));}),i.length===0&&n(o);},bt=e=>{var r=$e[e];delete $e[e];var t=r.rawConstructor,n=r.rawDestructor,o=r.fields,i=o.map(s=>s.getterReturnType).concat(o.map(s=>s.setterArgumentType));Z([e],i,s=>{var l={};return o.forEach((u,d)=>{var v=u.fieldName,y=s[d],m=u.getter,h=u.getterContext,g=s[d+o.length],C=u.setter,F=u.setterContext;l[v]={read:P=>y.fromWireType(m(h,P)),write:(P,c)=>{var p=[];C(F,P,g.toWireType(p,c)),Ye(p);}};}),[{name:r.name,fromWireType:u=>{var d={};for(var v in l)d[v]=l[v].read(u);return n(u),d},toWireType:(u,d)=>{for(var v in l)if(!(v in d))throw new TypeError(`Missing field: "${v}"`);var y=t();for(v in l)l[v].write(y,d[v]);return u!==null&&u.push(n,y),y},argPackAdvance:z,readValueFromPointer:ue,destructorFunction:n}]});},$t=(e,r,t,n,o)=>{},kt=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Dr=e;},Dr,j=e=>{for(var r="",t=e;O[t];)r+=Dr[O[t++]];return r},ae,k=e=>{throw new ae(e)};function Pt(e,r,t={}){var n=r.name;if(e||k(`type "${n}" must have a positive integer typeid pointer`),J.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;k(`Cannot register type '${n}' twice`);}if(J[e]=r,delete ke[e],ne.hasOwnProperty(e)){var o=ne[e];delete ne[e],o.forEach(i=>i());}}function x(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Pt(e,r,t)}var z=8,Ct=(e,r,t,n)=>{r=j(r),x(e,{name:r,fromWireType:function(o){return !!o},toWireType:function(o,i){return i?t:n},argPackAdvance:z,readValueFromPointer:function(o){return this.fromWireType(O[o])},destructorFunction:null});},Tt=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),qe=e=>{function r(t){return t.$$.ptrType.registeredClass.name}k(r(e)+" instance already deleted");},Xe=false,Ar=e=>{},Ft=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr);},Rr=e=>{e.count.value-=1;var r=e.count.value===0;r&&Ft(e);},Mr=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=Mr(e,r,t.baseClass);return n===null?null:t.downcast(n)},jr={},St=()=>Object.keys(ce).length,Dt=()=>{var e=[];for(var r in ce)ce.hasOwnProperty(r)&&e.push(ce[r]);return e},fe=[],Ge=()=>{for(;fe.length;){var e=fe.pop();e.$$.deleteScheduled=false,e.delete();}},de,At=e=>{de=e,fe.length&&de&&de(Ge);},Rt=()=>{f.getInheritedInstanceCount=St,f.getLiveInheritedInstances=Dt,f.flushPendingDeletes=Ge,f.setDelayFunction=At;},ce={},Mt=(e,r)=>{for(r===void 0&&k("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},jt=(e,r)=>(r=Mt(e,r),ce[r]),Ce=(e,r)=>{(!r.ptrType||!r.ptr)&&Pe("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Pe("Both smartPtrType and smartPtr must be specified"),r.count={value:1},ve(Object.create(e,{$$:{value:r,writable:true}}))};function Ot(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=jt(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function o(){return this.isSmartPointer?Ce(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Ce(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i=this.registeredClass.getActualType(r),s=jr[i];if(!s)return o.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var u=Mr(r,this.registeredClass,l.registeredClass);return u===null?o.call(this):this.isSmartPointer?Ce(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:e}):Ce(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var ve=e=>typeof FinalizationRegistry>"u"?(ve=r=>r,e):(Xe=new FinalizationRegistry(r=>{Rr(r.$$);}),ve=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var o={$$:t};Xe.register(r,o,r);}return r},Ar=r=>Xe.unregister(r),ve(e)),Wt=()=>{Object.assign(Te.prototype,{isAliasOf(e){if(!(this instanceof Te)||!(e instanceof Te))return false;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,o=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return r===n&&t===o},clone(){if(this.$$.ptr||qe(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=ve(Object.create(Object.getPrototypeOf(this),{$$:{value:Tt(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=false,e},delete(){this.$$.ptr||qe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&k("Object already scheduled for deletion"),Ar(this),Rr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0);},isDeleted(){return !this.$$.ptr},deleteLater(){return this.$$.ptr||qe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&k("Object already scheduled for deletion"),fe.push(this),fe.length===1&&de&&de(Ge),this.$$.deleteScheduled=true,this}});};function Te(){}var he=(e,r)=>Object.defineProperty(r,"name",{value:e}),Or=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...o){return e[r].overloadTable.hasOwnProperty(o.length)||k(`Function '${t}' called with an invalid number of arguments (${o.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[o.length].apply(this,o)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n;}},Ke=(e,r,t)=>{f.hasOwnProperty(e)?((t===void 0||f[e].overloadTable!==void 0&&f[e].overloadTable[t]!==void 0)&&k(`Cannot register public name '${e}' twice`),Or(f,e,e),f.hasOwnProperty(t)&&k(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),f[e].overloadTable[t]=r):(f[e]=r,t!==void 0&&(f[e].numArguments=t));},Ut=48,Ht=57,It=e=>{if(e===void 0)return "_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Ut&&r<=Ht?`_${e}`:e};function Lt(e,r,t,n,o,i,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[];}var Je=(e,r,t)=>{for(;r!==t;)r.upcast||k(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function xt(e,r){if(r===null)return this.isReference&&k(`null is not a valid ${this.name}`),0;r.$$||k(`Cannot pass "${nr(r)}" as a ${this.name}`),r.$$.ptr||k(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Je(r.$$.ptr,t,this.registeredClass);return n}function zt(e,r){var t;if(r===null)return this.isReference&&k(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&k(`Cannot pass "${nr(r)}" as a ${this.name}`),r.$$.ptr||k(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&k(`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(r.$$.smartPtr===void 0&&k("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:k(`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 o=r.clone();t=this.rawShare(t,W.toHandle(()=>o.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:k("Unsupporting sharing policy");}return t}function Nt(e,r){if(r===null)return this.isReference&&k(`null is not a valid ${this.name}`),0;r.$$||k(`Cannot pass "${nr(r)}" as a ${this.name}`),r.$$.ptr||k(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&k(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Je(r.$$.ptr,t,this.registeredClass);return n}var Bt=()=>{Object.assign(Fe.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e);},argPackAdvance:z,readValueFromPointer:ue,fromWireType:Ot});};function Fe(e,r,t,n,o,i,s,l,u,d,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=d,this.rawDestructor=v,!o&&r.baseClass===void 0?n?(this.toWireType=xt,this.destructorFunction=null):(this.toWireType=Nt,this.destructorFunction=null):this.toWireType=zt;}var Wr=(e,r,t)=>{f.hasOwnProperty(e)||Pe("Replacing nonexistent public symbol"),f[e].overloadTable!==void 0&&t!==void 0?f[e].overloadTable[t]=r:(f[e]=r,f[e].argCount=t);},Vt=(e,r,t)=>{var n=f["dynCall_"+e];return n(r,...t)},Se=[],Ur,Hr=e=>{var r=Se[e];return r||(e>=Se.length&&(Se.length=e+1),Se[e]=r=Ur.get(e)),r},Yt=(e,r,t=[])=>{if(e.includes("j"))return Vt(e,r,t);var n=Hr(r)(...t);return n},qt=(e,r)=>(...t)=>Yt(e,r,t),I=(e,r)=>{e=j(e);function t(){return e.includes("j")?qt(e,r):Hr(r)}var n=t();return typeof n!="function"&&k(`unknown function pointer with signature ${e}: ${r}`),n},Xt=(e,r)=>{var t=he(r,function(n){this.name=r,this.message=n;var o=new Error(n).stack;o!==void 0&&(this.stack=this.toString()+`
|
|
4
|
-
`+o.replace(/^Error(:[^\n]*)?\n/,""));});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},Ir,Lr=e=>{var r=Yr(e),t=j(r);return V(r),t},De=(e,r)=>{var t=[],n={};function o(i){if(!n[i]&&!J[i]){if(ke[i]){ke[i].forEach(o);return}t.push(i),n[i]=true;}}throw r.forEach(o),new Ir(`${e}: `+t.map(Lr).join([", "]))},Gt=(e,r,t,n,o,i,s,l,u,d,v,y,m)=>{v=j(v),i=I(o,i),l&&=I(s,l),d&&=I(u,d),m=I(y,m);var h=It(v);Ke(h,function(){De(`Cannot construct ${v} due to unbound types`,[n]);}),Z([e,r,t],n?[n]:[],g=>{g=g[0];var C,F;n?(C=g.registeredClass,F=C.instancePrototype):F=Te.prototype;var P=he(v,function(...S){if(Object.getPrototypeOf(this)!==c)throw new ae("Use 'new' to construct "+v);if(p.constructor_body===void 0)throw new ae(v+" has no accessible constructor");var Gr=p.constructor_body[S.length];if(Gr===void 0)throw new ae(`Tried to invoke ctor of ${v} with invalid number of parameters (${S.length}) - expected (${Object.keys(p.constructor_body).toString()}) parameters instead!`);return Gr.apply(this,S)}),c=Object.create(F,{constructor:{value:P}});P.prototype=c;var p=new Lt(v,P,c,m,C,i,l,d);p.baseClass&&(p.baseClass.__derivedClasses??=[],p.baseClass.__derivedClasses.push(p));var D=new Fe(v,p,true,false,false),$=new Fe(v+"*",p,false,false,false),U=new Fe(v+" const*",p,false,true,false);return jr[e]={pointerType:$,constPointerType:U},Wr(h,P),[D,$,U]});},Ze=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(b[r+n*4>>2]);return t};function Kt(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return true;return false}function Qe(e,r,t,n,o,i){var s=r.length;s<2&&k("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=r[1]!==null&&t!==null,u=Kt(r),d=r[0].name!=="void",v=s-2,y=new Array(v),m=[],h=[],g=function(...C){C.length!==v&&k(`function ${e} called with ${C.length} arguments, expected ${v}`),h.length=0;var F;m.length=l?2:1,m[0]=o,l&&(F=r[1].toWireType(h,this),m[1]=F);for(var P=0;P<v;++P)y[P]=r[P+2].toWireType(h,C[P]),m.push(y[P]);var c=n(...m);function p(D){if(u)Ye(h);else for(var $=l?1:2;$<r.length;$++){var U=$===1?F:y[$-2];r[$].destructorFunction!==null&&r[$].destructorFunction(U);}if(d)return r[0].fromWireType(D)}return p(c)};return he(e,g)}var Jt=(e,r,t,n,o,i)=>{var s=Ze(r,t);o=I(n,o),Z([],[e],l=>{l=l[0];var u=`constructor ${l.name}`;if(l.registeredClass.constructor_body===void 0&&(l.registeredClass.constructor_body=[]),l.registeredClass.constructor_body[r-1]!==void 0)throw new ae(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${l.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return l.registeredClass.constructor_body[r-1]=()=>{De(`Cannot construct ${l.name} due to unbound types`,s);},Z([],s,d=>(d.splice(1,0,null),l.registeredClass.constructor_body[r-1]=Qe(u,d,null,o,i),[])),[]});},xr=e=>{e=e.trim();let r=e.indexOf("(");return r!==-1?e.substr(0,r):e},Zt=(e,r,t,n,o,i,s,l,u)=>{var d=Ze(t,n);r=j(r),r=xr(r),i=I(o,i),Z([],[e],v=>{v=v[0];var y=`${v.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&v.registeredClass.pureVirtualFunctions.push(r);function m(){De(`Cannot call ${y} due to unbound types`,d);}var h=v.registeredClass.instancePrototype,g=h[r];return g===void 0||g.overloadTable===void 0&&g.className!==v.name&&g.argCount===t-2?(m.argCount=t-2,m.className=v.name,h[r]=m):(Or(h,r,y),h[r].overloadTable[t-2]=m),Z([],d,C=>{var F=Qe(y,C,v,i,s);return h[r].overloadTable===void 0?(F.argCount=t-2,h[r]=F):h[r].overloadTable[t-2]=F,[]}),[]});},er=[],B=[],rr=e=>{e>9&&--B[e+1]===0&&(B[e]=void 0,er.push(e));},Qt=()=>B.length/2-5-er.length,en=()=>{B.push(0,1,void 0,1,null,1,true,1,false,1),f.count_emval_handles=Qt;},W={toValue:e=>(e||k("Cannot use deleted val. handle = "+e),B[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case true:return 6;case false:return 8;default:{let r=er.pop()||B.length;return B[r]=e,B[r+1]=1,r}}}},rn={name:"emscripten::val",fromWireType:e=>{var r=W.toValue(e);return rr(e),r},toWireType:(e,r)=>W.toHandle(r),argPackAdvance:z,readValueFromPointer:ue,destructorFunction:null},tn=e=>x(e,rn),nn=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType(M[n])}:function(n){return this.fromWireType(O[n])};case 2:return t?function(n){return this.fromWireType(ee[n>>1])}:function(n){return this.fromWireType(se[n>>1])};case 4:return t?function(n){return this.fromWireType(_[n>>2])}:function(n){return this.fromWireType(b[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},an=(e,r,t,n)=>{r=j(r);function o(){}o.values={},x(e,{name:r,constructor:o,fromWireType:function(i){return this.constructor.values[i]},toWireType:(i,s)=>s.value,argPackAdvance:z,readValueFromPointer:nn(r,t,n),destructorFunction:null}),Ke(r,o);},tr=(e,r)=>{var t=J[e];return t===void 0&&k(`${r} has unknown type ${Lr(e)}`),t},on=(e,r,t)=>{var n=tr(e,"enum");r=j(r);var o=n.constructor,i=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:he(`${n.name}_${r}`,function(){})}});o.values[t]=i,o[r]=i;},nr=e=>{if(e===null)return "null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},sn=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(pr[t>>2])};case 8:return function(t){return this.fromWireType(mr[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},ln=(e,r,t)=>{r=j(r),x(e,{name:r,fromWireType:n=>n,toWireType:(n,o)=>o,argPackAdvance:z,readValueFromPointer:sn(r,t),destructorFunction:null});},un=(e,r,t,n,o,i,s)=>{var l=Ze(r,t);e=j(e),e=xr(e),o=I(n,o),Ke(e,function(){De(`Cannot call ${e} due to unbound types`,l);},r-1),Z([],l,u=>{var d=[u[0],null].concat(u.slice(1));return Wr(e,Qe(e,d,null,o,i),r-1),[]});},fn=(e,r,t)=>{switch(r){case 1:return t?n=>M[n]:n=>O[n];case 2:return t?n=>ee[n>>1]:n=>se[n>>1];case 4:return t?n=>_[n>>2]:n=>b[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},dn=(e,r,t,n,o)=>{r=j(r);var i=v=>v;if(n===0){var s=32-8*t;i=v=>v<<s>>>s;}var l=r.includes("unsigned"),u=(v,y)=>{},d;l?d=function(v,y){return u(y,this.name),y>>>0}:d=function(v,y){return u(y,this.name),y},x(e,{name:r,fromWireType:i,toWireType:d,argPackAdvance:z,readValueFromPointer:fn(r,t,n!==0),destructorFunction:null});},cn=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],o=n[r];function i(s){var l=b[s>>2],u=b[s+4>>2];return new o(M.buffer,u,l)}t=j(t),x(e,{name:t,fromWireType:i,argPackAdvance:z,readValueFromPointer:i},{ignoreDuplicateRegistrations:true});},vn=(e,r,t)=>Be(e,O,r,t),hn=(e,r)=>{r=j(r);var t=r==="std::string";x(e,{name:r,fromWireType(n){var o=b[n>>2],i=n+4,s;if(t)for(var l=i,u=0;u<=o;++u){var d=i+u;if(u==o||O[d]==0){var v=d-l,y=K(l,v);s===void 0?s=y:(s+="\0",s+=y),l=d+1;}}else {for(var m=new Array(o),u=0;u<o;++u)m[u]=String.fromCharCode(O[i+u]);s=m.join("");}return V(n),s},toWireType(n,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var i,s=typeof o=="string";s||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||k("Cannot pass non-string to std::string"),t&&s?i=Ne(o):i=o.length;var l=ir(4+i+1),u=l+4;if(b[l>>2]=i,t&&s)vn(o,u,i+1);else if(s)for(var d=0;d<i;++d){var v=o.charCodeAt(d);v>255&&(V(u),k("String has UTF-16 code units that do not fit in 8 bits")),O[u+d]=v;}else for(var d=0;d<i;++d)O[u+d]=o[d];return n!==null&&n.push(V,l),l},argPackAdvance:z,readValueFromPointer:ue,destructorFunction(n){V(n);}});},zr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,pn=(e,r)=>{for(var t=e,n=t>>1,o=n+r/2;!(n>=o)&&se[n];)++n;if(t=n<<1,t-e>32&&zr)return zr.decode(O.subarray(e,t));for(var i="",s=0;!(s>=r/2);++s){var l=ee[e+s*2>>1];if(l==0)break;i+=String.fromCharCode(l);}return i},mn=(e,r,t)=>{if(t??=2147483647,t<2)return 0;t-=2;for(var n=r,o=t<e.length*2?t/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);ee[r>>1]=s,r+=2;}return ee[r>>1]=0,r-n},yn=e=>e.length*2,gn=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var o=_[e+t*4>>2];if(o==0)break;if(++t,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|i&1023);}else n+=String.fromCharCode(o);}return n},wn=(e,r,t)=>{if(t??=2147483647,t<4)return 0;for(var n=r,o=n+t-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343){var l=e.charCodeAt(++i);s=65536+((s&1023)<<10)|l&1023;}if(_[r>>2]=s,r+=4,r+4>o)break}return _[r>>2]=0,r-n},_n=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},En=(e,r,t)=>{t=j(t);var n,o,i,s;r===2?(n=pn,o=mn,s=yn,i=l=>se[l>>1]):r===4&&(n=gn,o=wn,s=_n,i=l=>b[l>>2]),x(e,{name:t,fromWireType:l=>{for(var u=b[l>>2],d,v=l+4,y=0;y<=u;++y){var m=l+4+y*r;if(y==u||i(m)==0){var h=m-v,g=n(v,h);d===void 0?d=g:(d+="\0",d+=g),v=m+r;}}return V(l),d},toWireType:(l,u)=>{typeof u!="string"&&k(`Cannot pass non-string to C++ string type ${t}`);var d=s(u),v=ir(4+d+r);return b[v>>2]=d/r,o(u,v+4,d+r),l!==null&&l.push(V,v),v},argPackAdvance:z,readValueFromPointer:ue,destructorFunction(l){V(l);}});},bn=(e,r,t,n,o,i)=>{$e[e]={name:j(r),rawConstructor:I(t,n),rawDestructor:I(o,i),fields:[]};},$n=(e,r,t,n,o,i,s,l,u,d)=>{$e[e].fields.push({fieldName:j(r),getterReturnType:t,getter:I(n,o),getterContext:i,setterArgumentType:s,setter:I(l,u),setterContext:d});},kn=(e,r)=>{r=j(r),x(e,{isVoid:true,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}});},Ae=[],Pn=(e,r,t,n)=>(e=Ae[e],r=W.toValue(r),e(null,r,t,n)),Cn={},ar=e=>{var r=Cn[e];return r===void 0?j(e):r},Tn=(e,r,t,n,o)=>(e=Ae[e],r=W.toValue(r),t=ar(t),e(r,r[t],n,o)),Nr=()=>{if(typeof globalThis=="object")return globalThis;function e(r){r.$$$embind_global$$$=r;var t=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return t||delete r.$$$embind_global$$$,t}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&e(global)?$$$embind_global$$$=global:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")},Fn=e=>e===0?W.toHandle(Nr()):(e=ar(e),W.toHandle(Nr()[e])),Sn=e=>{var r=Ae.length;return Ae.push(e),r},Dn=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=tr(b[r+n*4>>2],"parameter "+n);return t},An=Reflect.construct,Rn=(e,r,t)=>{var n=[],o=e.toWireType(n,t);return n.length&&(b[r>>2]=W.toHandle(n)),o},Mn=(e,r,t)=>{var n=Dn(e,r),o=n.shift();e--;var i=new Array(e),s=(u,d,v,y)=>{for(var m=0,h=0;h<e;++h)i[h]=n[h].readValueFromPointer(y+m),m+=n[h].argPackAdvance;var g=t===1?An(d,i):d.apply(u,i);return Rn(o,v,g)},l=`methodCaller<(${n.map(u=>u.name).join(", ")}) => ${o.name}>`;return Sn(he(l,s))},jn=e=>{e>9&&(B[e+1]+=1);},On=()=>W.toHandle([]),Wn=e=>W.toHandle(ar(e)),Un=()=>W.toHandle({}),Hn=e=>{var r=W.toValue(e);Ye(r),rr(e);},In=(e,r,t)=>{e=W.toValue(e),r=W.toValue(r),t=W.toValue(t),e[r]=t;},Ln=(e,r)=>{e=tr(e,"_emval_take_value");var t=e.readValueFromPointer(r);return W.toHandle(t)},xn=()=>{re("");},zn=(e,r,t)=>O.copyWithin(e,r,r+t),Nn=()=>2147483648,Bn=e=>{var r=_e.buffer,t=(e-r.byteLength+65535)/65536;try{return _e.grow(t),yr(),1}catch{}},Vn=e=>{var r=O.length;e>>>=0;var t=Nn();if(e>t)return false;for(var n=(u,d)=>u+(d-u%d)%d,o=1;o<=4;o*=2){var i=r*(1+.2/o);i=Math.min(i,e+100663296);var s=Math.min(t,n(Math.max(e,i),65536)),l=Bn(s);if(l)return true}return false},or={},Yn=()=>je||"./this.program",pe=()=>{if(!pe.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Yn()};for(var t in or)or[t]===void 0?delete r[t]:r[t]=or[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);pe.strings=n;}return pe.strings},qn=(e,r)=>{for(var t=0;t<e.length;++t)M[r++]=e.charCodeAt(t);M[r]=0;},Xn=(e,r)=>{var t=0;return pe().forEach((n,o)=>{var i=r+t;b[e+o*4>>2]=i,qn(n,i),t+=n.length+1;}),0},Gn=(e,r)=>{var t=pe();b[e>>2]=t.length;var n=0;return t.forEach(o=>n+=o.length+1),b[r>>2]=n,0};function Kn(e){try{var r=L.getStreamFromFD(e);return a.close(r),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Jn=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=b[r>>2],l=b[r+4>>2];r+=8;var u=a.read(e,M,s,l,n);if(u<0)return -1;if(o+=u,u<l)break;}return o};function Zn(e,r,t,n){try{var o=L.getStreamFromFD(e),i=Jn(o,r,t);return b[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Qn=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN;function ea(e,r,t,n,o){var i=Qn(r,t);try{if(isNaN(i))return 61;var s=L.getStreamFromFD(e);return a.llseek(s,i,n),R=[s.position>>>0,(E=s.position,+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[o>>2]=R[0],_[o+4>>2]=R[1],s.getdents&&i===0&&n===0&&(s.getdents=null),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var ra=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=b[r>>2],l=b[r+4>>2];r+=8;var u=a.write(e,M,s,l,n);if(u<0)return -1;o+=u;}return o};function ta(e,r,t,n){try{var o=L.getStreamFromFD(e),i=ra(o,r,t);return b[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Re=e=>e%4===0&&(e%100!==0||e%400===0),na=(e,r)=>{for(var t=0,n=0;n<=r;t+=e[n++]);return t},Br=[31,29,31,30,31,30,31,31,30,31,30,31],Vr=[31,28,31,30,31,30,31,31,30,31,30,31],aa=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var n=Re(t.getFullYear()),o=t.getMonth(),i=(n?Br:Vr)[o];if(r>i-t.getDate())r-=i-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t},oa=(e,r)=>{M.set(e,r);},ia=(e,r,t,n)=>{var o=b[n+40>>2],i={tm_sec:_[n>>2],tm_min:_[n+4>>2],tm_hour:_[n+8>>2],tm_mday:_[n+12>>2],tm_mon:_[n+16>>2],tm_year:_[n+20>>2],tm_wday:_[n+24>>2],tm_yday:_[n+28>>2],tm_isdst:_[n+32>>2],tm_gmtoff:_[n+36>>2],tm_zone:o?K(o):""},s=K(t),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in l)s=s.replace(new RegExp(u,"g"),l[u]);var d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],v=["January","February","March","April","May","June","July","August","September","October","November","December"];function y(c,p,D){for(var $=typeof c=="number"?c.toString():c||"";$.length<p;)$=D[0]+$;return $}function m(c,p){return y(c,p,"0")}function h(c,p){function D(U){return U<0?-1:U>0?1:0}var $;return ($=D(c.getFullYear()-p.getFullYear()))===0&&($=D(c.getMonth()-p.getMonth()))===0&&($=D(c.getDate()-p.getDate())),$}function g(c){switch(c.getDay()){case 0:return new Date(c.getFullYear()-1,11,29);case 1:return c;case 2:return new Date(c.getFullYear(),0,3);case 3:return new Date(c.getFullYear(),0,2);case 4:return new Date(c.getFullYear(),0,1);case 5:return new Date(c.getFullYear()-1,11,31);case 6:return new Date(c.getFullYear()-1,11,30)}}function C(c){var p=aa(new Date(c.tm_year+1900,0,1),c.tm_yday),D=new Date(p.getFullYear(),0,4),$=new Date(p.getFullYear()+1,0,4),U=g(D),S=g($);return h(U,p)<=0?h(S,p)<=0?p.getFullYear()+1:p.getFullYear():p.getFullYear()-1}var F={"%a":c=>d[c.tm_wday].substring(0,3),"%A":c=>d[c.tm_wday],"%b":c=>v[c.tm_mon].substring(0,3),"%B":c=>v[c.tm_mon],"%C":c=>{var p=c.tm_year+1900;return m(p/100|0,2)},"%d":c=>m(c.tm_mday,2),"%e":c=>y(c.tm_mday,2," "),"%g":c=>C(c).toString().substring(2),"%G":C,"%H":c=>m(c.tm_hour,2),"%I":c=>{var p=c.tm_hour;return p==0?p=12:p>12&&(p-=12),m(p,2)},"%j":c=>m(c.tm_mday+na(Re(c.tm_year+1900)?Br:Vr,c.tm_mon-1),3),"%m":c=>m(c.tm_mon+1,2),"%M":c=>m(c.tm_min,2),"%n":()=>`
|
|
5
|
-
`,"%p":c=>c.tm_hour>=0&&c.tm_hour<12?"AM":"PM","%S":c=>m(c.tm_sec,2),"%t":()=>" ","%u":c=>c.tm_wday||7,"%U":c=>{var p=c.tm_yday+7-c.tm_wday;return m(Math.floor(p/7),2)},"%V":c=>{var p=Math.floor((c.tm_yday+7-(c.tm_wday+6)%7)/7);if((c.tm_wday+371-c.tm_yday-2)%7<=2&&p++,p){if(p==53){var $=(c.tm_wday+371-c.tm_yday)%7;$!=4&&($!=3||!Re(c.tm_year))&&(p=1);}}else {p=52;var D=(c.tm_wday+7-c.tm_yday-1)%7;(D==4||D==5&&Re(c.tm_year%400-1))&&p++;}return m(p,2)},"%w":c=>c.tm_wday,"%W":c=>{var p=c.tm_yday+7-(c.tm_wday+6)%7;return m(Math.floor(p/7),2)},"%y":c=>(c.tm_year+1900).toString().substring(2),"%Y":c=>c.tm_year+1900,"%z":c=>{var p=c.tm_gmtoff,D=p>=0;return p=Math.abs(p)/60,p=p/60*100+p%60,(D?"+":"-")+("0000"+p).slice(-4)},"%Z":c=>c.tm_zone,"%%":()=>"%"};s=s.replace(/%%/g,"\0\0");for(var u in F)s.includes(u)&&(s=s.replace(new RegExp(u,"g"),F[u](i)));s=s.replace(/\0\0/g,"%");var P=be(s,false);return P.length>r?0:(oa(P,e),P.length-1)},sa=(e,r,t,n,o)=>ia(e,r,t,n);a.createPreloadedFile=wt,a.staticInit(),Sr=f.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},kt(),ae=f.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Wt(),Rt(),Bt(),Ir=f.UnboundTypeError=Xt(Error,"UnboundTypeError"),en();var la={a:ut,m:ct,F:Et,O:bt,C:$t,M:Ct,o:Gt,A:Jt,y:Zt,L:tn,j:an,b:on,x:ln,e:un,i:dn,f:cn,w:hn,r:En,P:bn,t:$n,N:kn,p:Pn,z:Tn,c:rr,Q:Fn,l:Mn,q:jn,s:On,h:Wn,n:Un,k:Hn,g:In,d:Ln,u:xn,K:zn,E:Vn,I:Xn,J:Gn,G:Kn,H:Zn,B:ea,v:ta,D:sa},A=lt(),ir=e=>(ir=A.T)(e),V=e=>(V=A.V)(e),Yr=e=>(Yr=A.W)(e),qr=e=>(qr=A.X)(e);f.dynCall_ji=(e,r)=>(f.dynCall_ji=A.Y)(e,r);f.dynCall_iij=(e,r,t,n)=>(f.dynCall_iij=A.Z)(e,r,t,n);f.dynCall_jijj=(e,r,t,n,o,i)=>(f.dynCall_jijj=A._)(e,r,t,n,o,i);f.dynCall_vijj=(e,r,t,n,o,i)=>(f.dynCall_vijj=A.$)(e,r,t,n,o,i);f.dynCall_jiji=(e,r,t,n,o)=>(f.dynCall_jiji=A.aa)(e,r,t,n,o);f.dynCall_viijii=(e,r,t,n,o,i,s)=>(f.dynCall_viijii=A.ba)(e,r,t,n,o,i,s);f.dynCall_iiiiij=(e,r,t,n,o,i,s)=>(f.dynCall_iiiiij=A.ca)(e,r,t,n,o,i,s);f.dynCall_iiiiijj=(e,r,t,n,o,i,s,l,u)=>(f.dynCall_iiiiijj=A.da)(e,r,t,n,o,i,s,l,u);f.dynCall_iiiiiijj=(e,r,t,n,o,i,s,l,u,d)=>(f.dynCall_iiiiiijj=A.ea)(e,r,t,n,o,i,s,l,u,d);var Me;le=function e(){Me||Xr(),Me||(le=e);};function Xr(){if(X>0||(Qr(),X>0))return;function e(){Me||(Me=true,f.calledRun=true,!hr&&(et(),ur(f),f.onRuntimeInitialized&&f.onRuntimeInitialized(),rt()));}f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("");},1),e();},1)):e();}if(f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.pop()();return Xr(),lr.ready})})(),ka=wa;export{ka as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
'use strict';var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var wa=(()=>{var sr=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('heic-decoder-L3ME46HT.js', document.baseURI).href));return(async function(lr={}){var f=lr,ur,me;f.ready=new Promise((e,r)=>{ur=e,me=r;});var fr=Object.assign({},f),je="./this.program",vr=typeof window=="object",Q=typeof importScripts=="function",ye=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",H="";function Kr(e){return f.locateFile?f.locateFile(e,H):H+e}var oe,Oe,ge;if(ye){let{createRequire:e}=await import('module');var we=e((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('heic-decoder-L3ME46HT.js', document.baseURI).href))),We=we("fs"),Ue=we("path");Q?H=Ue.dirname(H)+"/":H=we("url").fileURLToPath(new URL("./",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('heic-decoder-L3ME46HT.js', document.baseURI).href)))),oe=(r,t)=>(r=br(r)?new URL(r):Ue.normalize(r),We.readFileSync(r,t?void 0:"utf8")),ge=r=>{var t=oe(r,true);return t.buffer||(t=new Uint8Array(t)),t},Oe=(r,t,n,o=true)=>{r=br(r)?new URL(r):Ue.normalize(r),We.readFile(r,o?void 0:"utf8",(i,s)=>{i?n(i):t(o?s.buffer:s);});},!f.thisProgram&&process.argv.length>1&&(je=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2);}else (vr||Q)&&(Q?H=self.location.href:typeof document<"u"&&document.currentScript&&(H=document.currentScript.src),sr&&(H=sr),H.startsWith("blob:")?H="":H=H.substr(0,H.replace(/[?#].*/,"").lastIndexOf("/")+1),oe=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.send(null),r.responseText},Q&&(ge=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Oe=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,true),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t();},n.onerror=t,n.send(null);});var He=f.print||console.log.bind(console),Y=f.printErr||console.error.bind(console);Object.assign(f,fr),fr=null,f.arguments&&(f.arguments),f.thisProgram&&(je=f.thisProgram),f.quit&&(f.quit);var ie;f.wasmBinary&&(ie=f.wasmBinary);var _e,hr=false,M,O,ee,se,_,b,pr,mr;function yr(){var e=_e.buffer;f.HEAP8=M=new Int8Array(e),f.HEAP16=ee=new Int16Array(e),f.HEAPU8=O=new Uint8Array(e),f.HEAPU16=se=new Uint16Array(e),f.HEAP32=_=new Int32Array(e),f.HEAPU32=b=new Uint32Array(e),f.HEAPF32=pr=new Float32Array(e),f.HEAPF64=mr=new Float64Array(e);}var gr=[],wr=[],_r=[];function Qr(){if(f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)tt(f.preRun.shift());xe(gr);}function et(){!f.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=false,xe(wr);}function rt(){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)at(f.postRun.shift());xe(_r);}function tt(e){gr.unshift(e);}function nt(e){wr.unshift(e);}function at(e){_r.unshift(e);}var X=0,le=null;function Le(e){X++,f.monitorRunDependencies?.(X);}function Ee(e){if(X--,f.monitorRunDependencies?.(X),X==0&&(le)){var r=le;le=null,r();}}function re(e){f.onAbort?.(e),e="Aborted("+e+")",Y(e),hr=true,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw me(r),r}var ot="data:application/octet-stream;base64,",Er=e=>e.startsWith(ot),br=e=>e.startsWith("file://"),G;f.locateFile?(G="heic-decoder.wasm",Er(G)||(G=Kr(G))):G=new URL("heic-decoder.wasm",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('heic-decoder-L3ME46HT.js', document.baseURI).href))).href;function $r(e){if(e==G&&ie)return new Uint8Array(ie);if(ge)return ge(e);throw "both async and sync fetching of the wasm failed"}function it(e){return !ie&&(vr||Q)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw `failed to load wasm binary file at '${e}'`;return r.arrayBuffer()}).catch(()=>$r(e)):Promise.resolve().then(()=>$r(e))}function kr(e,r,t){return it(e).then(n=>WebAssembly.instantiate(n,r)).then(t,n=>{Y(`failed to asynchronously prepare wasm: ${n}`),re(n);})}function st(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!Er(r)&&!ye&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(o=>{var i=WebAssembly.instantiateStreaming(o,t);return i.then(n,function(s){return Y(`wasm streaming compile failed: ${s}`),Y("falling back to ArrayBuffer instantiation"),kr(r,t,n)})}):kr(r,t,n)}function lt(){var e={a:la};function r(n,o){return A=n.exports,_e=A.R,yr(),Ur=A.U,nt(A.S),Ee(),A}Le();function t(n){r(n.instance);}if(f.instantiateWasm)try{return f.instantiateWasm(e,r)}catch(n){Y(`Module.instantiateWasm callback failed with error: ${n}`),me(n);}return st(ie,G,e,t).catch(me),{}}var E,R,xe=e=>{for(;e.length>0;)e.shift()(f);};f.noExitRuntime||true;var Pr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,te=(e,r,t)=>{for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.buffer&&Pr)return Pr.decode(e.subarray(r,o));for(var i="";r<o;){var s=e[r++];if(!(s&128)){i+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|l);continue}var u=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|u:s=(s&7)<<18|l<<12|u<<6|e[r++]&63,s<65536)i+=String.fromCharCode(s);else {var d=s-65536;i+=String.fromCharCode(55296|d>>10,56320|d&1023);}}return i},K=(e,r)=>e?te(O,e,r):"",ut=(e,r,t,n)=>{re(`Assertion failed: ${K(e)}, at: `+[r?K(r):"unknown filename",t,n?K(n):"unknown function"]);};class ft{constructor(r){this.excPtr=r,this.ptr=r-24;}set_type(r){b[this.ptr+4>>2]=r;}get_type(){return b[this.ptr+4>>2]}set_destructor(r){b[this.ptr+8>>2]=r;}get_destructor(){return b[this.ptr+8>>2]}set_caught(r){r=r?1:0,M[this.ptr+12]=r;}get_caught(){return M[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,M[this.ptr+13]=r;}get_rethrown(){return M[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t);}set_adjusted_ptr(r){b[this.ptr+16>>2]=r;}get_adjusted_ptr(){return b[this.ptr+16>>2]}get_exception_ptr(){var r=qr(this.get_type());if(r)return b[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Cr=0,ct=(e,r,t)=>{var n=new ft(e);throw n.init(r,t),Cr=e,Cr},T={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var o=e[n];o==="."?e.splice(n,1):o===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--);}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=T.isAbs(e),t=e.substr(-1)==="/";return e=T.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=T.splitPath(e),t=r[0],n=r[1];return !t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return "/";e=T.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>T.normalize(e.join("/")),join2:(e,r)=>T.normalize(e+"/"+r)},vt=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return n=>crypto.getRandomValues(n);if(ye)try{var e=we("crypto"),r=e.randomFillSync;if(r)return n=>e.randomFillSync(n);var t=e.randomBytes;return n=>(n.set(t(n.byteLength)),n)}catch{}re("initRandomDevice");},Tr=e=>(Tr=vt())(e),N={resolve:(...e)=>{for(var r="",t=false,n=e.length-1;n>=-1&&!t;n--){var o=n>=0?e[n]:a.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return "";r=o+"/"+r,t=T.isAbs(o);}return r=T.normalizeArray(r.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=N.resolve(e).substr(1),r=N.resolve(r).substr(1);function t(d){for(var v=0;v<d.length&&d[v]==="";v++);for(var y=d.length-1;y>=0&&d[y]==="";y--);return v>y?[]:d.slice(v,y-v+1)}for(var n=t(e.split("/")),o=t(r.split("/")),i=Math.min(n.length,o.length),s=i,l=0;l<i;l++)if(n[l]!==o[l]){s=l;break}for(var u=[],l=s;l<n.length;l++)u.push("..");return u=u.concat(o.slice(s)),u.join("/")}},ze=[],Ne=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},Be=(e,r,t,n)=>{if(!(n>0))return 0;for(var o=t,i=t+n-1,s=0;s<e.length;++s){var l=e.charCodeAt(s);if(l>=55296&&l<=57343){var u=e.charCodeAt(++s);l=65536+((l&1023)<<10)|u&1023;}if(l<=127){if(t>=i)break;r[t++]=l;}else if(l<=2047){if(t+1>=i)break;r[t++]=192|l>>6,r[t++]=128|l&63;}else if(l<=65535){if(t+2>=i)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63;}else {if(t+3>=i)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63;}}return r[t]=0,t-o};function be(e,r,t){var n=Ne(e)+1,o=new Array(n),i=Be(e,o,0,o.length);return r&&(o.length=i),o}var ht=()=>{if(!ze.length){var e=null;if(ye){var r=256,t=Buffer.alloc(r),n=0,o=process.stdin.fd;try{n=We.readSync(o,t);}catch(i){if(i.toString().includes("EOF"))n=0;else throw i}n>0?e=t.slice(0,n).toString("utf-8"):e=null;}else typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
2
|
-
`)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
|
|
3
|
-
`));if(!e)return null;ze=be(e,true);}return ze.shift()},q={ttys:[],init(){},shutdown(){},register(e,r){q.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,q.stream_ops);},stream_ops:{open(e){var r=q.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=false;},close(e){e.tty.ops.fsync(e.tty);},fsync(e){e.tty.ops.fsync(e.tty);},read(e,r,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var i=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty);}catch{throw new a.ErrnoError(29)}if(l===void 0&&i===0)throw new a.ErrnoError(6);if(l==null)break;i++,r[t+s]=l;}return i&&(e.node.timestamp=Date.now()),i},write(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,r[t+i]);}catch{throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char(e){return ht()},put_char(e,r){r===null||r===10?(He(te(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(He(te(e.output,0)),e.output=[]);},ioctl_tcgets(e){return {c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return [24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(Y(te(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(Y(te(e.output,0)),e.output=[]);}}},Fr=e=>{re();},w={ops_table:null,mount(e){return w.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);w.ops_table||={dir:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,lookup:w.node_ops.lookup,mknod:w.node_ops.mknod,rename:w.node_ops.rename,unlink:w.node_ops.unlink,rmdir:w.node_ops.rmdir,readdir:w.node_ops.readdir,symlink:w.node_ops.symlink},stream:{llseek:w.stream_ops.llseek}},file:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:{llseek:w.stream_ops.llseek,read:w.stream_ops.read,write:w.stream_ops.write,allocate:w.stream_ops.allocate,mmap:w.stream_ops.mmap,msync:w.stream_ops.msync}},link:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,readlink:w.node_ops.readlink},stream:{}},chrdev:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:a.chrdev_stream_ops}};var o=a.createNode(e,r,t,n);return a.isDir(o.mode)?(o.node_ops=w.ops_table.dir.node,o.stream_ops=w.ops_table.dir.stream,o.contents={}):a.isFile(o.mode)?(o.node_ops=w.ops_table.file.node,o.stream_ops=w.ops_table.file.stream,o.usedBytes=0,o.contents=null):a.isLink(o.mode)?(o.node_ops=w.ops_table.link.node,o.stream_ops=w.ops_table.link.stream):a.isChrdev(o.mode)&&(o.node_ops=w.ops_table.chrdev.node,o.stream_ops=w.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[r]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var o=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(o.subarray(0,e.usedBytes),0);}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else {var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r;}},node_ops:{getattr(e){var r={};return r.dev=a.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,a.isDir(e.mode)?r.size=4096:a.isFile(e.mode)?r.size=e.usedBytes:a.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&w.resizeFileStorage(e,r.size);},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return w.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t);}catch{}if(n)for(var o in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r;},unlink(e,r){delete e.contents[r],e.timestamp=Date.now();},rmdir(e,r){var t=a.lookupNode(e,r);for(var n in t.contents)throw new a.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now();},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var n=w.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(s>8&&i.subarray)r.set(i.subarray(o,o+s),t);else for(var l=0;l<s;l++)r[t+l]=i[o+l];return s},write(e,r,t,n,o,i){if(r.buffer===M.buffer&&(i=false),!n)return 0;var s=e.node;if(s.timestamp=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=r.subarray(t,t+n),s.usedBytes=n,n;if(s.usedBytes===0&&o===0)return s.contents=r.slice(t,t+n),s.usedBytes=n,n;if(o+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),o),n}if(w.expandFileStorage(s,o+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),o);else for(var l=0;l<n;l++)s.contents[o+l]=r[t+l];return s.usedBytes=Math.max(s.usedBytes,o+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&a.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new a.ErrnoError(28);return n},allocate(e,r,t){w.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t);},mmap(e,r,t,n,o){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var i,s,l=e.node.contents;if(!(o&2)&&l.buffer===M.buffer)s=false,i=l.byteOffset;else {if((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),s=true,i=Fr(),!i)throw new a.ErrnoError(48);M.set(l,i);}return {ptr:i,allocated:s}},msync(e,r,t,n,o){return w.stream_ops.write(e,r,0,n,t,false),0}}},pt=(e,r,t,n)=>{var o=`al ${e}`;Oe(e,i=>{r(new Uint8Array(i)),o&&Ee();},i=>{if(t)t();else throw `Loading data file "${e}" failed.`}),o&&Le();},mt=(e,r,t,n,o,i)=>{a.createDataFile(e,r,t,n,o,i);},yt=f.preloadPlugins||[],gt=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var o=false;return yt.forEach(i=>{o||i.canHandle(r)&&(i.handle(e,r,t,n),o=true);}),o},wt=(e,r,t,n,o,i,s,l,u,d)=>{var v=r?N.resolve(T.join2(e,r)):e;function m(h){function g(C){d?.(),l||mt(e,r,C,n,o,u),i?.(),Ee();}gt(h,v,g,()=>{s?.(),Ee();})||g(h);}Le(),typeof t=="string"?pt(t,m,s):m(t);},_t=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},Ve=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e;}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.shared={};}get object(){return this.node}set object(e){this.node=e;}get isRead(){return (this.flags&2097155)!==1}get isWrite(){return (this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e;}get position(){return this.shared.position}set position(e){this.shared.position=e;}},FSNode:class{constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=a.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146;}get read(){return (this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode;}get write(){return (this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode;}get isFolder(){return a.isDir(this.mode)}get isDevice(){return a.isChrdev(this.mode)}},lookupPath(e,r={}){if(e=N.resolve(e),!e)return {path:"",node:null};var t={follow_mount:true,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(y=>!!y),o=a.root,i="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(o=a.lookupNode(o,n[s]),i=T.join2(i,n[s]),a.isMountpoint(o)&&(!l||l&&r.follow_mount)&&(o=o.mounted.root),!l||r.follow)for(var u=0;a.isLink(o.mode);){var d=a.readlink(i);i=N.resolve(T.dirname(i),d);var v=a.lookupPath(i,{recurse_count:r.recurse_count+1});if(o=v.node,u++>40)throw new a.ErrnoError(32)}}return {path:i,node:o}},getPath(e){for(var r;;){if(a.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent;}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return (e+t>>>0)%a.nameTable.length},hashAddNode(e){var r=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[r],a.nameTable[r]=e;},hashRemoveNode(e){var r=a.hashName(e.parent.id,e.name);if(a.nameTable[r]===e)a.nameTable[r]=e.name_next;else for(var t=a.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next;}},lookupNode(e,r){var t=a.mayLookup(e);if(t)throw new a.ErrnoError(t);for(var n=a.hashName(e.id,r),o=a.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===r)return o}return a.lookup(e,r)},createNode(e,r,t,n){var o=new a.FSNode(e,r,t,n);return a.hashAddNode(o),o},destroyNode(e){a.hashRemoveNode(e);},isRoot(e){return e===e.parent},isMountpoint(e){return !!e.mounted},isFile(e){return (e&61440)===32768},isDir(e){return (e&61440)===16384},isLink(e){return (e&61440)===40960},isChrdev(e){return (e&61440)===8192},isBlkdev(e){return (e&61440)===24576},isFIFO(e){return (e&61440)===4096},isSocket(e){return (e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return a.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!a.isDir(e.mode))return 54;var r=a.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){try{var t=a.lookupNode(e,r);return 20}catch{}return a.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=a.lookupNode(e,r);}catch(i){return i.errno}var o=a.nodePermissions(e,"wx");if(o)return o;if(t){if(!a.isDir(n.mode))return 54;if(a.isRoot(n)||a.getPath(n)===a.cwd())return 10}else if(a.isDir(n.mode))return 31;return 0},mayOpen(e,r){return e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked(e){var r=a.getStream(e);if(!r)throw new a.ErrnoError(8);return r},getStream:e=>a.streams[e],createStream(e,r=-1){return e=Object.assign(new a.FSStream,e),r==-1&&(r=a.nextfd()),e.fd=r,a.streams[r]=e,e},closeStream(e){a.streams[e]=null;},dupStream(e,r=-1){var t=a.createStream(e,r);return t.stream_ops?.dup?.(t),t},chrdev_stream_ops:{open(e){var r=a.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e);},llseek(){throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){a.devices[e]={stream_ops:r};},getDevice:e=>a.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts);}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=false),a.syncFSRequests++,a.syncFSRequests>1&&Y(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=a.getMounts(a.root.mount),n=0;function o(s){return a.syncFSRequests--,r(s)}function i(s){if(s)return i.errored?void 0:(i.errored=true,o(s));++n>=t.length&&o(null);}t.forEach(s=>{if(!s.type.syncfs)return i(null);s.type.syncfs(s,e,i);});},mount(e,r,t){var n=t==="/",o=!t,i;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!o){var s=a.lookupPath(t,{follow_mount:false});if(t=s.path,i=s.node,a.isMountpoint(i))throw new a.ErrnoError(10);if(!a.isDir(i.mode))throw new a.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(l);return u.mount=l,l.root=u,n?a.root=u:i&&(i.mounted=l,i.mount&&i.mount.mounts.push(l)),u},unmount(e){var r=a.lookupPath(e,{follow_mount:false});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,o=a.getMounts(n);Object.keys(a.nameTable).forEach(s=>{for(var l=a.nameTable[s];l;){var u=l.name_next;o.includes(l.mount)&&a.destroyNode(l),l=u;}}),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1);},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=a.lookupPath(e,{parent:true}),o=n.node,i=T.basename(e);if(!i||i==="."||i==="..")throw new a.ErrnoError(28);var s=a.mayCreate(o,i);if(s)throw new a.ErrnoError(s);if(!o.node_ops.mknod)throw new a.ErrnoError(63);return o.node_ops.mknod(o,i,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{a.mkdir(n,r);}catch(i){if(i.errno!=20)throw i}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)},symlink(e,r){if(!N.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:true}),n=t.node;if(!n)throw new a.ErrnoError(44);var o=T.basename(r),i=a.mayCreate(n,o);if(i)throw new a.ErrnoError(i);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,o,e)},rename(e,r){var t=T.dirname(e),n=T.dirname(r),o=T.basename(e),i=T.basename(r),s,l,u;if(s=a.lookupPath(e,{parent:true}),l=s.node,s=a.lookupPath(r,{parent:true}),u=s.node,!l||!u)throw new a.ErrnoError(44);if(l.mount!==u.mount)throw new a.ErrnoError(75);var d=a.lookupNode(l,o),v=N.relative(e,n);if(v.charAt(0)!==".")throw new a.ErrnoError(28);if(v=N.relative(r,t),v.charAt(0)!==".")throw new a.ErrnoError(55);var y;try{y=a.lookupNode(u,i);}catch{}if(d!==y){var m=a.isDir(d.mode),h=a.mayDelete(l,o,m);if(h)throw new a.ErrnoError(h);if(h=y?a.mayDelete(u,i,m):a.mayCreate(u,i),h)throw new a.ErrnoError(h);if(!l.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(d)||y&&a.isMountpoint(y))throw new a.ErrnoError(10);if(u!==l&&(h=a.nodePermissions(l,"w"),h))throw new a.ErrnoError(h);a.hashRemoveNode(d);try{l.node_ops.rename(d,u,i);}catch(g){throw g}finally{a.hashAddNode(d);}}},rmdir(e){var r=a.lookupPath(e,{parent:true}),t=r.node,n=T.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,true);if(i)throw new a.ErrnoError(i);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(o);},readdir(e){var r=a.lookupPath(e,{follow:true}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=a.lookupPath(e,{parent:true}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=T.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,false);if(i)throw new a.ErrnoError(i);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(o);},readlink(e){var r=a.lookupPath(e),t=r.node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return N.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return a.stat(e,true)},chmod(e,r,t){var n;if(typeof e=="string"){var o=a.lookupPath(e,{follow:!t});n=o.node;}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()});},lchmod(e,r){a.chmod(e,r,true);},fchmod(e,r){var t=a.getStreamChecked(e);a.chmod(t.node,r);},chown(e,r,t,n){var o;if(typeof e=="string"){var i=a.lookupPath(e,{follow:!n});o=i.node;}else o=e;if(!o.node_ops.setattr)throw new a.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()});},lchown(e,r,t){a.chown(e,r,t,true);},fchown(e,r,t){var n=a.getStreamChecked(e);a.chown(n.node,r,t);},truncate(e,r){if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:true});t=n.node;}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var o=a.nodePermissions(t,"w");if(o)throw new a.ErrnoError(o);t.node_ops.setattr(t,{size:r,timestamp:Date.now()});},ftruncate(e,r){var t=a.getStreamChecked(e);if((t.flags&2097155)===0)throw new a.ErrnoError(28);a.truncate(t.node,r);},utime(e,r,t){var n=a.lookupPath(e,{follow:true}),o=n.node;o.node_ops.setattr(o,{timestamp:Math.max(r,t)});},open(e,r,t){if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?_t(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else {e=T.normalize(e);try{var o=a.lookupPath(e,{follow:!(r&131072)});n=o.node;}catch{}}var i=false;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),i=true;if(!n)throw new a.ErrnoError(44);if(a.isChrdev(n.mode)&&(r&=-513),r&65536&&!a.isDir(n.mode))throw new a.ErrnoError(54);if(!i){var s=a.mayOpen(n,r);if(s)throw new a.ErrnoError(s)}r&512&&!i&&a.truncate(n,0),r&=-131713;var l=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:true,position:0,stream_ops:n.stream_ops,ungotten:[],error:false});return l.stream_ops.open&&l.stream_ops.open(l),f.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),l},close(e){if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e);}catch(r){throw r}finally{a.closeStream(e.fd);}e.fd=null;},isClosed(e){return e.fd===null},llseek(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,o){if(n<0||o<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var i=typeof o<"u";if(!i)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,o);return i||(e.position+=s),s},write(e,r,t,n,o,i){if(n<0||o<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var s=typeof o<"u";if(!s)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,o,i);return s||(e.position+=l),l},allocate(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t);},mmap(e,r,t,n,o){if((n&2)!==0&&(o&2)===0&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,o)},msync(e,r,t,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new a.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=a.open(e,r.flags),o=a.stat(e),i=o.size,s=new Uint8Array(i);return a.read(n,s,0,i,0),r.encoding==="utf8"?t=te(s,0):r.encoding==="binary"&&(t=s),a.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var o=new Uint8Array(Ne(r)+1),i=Be(r,o,0,o.length);a.write(n,o,0,i,void 0,t.canOwn);}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n);},cwd:()=>a.currentPath,chdir(e){var r=a.lookupPath(e,{follow:true});if(r.node===null)throw new a.ErrnoError(44);if(!a.isDir(r.node.mode))throw new a.ErrnoError(54);var t=a.nodePermissions(r.node,"x");if(t)throw new a.ErrnoError(t);a.currentPath=r.path;},createDefaultDirectories(){a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user");},createDefaultDevices(){a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(n,o,i,s,l)=>s}),a.mkdev("/dev/null",a.makedev(1,3)),q.register(a.makedev(5,0),q.default_tty_ops),q.register(a.makedev(6,0),q.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=Tr(e).byteLength),e[--r]);a.createDevice("/dev","random",t),a.createDevice("/dev","urandom",t),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp");},createSpecialDirectories(){a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount(){var r=a.createNode(e,"fd",16895,73);return r.node_ops={lookup(t,n){var o=+n,i=a.getStreamChecked(o),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return s.parent=s,s}},r}},{},"/proc/self/fd");},createStandardStreams(){f.stdin?a.createDevice("/dev","stdin",f.stdin):a.symlink("/dev/tty","/dev/stdin"),f.stdout?a.createDevice("/dev","stdout",null,f.stdout):a.symlink("/dev/tty","/dev/stdout"),f.stderr?a.createDevice("/dev","stderr",null,f.stderr):a.symlink("/dev/tty1","/dev/stderr");a.open("/dev/stdin",0);a.open("/dev/stdout",1);a.open("/dev/stderr",1);},staticInit(){[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>";}),a.nameTable=new Array(4096),a.mount(w,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:w};},init(e,r,t){a.init.initialized=true,f.stdin=e||f.stdin,f.stdout=r||f.stdout,f.stderr=t||f.stderr,a.createStandardStreams();},quit(){a.init.initialized=false;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r);}},findObject(e,r){var t=a.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=a.lookupPath(e,{follow:!r});e=t.path;}catch{}var n={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var t=a.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=T.basename(e),t=a.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/";}catch(o){n.error=o.errno;}return n},createPath(e,r,t,n){e=typeof e=="string"?e:a.getPath(e);for(var o=r.split("/").reverse();o.length;){var i=o.pop();if(i){var s=T.join2(e,i);try{a.mkdir(s);}catch{}e=s;}}return s},createFile(e,r,t,n,o){var i=T.join2(typeof e=="string"?e:a.getPath(e),r),s=Ve(n,o);return a.create(i,s)},createDataFile(e,r,t,n,o,i){var s=r;e&&(e=typeof e=="string"?e:a.getPath(e),s=r?T.join2(e,r):e);var l=Ve(n,o),u=a.create(s,l);if(t){if(typeof t=="string"){for(var d=new Array(t.length),v=0,y=t.length;v<y;++v)d[v]=t.charCodeAt(v);t=d;}a.chmod(u,l|146);var m=a.open(u,577);a.write(m,t,0,t.length,0,i),a.close(m),a.chmod(u,l);}},createDevice(e,r,t,n){var o=T.join2(typeof e=="string"?e:a.getPath(e),r),i=Ve(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(l){l.seekable=false;},close(l){n?.buffer?.length&&n(10);},read(l,u,d,v,y){for(var m=0,h=0;h<v;h++){var g;try{g=t();}catch{throw new a.ErrnoError(29)}if(g===void 0&&m===0)throw new a.ErrnoError(6);if(g==null)break;m++,u[d+h]=g;}return m&&(l.node.timestamp=Date.now()),m},write(l,u,d,v,y){for(var m=0;m<v;m++)try{n(u[d+m]);}catch{throw new a.ErrnoError(29)}return v&&(l.node.timestamp=Date.now()),m}}),a.mkdev(o,i,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return true;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(oe)try{e.contents=be(oe(e.url),!0),e.usedBytes=e.contents.length;}catch{throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(e,r,t,n,o){class i{constructor(){this.lengthKnown=false,this.chunks=[];}get(h){if(!(h>this.length-1||h<0)){var g=h%this.chunkSize,C=h/this.chunkSize|0;return this.getter(C)[g]}}setDataGetter(h){this.getter=h;}cacheLength(){var h=new XMLHttpRequest;if(h.open("HEAD",t,false),h.send(null),!(h.status>=200&&h.status<300||h.status===304))throw new Error("Couldn't load "+t+". Status: "+h.status);var g=Number(h.getResponseHeader("Content-length")),C,F=(C=h.getResponseHeader("Accept-Ranges"))&&C==="bytes",P=(C=h.getResponseHeader("Content-Encoding"))&&C==="gzip",c=1024*1024;F||(c=g);var p=($,U)=>{if($>U)throw new Error("invalid range ("+$+", "+U+") or no bytes requested!");if(U>g-1)throw new Error("only "+g+" bytes available! programmer error!");var S=new XMLHttpRequest;if(S.open("GET",t,false),g!==c&&S.setRequestHeader("Range","bytes="+$+"-"+U),S.responseType="arraybuffer",S.overrideMimeType&&S.overrideMimeType("text/plain; charset=x-user-defined"),S.send(null),!(S.status>=200&&S.status<300||S.status===304))throw new Error("Couldn't load "+t+". Status: "+S.status);return S.response!==void 0?new Uint8Array(S.response||[]):be(S.responseText||"",true)},D=this;D.setDataGetter($=>{var U=$*c,S=($+1)*c-1;if(S=Math.min(S,g-1),typeof D.chunks[$]>"u"&&(D.chunks[$]=p(U,S)),typeof D.chunks[$]>"u")throw new Error("doXHR failed!");return D.chunks[$]}),(P||!g)&&(c=g=1,g=this.getter(0).length,c=g,He("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=c,this.lengthKnown=true;}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!Q)throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i,l={isDevice:false,contents:s};}else var l={isDevice:false,url:t};var u=a.createFile(e,r,l,n,o);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var d={},v=Object.keys(u.stream_ops);v.forEach(m=>{var h=u.stream_ops[m];d[m]=(...g)=>(a.forceLoadFile(u),h(...g));});function y(m,h,g,C,F){var P=m.node.contents;if(F>=P.length)return 0;var c=Math.min(P.length-F,C);if(P.slice)for(var p=0;p<c;p++)h[g+p]=P[F+p];else for(var p=0;p<c;p++)h[g+p]=P.get(F+p);return c}return d.read=(m,h,g,C,F)=>(a.forceLoadFile(u),y(m,h,g,C,F)),d.mmap=(m,h,g,C,F)=>{a.forceLoadFile(u);var P=Fr();if(!P)throw new a.ErrnoError(48);return y(m,M,P,h,g),{ptr:P,allocated:true}},u.stream_ops=d,u}},L={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(T.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else {var o=L.getStreamFromFD(e);n=o.path;}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return T.join2(n,r)},doStat(e,r,t){var n=e(r);_[t>>2]=n.dev,_[t+4>>2]=n.mode,b[t+8>>2]=n.nlink,_[t+12>>2]=n.uid,_[t+16>>2]=n.gid,_[t+20>>2]=n.rdev,R=[n.size>>>0,(E=n.size,+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+24>>2]=R[0],_[t+28>>2]=R[1],_[t+32>>2]=4096,_[t+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),s=n.ctime.getTime();return R=[Math.floor(o/1e3)>>>0,(E=Math.floor(o/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+40>>2]=R[0],_[t+44>>2]=R[1],b[t+48>>2]=o%1e3*1e3,R=[Math.floor(i/1e3)>>>0,(E=Math.floor(i/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+56>>2]=R[0],_[t+60>>2]=R[1],b[t+64>>2]=i%1e3*1e3,R=[Math.floor(s/1e3)>>>0,(E=Math.floor(s/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+72>>2]=R[0],_[t+76>>2]=R[1],b[t+80>>2]=s%1e3*1e3,R=[n.ino>>>0,(E=n.ino,+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[t+88>>2]=R[0],_[t+92>>2]=R[1],0},doMsync(e,r,t,n,o){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var i=O.slice(e,e+t);a.msync(r,i,o,t,n);},varargs:void 0,get(){var e=_[+L.varargs>>2];return L.varargs+=4,e},getp(){return L.get()},getStr(e){var r=K(e);return r},getStreamFromFD(e){var r=a.getStreamChecked(e);return r}};function Et(e,r,t){try{return r=L.getStr(r),r=L.calculateAt(e,r),t===0?a.unlink(r):t===512?a.rmdir(r):re("Invalid flags passed to unlinkat"),0}catch(n){if(typeof a>"u"||n.name!=="ErrnoError")throw n;return -n.errno}}var $e={},Ye=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r);}};function ue(e){return this.fromWireType(b[e>>2])}var ne={},J={},ke={},Sr,Pe=e=>{throw new Sr(e)},Z=(e,r,t)=>{e.forEach(function(l){ke[l]=r;});function n(l){var u=t(l);u.length!==e.length&&Pe("Mismatched type converter count");for(var d=0;d<e.length;++d)x(e[d],u[d]);}var o=new Array(r.length),i=[],s=0;r.forEach((l,u)=>{J.hasOwnProperty(l)?o[u]=J[l]:(i.push(l),ne.hasOwnProperty(l)||(ne[l]=[]),ne[l].push(()=>{o[u]=J[l],++s,s===i.length&&n(o);}));}),i.length===0&&n(o);},bt=e=>{var r=$e[e];delete $e[e];var t=r.rawConstructor,n=r.rawDestructor,o=r.fields,i=o.map(s=>s.getterReturnType).concat(o.map(s=>s.setterArgumentType));Z([e],i,s=>{var l={};return o.forEach((u,d)=>{var v=u.fieldName,y=s[d],m=u.getter,h=u.getterContext,g=s[d+o.length],C=u.setter,F=u.setterContext;l[v]={read:P=>y.fromWireType(m(h,P)),write:(P,c)=>{var p=[];C(F,P,g.toWireType(p,c)),Ye(p);}};}),[{name:r.name,fromWireType:u=>{var d={};for(var v in l)d[v]=l[v].read(u);return n(u),d},toWireType:(u,d)=>{for(var v in l)if(!(v in d))throw new TypeError(`Missing field: "${v}"`);var y=t();for(v in l)l[v].write(y,d[v]);return u!==null&&u.push(n,y),y},argPackAdvance:z,readValueFromPointer:ue,destructorFunction:n}]});},$t=(e,r,t,n,o)=>{},kt=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Dr=e;},Dr,j=e=>{for(var r="",t=e;O[t];)r+=Dr[O[t++]];return r},ae,k=e=>{throw new ae(e)};function Pt(e,r,t={}){var n=r.name;if(e||k(`type "${n}" must have a positive integer typeid pointer`),J.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;k(`Cannot register type '${n}' twice`);}if(J[e]=r,delete ke[e],ne.hasOwnProperty(e)){var o=ne[e];delete ne[e],o.forEach(i=>i());}}function x(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Pt(e,r,t)}var z=8,Ct=(e,r,t,n)=>{r=j(r),x(e,{name:r,fromWireType:function(o){return !!o},toWireType:function(o,i){return i?t:n},argPackAdvance:z,readValueFromPointer:function(o){return this.fromWireType(O[o])},destructorFunction:null});},Tt=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),qe=e=>{function r(t){return t.$$.ptrType.registeredClass.name}k(r(e)+" instance already deleted");},Xe=false,Ar=e=>{},Ft=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr);},Rr=e=>{e.count.value-=1;var r=e.count.value===0;r&&Ft(e);},Mr=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=Mr(e,r,t.baseClass);return n===null?null:t.downcast(n)},jr={},St=()=>Object.keys(ce).length,Dt=()=>{var e=[];for(var r in ce)ce.hasOwnProperty(r)&&e.push(ce[r]);return e},fe=[],Ge=()=>{for(;fe.length;){var e=fe.pop();e.$$.deleteScheduled=false,e.delete();}},de,At=e=>{de=e,fe.length&&de&&de(Ge);},Rt=()=>{f.getInheritedInstanceCount=St,f.getLiveInheritedInstances=Dt,f.flushPendingDeletes=Ge,f.setDelayFunction=At;},ce={},Mt=(e,r)=>{for(r===void 0&&k("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},jt=(e,r)=>(r=Mt(e,r),ce[r]),Ce=(e,r)=>{(!r.ptrType||!r.ptr)&&Pe("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Pe("Both smartPtrType and smartPtr must be specified"),r.count={value:1},ve(Object.create(e,{$$:{value:r,writable:true}}))};function Ot(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=jt(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function o(){return this.isSmartPointer?Ce(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Ce(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i=this.registeredClass.getActualType(r),s=jr[i];if(!s)return o.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var u=Mr(r,this.registeredClass,l.registeredClass);return u===null?o.call(this):this.isSmartPointer?Ce(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:e}):Ce(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var ve=e=>typeof FinalizationRegistry>"u"?(ve=r=>r,e):(Xe=new FinalizationRegistry(r=>{Rr(r.$$);}),ve=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var o={$$:t};Xe.register(r,o,r);}return r},Ar=r=>Xe.unregister(r),ve(e)),Wt=()=>{Object.assign(Te.prototype,{isAliasOf(e){if(!(this instanceof Te)||!(e instanceof Te))return false;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,o=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return r===n&&t===o},clone(){if(this.$$.ptr||qe(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=ve(Object.create(Object.getPrototypeOf(this),{$$:{value:Tt(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=false,e},delete(){this.$$.ptr||qe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&k("Object already scheduled for deletion"),Ar(this),Rr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0);},isDeleted(){return !this.$$.ptr},deleteLater(){return this.$$.ptr||qe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&k("Object already scheduled for deletion"),fe.push(this),fe.length===1&&de&&de(Ge),this.$$.deleteScheduled=true,this}});};function Te(){}var he=(e,r)=>Object.defineProperty(r,"name",{value:e}),Or=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...o){return e[r].overloadTable.hasOwnProperty(o.length)||k(`Function '${t}' called with an invalid number of arguments (${o.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[o.length].apply(this,o)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n;}},Ke=(e,r,t)=>{f.hasOwnProperty(e)?((t===void 0||f[e].overloadTable!==void 0&&f[e].overloadTable[t]!==void 0)&&k(`Cannot register public name '${e}' twice`),Or(f,e,e),f.hasOwnProperty(t)&&k(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),f[e].overloadTable[t]=r):(f[e]=r,t!==void 0&&(f[e].numArguments=t));},Ut=48,Ht=57,It=e=>{if(e===void 0)return "_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Ut&&r<=Ht?`_${e}`:e};function Lt(e,r,t,n,o,i,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[];}var Je=(e,r,t)=>{for(;r!==t;)r.upcast||k(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function xt(e,r){if(r===null)return this.isReference&&k(`null is not a valid ${this.name}`),0;r.$$||k(`Cannot pass "${nr(r)}" as a ${this.name}`),r.$$.ptr||k(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Je(r.$$.ptr,t,this.registeredClass);return n}function zt(e,r){var t;if(r===null)return this.isReference&&k(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&k(`Cannot pass "${nr(r)}" as a ${this.name}`),r.$$.ptr||k(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&k(`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(r.$$.smartPtr===void 0&&k("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:k(`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 o=r.clone();t=this.rawShare(t,W.toHandle(()=>o.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:k("Unsupporting sharing policy");}return t}function Nt(e,r){if(r===null)return this.isReference&&k(`null is not a valid ${this.name}`),0;r.$$||k(`Cannot pass "${nr(r)}" as a ${this.name}`),r.$$.ptr||k(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&k(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Je(r.$$.ptr,t,this.registeredClass);return n}var Bt=()=>{Object.assign(Fe.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e);},argPackAdvance:z,readValueFromPointer:ue,fromWireType:Ot});};function Fe(e,r,t,n,o,i,s,l,u,d,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=d,this.rawDestructor=v,!o&&r.baseClass===void 0?n?(this.toWireType=xt,this.destructorFunction=null):(this.toWireType=Nt,this.destructorFunction=null):this.toWireType=zt;}var Wr=(e,r,t)=>{f.hasOwnProperty(e)||Pe("Replacing nonexistent public symbol"),f[e].overloadTable!==void 0&&t!==void 0?f[e].overloadTable[t]=r:(f[e]=r,f[e].argCount=t);},Vt=(e,r,t)=>{var n=f["dynCall_"+e];return n(r,...t)},Se=[],Ur,Hr=e=>{var r=Se[e];return r||(e>=Se.length&&(Se.length=e+1),Se[e]=r=Ur.get(e)),r},Yt=(e,r,t=[])=>{if(e.includes("j"))return Vt(e,r,t);var n=Hr(r)(...t);return n},qt=(e,r)=>(...t)=>Yt(e,r,t),I=(e,r)=>{e=j(e);function t(){return e.includes("j")?qt(e,r):Hr(r)}var n=t();return typeof n!="function"&&k(`unknown function pointer with signature ${e}: ${r}`),n},Xt=(e,r)=>{var t=he(r,function(n){this.name=r,this.message=n;var o=new Error(n).stack;o!==void 0&&(this.stack=this.toString()+`
|
|
4
|
-
`+o.replace(/^Error(:[^\n]*)?\n/,""));});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},Ir,Lr=e=>{var r=Yr(e),t=j(r);return V(r),t},De=(e,r)=>{var t=[],n={};function o(i){if(!n[i]&&!J[i]){if(ke[i]){ke[i].forEach(o);return}t.push(i),n[i]=true;}}throw r.forEach(o),new Ir(`${e}: `+t.map(Lr).join([", "]))},Gt=(e,r,t,n,o,i,s,l,u,d,v,y,m)=>{v=j(v),i=I(o,i),l&&=I(s,l),d&&=I(u,d),m=I(y,m);var h=It(v);Ke(h,function(){De(`Cannot construct ${v} due to unbound types`,[n]);}),Z([e,r,t],n?[n]:[],g=>{g=g[0];var C,F;n?(C=g.registeredClass,F=C.instancePrototype):F=Te.prototype;var P=he(v,function(...S){if(Object.getPrototypeOf(this)!==c)throw new ae("Use 'new' to construct "+v);if(p.constructor_body===void 0)throw new ae(v+" has no accessible constructor");var Gr=p.constructor_body[S.length];if(Gr===void 0)throw new ae(`Tried to invoke ctor of ${v} with invalid number of parameters (${S.length}) - expected (${Object.keys(p.constructor_body).toString()}) parameters instead!`);return Gr.apply(this,S)}),c=Object.create(F,{constructor:{value:P}});P.prototype=c;var p=new Lt(v,P,c,m,C,i,l,d);p.baseClass&&(p.baseClass.__derivedClasses??=[],p.baseClass.__derivedClasses.push(p));var D=new Fe(v,p,true,false,false),$=new Fe(v+"*",p,false,false,false),U=new Fe(v+" const*",p,false,true,false);return jr[e]={pointerType:$,constPointerType:U},Wr(h,P),[D,$,U]});},Ze=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(b[r+n*4>>2]);return t};function Kt(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return true;return false}function Qe(e,r,t,n,o,i){var s=r.length;s<2&&k("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=r[1]!==null&&t!==null,u=Kt(r),d=r[0].name!=="void",v=s-2,y=new Array(v),m=[],h=[],g=function(...C){C.length!==v&&k(`function ${e} called with ${C.length} arguments, expected ${v}`),h.length=0;var F;m.length=l?2:1,m[0]=o,l&&(F=r[1].toWireType(h,this),m[1]=F);for(var P=0;P<v;++P)y[P]=r[P+2].toWireType(h,C[P]),m.push(y[P]);var c=n(...m);function p(D){if(u)Ye(h);else for(var $=l?1:2;$<r.length;$++){var U=$===1?F:y[$-2];r[$].destructorFunction!==null&&r[$].destructorFunction(U);}if(d)return r[0].fromWireType(D)}return p(c)};return he(e,g)}var Jt=(e,r,t,n,o,i)=>{var s=Ze(r,t);o=I(n,o),Z([],[e],l=>{l=l[0];var u=`constructor ${l.name}`;if(l.registeredClass.constructor_body===void 0&&(l.registeredClass.constructor_body=[]),l.registeredClass.constructor_body[r-1]!==void 0)throw new ae(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${l.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return l.registeredClass.constructor_body[r-1]=()=>{De(`Cannot construct ${l.name} due to unbound types`,s);},Z([],s,d=>(d.splice(1,0,null),l.registeredClass.constructor_body[r-1]=Qe(u,d,null,o,i),[])),[]});},xr=e=>{e=e.trim();let r=e.indexOf("(");return r!==-1?e.substr(0,r):e},Zt=(e,r,t,n,o,i,s,l,u)=>{var d=Ze(t,n);r=j(r),r=xr(r),i=I(o,i),Z([],[e],v=>{v=v[0];var y=`${v.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&v.registeredClass.pureVirtualFunctions.push(r);function m(){De(`Cannot call ${y} due to unbound types`,d);}var h=v.registeredClass.instancePrototype,g=h[r];return g===void 0||g.overloadTable===void 0&&g.className!==v.name&&g.argCount===t-2?(m.argCount=t-2,m.className=v.name,h[r]=m):(Or(h,r,y),h[r].overloadTable[t-2]=m),Z([],d,C=>{var F=Qe(y,C,v,i,s);return h[r].overloadTable===void 0?(F.argCount=t-2,h[r]=F):h[r].overloadTable[t-2]=F,[]}),[]});},er=[],B=[],rr=e=>{e>9&&--B[e+1]===0&&(B[e]=void 0,er.push(e));},Qt=()=>B.length/2-5-er.length,en=()=>{B.push(0,1,void 0,1,null,1,true,1,false,1),f.count_emval_handles=Qt;},W={toValue:e=>(e||k("Cannot use deleted val. handle = "+e),B[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case true:return 6;case false:return 8;default:{let r=er.pop()||B.length;return B[r]=e,B[r+1]=1,r}}}},rn={name:"emscripten::val",fromWireType:e=>{var r=W.toValue(e);return rr(e),r},toWireType:(e,r)=>W.toHandle(r),argPackAdvance:z,readValueFromPointer:ue,destructorFunction:null},tn=e=>x(e,rn),nn=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType(M[n])}:function(n){return this.fromWireType(O[n])};case 2:return t?function(n){return this.fromWireType(ee[n>>1])}:function(n){return this.fromWireType(se[n>>1])};case 4:return t?function(n){return this.fromWireType(_[n>>2])}:function(n){return this.fromWireType(b[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},an=(e,r,t,n)=>{r=j(r);function o(){}o.values={},x(e,{name:r,constructor:o,fromWireType:function(i){return this.constructor.values[i]},toWireType:(i,s)=>s.value,argPackAdvance:z,readValueFromPointer:nn(r,t,n),destructorFunction:null}),Ke(r,o);},tr=(e,r)=>{var t=J[e];return t===void 0&&k(`${r} has unknown type ${Lr(e)}`),t},on=(e,r,t)=>{var n=tr(e,"enum");r=j(r);var o=n.constructor,i=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:he(`${n.name}_${r}`,function(){})}});o.values[t]=i,o[r]=i;},nr=e=>{if(e===null)return "null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},sn=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(pr[t>>2])};case 8:return function(t){return this.fromWireType(mr[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},ln=(e,r,t)=>{r=j(r),x(e,{name:r,fromWireType:n=>n,toWireType:(n,o)=>o,argPackAdvance:z,readValueFromPointer:sn(r,t),destructorFunction:null});},un=(e,r,t,n,o,i,s)=>{var l=Ze(r,t);e=j(e),e=xr(e),o=I(n,o),Ke(e,function(){De(`Cannot call ${e} due to unbound types`,l);},r-1),Z([],l,u=>{var d=[u[0],null].concat(u.slice(1));return Wr(e,Qe(e,d,null,o,i),r-1),[]});},fn=(e,r,t)=>{switch(r){case 1:return t?n=>M[n]:n=>O[n];case 2:return t?n=>ee[n>>1]:n=>se[n>>1];case 4:return t?n=>_[n>>2]:n=>b[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},dn=(e,r,t,n,o)=>{r=j(r);var i=v=>v;if(n===0){var s=32-8*t;i=v=>v<<s>>>s;}var l=r.includes("unsigned"),u=(v,y)=>{},d;l?d=function(v,y){return u(y,this.name),y>>>0}:d=function(v,y){return u(y,this.name),y},x(e,{name:r,fromWireType:i,toWireType:d,argPackAdvance:z,readValueFromPointer:fn(r,t,n!==0),destructorFunction:null});},cn=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],o=n[r];function i(s){var l=b[s>>2],u=b[s+4>>2];return new o(M.buffer,u,l)}t=j(t),x(e,{name:t,fromWireType:i,argPackAdvance:z,readValueFromPointer:i},{ignoreDuplicateRegistrations:true});},vn=(e,r,t)=>Be(e,O,r,t),hn=(e,r)=>{r=j(r);var t=r==="std::string";x(e,{name:r,fromWireType(n){var o=b[n>>2],i=n+4,s;if(t)for(var l=i,u=0;u<=o;++u){var d=i+u;if(u==o||O[d]==0){var v=d-l,y=K(l,v);s===void 0?s=y:(s+="\0",s+=y),l=d+1;}}else {for(var m=new Array(o),u=0;u<o;++u)m[u]=String.fromCharCode(O[i+u]);s=m.join("");}return V(n),s},toWireType(n,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var i,s=typeof o=="string";s||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||k("Cannot pass non-string to std::string"),t&&s?i=Ne(o):i=o.length;var l=ir(4+i+1),u=l+4;if(b[l>>2]=i,t&&s)vn(o,u,i+1);else if(s)for(var d=0;d<i;++d){var v=o.charCodeAt(d);v>255&&(V(u),k("String has UTF-16 code units that do not fit in 8 bits")),O[u+d]=v;}else for(var d=0;d<i;++d)O[u+d]=o[d];return n!==null&&n.push(V,l),l},argPackAdvance:z,readValueFromPointer:ue,destructorFunction(n){V(n);}});},zr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,pn=(e,r)=>{for(var t=e,n=t>>1,o=n+r/2;!(n>=o)&&se[n];)++n;if(t=n<<1,t-e>32&&zr)return zr.decode(O.subarray(e,t));for(var i="",s=0;!(s>=r/2);++s){var l=ee[e+s*2>>1];if(l==0)break;i+=String.fromCharCode(l);}return i},mn=(e,r,t)=>{if(t??=2147483647,t<2)return 0;t-=2;for(var n=r,o=t<e.length*2?t/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);ee[r>>1]=s,r+=2;}return ee[r>>1]=0,r-n},yn=e=>e.length*2,gn=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var o=_[e+t*4>>2];if(o==0)break;if(++t,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|i&1023);}else n+=String.fromCharCode(o);}return n},wn=(e,r,t)=>{if(t??=2147483647,t<4)return 0;for(var n=r,o=n+t-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343){var l=e.charCodeAt(++i);s=65536+((s&1023)<<10)|l&1023;}if(_[r>>2]=s,r+=4,r+4>o)break}return _[r>>2]=0,r-n},_n=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},En=(e,r,t)=>{t=j(t);var n,o,i,s;r===2?(n=pn,o=mn,s=yn,i=l=>se[l>>1]):r===4&&(n=gn,o=wn,s=_n,i=l=>b[l>>2]),x(e,{name:t,fromWireType:l=>{for(var u=b[l>>2],d,v=l+4,y=0;y<=u;++y){var m=l+4+y*r;if(y==u||i(m)==0){var h=m-v,g=n(v,h);d===void 0?d=g:(d+="\0",d+=g),v=m+r;}}return V(l),d},toWireType:(l,u)=>{typeof u!="string"&&k(`Cannot pass non-string to C++ string type ${t}`);var d=s(u),v=ir(4+d+r);return b[v>>2]=d/r,o(u,v+4,d+r),l!==null&&l.push(V,v),v},argPackAdvance:z,readValueFromPointer:ue,destructorFunction(l){V(l);}});},bn=(e,r,t,n,o,i)=>{$e[e]={name:j(r),rawConstructor:I(t,n),rawDestructor:I(o,i),fields:[]};},$n=(e,r,t,n,o,i,s,l,u,d)=>{$e[e].fields.push({fieldName:j(r),getterReturnType:t,getter:I(n,o),getterContext:i,setterArgumentType:s,setter:I(l,u),setterContext:d});},kn=(e,r)=>{r=j(r),x(e,{isVoid:true,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}});},Ae=[],Pn=(e,r,t,n)=>(e=Ae[e],r=W.toValue(r),e(null,r,t,n)),Cn={},ar=e=>{var r=Cn[e];return r===void 0?j(e):r},Tn=(e,r,t,n,o)=>(e=Ae[e],r=W.toValue(r),t=ar(t),e(r,r[t],n,o)),Nr=()=>{if(typeof globalThis=="object")return globalThis;function e(r){r.$$$embind_global$$$=r;var t=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return t||delete r.$$$embind_global$$$,t}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&e(global)?$$$embind_global$$$=global:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")},Fn=e=>e===0?W.toHandle(Nr()):(e=ar(e),W.toHandle(Nr()[e])),Sn=e=>{var r=Ae.length;return Ae.push(e),r},Dn=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=tr(b[r+n*4>>2],"parameter "+n);return t},An=Reflect.construct,Rn=(e,r,t)=>{var n=[],o=e.toWireType(n,t);return n.length&&(b[r>>2]=W.toHandle(n)),o},Mn=(e,r,t)=>{var n=Dn(e,r),o=n.shift();e--;var i=new Array(e),s=(u,d,v,y)=>{for(var m=0,h=0;h<e;++h)i[h]=n[h].readValueFromPointer(y+m),m+=n[h].argPackAdvance;var g=t===1?An(d,i):d.apply(u,i);return Rn(o,v,g)},l=`methodCaller<(${n.map(u=>u.name).join(", ")}) => ${o.name}>`;return Sn(he(l,s))},jn=e=>{e>9&&(B[e+1]+=1);},On=()=>W.toHandle([]),Wn=e=>W.toHandle(ar(e)),Un=()=>W.toHandle({}),Hn=e=>{var r=W.toValue(e);Ye(r),rr(e);},In=(e,r,t)=>{e=W.toValue(e),r=W.toValue(r),t=W.toValue(t),e[r]=t;},Ln=(e,r)=>{e=tr(e,"_emval_take_value");var t=e.readValueFromPointer(r);return W.toHandle(t)},xn=()=>{re("");},zn=(e,r,t)=>O.copyWithin(e,r,r+t),Nn=()=>2147483648,Bn=e=>{var r=_e.buffer,t=(e-r.byteLength+65535)/65536;try{return _e.grow(t),yr(),1}catch{}},Vn=e=>{var r=O.length;e>>>=0;var t=Nn();if(e>t)return false;for(var n=(u,d)=>u+(d-u%d)%d,o=1;o<=4;o*=2){var i=r*(1+.2/o);i=Math.min(i,e+100663296);var s=Math.min(t,n(Math.max(e,i),65536)),l=Bn(s);if(l)return true}return false},or={},Yn=()=>je||"./this.program",pe=()=>{if(!pe.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Yn()};for(var t in or)or[t]===void 0?delete r[t]:r[t]=or[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);pe.strings=n;}return pe.strings},qn=(e,r)=>{for(var t=0;t<e.length;++t)M[r++]=e.charCodeAt(t);M[r]=0;},Xn=(e,r)=>{var t=0;return pe().forEach((n,o)=>{var i=r+t;b[e+o*4>>2]=i,qn(n,i),t+=n.length+1;}),0},Gn=(e,r)=>{var t=pe();b[e>>2]=t.length;var n=0;return t.forEach(o=>n+=o.length+1),b[r>>2]=n,0};function Kn(e){try{var r=L.getStreamFromFD(e);return a.close(r),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Jn=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=b[r>>2],l=b[r+4>>2];r+=8;var u=a.read(e,M,s,l,n);if(u<0)return -1;if(o+=u,u<l)break;}return o};function Zn(e,r,t,n){try{var o=L.getStreamFromFD(e),i=Jn(o,r,t);return b[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Qn=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN;function ea(e,r,t,n,o){var i=Qn(r,t);try{if(isNaN(i))return 61;var s=L.getStreamFromFD(e);return a.llseek(s,i,n),R=[s.position>>>0,(E=s.position,+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],_[o>>2]=R[0],_[o+4>>2]=R[1],s.getdents&&i===0&&n===0&&(s.getdents=null),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var ra=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=b[r>>2],l=b[r+4>>2];r+=8;var u=a.write(e,M,s,l,n);if(u<0)return -1;o+=u;}return o};function ta(e,r,t,n){try{var o=L.getStreamFromFD(e),i=ra(o,r,t);return b[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Re=e=>e%4===0&&(e%100!==0||e%400===0),na=(e,r)=>{for(var t=0,n=0;n<=r;t+=e[n++]);return t},Br=[31,29,31,30,31,30,31,31,30,31,30,31],Vr=[31,28,31,30,31,30,31,31,30,31,30,31],aa=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var n=Re(t.getFullYear()),o=t.getMonth(),i=(n?Br:Vr)[o];if(r>i-t.getDate())r-=i-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t},oa=(e,r)=>{M.set(e,r);},ia=(e,r,t,n)=>{var o=b[n+40>>2],i={tm_sec:_[n>>2],tm_min:_[n+4>>2],tm_hour:_[n+8>>2],tm_mday:_[n+12>>2],tm_mon:_[n+16>>2],tm_year:_[n+20>>2],tm_wday:_[n+24>>2],tm_yday:_[n+28>>2],tm_isdst:_[n+32>>2],tm_gmtoff:_[n+36>>2],tm_zone:o?K(o):""},s=K(t),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in l)s=s.replace(new RegExp(u,"g"),l[u]);var d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],v=["January","February","March","April","May","June","July","August","September","October","November","December"];function y(c,p,D){for(var $=typeof c=="number"?c.toString():c||"";$.length<p;)$=D[0]+$;return $}function m(c,p){return y(c,p,"0")}function h(c,p){function D(U){return U<0?-1:U>0?1:0}var $;return ($=D(c.getFullYear()-p.getFullYear()))===0&&($=D(c.getMonth()-p.getMonth()))===0&&($=D(c.getDate()-p.getDate())),$}function g(c){switch(c.getDay()){case 0:return new Date(c.getFullYear()-1,11,29);case 1:return c;case 2:return new Date(c.getFullYear(),0,3);case 3:return new Date(c.getFullYear(),0,2);case 4:return new Date(c.getFullYear(),0,1);case 5:return new Date(c.getFullYear()-1,11,31);case 6:return new Date(c.getFullYear()-1,11,30)}}function C(c){var p=aa(new Date(c.tm_year+1900,0,1),c.tm_yday),D=new Date(p.getFullYear(),0,4),$=new Date(p.getFullYear()+1,0,4),U=g(D),S=g($);return h(U,p)<=0?h(S,p)<=0?p.getFullYear()+1:p.getFullYear():p.getFullYear()-1}var F={"%a":c=>d[c.tm_wday].substring(0,3),"%A":c=>d[c.tm_wday],"%b":c=>v[c.tm_mon].substring(0,3),"%B":c=>v[c.tm_mon],"%C":c=>{var p=c.tm_year+1900;return m(p/100|0,2)},"%d":c=>m(c.tm_mday,2),"%e":c=>y(c.tm_mday,2," "),"%g":c=>C(c).toString().substring(2),"%G":C,"%H":c=>m(c.tm_hour,2),"%I":c=>{var p=c.tm_hour;return p==0?p=12:p>12&&(p-=12),m(p,2)},"%j":c=>m(c.tm_mday+na(Re(c.tm_year+1900)?Br:Vr,c.tm_mon-1),3),"%m":c=>m(c.tm_mon+1,2),"%M":c=>m(c.tm_min,2),"%n":()=>`
|
|
5
|
-
`,"%p":c=>c.tm_hour>=0&&c.tm_hour<12?"AM":"PM","%S":c=>m(c.tm_sec,2),"%t":()=>" ","%u":c=>c.tm_wday||7,"%U":c=>{var p=c.tm_yday+7-c.tm_wday;return m(Math.floor(p/7),2)},"%V":c=>{var p=Math.floor((c.tm_yday+7-(c.tm_wday+6)%7)/7);if((c.tm_wday+371-c.tm_yday-2)%7<=2&&p++,p){if(p==53){var $=(c.tm_wday+371-c.tm_yday)%7;$!=4&&($!=3||!Re(c.tm_year))&&(p=1);}}else {p=52;var D=(c.tm_wday+7-c.tm_yday-1)%7;(D==4||D==5&&Re(c.tm_year%400-1))&&p++;}return m(p,2)},"%w":c=>c.tm_wday,"%W":c=>{var p=c.tm_yday+7-(c.tm_wday+6)%7;return m(Math.floor(p/7),2)},"%y":c=>(c.tm_year+1900).toString().substring(2),"%Y":c=>c.tm_year+1900,"%z":c=>{var p=c.tm_gmtoff,D=p>=0;return p=Math.abs(p)/60,p=p/60*100+p%60,(D?"+":"-")+("0000"+p).slice(-4)},"%Z":c=>c.tm_zone,"%%":()=>"%"};s=s.replace(/%%/g,"\0\0");for(var u in F)s.includes(u)&&(s=s.replace(new RegExp(u,"g"),F[u](i)));s=s.replace(/\0\0/g,"%");var P=be(s,false);return P.length>r?0:(oa(P,e),P.length-1)},sa=(e,r,t,n,o)=>ia(e,r,t,n);a.createPreloadedFile=wt,a.staticInit(),Sr=f.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},kt(),ae=f.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Wt(),Rt(),Bt(),Ir=f.UnboundTypeError=Xt(Error,"UnboundTypeError"),en();var la={a:ut,m:ct,F:Et,O:bt,C:$t,M:Ct,o:Gt,A:Jt,y:Zt,L:tn,j:an,b:on,x:ln,e:un,i:dn,f:cn,w:hn,r:En,P:bn,t:$n,N:kn,p:Pn,z:Tn,c:rr,Q:Fn,l:Mn,q:jn,s:On,h:Wn,n:Un,k:Hn,g:In,d:Ln,u:xn,K:zn,E:Vn,I:Xn,J:Gn,G:Kn,H:Zn,B:ea,v:ta,D:sa},A=lt(),ir=e=>(ir=A.T)(e),V=e=>(V=A.V)(e),Yr=e=>(Yr=A.W)(e),qr=e=>(qr=A.X)(e);f.dynCall_ji=(e,r)=>(f.dynCall_ji=A.Y)(e,r);f.dynCall_iij=(e,r,t,n)=>(f.dynCall_iij=A.Z)(e,r,t,n);f.dynCall_jijj=(e,r,t,n,o,i)=>(f.dynCall_jijj=A._)(e,r,t,n,o,i);f.dynCall_vijj=(e,r,t,n,o,i)=>(f.dynCall_vijj=A.$)(e,r,t,n,o,i);f.dynCall_jiji=(e,r,t,n,o)=>(f.dynCall_jiji=A.aa)(e,r,t,n,o);f.dynCall_viijii=(e,r,t,n,o,i,s)=>(f.dynCall_viijii=A.ba)(e,r,t,n,o,i,s);f.dynCall_iiiiij=(e,r,t,n,o,i,s)=>(f.dynCall_iiiiij=A.ca)(e,r,t,n,o,i,s);f.dynCall_iiiiijj=(e,r,t,n,o,i,s,l,u)=>(f.dynCall_iiiiijj=A.da)(e,r,t,n,o,i,s,l,u);f.dynCall_iiiiiijj=(e,r,t,n,o,i,s,l,u,d)=>(f.dynCall_iiiiiijj=A.ea)(e,r,t,n,o,i,s,l,u,d);var Me;le=function e(){Me||Xr(),Me||(le=e);};function Xr(){if(X>0||(Qr(),X>0))return;function e(){Me||(Me=true,f.calledRun=true,!hr&&(et(),ur(f),f.onRuntimeInitialized&&f.onRuntimeInitialized(),rt()));}f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("");},1),e();},1)):e();}if(f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.pop()();return Xr(),lr.ready})})(),ka=wa;module.exports=ka;
|