"use strict";var e,t=require("./qsp-api-Dw3c699x.js"),r="undefined"!=typeof document?document.currentScript:null,a=(e="undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("wasm-engine.cjs",document.baseURI).href,async function(t={}){var a,n,s=t,i=new Promise(((e,t)=>{a=e,n=t})),o="object"==typeof window,c="function"==typeof importScripts,u="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(u){const{createRequire:e}=await import("module");var l=e("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("wasm-engine.cjs",document.baseURI).href)}var f,p,d=Object.assign({},s),m="./this.program",h=(e,t)=>{throw t},g="";if(u){var _=l("fs"),w=l("path");g=l("url").fileURLToPath(new URL("./","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("wasm-engine.cjs",document.baseURI).href)),p=e=>(e=W(e)?new URL(e):w.normalize(e),_.readFileSync(e)),f=(e,t=!0)=>(e=W(e)?new URL(e):w.normalize(e),new Promise(((r,a)=>{_.readFile(e,t?void 0:"utf8",((e,n)=>{e?a(e):r(t?n.buffer:n)}))}))),!s.thisProgram&&process.argv.length>1&&(m=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),h=(e,t)=>{throw process.exitCode=e,t}}else(o||c)&&(c?g=self.location.href:"undefined"!=typeof document&&document.currentScript&&(g=document.currentScript.src),e&&(g=e),g=g.startsWith("blob:")?"":g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1),c&&(p=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),f=e=>W(e)?new Promise(((t,r)=>{var a=new XMLHttpRequest;a.open("GET",e,!0),a.responseType="arraybuffer",a.onload=()=>{200==a.status||0==a.status&&a.response?t(a.response):r(a.status)},a.onerror=r,a.send(null)})):fetch(e,{credentials:"same-origin"}).then((e=>e.ok?e.arrayBuffer():Promise.reject(new Error(e.status+" : "+e.url)))));s.print||console.log.bind(console);var v=s.printErr||console.error.bind(console);Object.assign(s,d),d=null,s.arguments&&s.arguments,s.thisProgram&&(m=s.thisProgram);var y,b,S,R,A,D,I=s.wasmBinary,U=!1;function k(){var e=y.buffer;s.HEAP8=S=new Int8Array(e),s.HEAP16=new Int16Array(e),s.HEAPU8=R=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAP32=A=new Int32Array(e),s.HEAPU32=D=new Uint32Array(e),s.HEAPF32=new Float32Array(e),s.HEAPF64=new Float64Array(e)}function C(){if(!U){var e=_e();0==e&&(e+=4);var t=D[e>>2],r=D[e+4>>2];34821223==t&&2310721022==r||j(`Stack overflow! Stack cookie has been overwritten at ${z(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${z(r)} ${z(t)}`),1668509029!=D[0]&&j("Runtime error: The application has corrupted its heap memory area (address zero)!")}}var E=[],x=[],P=[],L=0,T=null;function j(e){s.onAbort?.(e),v(e="Aborted("+e+")"),U=!0,b=1,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}var F,V=e=>e.startsWith("data:application/octet-stream;base64,"),W=e=>e.startsWith("file://");function B(){if(s.locateFile){var e="qsp-engine.wasm";return V(e)?e:(t=e,s.locateFile?s.locateFile(t,g):g+t)}var t;return new URL("qsp-engine.wasm","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("wasm-engine.cjs",document.baseURI).href).href}function H(e){if(e==F&&I)return new Uint8Array(I);if(p)return p(e);throw"both async and sync fetching of the wasm failed"}function M(e,t,r){return function(e){return I?Promise.resolve().then((()=>H(e))):f(e).then((e=>new Uint8Array(e)),(()=>H(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then(r,(e=>{v(`failed to asynchronously prepare wasm: ${e}`),j(e)}))}function N(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var O,$,G=e=>{for(;e.length>0;)e.shift()(s)},q=s.noExitRuntime||!0,z=e=>"0x"+(e>>>=0).toString(16).padStart(8,"0"),K=()=>{var e=ge(),t=_e();ve(e,t)},Q=e=>{var t=(e-y.buffer.byteLength+65535)/65536;try{return y.grow(t),k(),1}catch(e){}},X={},Z=()=>{if(!Z.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:m||"./this.program"};for(var t in X)void 0===X[t]?delete e[t]:e[t]=X[t];var r=[];for(var t in e)r.push(`${t}=${e[t]}`);Z.strings=r}return Z.strings},Y=e=>{try{return e()}catch(e){j(e)}},J=e=>{if(e instanceof N||"unwind"==e)return b;C(),e instanceof WebAssembly.RuntimeError&&we()<=0&&v("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 5242880)"),h(1,e)},ee=()=>q||!1,te=(e,t)=>{var r;b=e,b=r=e,ee()||(s.onExit?.(r),U=!0),h(r,new N(r))},re=e=>{if(!U)try{e(),(()=>{if(!ee())try{te(b)}catch(e){J(e)}})()}catch(e){J(e)}},ae={instrumentWasmImports(e){var t=/^(invoke_.*|__asyncjs__.*)$/;for(let[r,a]of Object.entries(e))"function"==typeof a&&(a.isAsync||t.test(r))},instrumentWasmExports(e){var t={};for(let[r,a]of Object.entries(e))t[r]="function"==typeof a?(...e)=>{ae.exportCallStack.push(r);try{return a(...e)}finally{U||(ae.exportCallStack.pop(),ae.maybeStopUnwind())}}:a;return t},State:{Normal:0,Unwinding:1,Rewinding:2,Disabled:3},state:0,StackSize:16384,currData:null,handleSleepReturnValue:0,exportCallStack:[],callStackNameToId:{},callStackIdToName:{},callStackId:0,asyncPromiseHandlers:null,sleepCallbacks:[],getCallStackId(e){var t=ae.callStackNameToId[e];return void 0===t&&(t=ae.callStackId++,ae.callStackNameToId[e]=t,ae.callStackIdToName[t]=e),t},maybeStopUnwind(){ae.currData&&ae.state===ae.State.Unwinding&&0===ae.exportCallStack.length&&(ae.state=ae.State.Normal,Y(be),"undefined"!=typeof Fibers&&Fibers.trampoline())},whenDone:()=>new Promise(((e,t)=>{ae.asyncPromiseHandlers={resolve:e,reject:t}})),allocateData(){var e=pe(12+ae.StackSize);return ae.setDataHeader(e,e+12,ae.StackSize),ae.setDataRewindFunc(e),e},setDataHeader(e,t,r){D[e>>2]=t,D[e+4>>2]=t+r},setDataRewindFunc(e){var t=ae.exportCallStack[0],r=ae.getCallStackId(t);A[e+8>>2]=r},getDataRewindFuncName(e){var t=A[e+8>>2];return ae.callStackIdToName[t]},getDataRewindFunc:e=>fe[e],doRewind(e){var t=ae.getDataRewindFuncName(e);return ae.getDataRewindFunc(t)()},handleSleep(e){if(!U){if(ae.state===ae.State.Normal){var t=!1,r=!1;e(((e=0)=>{if(!U&&(ae.handleSleepReturnValue=e,t=!0,r)){ae.state=ae.State.Rewinding,Y((()=>Se(ae.currData))),"undefined"!=typeof Browser&&Browser.mainLoop.func&&Browser.mainLoop.resume();var a,n=!1;try{a=ae.doRewind(ae.currData)}catch(e){a=e,n=!0}var s=!1;if(!ae.currData){var i=ae.asyncPromiseHandlers;i&&(ae.asyncPromiseHandlers=null,(n?i.reject:i.resolve)(a),s=!0)}if(n&&!s)throw a}})),r=!0,t||(ae.state=ae.State.Unwinding,ae.currData=ae.allocateData(),"undefined"!=typeof Browser&&Browser.mainLoop.func&&Browser.mainLoop.pause(),Y((()=>ye(ae.currData))))}else ae.state===ae.State.Rewinding?(ae.state=ae.State.Normal,Y(Re),de(ae.currData),ae.currData=null,ae.sleepCallbacks.forEach(re)):j(`invalid state: ${ae.state}`);return ae.handleSleepReturnValue}},handleAsync:e=>ae.handleSleep((t=>{e().then(t)}))},ne=(e,t)=>{e<128?t.push(e):t.push(e%128|128,e>>7)},se=(e,t)=>{if("function"==typeof WebAssembly.Function)return new WebAssembly.Function((e=>{for(var t={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},r={parameters:[],results:"v"==e[0]?[]:[t[e[0]]]},a=1;a{var r=e.slice(0,1),a=e.slice(1),n={i:127,p:127,j:126,f:125,d:124,e:111};t.push(96),ne(a.length,t);for(var s=0;s($||($=new WeakMap,((e,t)=>{if($)for(var r=e;r=ie.length&&(ie.length=n+1),ie[n]=s=O.get(n)),s);a&&$.set(a,r)}var n,s})(0,O.length)),$.get(e)||0),ce=[],ue=(e,t)=>{O.set(e,t),ie[e]=O.get(e)},le={a:e=>{var t=ge(),r=_e();j(`stack overflow (Attempt to set SP to ${z(e)}, with stack limits [${z(r)} - ${z(t)}]). If you require more stack space build with -sSTACK_SIZE=`)},f:(e,t,r)=>R.copyWithin(e,t,t+r),e:()=>Date.now(),b:e=>{var t,r,a=R.length,n=2147483648;if((e>>>=0)>n)return!1;for(var s=1;s<=4;s*=2){var i=a*(1+.2/s);i=Math.min(i,e+100663296);var o=Math.min(n,(t=Math.max(e,i),r=65536,Math.ceil(t/r)*r));if(Q(o))return!0}return!1},c:(e,t)=>{var r=0;return Z().forEach(((a,n)=>{var s=t+r;D[e+4*n>>2]=s,((e,t)=>{for(var r=0;r{var r=Z();D[e>>2]=r.length;var a=0;return r.forEach((e=>a+=e.length+1)),D[t>>2]=a,0}},fe=function(){var e,t,r,a,i={a:le};function o(e,t){var r;return fe=e.exports,fe=ae.instrumentWasmExports(fe),y=fe.g,k(),O=fe.n,r=fe.h,x.unshift(r),function(){if(L--,s.monitorRunDependencies?.(L),0==L&&T){var e=T;T=null,e()}}(),fe}if(L++,s.monitorRunDependencies?.(L),s.instantiateWasm)try{return s.instantiateWasm(i,o)}catch(e){v(`Module.instantiateWasm callback failed with error: ${e}`),n(e)}return F||(F=B()),(e=I,t=F,r=i,a=function(e){o(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||V(t)||W(t)||u||"function"!=typeof fetch?M(t,r,a):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,r).then(a,(function(e){return v(`wasm streaming compile failed: ${e}`),v("falling back to ArrayBuffer instantiation"),M(t,r,a)}))))).catch(n),{}}();s.___asan_default_options=()=>(s.___asan_default_options=fe.i)(),s._init=()=>(s._init=fe.j)(),s._dispose=()=>(s._dispose=fe.k)(),s._getVersion=e=>(s._getVersion=fe.l)(e),s._setErrorCallback=e=>(s._setErrorCallback=fe.m)(e),s._getMainDesc=e=>(s._getMainDesc=fe.o)(e),s._isMainDescChanged=()=>(s._isMainDescChanged=fe.p)(),s._getVarsDesc=e=>(s._getVarsDesc=fe.q)(e),s._isVarsDescChanged=()=>(s._isVarsDescChanged=fe.r)(),s._getActions=e=>(s._getActions=fe.s)(e);var pe=s._malloc=e=>(pe=s._malloc=fe.t)(e);s._selectAction=e=>(s._selectAction=fe.u)(e),s._executeSelAction=()=>(s._executeSelAction=fe.v)(),s._isActionsChanged=()=>(s._isActionsChanged=fe.w)(),s._getObjects=e=>(s._getObjects=fe.x)(e),s._selectObject=e=>(s._selectObject=fe.y)(e),s._isObjectsChanged=()=>(s._isObjectsChanged=fe.z)(),s._loadGameData=(e,t,r)=>(s._loadGameData=fe.A)(e,t,r),s._restartGame=()=>(s._restartGame=fe.B)(),s._saveGameData=e=>(s._saveGameData=fe.C)(e);var de=s._free=e=>(de=s._free=fe.D)(e);s._loadSavedGameData=(e,t)=>(s._loadSavedGameData=fe.E)(e,t),s._execString=(e,t)=>(s._execString=fe.F)(e,t),s._execCounter=()=>(s._execCounter=fe.G)(),s._execLoc=e=>(s._execLoc=fe.H)(e),s._execUserInput=e=>(s._execUserInput=fe.I)(e),s._getLastError=e=>(s._getLastError=fe.J)(e),s._getVarValue=(e,t)=>(s._getVarValue=fe.K)(e,t),s._getVarValueByIndex=(e,t,r)=>(s._getVarValueByIndex=fe.L)(e,t,r),s._getVarValueByKey=(e,t,r)=>(s._getVarValueByKey=fe.M)(e,t,r),s._getVarSize=e=>(s._getVarSize=fe.N)(e),s._setCallback=(e,t)=>(s._setCallback=fe.O)(e,t),s._freeItemsList=e=>(s._freeItemsList=fe.P)(e),s._freeSaveBuffer=e=>(s._freeSaveBuffer=fe.Q)(e),s._freeStringsBuffer=e=>(s._freeStringsBuffer=fe.R)(e),s._enableDebugMode=()=>(s._enableDebugMode=fe.S)(),s._disableDebugMode=()=>(s._disableDebugMode=fe.T)(),s._getCurStateData=(e,t,r)=>(s._getCurStateData=fe.U)(e,t,r),s.__run_checks=()=>(s.__run_checks=fe.V)();var me,he=()=>(he=fe.W)(),ge=()=>(ge=fe.X)(),_e=()=>(_e=fe.Y)(),we=()=>(we=fe.Z)(),ve=s.___set_stack_limits=(e,t)=>(ve=s.___set_stack_limits=fe._)(e,t),ye=e=>(ye=fe.$)(e),be=()=>(be=fe.aa)(),Se=e=>(Se=fe.ba)(e),Re=()=>(Re=fe.ca)();function Ae(){var e;he(),0==(e=_e())&&(e+=4),D[e>>2]=34821223,D[e+4>>2]=2310721022,D[0]=1668509029}function De(){function e(){me||(me=!0,s.calledRun=!0,U||(C(),K(),G(x),a(s),s.onRuntimeInitialized?.(),function(){if(C(),s.postRun)for("function"==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;)e=s.postRun.shift(),P.unshift(e);var e;G(P)}()))}L>0||(Ae(),function(){if(s.preRun)for("function"==typeof s.preRun&&(s.preRun=[s.preRun]);s.preRun.length;)e=s.preRun.shift(),E.unshift(e);var e;G(E)}(),L>0||(s.setStatus?(s.setStatus("Running..."),setTimeout((function(){setTimeout((function(){s.setStatus("")}),1),e()}),1)):e(),C()))}if(s.addFunction=(e,t)=>{var r=oe(e);if(r)return r;var a=(()=>{if(ce.length)return ce.pop();try{O.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return O.length-1})();try{ue(a,e)}catch(r){if(!(r instanceof TypeError))throw r;var n=se(e,t);ue(a,n)}return $.set(e,a),a},s.Asyncify=ae,T=function e(){me||De(),me||(T=e)},s.preInit)for("function"==typeof s.preInit&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();return De(),i});Object.defineProperty(exports,"QspPanel",{enumerable:!0,get:function(){return t.QspPanel}}),exports.initQspEngine=function(e){return new Promise((r=>{a({wasmBinary:e}).then((e=>{r(new t.QspAPIImpl(e))}))}))}; //# sourceMappingURL=wasm-engine.cjs.map