'),svgIcoSoundOn=CreateSVG(''),svgIcoSoundOff=CreateSVG(''),svgIcoNoSound=CreateSVG(' '),svgIcoGamepad=CreateSVG(''),svgIcoKeyboard=CreateSVG(''),svgIcoFullscreen=CreateSVG('');var hSnd=document.getElementById("canvasSndBtn");function simulateKeyEvent(e,t,n,l,c){var o={isTrusted:!0,type:e,bubbles:!0,canceable:!0,char:c,key:c,code:l,keyCode:t,which:t,charCode:n,preventDefault:function(){},defaultPrevented:!1,composed:!0,detail:0,location:0,isComposing:!1,repeat:!1,ctrlKey:!1,metaKey:!1,altKey:!1,shiftKey:!1,currentTarget:window,srcElement:document.body,target:document.body,timeStamp:Date.now(),view:window};if("undefined"!=typeof JSEvents&&JSEvents.eventHandlers&&JSEvents.eventHandlers.length>0)for(var a=0;a{e.addEventListener(t,(e=>{blockEvent(e)}),{capture:!0,passive:!0})}))}function processKeyEvent(e,t){if(e.target.classList.contains("vkey")){e.preventDefault(),e.stopPropagation();var n=e.target,l=n.dataset;if(-1!=Module.keyboardTimeoutId&&l.view){if(t)return;if((s=n.parentElement.parentElement).classList.contains("slide-out")&&!s.classList.contains("slide-in"))return s.classList.add("slide-in"),void doKeyboardTimeout(s);doKeyboardTimeout(s)}var c=parseInt(l.keycode),o=parseInt(l.keychar),a=l.key;if(simulateKeyEvent(t?"keydown":"keyup",c,0,"",a),t)n.classList.add("active"),n.setPointerCapture(e.pointerId);else{var s=document.getElementById("keyboard-container");n.classList.remove("active"),n.releasePointerCapture(e.pointerId),"changeKeyboardView"==l.action&&changeKeyboardView(s)}t&&0!=o&&simulateKeyEvent("keypress",c,o,"",a)}}function initKeyboard(){var e=document.getElementById("keyboard-container");e.querySelectorAll(".keyrow");SetEventBlock(e,["pointerover","touchstart","touchmove","pointermove","gotpointercapture","lostpointercapture","pointerout","touchend","mouseout","mousemove","mousedown","mousepress","mouseup"]),e.dataset.view=3,changeKeyboardView(e)}function initGamePad(e){const t=document,n=document.getElementById(e+"L"),l=document.getElementById(e+"R");0==l.innerHTML.length&&(l.innerHTML=n.innerHTML),SetEventBlock(n,["pointerover","touchstart","touchmove","pointermove","gotpointercapture","lostpointercapture","pointerout","touchend","mouseout","mousemove","mousedown","mousepress","mouseup"]),SetEventBlock(l,["pointerover","touchstart","touchmove","pointermove","gotpointercapture","lostpointercapture","pointerout","touchend","mouseout","mousemove","mousedown","mousepress","mouseup"]),t.addEventListener("dblclick",(e=>{blockEvent(e)})),t.addEventListener("click",(e=>{blockEvent(e)})),t.addEventListener("contextmenu",(e=>{blockEvent(e)})),t.ondragstart=()=>!1,t.addEventListener("pointerdown",(e=>{processKeyEvent(e,!0)}),{capture:!0,passive:!0}),t.addEventListener("pointerup",(e=>{processKeyEvent(e,!1)}),{capture:!0,passive:!0}),t.addEventListener("pointercancel",(e=>{processKeyEvent(e,!1)}),{capture:!0,passive:!0})}function toggleVolume(e){if(Module.pi8_AudioInit&&e.classList.contains("sound_off")){e.classList.remove("sound_off"),e.classList.add("sound_on"),e.src=svgIcoSoundOn;var t=document.body;t.onpointerdown=t.onclick=t.onkeydown="",Module.HEAP8[Module.pi8_AudioInit]=1,document.querySelectorAll(".AudioItem").forEach((e=>{e.muted=!1}))}else e.classList.contains("sound_mute")?(e.classList.remove("sound_mute"),e.src=svgIcoSoundOn,document.querySelectorAll(".AudioItem").forEach((e=>{e.muted=!1}))):e.classList.contains("sound_on")&&(e.classList.add("sound_mute"),e.src=svgIcoSoundOff,document.querySelectorAll(".AudioItem").forEach((e=>{e.muted=!0})))}function toggleKeyboard(e){var t=document.getElementById("keyboard-container");e.target.classList.toggle("active"),t.classList.toggle("hidden"),Module.Gfx_adjustHeaderSize(),window.setTimeout((function(){Module.Gfx_adjustHeaderSize()}),50)}function changeKeyboardView(e){document.getElementById("keyboard-container");var t=e.dataset,n=2^parseInt(t.view);t.view=n,e.querySelectorAll(".vkey").forEach((e=>{e.style.display=e.dataset.view&n?"":"none"})),e.querySelectorAll(".keyrow").forEach((e=>{e.dataset.view<0?e.style.display=e.dataset.view==-n?"":"none":e.style.display=e.dataset.view&n?"":"none";var t="";1&n&&(t+=" "+e.dataset.grid1),2&n&&(t+=" "+e.dataset.grid2),e.style.gridTemplateColumns=t})),Module.Gfx_adjustHeaderSize()}function toggleGamepad(e){const t=document.getElementById("gamepad-containerL"),n=document.getElementById("gamepad-containerR");e.target.classList.toggle("active"),t.classList.toggle("hidden"),n.classList.toggle("hidden"),Module.Gfx_adjustHeaderSize(),window.setTimeout((function(){Module.Gfx_adjustHeaderSize()}),50)}function doKeyboardTimeout(e){-1!=Module.keyboardTimeoutId&&window.clearTimeout(Module.keyboardTimeoutId),e.classList.remove("slide-out"),Module.keyboardTimeoutId=window.setTimeout((function(){e.classList.remove("slide-in"),e.classList.add("slide-out")}),5e3)}hSnd.src=svgIcoNoSound,document.getElementById("spinico").src=svgIcoFreebasic,document.getElementById("canvasPadBtn").src=svgIcoGamepad,document.getElementById("canvasKeyBtn").src=svgIcoKeyboard,document.getElementById("canvasFulBtn").src=svgIcoFullscreen,document.body.onclick=function(e){toggleVolume(hSnd)},document.body.pointerdown=function(e){toggleVolume(hSnd)},document.body.onkeydown=function(e){toggleVolume(hSnd)};var Module={isFullscreen:!0,keyboardTimeoutId:-1,preRun:[function(){Module.isFullscreen=!0,Module.keyboardTimeoutId=-1,"undefined"!=typeof __fb_rtlib&&(__fb_rtlib.console.open(80,25),null!=__fb_rtlib.console.term&&document.getElementById("termContainer").classList.remove("hidden")),addRunDependency("syncfs"),FS.mkdir("/appData");var e="/appData/web"+window.location.pathname.split(":").pop().replace(/\/\//g,".").replace(/[/\/]/g,".");FS.mkdir(e),FS.mount(IDBFS,{autoPersist:!0},e),FS.symlink(e,"/localStorage"),FS.syncfs(!0,(function(e){removeRunDependency("syncfs")}));new ResizeObserver((()=>{window.setTimeout((function(){Module.Gfx_adjustHeaderSize()}),50)})).observe(document.getElementById("canvas")),window.onresize=function(){window.setTimeout((function(){Module.Gfx_adjustHeaderSize()}),50)},initGamePad("gamepad-container"),initKeyboard();const t=document.querySelector("title");new MutationObserver((e=>{e.forEach((e=>{if("childList"===e.type){const e=document.getElementById("canvasTitle");e.title=document.title,e.innerText=" "+document.title}}))})).observe(t,{childList:!0})}],postRun:[],print:function(e){arguments.length>1&&(e=Array.prototype.slice.call(arguments).join(" ")),__fb_rtlib.console.write(e)},printErr:function(e){arguments.length>1&&(e=Array.prototype.slice.call(arguments).join(" ")),console.error(e)},canvas:function(){var e=document.getElementById("canvas");return e.addEventListener("webglcontextlost",(function(e){alert("WebGL context lost. You will need to reload the page."),e.preventDefault()}),!1),e}(),setStatus:function(e){if(Module.setStatus.last||(Module.setStatus.last={time:Date.now(),text:""}),e!==Module.setStatus.text){var t=e.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/),n=Date.now();t&&n-Date.now()<30||(t?(e=t[1],progressElement.value=100*parseInt(t[2]),progressElement.max=100*parseInt(t[4]),progressElement.hidden=!1,spinnerElement.hidden=!1):(progressElement.value=null,progressElement.max=null,progressElement.hidden=!0,e||(spinnerElement.hidden=!0)),statusElement.innerHTML=e)}},leaveFullscreen:function(){var e=document.getElementById("canvasHeader"),t=document.getElementById("canvas");document.getElementById("keyboard-container");e.classList.remove("hidden"),t.style.width="",t.style.height=""},enterFullscreen:function(e){Module.isFullscreen=!0,document.getElementById("canvasHeader").classList.add("hidden"),document.getElementById(e).requestFullscreen(),canvas.style.width="100%",canvas.style.height="100%",canvas.width>canvas.height?window.screen.orientation.lock("landscape").then((function(){}),(function(){})):window.screen.orientation.lock("portrait").then((function(){}),(function(){})),console.log("Entered fullscreen")},Gfx_adjustHeaderSize:function(){var e=document.fullscreenElement;Module.isFullscreen&&null==e&&(Module.isFullscreen=!1,Module.leaveFullscreen());var t=document.getElementById("canvasHeader");document.getElementById("hdrFirstBtn");if(!Module.isFullscreen)if(canvas.height+t.clientHeight>window.innerHeight)canvas.style.height=window.innerHeight-t.clientHeight+"px";else if(canvas.clientHeightwindow.innerHeight)&&!(n*canvas.height>240);)n+=1;n*canvas.height+t.clientHeightwindow.innerWidth&&(a=window.innerWidth-c.clientWidth),c.style.left=a+"px";var s=document.getElementById("keyboard-container");s.style.left=(window.innerWidth-s.clientWidth)/2+"px",canvas.clientHeight+t.clientHeight+s.clientHeight<=window.innerHeight?(s.style.top=canvas.offsetTop+canvas.clientHeight+"px",s.classList.remove("slide-out"),s.classList.remove("slide-in"),-1!=Module.keyboardTimeoutId&&window.clearTimeout(Module.keyboardTimeoutId),Module.keyboardTimeoutId=-1):(s.style.top=window.innerHeight-s.clientHeight+"px",doKeyboardTimeout(document.getElementById("keyboard-container")))},totalDependencies:0,monitorRunDependencies:function(e){this.totalDependencies=Math.max(this.totalDependencies,e),Module.setStatus(e?"Preparing... ("+(this.totalDependencies-e)+"/"+this.totalDependencies+")":"All downloads complete.")}};Module.setStatus("Downloading..."),window.onerror=function(){Module.setStatus("Exception thrown, see JavaScript console"),spinnerElement.style.display="none",Module.setStatus=function(e){e&&Module.printErr("[post-exception status] "+e)}}