!function(vorple){"use strict";function eToInt(x){var e;return Math.abs(x)<1?(e=parseInt(x.toString().split("e-")[1]),e&&(x*=Math.pow(10,e-1),x="0."+new Array(e).join("0")+x.toString().substring(2))):(e=parseInt(x.toString().split("+")[1]),e>20&&(e-=20,x/=Math.pow(10,e),x+=new Array(e+1).join("0"))),x}function getHeader(content){return"*"===content.charAt(0)?content.substr(0,content.indexOf("\n")+1):""}function handshake(filename){var gameHandshake=FS.readFile(filename,{encoding:"utf8"}),header=getHeader(gameHandshake),content=gameHandshake.substr(header.length);"Callooh!"===content?(vorple.debug.log("Handshake passed, Vorple story confirmed"),FS.unlink(filename),FS.writeFile(filename,header+"Callay!",{encoding:"utf8"})):vorple.debug.log('Handshake failed, expected "Callooh!" but received "'+content+'" instead')}const VERSION="3.0";vorple.debug=function(text){console.log(text),haven.buffer.append("["+text+"]\n",0)},vorple.error=function(text){haven.error(text)},vorple.fileClosed=function(filename){if(filenam e.indexOf("VpHndshk.glkdata")!==-1)return void handshake(filename);if(filename.indexOf("VpJSEval.glkdata")!==-1){var retval,code=FS.readFile(filename,{encoding:"utf8"}),header=getHeader(code);code=code.substr(header.length),vorple.debug.log("Evaluating: "+code);try{retval=function(){return(0,eval)(code)}()}catch(e){vorple.error("JavaScript from story file threw an error: "+e.message)}retval="string"==typeof retval?'"'+retval+'"':"number"==typeof retval?Math.abs(retval)>1e20?eToInt(retval):""+retval:void 0===retval?"undefined":"function"==typeof retval||"symbol"==typeof retval?retval.toString():"undefined"!=typeof Set&&retval instanceof Set?JSON.stringify(Array.from(retval)):retval===1/0?"Infinity":retval===-(1/0)?"-Infinity":retval!==retval?"NaN":JSON.stringify(retval),vorple.debug.log("Return value: "+retval),FS.writeFile("VpJSRtrn.glkdata",header+retval,{encoding:"utf8"})}},vorple.init=function(){vorple.prompt.init(),haven.start({enginePrompt:!1,engineFontFamily:!1,options:vorple.options,unicode:!0,virtual Storyfile:"storyfile.gblorb"}),haven.assets.addCallback(function(done){FS.syncfs(!0,function(){FS.writeFile("/gamedata/VpHndshk.glkdata","");try{FS.unlink("/gamedata/VpJSEval.glkdata")}catch(e){}try{FS.unlink("/gamedata/VpJSRtrn.glkdata")}catch(e){}FS.syncfs(!1,done)})}),window.vex&&(vex.defaultOptions.className="vex-theme-plain")},vorple.options={},vorple.requireVersion=function(requiredVersion){var thisVer=VERSION.split("."),reqVer=(""+requiredVersion).split("."),mismatch=function(){vorple.error("Vorple version "+requiredVersion+" was requested, but Vorple is at version "+VERSION)};if(thisVer[0]reqVer[0]||1===reqVer.length))return thisVer[1]reqVer[1]||2===reqVer.length||2===thisVer.length||thisVer[2]0?fadeOutTimer=setTimeout(function(){next(vol ume-.05)},50):($sound.remove(),callback())}var $sound=$(element),sound=$sound.get(0);clearTimeout(fadeOutTimer),$sound.data("stopping",!0),next(sound.volume-.05)}function timeNextTrack(){clearTimeout(musicPauseTimer),0===musicQueue.length&&playlist.length>0&&(musicQueue=playlist.slice()),0!==musicQueue.length&&(musicPauseTimer=setTimeout(function(){var next=musicQueue.shift();next&&audio.playMusic(next)},1e3))}var fadeOutTimer,musicPauseTimer,audio={},musicQueue=[],playlist=[];audio.clearPlaylist=function(){playlist=[],musicQueue=[]},audio.currentMusicPlaying=function(){var $music=$(".vorple-music");return 0===$music.length?null:$music.data("stopping")?musicQueue.length>0?musicQueue[0]:playlist.length>0?playlist[0]:null:$music.attr("src")},audio.isAudioPlaying=function(){return audio.isEffectPlaying()||audio.isMusicPlaying()},audio.isEffectPlaying=function(){var isEffectPlaying=!1;return $(".vorple-sound").each(function(){if(audio.isElementPlaying(this))return isEffectPlaying=!0,!1}),isEffectPlaying},audio.i sElementPlaying=function(audioElement){var elem=$(audioElement).get(0);return!(!(elem&&elem.currentTime>0)||elem.paused)},audio.isMusicPlaying=function(){var $music=$(".vorple-music");return 0!==$music.length&&(musicQueue.length>0||(playlist.length>0||!$music.data("stopping")&&audio.isElementPlaying($music)))},audio.playMusic=function(url,loop){var $music=$(".vorple-music");clearTimeout(musicPauseTimer),$music.length>0&&$music.attr("src")===url||0===$music.length&&musicQueue[0]===url?(clearTimeout(fadeOutTimer),$music.prop("volume",1).data("stopping",!1).prop("loop",!!loop).get(0).play()):audio.isElementPlaying(".vorple-music")?(musicQueue.unshift(url),fadeOut($music,timeNextTrack)):($music.remove(),$('