diff --git a/bin/WebStoryEngine.js b/bin/WebStoryEngine.js index 2b1dd18..f2bac03 100644 --- a/bin/WebStoryEngine.js +++ b/bin/WebStoryEngine.js @@ -7008,7 +7008,7 @@ define("WSE", function (EventBus, assets, commands, dataSources, functions) { "use strict"; - var WSE = {}, version = "2015.10.1-final.1510032031"; + var WSE = {}, version = "2015.10.2-final.1510051136"; EventBus.inject(WSE); diff --git a/bin/WebStoryEngine.min.js b/bin/WebStoryEngine.min.js index 12e81b9..0761387 100644 --- a/bin/WebStoryEngine.min.js +++ b/bin/WebStoryEngine.min.js @@ -1,5 +1,5 @@ "undefined"!=typeof window&&(window.requestAnimationFrame=function(){"use strict";return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}()),function(){Array.prototype.forEach||(Array.prototype.forEach=function(e){for(var t=0,n=this.length;n>t;t+=1)e(this[t],t,this)})}(),function(){Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var n;if(null==this)throw new TypeError('"this" is null or not defined');var i=Object(this),r=i.length>>>0;if(0===r)return-1;var s=+t||0;if(1/0===Math.abs(s)&&(s=0),s>=r)return-1;for(n=Math.max(s>=0?s:r-Math.abs(s),0);r>n;){if(n in i&&i[n]===e)return n;n++}return-1})}(),"undefined"==typeof console&&(this.console={}),console.log||(console.log=function(){}),console.dir||(console.dir=console.log),console.error||(console.error=console.log),console.warn||(console.warn=console.log);var MO5=function(){"use strict";function e(n){var i,s=[],l=o[n];0===l.length?(i=a[n](),i||console.error("Module '"+n+"' returned nothing"),r[n]=i,u[n].forEach(e)):t(l)&&(l.forEach(function(e){s.push(r[e])}),i=a[n].apply(void 0,s),i||console.error("Module '"+n+"' returned nothing."),r[n]=i,u[n].forEach(e)),c.forEach(function(e){e()})}function t(e){var t=!0;return e.forEach(function(e){r[e]||(t=!1)}),t}function n(){function s(e){function n(i){var s=[];return t(d)?(d.forEach(function(e){s.push(r[e])}),e.apply(void 0,s),i||c.splice(c.indexOf(n),1),!0):!1}return n(!0)||c.push(n),h}function l(t,n){if(t in a)throw new Error("Module '"+t+"' is already defined.");return a[t]=n,o[t]=d,u[t]||(u[t]=[]),d.forEach(function(e){u[e]||(u[e]=[]),u[e].push(t)}),e(t),h}var d,h;return d=[].slice.call(arguments),d.forEach(function(t){function s(n){r[t]=n,u[t].forEach(e)}t in o||t in r||(o[t]=[],u[t]||(u[t]=[]),t.match(/^ajax:/)?n.ajax(n.ajax.HTTP_METHOD_GET,t.replace(/^ajax:/,""),null,s,s):i(t))}),h={run:s,define:l}}function i(e){if(!(e in n.modules))throw new Error("Unknown module '"+e+"'.");n.loadScript(n.modules[e])}var r={},s={},o={},a={},u={},c=[];return n.path="",function(){var e=document.getElementsByTagName("script");n.path=e[e.length-1].src.replace(/MO5\.js$/,"")}(),n.modules={"MO5.ajax":n.path+"ajax.js","MO5.assert":n.path+"assert.js","MO5.Exception":n.path+"Exception.js","MO5.fail":n.path+"fail.js","MO5.EventBus":n.path+"EventBus.js","MO5.CoreObject":n.path+"CoreObject.js","MO5.List":n.path+"List.js","MO5.Queue":n.path+"Queue.js","MO5.Map":n.path+"Map.js","MO5.Set":n.path+"Set.js","MO5.Result":n.path+"Result.js","MO5.Promise":n.path+"Promise.js","MO5.Timer":n.path+"Timer.js","MO5.TimerWatcher":n.path+"TimerWatcher.js","MO5.easing":n.path+"easing.js","MO5.transform":n.path+"transform.js","MO5.range":n.path+"range.js","MO5.tools":n.path+"tools.js","MO5.Point":n.path+"Point.js","MO5.Size":n.path+"Size.js","MO5.Animation":n.path+"Animation.js","MO5.dom.effects.typewriter":n.path+"dom.effects.typewriter.js","MO5.dom.Element":n.path+"dom.Element.js","MO5.dom.escape":n.path+"dom.escape.js","MO5.globals.document":n.path+"globals.document.js","MO5.globals.window":n.path+"globals.window.js","MO5.types":n.path+"types.js"},n.loadScript=function(e){var t=document.createElement("script"),n="MO5_script_"+e;s[e]||document.getElementById(n)||(t.setAttribute("id",n),t.src=e,document.body.appendChild(t))},n.defaults={fps:60,debug:!0,canvas:{width:640,height:480}},n}();MO5.ajax=function(){function e(e,n,i,r,s,a){var u=XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");return u.open(e,n+"?random="+Math.random(),!0),a&&(u.timeout=a,u.ontimeout=function(){u.abort(),s&&s(new Error("Connection has reached the timeout of "+a+" ms."))}),u.onreadystatechange=function(){var e,n;if(e=u.readyState===o){try{n=u.status===t}catch(i){console.error(i),n=!1}n?r(u):s(u)}},i?u.send(i):u.send(),u}var t=200,n=0,i=1,r=2,s=3,o=4;return e.HTTP_STATUS_OK=t,e.READY_STATE_UNSENT=n,e.READY_STATE_OPENED=i,e.READY_STATE_HEADERS_RECEIVED=r,e.READY_STATE_LOADING=s,e.READY_STATE_DONE=o,e.HTTP_METHOD_GET="GET",e.HTTP_METHOD_POST="POST",e.HTTP_METHOD_PUT="PUT",e.HTTP_METHOD_DELETE="DELETE",e.HTTP_METHOD_HEAD="HEAD",e}();var $__WSEScripts=document.getElementsByTagName("script");WSEPath=$__WSEScripts[$__WSEScripts.length-1].src,MO5.modules.howler=WSEPath,MO5.modules["MO5.ajax"]=WSEPath,MO5.modules["MO5.Animation"]=WSEPath,MO5.modules["MO5.assert"]=WSEPath,MO5.modules["MO5.CoreObject"]=WSEPath,MO5.modules["MO5.dom.effects.typewriter"]=WSEPath,MO5.modules["MO5.dom.Element"]=WSEPath,MO5.modules["MO5.dom.escape"]=WSEPath,MO5.modules["MO5.easing"]=WSEPath,MO5.modules["MO5.EventBus"]=WSEPath,MO5.modules["MO5.Exception"]=WSEPath,MO5.modules["MO5.fail"]=WSEPath,MO5.modules["MO5.globals.document"]=WSEPath,MO5.modules["MO5.globals.window"]=WSEPath,MO5.modules["MO5.List"]=WSEPath,MO5.modules["MO5.Map"]=WSEPath,MO5.modules["MO5.Point"]=WSEPath,MO5.modules["MO5.Promise"]=WSEPath,MO5.modules["MO5.Queue"]=WSEPath,MO5.modules["MO5.range"]=WSEPath,MO5.modules["MO5.Result"]=WSEPath,MO5.modules["MO5.Set"]=WSEPath,MO5.modules["MO5.Size"]=WSEPath,MO5.modules["MO5.Timer"]=WSEPath,MO5.modules["MO5.TimerWatcher"]=WSEPath,MO5.modules["MO5.tools"]=WSEPath,MO5.modules["MO5.transform"]=WSEPath,MO5.modules["MO5.types"]=WSEPath,MO5.modules["WSE.assets"]=WSEPath,MO5.modules["WSE.commands"]=WSEPath,MO5.modules["WSE.functions"]=WSEPath,MO5.modules["WSE.dataSources"]=WSEPath,MO5.modules.WSE=WSEPath,MO5.modules["WSE.Keys"]=WSEPath,MO5.modules["WSE.tools"]=WSEPath,MO5.modules["WSE.dataSources.LocalStorage"]=WSEPath,MO5.modules["WSE.Trigger"]=WSEPath,MO5.modules["WSE.Game"]=WSEPath,MO5.modules["WSE.Interpreter"]=WSEPath,MO5.modules["WSE.tools.ui"]=WSEPath,MO5.modules["WSE.DisplayObject"]=WSEPath,MO5.modules["WSE.assets.Animation"]=WSEPath,MO5.modules["WSE.assets.Audio"]=WSEPath,MO5.modules["WSE.assets.Character"]=WSEPath,MO5.modules["WSE.assets.Curtain"]=WSEPath,MO5.modules["WSE.assets.Imagepack"]=WSEPath,MO5.modules["WSE.assets.Textbox"]=WSEPath,MO5.modules["WSE.assets.Background"]=WSEPath,MO5.modules["WSE.commands.alert"]=WSEPath,MO5.modules["WSE.commands.break"]=WSEPath,MO5.modules["WSE.commands.choice"]=WSEPath,MO5.modules["WSE.commands.confirm"]=WSEPath,MO5.modules["WSE.commands.do"]=WSEPath,MO5.modules["WSE.commands.fn"]=WSEPath,MO5.modules["WSE.commands.global"]=WSEPath,MO5.modules["WSE.commands.globalize"]=WSEPath,MO5.modules["WSE.commands.goto"]=WSEPath,MO5.modules["WSE.commands.line"]=WSEPath,MO5.modules["WSE.commands.localize"]=WSEPath,MO5.modules["WSE.commands.prompt"]=WSEPath,MO5.modules["WSE.commands.restart"]=WSEPath,MO5.modules["WSE.commands.sub"]=WSEPath,MO5.modules["WSE.commands.trigger"]=WSEPath,MO5.modules["WSE.commands.var"]=WSEPath,MO5.modules["WSE.commands.set_vars"]=WSEPath,MO5.modules["WSE.commands.wait"]=WSEPath,MO5.modules["WSE.commands.with"]=WSEPath,MO5.modules["WSE.commands.while"]=WSEPath,function(){var e={},t=null,n=!0,i=!1;try{"undefined"!=typeof AudioContext?t=new AudioContext:"undefined"!=typeof webkitAudioContext?t=new webkitAudioContext:n=!1}catch(r){n=!1}if(!n)if("undefined"!=typeof Audio)try{new Audio}catch(r){i=!0}else i=!0;if(n){var s="undefined"==typeof t.createGain?t.createGainNode():t.createGain();s.gain.value=1,s.connect(t.destination)}var o=function(e){this._volume=1,this._muted=!1,this.usingWebAudio=n,this.ctx=t,this.noAudio=i,this._howls=[],this._codecs=e,this.iOSAutoEnable=!0};o.prototype={volume:function(e){var t=this;if(e=parseFloat(e),e>=0&&1>=e){t._volume=e,n&&(s.gain.value=e);for(var i in t._howls)if(t._howls.hasOwnProperty(i)&&t._howls[i]._webAudio===!1)for(var r=0;r0?r._pos:i._sprite[e][0]/1e3,o=0;i._webAudio?(o=i._sprite[e][1]/1e3-r._pos,r._pos>0&&(s=i._sprite[e][0]/1e3+s)):o=i._sprite[e][1]/1e3-(s-i._sprite[e][0]/1e3);var a,u=!(!i._loop&&!i._sprite[e][2]),l="string"==typeof n?n:Math.round(Date.now()*Math.random())+"";if(function(){var t={id:l,sprite:e,loop:u};a=setTimeout(function(){!i._webAudio&&u&&i.stop(t.id).play(e,t.id),i._webAudio&&!u&&(i._nodeById(t.id).paused=!0,i._nodeById(t.id)._pos=0,i._clearEndTimer(t.id)),i._webAudio||u||i.stop(t.id),i.on("end",l)},1e3*o),i._onendTimer.push({timer:a,id:t.id})}(),i._webAudio){var d=i._sprite[e][0]/1e3,h=i._sprite[e][1]/1e3;r.id=l,r.paused=!1,f(i,[u,d,h],l),i._playStart=t.currentTime,r.gain.value=i._volume,"undefined"==typeof r.bufferSource.start?u?r.bufferSource.noteGrainOn(0,s,86400):r.bufferSource.noteGrainOn(0,s,o):u?r.bufferSource.start(0,s,86400):r.bufferSource.start(0,s,o)}else{if(4!==r.readyState&&(r.readyState||!navigator.isCocoonJS))return i._clearEndTimer(l),function(){var t=i,s=e,o=n,a=r,u=function(){t.play(s,o),a.removeEventListener("canplaythrough",u,!1)};a.addEventListener("canplaythrough",u,!1)}(),i;r.readyState=4,r.id=l,r.currentTime=s,r.muted=c._muted||r.muted,r.volume=i._volume*c.volume(),setTimeout(function(){r.play()},0)}return i.on("play"),"function"==typeof n&&n(l),i}),i):("function"==typeof n&&n(),i):(i.on("load",function(){i.play(e,n)}),i)},pause:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.pause(e)}),t;t._clearEndTimer(e);var n=e?t._nodeById(e):t._activeNode();if(n)if(n._pos=t.pos(null,e),t._webAudio){if(!n.bufferSource||n.paused)return t;n.paused=!0,"undefined"==typeof n.bufferSource.stop?n.bufferSource.noteOff(0):n.bufferSource.stop(0)}else n.pause();return t.on("pause"),t},stop:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.stop(e)}),t;t._clearEndTimer(e);var n=e?t._nodeById(e):t._activeNode();if(n)if(n._pos=0,t._webAudio){if(!n.bufferSource||n.paused)return t;n.paused=!0,"undefined"==typeof n.bufferSource.stop?n.bufferSource.noteOff(0):n.bufferSource.stop(0)}else isNaN(n.duration)||(n.pause(),n.currentTime=0);return t},mute:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.mute(e)}),t;var n=e?t._nodeById(e):t._activeNode();return n&&(t._webAudio?n.gain.value=0:n.muted=!0),t},unmute:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.unmute(e)}),t;var n=e?t._nodeById(e):t._activeNode();return n&&(t._webAudio?n.gain.value=t._volume:n.muted=!1),t},volume:function(e,t){var n=this;if(e=parseFloat(e),e>=0&&1>=e){if(n._volume=e,!n._loaded)return n.on("play",function(){n.volume(e,t)}),n;var i=t?n._nodeById(t):n._activeNode();return i&&(n._webAudio?i.gain.value=e:i.volume=e*c.volume()),n}return n._volume},loop:function(e){var t=this;return"boolean"==typeof e?(t._loop=e,t):t._loop},sprite:function(e){var t=this;return"object"==typeof e?(t._sprite=e,t):t._sprite},pos:function(e,n){var i=this;if(!i._loaded)return i.on("load",function(){i.pos(e)}),"number"==typeof e?i:i._pos||0;e=parseFloat(e);var r=n?i._nodeById(n):i._activeNode();if(r)return e>=0?(i.pause(n),r._pos=e,i.play(r._sprite,n),i):i._webAudio?r._pos+(t.currentTime-i._playStart):r.currentTime;if(e>=0)return i;for(var s=0;s=0||0>e))return r._pos3d;if(r._webAudio){var s=i?r._nodeById(i):r._activeNode();s&&(r._pos3d=[e,t,n],s.panner.setPosition(e,t,n),s.panner.panningModel=r._model||"HRTF")}return r},fade:function(e,t,n,i,r){var s=this,o=Math.abs(e-t),a=e>t?"down":"up",u=o/.01,c=n/u;if(!s._loaded)return s.on("load",function(){s.fade(e,t,n,i,r)}),s;s.volume(e,r);for(var l=1;u>=l;l++)!function(){var e=s._volume+("up"===a?.01:-.01)*l,n=Math.round(1e3*e)/1e3,o=t;setTimeout(function(){s.volume(n,r),n===o&&i&&i()},c*l)}()},fadeIn:function(e,t,n){return this.volume(0).play().fade(0,e,t,n)},fadeOut:function(e,t,n,i){var r=this;return r.fade(r._volume,e,t,function(){n&&n(),r.pause(i),r.on("end")},i)},_nodeById:function(e){for(var t=this,n=t._audioNode[0],i=0;i=0&&!(5>=n);e--)t._audioNode[e].paused&&(t._webAudio&&t._audioNode[e].disconnect(0),n--,t._audioNode.splice(e,1))},_clearEndTimer:function(e){for(var t=this,n=0,i=0;i=0&&c._howls.splice(r,1),delete e[t._src],t=null}},n)var d=function(t,n){if(n in e)return t._duration=e[n].duration,void p(t);if(/^data:[^;]+;base64,/.test(n)){for(var i=atob(n.split(",")[1]),r=new Uint8Array(i.length),s=0;se)throw new Error("Parameter 1 is expected to be greater than zero.");return this.count=0,this.limit=e,this.start()},s.prototype.promise=function(){return i.prototype.promise.call(this)},s}"function"==typeof MO5?MO5("MO5.Exception","MO5.CoreObject","MO5.Queue","MO5.Timer","MO5.TimerWatcher").define("MO5.Animation",e):"undefined"!=typeof window?window.MO5.Animation=e(MO5.Exception,MO5.CoreObject,MO5.Queue,MO5.Timer,MO5.TimerWatcher):module.exports=e(require("./Exception.js"),require("./CoreObject.js"),require("./Queue.js"),require("./Timer.js"),require("./TimerWatcher.js"))}(),MO5("MO5.Exception").define("MO5.assert",function(e){function t(){e.apply(this,arguments),this.name="AssertionException"}function n(e,n){if(!e)throw new t(n)}return t.prototype=new e,n}),function(){function e(e,t,n){function i(e){e=e||{},e.bus=e.bus||{},u+=1,Object.defineProperty?Object.defineProperty(this,"id",{value:u,configurable:!1,enumerable:!1,writable:!1}):this.id=u,this.destroyed=!1,n.inject(this,e.bus),o[this.id]={}}function r(e){return a+e}function s(e){return e.replace(new RegExp(a),"")}var o={},a="CoreObject",u=0;return i.hasId=function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.id},i.isCoreObject=function(e){return e instanceof i},i.prototype.setFlag=function(e){var t=r(e);if(o[this.id])return o[this.id][t]=!0,this.trigger("flag_set",e),this},i.prototype.removeFlag=function(e){return this.hasFlag(e)?(delete o[this.id][r(e)],this.trigger("flag_removed",e),this):void 0},i.prototype.hasFlag=function(e){var t=r(e);return o[this.id]&&o[this.id].hasOwnProperty(t)},i.prototype.getFlags=function(){var e=[];for(var t in o[this.id])e.push(s(t));return e},i.prototype.connect=function(n,r,s,o){function a(e){e=e||null,"undefined"==typeof o||o!==!0&&o!==!1?r.trigger(s,e):r.trigger(s,e,o)}var u=this;return n=n||"*",s=s||"*",r&&r instanceof i?(this.subscribe(a,n),r.once(function(){u.unsubscribe(a,n)},"destroyed"),this):(t(new e("Cannot connect events: Parameter 3 is expected to be of type CoreObject.")),this)},i.prototype.implements=function(e){for(var t in e)if(typeof this[t]!=typeof e[t])return!1;return!0},i.prototype.toString=function(){return""+this.id},i.prototype.valueOf=function(){return this.id},i.prototype.destroy=function(){var e=this.id;this.destroyed=!0,this.trigger("destroyed",null,!1);for(var t in this)this[t]=null;delete o[e],this.destroyed=!0,this.id=e,delete this.toString,delete this.valueOf},i}"function"==typeof MO5?MO5("MO5.Exception","MO5.fail","MO5.EventBus").define("MO5.CoreObject",e):"undefined"!=typeof window?window.MO5.CoreObject=e(MO5.Exception,MO5.fail,MO5.EventBus):module.exports=e(require("./Exception.js"),require("./fail.js"),require("./EventBus.js"))}(),MO5().define("MO5.dom.effects.typewriter",function(){function e(e,t){function n(e){var t,i,r=e.childNodes;if(e.nodeType===o)for(e.style.display="none",t=0,i=r.length;i>t;t+=1)n(r[t])}function i(e,t){e.nodeType===o?!function(){for(var n=[];e.hasChildNodes();)n.push(e.removeChild(e.firstChild));e.style.display="",function r(){n.length>0?(i(n[0],r),e.appendChild(n.shift())):t&&setTimeout(t,0)}()}():e.nodeType===a&&!function(){function n(){e.data+=o[i],i+=1,s>i?setTimeout(n,1e3/r):t&&setTimeout(t,0)}var i,s,o=e.data.replace(/ +/g," ");e.data="",i=0,s=o.length,n()}()}var r,s,o=1,a=3;t=t||{},r=t.speed||50,s=t.onFinish||null,n(e),i(e,s)}return e}),MO5("MO5.CoreObject","MO5.transform","MO5.TimerWatcher","MO5.dom.effects.typewriter","MO5.types","MO5.Point","MO5.Size").define("MO5.dom.Element",function(e,t,n,i,r,s,o){function a(t){var n=this;t=t||{},e.call(this),this.parent=t.parent||document.body,this.nodeType=t.nodeType||"div",this.element=t.element||document.createElement(this.nodeType),u(this,this.element),a.propertiesToExclude.forEach(function(e){delete n[e]})}function u(e,t){for(var n in t)!function(n,i){"id"!==i&&(e[i]="function"==typeof n?function(){return t[i].apply(t,arguments)}:function(n){return arguments.length?(t[i]=n,e):t[i]})}(t[n],n)}function c(e,t){return-1!==e.indexOf(t)}return a.propertiesToExclude=["appendChild"],a.fromDomElement=function(e){return new a({element:e,nodeType:e.nodeName})},a.prototype=new e,a.prototype.constructor=a,a.prototype.appendTo=function(e){return e.appendChild(this.element)},a.prototype.remove=function(){return this.element.parentNode.removeChild(this.element)},a.prototype.appendChild=function(e){var t=e instanceof a?e.element:e;return this.element.appendChild(t)},a.prototype.addAsFirstChild=function(e){var t=e instanceof a?e.element:e;return this.element.childElementCount>0?this.element.insertBefore(t,this.element.childNodes[0]):this.element.appendChild(t)},a.prototype.fadeIn=function(e){e=e||{};var n=this.element;return this._lastFadeTimer&&this._lastFadeTimer.isRunning()&&this._lastFadeTimer.cancel(),this.show(),this._lastFadeTimer=t(function(e){n.style.opacity=e},parseInt(n.style.opacity,10)||0,1,e),this._lastFadeTimer},a.prototype.fadeOut=function(e){e=e||{};var n=this.element;return this._lastFadeTimer&&this._lastFadeTimer.isRunning()&&this._lastFadeTimer.cancel(),this._lastFadeTimer=t(function(e){n.style.opacity=e},parseInt(n.style.opacity,10)||1,0,e),this._lastFadeTimer.once("stopped",this.hide.bind(this)),this._lastFadeTimer},a.prototype.opacity=function(e){return"number"==typeof e&&(this.element.style.opacity=e),this.element.style.opacity},a.prototype.position=function(e){var t,n,i=this.element,o={};return r.isObject(e)&&(i.style.left=""+ +e.x+"px",i.style.top=""+ +e.y+"px"),o.left=i.offsetLeft,o.top=i.offsetTop,i.getBoundingClientRect&&(o=i.getBoundingClientRect()),t=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),n=Math.max(document.documentElement.scrollTop,document.body.scrollTop),new s(t+o.left,n+o.top)},a.prototype.size=function(e){return r.isObject(e)&&(this.element.style.width=""+e.width+"px",this.element.style.height=""+e.height+"px"),new o(this.element.offsetWidth,this.element.offsetHeight)},a.prototype.width=function(e){return r.isNumber(e)&&(this.element.style.width=""+e+"px"),this.element.offsetWidth},a.prototype.height=function(e){return r.isNumber(e)&&(this.element.style.height=""+e+"px"),this.element.offsetHeight},a.prototype.moveTo=function(e,i,r){r=r||{};var s,o,a=this.element,u=a.offsetLeft,c=a.offsetTop;return s=t(function(e){a.style.left=e+"px"},u,e,r),o=t(function(e){a.style.top=e+"px"},c,i,r),(new n).addTimer(s).addTimer(o)},a.prototype.move=function(e,t,n){n=n||{};var i=this.element,r=i.offsetLeft+e,s=i.offsetTop+t;return this.moveTo(r,s,n)},a.prototype.display=function(){this.element.style.visibility=""},a.prototype.show=a.prototype.display,a.prototype.hide=function(){this.element.style.visibility="hidden"},a.prototype.typewriter=function(e){e=e||{},i(this.element,e)},a.prototype.addCssClass=function(e){var t;return this.element.classList?(this.element.classList.add(e),this):(t=this.getCssClasses(),c(t,e)||(t.push(e),this.element.setAttribute("class",t.join(" "))),this)},a.prototype.removeCssClass=function(e){var t;return this.element.classList&&this.element.classList.remove(e),t=this.getCssClasses(),c(t,e)&&this.element.setAttribute("class",t.filter(function(t){return t!==e}).join(" ")),this},a.prototype.getCssClasses=function(){return(this.element.getAttribute("class")||"").split(" ")},a.prototype.hasCssClass=function(e){return this.element.classList?this.element.classList.contains(e):c(this.getCssClasses(),e)},a.prototype.clearCssClasses=function(){return this.element.setAttribute("class",""),this},a.prototype.setCssId=function(e){return this.element.setAttribute("id",e),this},a.prototype.destroy=function(){try{this.element.parentNode.removeChild(this.element)}catch(e){console.log(e)}this.element=null,this.destroyed=!0,this.trigger("destroyed",null,!1);for(var t in this)this.hasOwnProperty(t)&&delete this[t];this.destroyed=!0},a}),MO5().define("MO5.dom.escape",function(){function e(e){var t="";return t=e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}return e}),MO5().define("MO5.easing",function(){function e(e){return function(t){return function(n,i){return r[e](t,n,i)}}}function t(t){return e("easeIn")(t)}function n(t){return e("easeOut")(t)}function i(t){return e("easeInOut")(t)}var r=function(e){"use asm";function t(e,t){return e|=0,t|=0,+(t/e)}function n(t,n){t|=0,n|=0;var i=+(e.Math.PI/(2*t)),r=+e.Math.abs(e.Math.sin(n*i));return+r}function i(t,n){t|=0,n|=0;var i=+(e.Math.PI/(2*t)),r=+e.Math.abs(-e.Math.cos(n*i)+1);return+r}function r(e,t){return e|=0,t|=0,+(t/(e/2)<1)?+i(e,t):+n(e,t)}function s(e,t){e|=0,t|=0;var n=0,i=1,r=0;return r=(t/=e)<1/2.75?+(i*7.5625*t*t+n):t<2/2.75?+(i*(7.5625*(t-=1.5/2.75)*t+.75)+n):t<2.5/2.75?+(i*(7.5625*(t-=2.25/2.75)*t+.9375)+n):+(i*(7.5625*(t-=2.625/2.75)*t+.984375)+n),+r}function o(t,n,i){return n|=0,i|=0,+(1-e.Math.pow(1-i/n,t))}function a(t,n,i){return n|=0,i|=0,+e.Math.pow(i/n,t)}function u(e,t,n){t|=0,n|=0;var i=0;return i=n>t/2?+o(e,t,n):+a(e,t,n),+i}return{linear:t,sineEaseOut:n,sineEaseIn:i,sineEaseInOut:r,easeOutBounce:s,easeIn:a,easeOut:o,easeInOut:u}}(window);return r.easingFunctionGenerator=e,r.createEaseInFunction=t,r.createEaseOutFunction=n,r.createEaseInOutFunction=i,r.easeInQuad=t(2),r.easeInCubic=t(3),r.easeInQuart=t(4),r.easeInQuint=t(5),r.easeOutQuad=n(2),r.easeOutCubic=n(3),r.easeOutQuart=n(4),r.easeOutQuint=n(5),r.easeInOutQuad=i(2),r.easeInOutCubic=i(3),r.easeInOutQuart=i(4),r.easeInOutQuint=i(5),r}),function(){function e(){"use strict";function e(t){function n(e){var t;i.debug===!0&&(t=e.error.name||"Error",console.log(t+" in listener; Event: "+e.info.event+"; Message: "+e.error.message))}var i=this;return t=t||{},this instanceof e?(this.debug=t.debug||!1,this.interceptErrors=t.interceptErrors||!1,this.log=t.log||!1,this.logData=t.logData||!1,this.defaults=t.defaults||{},this.defaults.flowType=this.defaults.flowType||e.FLOW_TYPE_ASYNCHRONOUS,this.callbacks={"*":[]},void this.subscribe(n,"EventBus.error")):new e(t)}return e.FLOW_TYPE_ASYNCHRONOUS=0,e.FLOW_TYPE_SYNCHRONOUS=1,e.create=function(t){return t=t||{},new e(t)},e.prototype.subscribe=function(e,t){var n,i,r=this;if(void 0===t?(i="*",n=e):"string"==typeof e||"number"==typeof e?(i=e,n=t):("string"==typeof t||"number"==typeof t)&&(i=t,n=e),"string"!=typeof i&&"number"!=typeof i)throw new Error("Event names can only be strings or numbers! event: ",i);if("function"!=typeof n)throw new Error("Only functions may be used as listeners!");return i=i||"*",this.callbacks[i]=this.callbacks[i]||[],this.callbacks[i].push(n),this.trigger("EventBus.subscribe",{listener:n,event:i,bus:this}),function(){r.unsubscribe(n,i) -}},e.prototype.unsubscribe=function(e,t){var n,i,r,s,o;if(void 0===t?(o="*",s=e):"string"==typeof e||"number"==typeof e?(o=e,s=t):("string"==typeof t||"number"==typeof t)&&(o=t,s=e),"string"!=typeof o&&"number"!=typeof o)throw new Error("Event names can only be strings or numbers! event: ",o);if("function"!=typeof s)throw new Error("Only functions may be used as listeners!");for(o=o||"*",n=this.callbacks[o]||[],i=n.length,r=0;i>r;++r)n[r]===s&&this.callbacks[o].splice(r,1);this.trigger("EventBus.unsubscribe",{listener:s,event:o,bus:this})},e.prototype.once=function(e,t){var n,i,r,s,o,a=this,u=!1;if(s="function"==typeof e,o="function"==typeof t,s&&o||!s&&!o)throw new Error("Parameter mismatch; one parameter needs to be a function, the other one must be a string.");s?(r=e,i=t):(r=t,i=e),i=i||"*",n=function(e,t){u||(u=!0,a.unsubscribe(n,i),r(e,t))},this.subscribe(n,i)},e.prototype.trigger=function(t,n,i){function r(e){setTimeout(function(){throw e},0)}var s,o,a,u,c,l,d,h;if("undefined"!=typeof t&&"string"!=typeof t&&"number"!=typeof t)throw new Error("Event names can only be strings or numbers! event: ",t);t=arguments.length?t:"*",h="undefined"!=typeof i&&i===!1?e.FLOW_TYPE_SYNCHRONOUS:this.defaults.flowType,d=this,s=function(){var e,n,i,r,s,o,a="",u=[];for(n=t.split("."),e=0,i=n.length;i>e;++e)for(a=a+(e>0?".":"")+n[e],r=d.callbacks[a]||[],s=0,o=r.length;o>s;++s)u.push(r[s]);if("*"===t)return u;for(r=d.callbacks["*"]||[],s=0,o=r.length;o>s;++s)u.push(r[s]);return u}(),o=s.length,a={event:t,subscribers:o,async:h===e.FLOW_TYPE_ASYNCHRONOUS?!0:!1,getQueueLength:function(){return 0===o?0:o-(u+1)}},c=function(){for(d.log===!0&&console.log("EventBus event triggered: "+t+"; Subscribers: "+o,d.logData===!0?"; Data: "+n:""),u=0;o>u;++u){l=s[u];try{l(n,a)}catch(e){console.log(e),d.trigger("EventBus.error",{error:e,info:a}),d.interceptErrors!==!0&&r(e)}}},h===e.FLOW_TYPE_ASYNCHRONOUS?setTimeout(c,0):c()},e.prototype.triggerSync=function(e,t){return this.trigger(e,t,!1)},e.prototype.triggerAsync=function(e,t){return this.trigger(e,t,!0)},e.inject=function(t,n){n=n||{};var i=new e(n);t.subscribe=function(e,t){i.subscribe(e,t)},t.unsubscribe=function(e,t){i.unsubscribe(e,t)},t.once=function(e,t){i.once(e,t)},t.trigger=function(e,t,n){n="undefined"!=typeof n&&n===!1?!1:!0,i.trigger(e,t,n)},t.triggerSync=i.triggerSync.bind(i),t.triggerAsync=i.triggerAsync.bind(i)},e}"function"==typeof MO5?MO5().define("MO5.EventBus",e):"undefined"!=typeof window?(window.MO5=MO5||{},window.MO5.EventBus=e()):module.exports=e()}(),function(){function e(){function e(e){var t,n=Error.apply(null,arguments);for(t in n)this[t]=n[t];this.message=e,this.name="MO5.Exception"}return e.prototype=new Error,e.prototype.constructor=e,e}"function"==typeof MO5?MO5().define("MO5.Exception",e):"undefined"!=typeof window?(window.MO5=window.MO5||{},window.MO5.Exception=e()):module.exports=e()}(),function(){function e(){function e(e){console.error?console.error(e.toString()):console.log(e.toString()),e.stack&&console.log(e.stack)}return e}"function"==typeof MO5?MO5().define("MO5.fail",e):"undefined"!=typeof window?window.MO5.fail=e():module.exports=e()}(),MO5().define("MO5.globals.document",function(){return document}),MO5().define("MO5.globals.window",function(){return window}),function(){function e(e,t,n){function i(t){e.call(this),this.unsubscribers={},this.items=n.isArray(t)?t:[]}return i.prototype=new e,i.prototype.length=function(){return this.items.length},i.prototype.append=function(t){function n(){var e,n;for(e=0,n=r.items.length;n>e;e+=1)r.items[e]===t&&r.items.splice(e,1);delete r.unsubscribers[t.id]}function i(){t.unsubscribe(n,"destroyed")}var r=this;return e.isCoreObject(t)&&(this.unsubscribers[t.id]=i,t.subscribe(n,"destroyed")),this.items.push(t),this},i.prototype.remove=function(t){var n=this.items[t];return e.isCoreObject(n)&&(this.unsubscribers[n.id](),delete this.unsubscribers[n.id]),this.items.splice(t,1),this},i.prototype.at=function(e){return this.items[+e]},i.prototype.indexOf=function(e){return this.items.indexOf(e)},i.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},i.prototype.toQueue=function(){var e=new t;return this.items.forEach(function(t){e.add(t)}),e},i.prototype.forEach=function(e){this.items.forEach(e)},i.prototype.filter=function(e){return this.items.filter(e)},i.prototype.map=function(e){return this.items.map(e)},i.prototype.reduce=function(e){return this.items.reduce(e)},i.prototype.every=function(e){return this.items.every(e)},i.prototype.some=function(e){return this.items.some(e)},i.prototype.find=function(e){var t,n=this.items.length;for(t=0;n>t;t+=1)if(e(this.items[t]))return this.items[t];return void 0},i.prototype.combine=function(e){return new i(this.items.slice().concat(e.items))},i.prototype.clone=function(){return new i(this.items.slice())},i}"function"==typeof MO5?MO5("MO5.CoreObject","MO5.Queue","MO5.types").define("MO5.List",e):"undefined"!=typeof window?window.MO5.List=e(MO5.CoreObject,MO5.Queue,MO5.types):module.exports=e(require("./CoreObject.js"),require("./Queue.js"),require("./types.js"))}(),function(){function e(e){function t(e){return r+e}function n(e){return e.replace(new RegExp(r),"")}function i(t){var n;if(e.call(this),this.clear(),t)for(n in t)this.set(n,t[n])}var r="MO5Map";return i.prototype=new e,i.prototype.clear=function(){this.items={},this.unsubscribers={},this.count=0},i.prototype.length=function(){return this.count},i.prototype.set=function(n,i){function r(){delete s.items[o],s.count-=1}var s=this,o=t(n);if(!n)throw new Error("MO5.Map keys cannot be falsy.");if(this.has(o)&&this.remove(o),i&&i instanceof e){if(i.destroyed)throw new Error("Trying to add an MO5.Object that has already been destroyed.");i.subscribe(r,"destroyed")}if(n instanceof e){if(n.destroyed)throw new Error("Trying to use an MO5.Object as key that has already been destroyed.");n.subscribe(r,"destroyed")}return(i&&i instanceof e||n instanceof e)&&(this.unsubscribers[o]=function(){i instanceof e&&i.unsubscribe(r,"destroyed"),n instanceof e&&n.unsubscribe(r,"destroyed")}),this.items[o]=i,this.count+=1,this.trigger("updated",null,!1),this.trigger("set",o,!1),this},i.prototype.get=function(e){var n=t(e);return this.items.hasOwnProperty(n)?this.items[n]:void 0},i.prototype.require=function(e){if(!this.has(e))throw new Error("Required key '"+e+"' does not exist.");return this.get(e)},i.prototype.remove=function(e){var n=t(e);if(!this.has(e))throw new Error("Trying to remove an unknown key from an MO5.Map.");return this.unsubscribers.hasOwnProperty(n)&&(this.unsubscribers[n](),delete this.unsubscribers[n]),delete this.items[n],this.count-=1,this.trigger("updated",null,!1),this.trigger("removed",n,!1),this},i.prototype.has=function(e){var n=t(e);return this.items.hasOwnProperty(n)},i.prototype.destroy=function(){for(var t in this.unsubscribers)this.unsubscribers[t](),delete this.unsubscribers[t];e.prototype.destroy.call(this)},i.prototype.forEach=function(e){if(!e||"function"!=typeof e)throw new Error("Parameter 1 is expected to be of type function.");for(var t in this.items)e(this.items[t],n(t),this);return this},i.prototype.filter=function(e){var t=new i;return this.forEach(function(n,i,r){e(n,i,r)&&t.set(i,n)}),t},i.prototype.find=function(e){var t,n=!1;return this.forEach(function(i,r,s){!n&&e(i,r,s)&&(t=i,n=!0)}),t},i.prototype.map=function(e){var t=new i;return this.forEach(function(n,i,r){t.set(i,e(n,i,r))}),t},i.prototype.reduce=function(e,t){var n=t;return this.forEach(function(t,i,r){n=e(n,t,i,r)}),n},i.prototype.every=function(e){return this.reduce(function(t,n,i,r){return t&&e(n,i,r)},!0)},i.prototype.some=function(e){var t=!1;return this.forEach(function(n,i,r){!t&&e(n,i,r)&&(t=!0)}),t},i.prototype.keys=function(){var e=[];return this.forEach(function(t,n){e.push(n)}),e},i.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},i.prototype.toObject=function(){var e={};return this.forEach(function(t,n){e[n]=t}),e},i.prototype.clone=function(){var e=new i;return this.forEach(function(t,n){e.set(n,t)}),e},i.prototype.addMap=function(e){var t=this;return e.forEach(function(e,n){t.set(n,e)}),this},i.prototype.join=function(e){return this.clone().addMap(e)},i}"function"==typeof MO5?MO5("MO5.CoreObject","MO5.Exception").define("MO5.Map",e):"undefined"!=typeof window?window.MO5.Map=e(MO5.CoreObject,MO5.Exception):module.exports=e(require("./CoreObject.js"),require("./Exception.js"))}(),MO5().define("MO5.Point",function(){function e(e,t){this.x=e,this.y=t}return e.prototype.getDistance=function(e){var t=this.x-e.x,n=this.y-e.y,i=Math.squrt(t*t+n*n);return i},e}),function(){var e,t,n,i;!function(){var r={},s={};e=function(e,t,n){r[e]={deps:t,callback:n}},i=n=t=function(e){function n(t){if("."!==t.charAt(0))return t;for(var n=t.split("/"),i=e.split("/").slice(0,-1),r=0,s=n.length;s>r;r++){var o=n[r];if(".."===o)i.pop();else{if("."===o)continue;i.push(o)}}return i.join("/")}if(i._eak_seen=r,s[e])return s[e];if(s[e]={},!r[e])throw new Error("Could not find module "+e);for(var o,a=r[e],u=a.deps,c=a.callback,l=[],d=0,h=u.length;h>d;d++)l.push("exports"===u[d]?o={}:t(n(u[d])));var p=c.apply(this,l);return s[e]=o||p}}(),e("promise/all",["./utils","exports"],function(e,t){"use strict";function n(e){var t=this;if(!i(e))throw new TypeError("You must pass an array to all.");return new t(function(t,n){function i(e){return function(t){s(e,t)}}function s(e,n){a[e]=n,0===--u&&t(a)}var o,a=[],u=e.length;0===u&&t([]);for(var c=0;c0},n.prototype.clear=function(){return this.arr=[],this.trigger("updated"),this.trigger("cleared"),this},n.prototype.reverse=function(){for(var e=new n,t=this.length(),i=t-1;i>=0;)e.add(this.arr[i]),i-=1;return e},n.prototype.clone=function(){return new n(this.arr.slice())},n}"function"==typeof MO5?MO5("MO5.Exception","MO5.CoreObject").define("MO5.Queue",e):"undefined"!=typeof window?window.MO5.Queue=e(MO5.Exception,MO5.CoreObject):module.exports=e(require("./Exception.js"),require("./CoreObject.js"))}(),function(){function e(){function e(e,t){var n,i=[];for(n=e;t>=n;n+=1)i.push(n);return i}return e}"function"==typeof MO5?MO5().define("MO5.range",e):"undefined"!=typeof window?window.MO5.range=e():module.exports=e()}(),function(){function e(e,t,n,i){function r(e,t){for(;e.hasNext();)u(function(e){return function(){e(t)}}(e.next()))}function s(e,t,n,i){t.add("function"==typeof n?function(e){var t;try{t=n(e),t&&t instanceof a?t.then(i.success,i.failure):i.success(t)}catch(r){i.failure(r)}return t}:function(t){i[e](t)})}function o(){e.call(this),this.successQueue=new t,this.failureQueue=new t,this.value=void 0,this.status=o.STATUS_PENDING,this.promise=new a(this)}function a(t){e.call(this),this.then=function(e,n){var i=new o;switch(t.status){case o.STATUS_PENDING:o.addToQueue("success",t.successQueue,e,i),o.addToQueue("failure",t.failureQueue,n,i);break;case o.STATUS_SUCCESS:o.addToQueue("success",t.successQueue,e,i),o.resolve(t.successQueue,t.value);break;case o.STATUS_FAILURE:o.addToQueue("failure",t.failureQueue,n,i),o.resolve(t.failureQueue,t.value)}return i.promise}}var u;return u="undefined"!=typeof window&&window.setImmediate?window.setImmediate:"undefined"!=typeof process?function(e){process.nextTick(e)}:function(e){setTimeout(e,0)},o.STATUS_PENDING=1,o.STATUS_FAILURE=2,o.STATUS_SUCCESS=3,o.getFulfilledPromise=function(){return(new o).success().promise},o.getBrokenPromise=function(){return(new o).failure().promise},o.prototype=new e,o.prototype.isPending=function(){return this.status===o.STATUS_PENDING},o.prototype.failure=function(e){return this.status!==o.STATUS_PENDING?void i(new n("The result of the action has already been determined.")):(this.value=e,this.status=o.STATUS_FAILURE,r(this.failureQueue,e),this.successQueue.clear(),this.failureQueue.clear(),this)},o.prototype.success=function(e){return this.status!==o.STATUS_PENDING?void i(new n("The result of the action has already been determined.")):(this.value=e,this.status=o.STATUS_SUCCESS,r(this.successQueue,e),this.successQueue.clear(),this.failureQueue.clear(),this)},o.addToQueue=s,o.resolve=r,a.prototype=new e,o}console.warn("MO5.Result is deprecated - use MO5.Promise instead!"),"function"==typeof MO5?MO5("MO5.CoreObject","MO5.Queue","MO5.Exception","MO5.fail").define("MO5.Result",e):"undefined"!=typeof window?window.MO5.CoreObject=e(MO5.CoreObject,MO5.Queue,MO5.Exception,MO5.fail):module.exports=e(require("./CoreObject.js"),require("./Queue.js"),require("./Exception.js"),require("./fail.js"))}(),function(){function e(e,t){function n(n){e.call(this),this._unsubscribers={},this._stringItems={},this._items=[],n&&t.hasForEach(n)&&this.addMany(n)}function i(e){return t.isObject(e)?t.isNumber(e.id)?!0:!1:!0}function r(e){return t.isObject(e)?s+"MO5CoreObject_"+e.id:s+"SimpleValue_"+JSON.stringify(e)}var s="MO5Set_";return n.fromRange=function(e,t){var i,r=new n;for(i=e;t>=i;i+=1)r.add(i);return r},n.prototype=new e,n.prototype.has=function(e){var t,n;if(i(e))return r(e)in this._stringItems;for(t=0,n=this._items.length;n>t;t+=1)if(this._items[t]===e)return!0;return!1},n.prototype.add=function(t){var n;return this.has(t)?this:(i(t)?(n=r(t),this._stringItems[n]=t,e.isCoreObject(t)&&(this._unsubscribers[n]=this.delete.bind(this,t),t.subscribe("destroyed",this._unsubscribers[n]))):this._items.push(t),this)},n.prototype.delete=function(t){var n;return this.has(t)?(i(t)?(n=r(t),delete this._stringItems[n],e.isCoreObject(t)&&(t.unsubscribe("destroyed",this._unsubscribers[n]),delete this._unsubscribers[n])):this._items.splice(this._items.indexOf(t),1),!0):!1},n.prototype.clear=function(){this._items.forEach(this.delete.bind(this)),this._items=[],this._stringItems={},this._unsubscribers={}},n.prototype.forEach=function(e){var t,n=0;for(t in this._stringItems)e(this._stringItems[t],n,this),n+=1;this._items.forEach(function(t){e(t,n,this),n+=1}.bind(this))},n.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},n.prototype.keys=n.prototype.values,n.prototype.addMany=function(e){return e.forEach(this.add.bind(this)),this},n.prototype.intersection=function(e){var t=new n;return e.forEach(function(e){this.has(e)&&t.add(e)}.bind(this)),t},n.prototype.difference=function(e){var t=new n(this.values());return e.forEach(function(e){t.has(e)?t.delete(e):t.add(e)}),t},n.prototype.size=function(){var e,t=this._items.length;for(e in this._stringItems)t+=1;return t},n}"function"==typeof MO5?MO5("MO5.CoreObject","MO5.types").define("MO5.Set",e):"undefined"!=typeof window?window.MO5.Set=e(MO5.CoreObject,MO5.types):module.exports=e(require("./CoreObject.js"),require("./types.js"))}(),MO5().define("MO5.Size",function(){function e(e,t){this.width=e||0,this.height=t||0}return e}),function(){function e(e,t,n,i){function r(t){e.call(this),this.message=t,this.name="MO5.TimerError"}function s(){t.call(this),this.running=!1,this.paused=!1,this.canceled=!1,this.startTime=+new Date,this.timeElapsed=0,this.pauseTimeElapsed=0,this.pauseStartTime=this.startTime}return r.prototype=new e,s.prototype=new t,s.prototype.constructor=s,s.prototype.start=function(){return this.startTime=+new Date,this.running=!0,this.trigger("started",null,!1),this},s.prototype.stop=function(){return this.running=!1,this.paused=!1,this.trigger("stopped",null,!1),this},s.prototype.cancel=function(){return this.running||n(new r("Trying to cancel a Timer that isn't running.")),this.elapsed(),this.canceled=!0,this.running=!1,this.paused=!1,this.trigger("canceled",null,!1),this},s.prototype.isRunning=function(){return this.running},s.prototype.isCanceled=function(){return this.canceled},s.prototype.isPaused=function(){return this.paused},s.prototype.pause=function(){this.paused=!0,this.pauseStartTime=+new Date,this.trigger("paused",null,!1)},s.prototype.resume=function(){this.paused||n(new r("Trying to resume a timer that isn't paused.")),this.paused=!1,this.pauseTimeElapsed+=+new Date-this.pauseStartTime,this.trigger("resumed",null,!1)},s.prototype.elapsed=function(){return this.running&&!this.paused&&(this.timeElapsed=+new Date-this.startTime-this.pauseTimeElapsed),this.timeElapsed},s.prototype.getReadOnlyCapability=function(){var e=this;return{isRunning:function(){return e.running},isCanceled:function(){return e.canceled},isPaused:function(){return e.paused},elapsed:function(){return e.elapsed()}}},s.prototype.promise=function(){var e=new i,t=this;return this.once(function(){e.resolve(t)},"stopped"),this.once(function(){e.reject(t)},"canceled"),this.once(function(){e.reject(t)},"destroyed"),e},s}"function"==typeof MO5?MO5("MO5.Exception","MO5.CoreObject","MO5.fail","MO5.Promise").define("MO5.Timer",e):"undefined"!=typeof window?window.MO5.Timer=e(MO5.Exception,MO5.CoreObject,MO5.fail,MO5.Promise):module.exports=e(require("./Exception.js"),require("./CoreObject.js"),require("./fail.js"),require("./Promise.js"))}(),function(){function e(e,t,n,i){function r(n){var i;if(t.call(this),n&&!(n instanceof Array))throw new e("Parameter 1 is expected to be of type Array.").log();n=n||[],i=this,this.timers={},this.count=0,n.forEach(function(e){i.addTimer(e)})}return r.prototype=new t,r.prototype.constructor=r,r.prototype.addTimer=function(t){var i,r=this;return this.timers[+t]?(n(new e("A timer with ID '"+t+"' has already been added to the watcher.")),this):(this.count+=1,i=function(){r.count-=1,r.count<1&&r.trigger("stopped",null,!1)},this.timers[+t]={timer:t,unsubscribe:function(){t.unsubscribe(i,"stopped")}},t.subscribe(i,"stopped"),this.trigger("added",t,!1),this)},r.prototype.createTimer=function(){var e=new i;return this.trigger("created",e,!1),this.addTimer(e),e},r.prototype.removeTimer=function(t){return this.timers[+t]?(this.timers[+t].unsubscribe(),delete this.timers[+t],this.trigger("removed",t,!1),this):(n(new e("Trying to remove a timer that is unknown to the watcher.")),this)},r.prototype.forAll=function(e){var t,n;for(t in this.timers)this.timers.hasOwnProperty(t)&&(n=this.timers[t].timer,n instanceof r?this.timers[t].timer.forAll(e):this.timers[t].timer[e]());return this},r.prototype.cancel=function(){return this.forAll("cancel"),this.trigger("canceled",null,!1),this},r.prototype.pause=function(){return this.forAll("pause"),this.trigger("paused",null,!1),this},r.prototype.resume=function(){return this.forAll("resume"),this.trigger("resumed",null,!1),this},r.prototype.stop=function(){return this.forAll("stop")},r.prototype.start=function(){return this.forAll("start"),this.trigger("started",null,!1),this},r.prototype.promise=function(){return i.prototype.promise.call(this)},r}"function"==typeof MO5?MO5("MO5.Exception","MO5.CoreObject","MO5.fail","MO5.Timer").define("MO5.TimerWatcher",e):"undefined"!=typeof window?window.MO5.TimerWatcher=e(MO5.Exception,MO5.CoreObject,MO5.fail,MO5.Timer):module.exports=e(require("./Exception.js"),require("./CoreObject.js"),require("./fail.js"),require("./Timer.js"))}(),MO5().define("MO5.tools",function(){var e={};return e.getUniqueId=function(){var e=0;return function(){return e++}}(),e.getWindowDimensions=function(){var e=window,t="inner";return"innerWidth"in e||(t="client",e=document.documentElement||document.body),{width:e[t+"Width"],height:e[t+"Height"]}},e.fitToWindow=function(t,n,i){var r,s,o,a,u,c;r=e.getWindowDimensions(),o=r.width,a=r.height,u=o/n,c=a/i,s=u>c?c:u,t.setAttribute("style",t.getAttribute("style")+" -moz-transform: scale("+s+","+s+") rotate(0.01deg); -ms-transform: scale("+s+","+s+"); -o-transform: scale("+s+","+s+"); -webkit-transform: scale("+s+","+s+"); transform: scale("+s+","+s+");")},e.timeoutInspector=function(){var e,t,n,i,r,s={},o=0,a=0,u=0;return e=window.setTimeout,t=window.setInterval,n=window.clearTimeout,i=window.clearInterval,r=window.requestAnimationFrame,{logAnimationFrameRequests:!1,logTimeouts:!1,logIntervals:!1,enable:function(){window.setTimeout=function(t,n){var i=e(t,n);return o+=1,this.logTimeouts&&console.log("Setting timeout: ",{callback:t.toString(),time:n},i),i},window.setInterval=function(e,n){var i=t(e,n);return a+=1,s[i]=!0,this.logIntervals&&console.log("Setting interval: ",{callback:e.toString(),time:n},i),i},window.clearTimeout=function(e){return console.log("Clearing timeout: ",e),n(e)},window.clearInterval=function(e){return console.log("Clearing interval: ",e),e in s?delete s[e]:console.log("Warning: Interval "+e+" doesn't exist."),i(e)},window.requestAnimationFrame=function(e){return u+=1,this.logAnimationFrameRequests&&console.log("Requesting animation frame: ",{callback:e.toString()}),r(e)}},disable:function(){window.setTimeout=e,window.setInterval=t,window.clearTimeout=n,window.clearInterval=i,window.requestAnimationFrame=r},getActiveIntervals:function(){var e,t=[];for(e in this.activeIntervals)t.push(e);return t},totalTimeoutCalls:function(){return o},totalIntervalCalls:function(){return a},totalRequestAnimationFrameCalls:function(){return u}}}(),e}),MO5("MO5.Exception","MO5.Timer","MO5.easing").define("MO5.transform",function(e,t,n){function i(i,r,s,o){if(o=o||{},"undefined"==typeof i||!i)throw new e("MO5.transform expects parameter callback to be a function.");var a,u,c="undefined"!=typeof o.duration&&o.duration>=0?o.duration:500,l=r,d=o.timer||new t,h=s-r,p=o.log||!1,f=0,m=0,g=o.fps||MO5.defaults.fps;return a=o.easing||n.sineEaseOut,u=function(){var e,t;if(Date.now()-m>1e3/g){if(d.canceled)return;if(d.paused)return void d.once(u,"resumed");if(f+=1,t=d.elapsed(),t>c||d.stopped)return l=r+h,i(s),void(d.stopped||d.stop());l=a(c,t)*h+r,i(l),e=d.elapsed()-t,p===!0&&console.log("Current value: "+l+"; c: "+f+"; Exec time: "+e),m=Date.now()}requestAnimationFrame(u)},d.start(),requestAnimationFrame(u),d}return i}),function(){function e(){var e={};return e.isObject=function(e){return"object"==typeof e&&null!==e},e.isString=function(e){return"string"==typeof e},e.isNumber=function(e){return"number"==typeof e},e.isFunction=function(e){return"function"==typeof e},e.isArray=function(t){return Array.isArray?Array.isArray(t):e.isObject(t)?t instanceof Array:!1},e.hasForEach=function(t){return e.isObject(t)&&e.isFunction(t.forEach)},e}"function"==typeof MO5?MO5().define("MO5.types",e):"undefined"!=typeof window?window.MO5.types=e():module.exports=e()}(),MO5("WSE.assets.Animation","WSE.assets.Audio","WSE.assets.Background","WSE.assets.Character","WSE.assets.Curtain","WSE.assets.Imagepack","WSE.assets.Textbox").define("WSE.assets",function(e,t,n,i,r,s,o){var a={Animation:e,Audio:t,Background:n,Character:i,Curtain:r,Imagepack:s,Textbox:o};return a}),MO5("WSE.commands.alert","WSE.commands.break","WSE.commands.choice","WSE.commands.confirm","WSE.commands.do","WSE.commands.fn","WSE.commands.global","WSE.commands.globalize","WSE.commands.goto","WSE.commands.line","WSE.commands.localize","WSE.commands.prompt","WSE.commands.restart","WSE.commands.set_vars","WSE.commands.sub","WSE.commands.trigger","WSE.commands.var","WSE.commands.wait","WSE.commands.while","WSE.commands.with").define("WSE.commands",function(e,t,n,i,r,s,o,a,u,c,l,d,h,p,f,m,g,y,b,w){"use strict";var v={alert:e,"break":t,choice:n,confirm:i,"do":r,fn:s,global:o,globalize:a,"goto":u,line:c,localize:l,prompt:d,restart:h,set_vars:p,sub:f,trigger:m,"var":g,wait:y,"while":b,"with":w};return v}),MO5().define("WSE.functions",function(){"use strict";var e={savegames:function(e){e.toggleSavegameMenu()},stageclick_disable:function(e){e.game.unsubscribeListeners()},stageclick_enable:function(e){e.game.subscribeListeners()}};return e}),MO5("WSE.dataSources.LocalStorage").define("WSE.dataSources",function(e){var t={LocalStorage:e};return t}),MO5("MO5.EventBus","WSE.assets","WSE.commands","WSE.dataSources","WSE.functions").define("WSE",function(e,t,n,i,r){"use strict";var s={},o="2015.10.1-final.1510032031";return e.inject(s),s.dataSources=i,s.assets=t,s.commands=n,s.functions=r,s.getVersion=function(){return o},s}),MO5().define("WSE.Keys",function(){function e(e){e=e||{},this.keys={},this.keys.BACKSPACE={kc:8},this.keys.TAB={kc:9},this.keys.ENTER={kc:13,which:13},this.keys.SHIFT={kc:16},this.keys.CTRL={kc:17},this.keys.ALT={kc:18},this.keys.PAUSE={kc:19},this.keys.CAPS_LOCK={kc:20},this.keys.ESCAPE={kc:27},this.keys.SPACE={kc:32},this.keys.PAGE_UP={kc:33},this.keys.PAGE_DOWN={kc:20},this.keys.END={kc:20},this.keys.HOME={kc:20},this.keys.LEFT_ARROW={kc:37},this.keys.UP_ARROW={kc:38},this.keys.RIGHT_ARROW={kc:39},this.keys.DOWN_ARROW={kc:40},this.keys.INSERT={kc:45},this.keys.DELETE={kc:46},this.keys.NUM_0={kc:48},this.keys.NUM_1={kc:49},this.keys.NUM_2={kc:50},this.keys.NUM_3={kc:51},this.keys.NUM_4={kc:52},this.keys.NUM_5={kc:53},this.keys.NUM_6={kc:54},this.keys.NUM_7={kc:55},this.keys.NUM_8={kc:56},this.keys.NUM_9={kc:57},this.keys.A={kc:65},this.keys.B={kc:66},this.keys.C={kc:67},this.keys.D={kc:68},this.keys.E={kc:69},this.keys.F={kc:70},this.keys.G={kc:71},this.keys.H={kc:72},this.keys.I={kc:73},this.keys.J={kc:74},this.keys.K={kc:75},this.keys.L={kc:76},this.keys.M={kc:77},this.keys.N={kc:78},this.keys.O={kc:79},this.keys.P={kc:80},this.keys.Q={kc:81},this.keys.R={kc:82},this.keys.S={kc:83},this.keys.T={kc:84},this.keys.U={kc:85},this.keys.V={kc:86},this.keys.W={kc:87},this.keys.X={kc:88},this.keys.Y={kc:89},this.keys.Z={kc:90},this.keys.LEFT_WIN={kc:91},this.keys.RIGHT_WIN={kc:92},this.keys.SELECT={kc:93},this.keys.NUMPAD_0={kc:96},this.keys.NUMPAD_1={kc:97},this.keys.NUMPAD_2={kc:98},this.keys.NUMPAD_3={kc:99},this.keys.NUMPAD_4={kc:100},this.keys.NUMPAD_5={kc:101},this.keys.NUMPAD_6={kc:102},this.keys.NUMPAD_7={kc:103},this.keys.NUMPAD_8={kc:104},this.keys.NUMPAD_9={kc:105},this.keys.MULTIPLY={kc:106},this.keys.ADD={kc:107},this.keys.SUBSTRACT={kc:109},this.keys.DECIMAL_POINT={kc:110},this.keys.DIVIDE={kc:111},this.keys.F1={kc:112},this.keys.F2={kc:113},this.keys.F3={kc:114},this.keys.F4={kc:115},this.keys.F5={kc:116},this.keys.F6={kc:117},this.keys.F7={kc:118},this.keys.F8={kc:119},this.keys.F9={kc:120},this.keys.F10={kc:121},this.keys.F11={kc:122},this.keys.F12={kc:123},this.keys.NUM_LOCK={kc:144},this.keys.SCROLL_LOCK={kc:145},this.keys.SEMI_COLON={kc:186},this.keys.EQUALS={kc:187},this.keys.COMMA={kc:188},this.keys.DASH={kc:189},this.keys.PERIOD={kc:190},this.keys.SLASH={kc:191},this.keys.GRAVE={kc:192},this.keys.OPEN_BRACKET={kc:219},this.keys.BACK_SLASH={kc:220},this.keys.CLOSE_BRACKET={kc:221},this.keys.SINGLE_QUOTE={kc:222},this.listeners=[]; +}},e.prototype.unsubscribe=function(e,t){var n,i,r,s,o;if(void 0===t?(o="*",s=e):"string"==typeof e||"number"==typeof e?(o=e,s=t):("string"==typeof t||"number"==typeof t)&&(o=t,s=e),"string"!=typeof o&&"number"!=typeof o)throw new Error("Event names can only be strings or numbers! event: ",o);if("function"!=typeof s)throw new Error("Only functions may be used as listeners!");for(o=o||"*",n=this.callbacks[o]||[],i=n.length,r=0;i>r;++r)n[r]===s&&this.callbacks[o].splice(r,1);this.trigger("EventBus.unsubscribe",{listener:s,event:o,bus:this})},e.prototype.once=function(e,t){var n,i,r,s,o,a=this,u=!1;if(s="function"==typeof e,o="function"==typeof t,s&&o||!s&&!o)throw new Error("Parameter mismatch; one parameter needs to be a function, the other one must be a string.");s?(r=e,i=t):(r=t,i=e),i=i||"*",n=function(e,t){u||(u=!0,a.unsubscribe(n,i),r(e,t))},this.subscribe(n,i)},e.prototype.trigger=function(t,n,i){function r(e){setTimeout(function(){throw e},0)}var s,o,a,u,c,l,d,h;if("undefined"!=typeof t&&"string"!=typeof t&&"number"!=typeof t)throw new Error("Event names can only be strings or numbers! event: ",t);t=arguments.length?t:"*",h="undefined"!=typeof i&&i===!1?e.FLOW_TYPE_SYNCHRONOUS:this.defaults.flowType,d=this,s=function(){var e,n,i,r,s,o,a="",u=[];for(n=t.split("."),e=0,i=n.length;i>e;++e)for(a=a+(e>0?".":"")+n[e],r=d.callbacks[a]||[],s=0,o=r.length;o>s;++s)u.push(r[s]);if("*"===t)return u;for(r=d.callbacks["*"]||[],s=0,o=r.length;o>s;++s)u.push(r[s]);return u}(),o=s.length,a={event:t,subscribers:o,async:h===e.FLOW_TYPE_ASYNCHRONOUS?!0:!1,getQueueLength:function(){return 0===o?0:o-(u+1)}},c=function(){for(d.log===!0&&console.log("EventBus event triggered: "+t+"; Subscribers: "+o,d.logData===!0?"; Data: "+n:""),u=0;o>u;++u){l=s[u];try{l(n,a)}catch(e){console.log(e),d.trigger("EventBus.error",{error:e,info:a}),d.interceptErrors!==!0&&r(e)}}},h===e.FLOW_TYPE_ASYNCHRONOUS?setTimeout(c,0):c()},e.prototype.triggerSync=function(e,t){return this.trigger(e,t,!1)},e.prototype.triggerAsync=function(e,t){return this.trigger(e,t,!0)},e.inject=function(t,n){n=n||{};var i=new e(n);t.subscribe=function(e,t){i.subscribe(e,t)},t.unsubscribe=function(e,t){i.unsubscribe(e,t)},t.once=function(e,t){i.once(e,t)},t.trigger=function(e,t,n){n="undefined"!=typeof n&&n===!1?!1:!0,i.trigger(e,t,n)},t.triggerSync=i.triggerSync.bind(i),t.triggerAsync=i.triggerAsync.bind(i)},e}"function"==typeof MO5?MO5().define("MO5.EventBus",e):"undefined"!=typeof window?(window.MO5=MO5||{},window.MO5.EventBus=e()):module.exports=e()}(),function(){function e(){function e(e){var t,n=Error.apply(null,arguments);for(t in n)this[t]=n[t];this.message=e,this.name="MO5.Exception"}return e.prototype=new Error,e.prototype.constructor=e,e}"function"==typeof MO5?MO5().define("MO5.Exception",e):"undefined"!=typeof window?(window.MO5=window.MO5||{},window.MO5.Exception=e()):module.exports=e()}(),function(){function e(){function e(e){console.error?console.error(e.toString()):console.log(e.toString()),e.stack&&console.log(e.stack)}return e}"function"==typeof MO5?MO5().define("MO5.fail",e):"undefined"!=typeof window?window.MO5.fail=e():module.exports=e()}(),MO5().define("MO5.globals.document",function(){return document}),MO5().define("MO5.globals.window",function(){return window}),function(){function e(e,t,n){function i(t){e.call(this),this.unsubscribers={},this.items=n.isArray(t)?t:[]}return i.prototype=new e,i.prototype.length=function(){return this.items.length},i.prototype.append=function(t){function n(){var e,n;for(e=0,n=r.items.length;n>e;e+=1)r.items[e]===t&&r.items.splice(e,1);delete r.unsubscribers[t.id]}function i(){t.unsubscribe(n,"destroyed")}var r=this;return e.isCoreObject(t)&&(this.unsubscribers[t.id]=i,t.subscribe(n,"destroyed")),this.items.push(t),this},i.prototype.remove=function(t){var n=this.items[t];return e.isCoreObject(n)&&(this.unsubscribers[n.id](),delete this.unsubscribers[n.id]),this.items.splice(t,1),this},i.prototype.at=function(e){return this.items[+e]},i.prototype.indexOf=function(e){return this.items.indexOf(e)},i.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},i.prototype.toQueue=function(){var e=new t;return this.items.forEach(function(t){e.add(t)}),e},i.prototype.forEach=function(e){this.items.forEach(e)},i.prototype.filter=function(e){return this.items.filter(e)},i.prototype.map=function(e){return this.items.map(e)},i.prototype.reduce=function(e){return this.items.reduce(e)},i.prototype.every=function(e){return this.items.every(e)},i.prototype.some=function(e){return this.items.some(e)},i.prototype.find=function(e){var t,n=this.items.length;for(t=0;n>t;t+=1)if(e(this.items[t]))return this.items[t];return void 0},i.prototype.combine=function(e){return new i(this.items.slice().concat(e.items))},i.prototype.clone=function(){return new i(this.items.slice())},i}"function"==typeof MO5?MO5("MO5.CoreObject","MO5.Queue","MO5.types").define("MO5.List",e):"undefined"!=typeof window?window.MO5.List=e(MO5.CoreObject,MO5.Queue,MO5.types):module.exports=e(require("./CoreObject.js"),require("./Queue.js"),require("./types.js"))}(),function(){function e(e){function t(e){return r+e}function n(e){return e.replace(new RegExp(r),"")}function i(t){var n;if(e.call(this),this.clear(),t)for(n in t)this.set(n,t[n])}var r="MO5Map";return i.prototype=new e,i.prototype.clear=function(){this.items={},this.unsubscribers={},this.count=0},i.prototype.length=function(){return this.count},i.prototype.set=function(n,i){function r(){delete s.items[o],s.count-=1}var s=this,o=t(n);if(!n)throw new Error("MO5.Map keys cannot be falsy.");if(this.has(o)&&this.remove(o),i&&i instanceof e){if(i.destroyed)throw new Error("Trying to add an MO5.Object that has already been destroyed.");i.subscribe(r,"destroyed")}if(n instanceof e){if(n.destroyed)throw new Error("Trying to use an MO5.Object as key that has already been destroyed.");n.subscribe(r,"destroyed")}return(i&&i instanceof e||n instanceof e)&&(this.unsubscribers[o]=function(){i instanceof e&&i.unsubscribe(r,"destroyed"),n instanceof e&&n.unsubscribe(r,"destroyed")}),this.items[o]=i,this.count+=1,this.trigger("updated",null,!1),this.trigger("set",o,!1),this},i.prototype.get=function(e){var n=t(e);return this.items.hasOwnProperty(n)?this.items[n]:void 0},i.prototype.require=function(e){if(!this.has(e))throw new Error("Required key '"+e+"' does not exist.");return this.get(e)},i.prototype.remove=function(e){var n=t(e);if(!this.has(e))throw new Error("Trying to remove an unknown key from an MO5.Map.");return this.unsubscribers.hasOwnProperty(n)&&(this.unsubscribers[n](),delete this.unsubscribers[n]),delete this.items[n],this.count-=1,this.trigger("updated",null,!1),this.trigger("removed",n,!1),this},i.prototype.has=function(e){var n=t(e);return this.items.hasOwnProperty(n)},i.prototype.destroy=function(){for(var t in this.unsubscribers)this.unsubscribers[t](),delete this.unsubscribers[t];e.prototype.destroy.call(this)},i.prototype.forEach=function(e){if(!e||"function"!=typeof e)throw new Error("Parameter 1 is expected to be of type function.");for(var t in this.items)e(this.items[t],n(t),this);return this},i.prototype.filter=function(e){var t=new i;return this.forEach(function(n,i,r){e(n,i,r)&&t.set(i,n)}),t},i.prototype.find=function(e){var t,n=!1;return this.forEach(function(i,r,s){!n&&e(i,r,s)&&(t=i,n=!0)}),t},i.prototype.map=function(e){var t=new i;return this.forEach(function(n,i,r){t.set(i,e(n,i,r))}),t},i.prototype.reduce=function(e,t){var n=t;return this.forEach(function(t,i,r){n=e(n,t,i,r)}),n},i.prototype.every=function(e){return this.reduce(function(t,n,i,r){return t&&e(n,i,r)},!0)},i.prototype.some=function(e){var t=!1;return this.forEach(function(n,i,r){!t&&e(n,i,r)&&(t=!0)}),t},i.prototype.keys=function(){var e=[];return this.forEach(function(t,n){e.push(n)}),e},i.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},i.prototype.toObject=function(){var e={};return this.forEach(function(t,n){e[n]=t}),e},i.prototype.clone=function(){var e=new i;return this.forEach(function(t,n){e.set(n,t)}),e},i.prototype.addMap=function(e){var t=this;return e.forEach(function(e,n){t.set(n,e)}),this},i.prototype.join=function(e){return this.clone().addMap(e)},i}"function"==typeof MO5?MO5("MO5.CoreObject","MO5.Exception").define("MO5.Map",e):"undefined"!=typeof window?window.MO5.Map=e(MO5.CoreObject,MO5.Exception):module.exports=e(require("./CoreObject.js"),require("./Exception.js"))}(),MO5().define("MO5.Point",function(){function e(e,t){this.x=e,this.y=t}return e.prototype.getDistance=function(e){var t=this.x-e.x,n=this.y-e.y,i=Math.squrt(t*t+n*n);return i},e}),function(){var e,t,n,i;!function(){var r={},s={};e=function(e,t,n){r[e]={deps:t,callback:n}},i=n=t=function(e){function n(t){if("."!==t.charAt(0))return t;for(var n=t.split("/"),i=e.split("/").slice(0,-1),r=0,s=n.length;s>r;r++){var o=n[r];if(".."===o)i.pop();else{if("."===o)continue;i.push(o)}}return i.join("/")}if(i._eak_seen=r,s[e])return s[e];if(s[e]={},!r[e])throw new Error("Could not find module "+e);for(var o,a=r[e],u=a.deps,c=a.callback,l=[],d=0,h=u.length;h>d;d++)l.push("exports"===u[d]?o={}:t(n(u[d])));var p=c.apply(this,l);return s[e]=o||p}}(),e("promise/all",["./utils","exports"],function(e,t){"use strict";function n(e){var t=this;if(!i(e))throw new TypeError("You must pass an array to all.");return new t(function(t,n){function i(e){return function(t){s(e,t)}}function s(e,n){a[e]=n,0===--u&&t(a)}var o,a=[],u=e.length;0===u&&t([]);for(var c=0;c0},n.prototype.clear=function(){return this.arr=[],this.trigger("updated"),this.trigger("cleared"),this},n.prototype.reverse=function(){for(var e=new n,t=this.length(),i=t-1;i>=0;)e.add(this.arr[i]),i-=1;return e},n.prototype.clone=function(){return new n(this.arr.slice())},n}"function"==typeof MO5?MO5("MO5.Exception","MO5.CoreObject").define("MO5.Queue",e):"undefined"!=typeof window?window.MO5.Queue=e(MO5.Exception,MO5.CoreObject):module.exports=e(require("./Exception.js"),require("./CoreObject.js"))}(),function(){function e(){function e(e,t){var n,i=[];for(n=e;t>=n;n+=1)i.push(n);return i}return e}"function"==typeof MO5?MO5().define("MO5.range",e):"undefined"!=typeof window?window.MO5.range=e():module.exports=e()}(),function(){function e(e,t,n,i){function r(e,t){for(;e.hasNext();)u(function(e){return function(){e(t)}}(e.next()))}function s(e,t,n,i){t.add("function"==typeof n?function(e){var t;try{t=n(e),t&&t instanceof a?t.then(i.success,i.failure):i.success(t)}catch(r){i.failure(r)}return t}:function(t){i[e](t)})}function o(){e.call(this),this.successQueue=new t,this.failureQueue=new t,this.value=void 0,this.status=o.STATUS_PENDING,this.promise=new a(this)}function a(t){e.call(this),this.then=function(e,n){var i=new o;switch(t.status){case o.STATUS_PENDING:o.addToQueue("success",t.successQueue,e,i),o.addToQueue("failure",t.failureQueue,n,i);break;case o.STATUS_SUCCESS:o.addToQueue("success",t.successQueue,e,i),o.resolve(t.successQueue,t.value);break;case o.STATUS_FAILURE:o.addToQueue("failure",t.failureQueue,n,i),o.resolve(t.failureQueue,t.value)}return i.promise}}var u;return u="undefined"!=typeof window&&window.setImmediate?window.setImmediate:"undefined"!=typeof process?function(e){process.nextTick(e)}:function(e){setTimeout(e,0)},o.STATUS_PENDING=1,o.STATUS_FAILURE=2,o.STATUS_SUCCESS=3,o.getFulfilledPromise=function(){return(new o).success().promise},o.getBrokenPromise=function(){return(new o).failure().promise},o.prototype=new e,o.prototype.isPending=function(){return this.status===o.STATUS_PENDING},o.prototype.failure=function(e){return this.status!==o.STATUS_PENDING?void i(new n("The result of the action has already been determined.")):(this.value=e,this.status=o.STATUS_FAILURE,r(this.failureQueue,e),this.successQueue.clear(),this.failureQueue.clear(),this)},o.prototype.success=function(e){return this.status!==o.STATUS_PENDING?void i(new n("The result of the action has already been determined.")):(this.value=e,this.status=o.STATUS_SUCCESS,r(this.successQueue,e),this.successQueue.clear(),this.failureQueue.clear(),this)},o.addToQueue=s,o.resolve=r,a.prototype=new e,o}console.warn("MO5.Result is deprecated - use MO5.Promise instead!"),"function"==typeof MO5?MO5("MO5.CoreObject","MO5.Queue","MO5.Exception","MO5.fail").define("MO5.Result",e):"undefined"!=typeof window?window.MO5.CoreObject=e(MO5.CoreObject,MO5.Queue,MO5.Exception,MO5.fail):module.exports=e(require("./CoreObject.js"),require("./Queue.js"),require("./Exception.js"),require("./fail.js"))}(),function(){function e(e,t){function n(n){e.call(this),this._unsubscribers={},this._stringItems={},this._items=[],n&&t.hasForEach(n)&&this.addMany(n)}function i(e){return t.isObject(e)?t.isNumber(e.id)?!0:!1:!0}function r(e){return t.isObject(e)?s+"MO5CoreObject_"+e.id:s+"SimpleValue_"+JSON.stringify(e)}var s="MO5Set_";return n.fromRange=function(e,t){var i,r=new n;for(i=e;t>=i;i+=1)r.add(i);return r},n.prototype=new e,n.prototype.has=function(e){var t,n;if(i(e))return r(e)in this._stringItems;for(t=0,n=this._items.length;n>t;t+=1)if(this._items[t]===e)return!0;return!1},n.prototype.add=function(t){var n;return this.has(t)?this:(i(t)?(n=r(t),this._stringItems[n]=t,e.isCoreObject(t)&&(this._unsubscribers[n]=this.delete.bind(this,t),t.subscribe("destroyed",this._unsubscribers[n]))):this._items.push(t),this)},n.prototype.delete=function(t){var n;return this.has(t)?(i(t)?(n=r(t),delete this._stringItems[n],e.isCoreObject(t)&&(t.unsubscribe("destroyed",this._unsubscribers[n]),delete this._unsubscribers[n])):this._items.splice(this._items.indexOf(t),1),!0):!1},n.prototype.clear=function(){this._items.forEach(this.delete.bind(this)),this._items=[],this._stringItems={},this._unsubscribers={}},n.prototype.forEach=function(e){var t,n=0;for(t in this._stringItems)e(this._stringItems[t],n,this),n+=1;this._items.forEach(function(t){e(t,n,this),n+=1}.bind(this))},n.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},n.prototype.keys=n.prototype.values,n.prototype.addMany=function(e){return e.forEach(this.add.bind(this)),this},n.prototype.intersection=function(e){var t=new n;return e.forEach(function(e){this.has(e)&&t.add(e)}.bind(this)),t},n.prototype.difference=function(e){var t=new n(this.values());return e.forEach(function(e){t.has(e)?t.delete(e):t.add(e)}),t},n.prototype.size=function(){var e,t=this._items.length;for(e in this._stringItems)t+=1;return t},n}"function"==typeof MO5?MO5("MO5.CoreObject","MO5.types").define("MO5.Set",e):"undefined"!=typeof window?window.MO5.Set=e(MO5.CoreObject,MO5.types):module.exports=e(require("./CoreObject.js"),require("./types.js"))}(),MO5().define("MO5.Size",function(){function e(e,t){this.width=e||0,this.height=t||0}return e}),function(){function e(e,t,n,i){function r(t){e.call(this),this.message=t,this.name="MO5.TimerError"}function s(){t.call(this),this.running=!1,this.paused=!1,this.canceled=!1,this.startTime=+new Date,this.timeElapsed=0,this.pauseTimeElapsed=0,this.pauseStartTime=this.startTime}return r.prototype=new e,s.prototype=new t,s.prototype.constructor=s,s.prototype.start=function(){return this.startTime=+new Date,this.running=!0,this.trigger("started",null,!1),this},s.prototype.stop=function(){return this.running=!1,this.paused=!1,this.trigger("stopped",null,!1),this},s.prototype.cancel=function(){return this.running||n(new r("Trying to cancel a Timer that isn't running.")),this.elapsed(),this.canceled=!0,this.running=!1,this.paused=!1,this.trigger("canceled",null,!1),this},s.prototype.isRunning=function(){return this.running},s.prototype.isCanceled=function(){return this.canceled},s.prototype.isPaused=function(){return this.paused},s.prototype.pause=function(){this.paused=!0,this.pauseStartTime=+new Date,this.trigger("paused",null,!1)},s.prototype.resume=function(){this.paused||n(new r("Trying to resume a timer that isn't paused.")),this.paused=!1,this.pauseTimeElapsed+=+new Date-this.pauseStartTime,this.trigger("resumed",null,!1)},s.prototype.elapsed=function(){return this.running&&!this.paused&&(this.timeElapsed=+new Date-this.startTime-this.pauseTimeElapsed),this.timeElapsed},s.prototype.getReadOnlyCapability=function(){var e=this;return{isRunning:function(){return e.running},isCanceled:function(){return e.canceled},isPaused:function(){return e.paused},elapsed:function(){return e.elapsed()}}},s.prototype.promise=function(){var e=new i,t=this;return this.once(function(){e.resolve(t)},"stopped"),this.once(function(){e.reject(t)},"canceled"),this.once(function(){e.reject(t)},"destroyed"),e},s}"function"==typeof MO5?MO5("MO5.Exception","MO5.CoreObject","MO5.fail","MO5.Promise").define("MO5.Timer",e):"undefined"!=typeof window?window.MO5.Timer=e(MO5.Exception,MO5.CoreObject,MO5.fail,MO5.Promise):module.exports=e(require("./Exception.js"),require("./CoreObject.js"),require("./fail.js"),require("./Promise.js"))}(),function(){function e(e,t,n,i){function r(n){var i;if(t.call(this),n&&!(n instanceof Array))throw new e("Parameter 1 is expected to be of type Array.").log();n=n||[],i=this,this.timers={},this.count=0,n.forEach(function(e){i.addTimer(e)})}return r.prototype=new t,r.prototype.constructor=r,r.prototype.addTimer=function(t){var i,r=this;return this.timers[+t]?(n(new e("A timer with ID '"+t+"' has already been added to the watcher.")),this):(this.count+=1,i=function(){r.count-=1,r.count<1&&r.trigger("stopped",null,!1)},this.timers[+t]={timer:t,unsubscribe:function(){t.unsubscribe(i,"stopped")}},t.subscribe(i,"stopped"),this.trigger("added",t,!1),this)},r.prototype.createTimer=function(){var e=new i;return this.trigger("created",e,!1),this.addTimer(e),e},r.prototype.removeTimer=function(t){return this.timers[+t]?(this.timers[+t].unsubscribe(),delete this.timers[+t],this.trigger("removed",t,!1),this):(n(new e("Trying to remove a timer that is unknown to the watcher.")),this)},r.prototype.forAll=function(e){var t,n;for(t in this.timers)this.timers.hasOwnProperty(t)&&(n=this.timers[t].timer,n instanceof r?this.timers[t].timer.forAll(e):this.timers[t].timer[e]());return this},r.prototype.cancel=function(){return this.forAll("cancel"),this.trigger("canceled",null,!1),this},r.prototype.pause=function(){return this.forAll("pause"),this.trigger("paused",null,!1),this},r.prototype.resume=function(){return this.forAll("resume"),this.trigger("resumed",null,!1),this},r.prototype.stop=function(){return this.forAll("stop")},r.prototype.start=function(){return this.forAll("start"),this.trigger("started",null,!1),this},r.prototype.promise=function(){return i.prototype.promise.call(this)},r}"function"==typeof MO5?MO5("MO5.Exception","MO5.CoreObject","MO5.fail","MO5.Timer").define("MO5.TimerWatcher",e):"undefined"!=typeof window?window.MO5.TimerWatcher=e(MO5.Exception,MO5.CoreObject,MO5.fail,MO5.Timer):module.exports=e(require("./Exception.js"),require("./CoreObject.js"),require("./fail.js"),require("./Timer.js"))}(),MO5().define("MO5.tools",function(){var e={};return e.getUniqueId=function(){var e=0;return function(){return e++}}(),e.getWindowDimensions=function(){var e=window,t="inner";return"innerWidth"in e||(t="client",e=document.documentElement||document.body),{width:e[t+"Width"],height:e[t+"Height"]}},e.fitToWindow=function(t,n,i){var r,s,o,a,u,c;r=e.getWindowDimensions(),o=r.width,a=r.height,u=o/n,c=a/i,s=u>c?c:u,t.setAttribute("style",t.getAttribute("style")+" -moz-transform: scale("+s+","+s+") rotate(0.01deg); -ms-transform: scale("+s+","+s+"); -o-transform: scale("+s+","+s+"); -webkit-transform: scale("+s+","+s+"); transform: scale("+s+","+s+");")},e.timeoutInspector=function(){var e,t,n,i,r,s={},o=0,a=0,u=0;return e=window.setTimeout,t=window.setInterval,n=window.clearTimeout,i=window.clearInterval,r=window.requestAnimationFrame,{logAnimationFrameRequests:!1,logTimeouts:!1,logIntervals:!1,enable:function(){window.setTimeout=function(t,n){var i=e(t,n);return o+=1,this.logTimeouts&&console.log("Setting timeout: ",{callback:t.toString(),time:n},i),i},window.setInterval=function(e,n){var i=t(e,n);return a+=1,s[i]=!0,this.logIntervals&&console.log("Setting interval: ",{callback:e.toString(),time:n},i),i},window.clearTimeout=function(e){return console.log("Clearing timeout: ",e),n(e)},window.clearInterval=function(e){return console.log("Clearing interval: ",e),e in s?delete s[e]:console.log("Warning: Interval "+e+" doesn't exist."),i(e)},window.requestAnimationFrame=function(e){return u+=1,this.logAnimationFrameRequests&&console.log("Requesting animation frame: ",{callback:e.toString()}),r(e)}},disable:function(){window.setTimeout=e,window.setInterval=t,window.clearTimeout=n,window.clearInterval=i,window.requestAnimationFrame=r},getActiveIntervals:function(){var e,t=[];for(e in this.activeIntervals)t.push(e);return t},totalTimeoutCalls:function(){return o},totalIntervalCalls:function(){return a},totalRequestAnimationFrameCalls:function(){return u}}}(),e}),MO5("MO5.Exception","MO5.Timer","MO5.easing").define("MO5.transform",function(e,t,n){function i(i,r,s,o){if(o=o||{},"undefined"==typeof i||!i)throw new e("MO5.transform expects parameter callback to be a function.");var a,u,c="undefined"!=typeof o.duration&&o.duration>=0?o.duration:500,l=r,d=o.timer||new t,h=s-r,p=o.log||!1,f=0,m=0,g=o.fps||MO5.defaults.fps;return a=o.easing||n.sineEaseOut,u=function(){var e,t;if(Date.now()-m>1e3/g){if(d.canceled)return;if(d.paused)return void d.once(u,"resumed");if(f+=1,t=d.elapsed(),t>c||d.stopped)return l=r+h,i(s),void(d.stopped||d.stop());l=a(c,t)*h+r,i(l),e=d.elapsed()-t,p===!0&&console.log("Current value: "+l+"; c: "+f+"; Exec time: "+e),m=Date.now()}requestAnimationFrame(u)},d.start(),requestAnimationFrame(u),d}return i}),function(){function e(){var e={};return e.isObject=function(e){return"object"==typeof e&&null!==e},e.isString=function(e){return"string"==typeof e},e.isNumber=function(e){return"number"==typeof e},e.isFunction=function(e){return"function"==typeof e},e.isArray=function(t){return Array.isArray?Array.isArray(t):e.isObject(t)?t instanceof Array:!1},e.hasForEach=function(t){return e.isObject(t)&&e.isFunction(t.forEach)},e}"function"==typeof MO5?MO5().define("MO5.types",e):"undefined"!=typeof window?window.MO5.types=e():module.exports=e()}(),MO5("WSE.assets.Animation","WSE.assets.Audio","WSE.assets.Background","WSE.assets.Character","WSE.assets.Curtain","WSE.assets.Imagepack","WSE.assets.Textbox").define("WSE.assets",function(e,t,n,i,r,s,o){var a={Animation:e,Audio:t,Background:n,Character:i,Curtain:r,Imagepack:s,Textbox:o};return a}),MO5("WSE.commands.alert","WSE.commands.break","WSE.commands.choice","WSE.commands.confirm","WSE.commands.do","WSE.commands.fn","WSE.commands.global","WSE.commands.globalize","WSE.commands.goto","WSE.commands.line","WSE.commands.localize","WSE.commands.prompt","WSE.commands.restart","WSE.commands.set_vars","WSE.commands.sub","WSE.commands.trigger","WSE.commands.var","WSE.commands.wait","WSE.commands.while","WSE.commands.with").define("WSE.commands",function(e,t,n,i,r,s,o,a,u,c,l,d,h,p,f,m,g,y,b,w){"use strict";var v={alert:e,"break":t,choice:n,confirm:i,"do":r,fn:s,global:o,globalize:a,"goto":u,line:c,localize:l,prompt:d,restart:h,set_vars:p,sub:f,trigger:m,"var":g,wait:y,"while":b,"with":w};return v}),MO5().define("WSE.functions",function(){"use strict";var e={savegames:function(e){e.toggleSavegameMenu()},stageclick_disable:function(e){e.game.unsubscribeListeners()},stageclick_enable:function(e){e.game.subscribeListeners()}};return e}),MO5("WSE.dataSources.LocalStorage").define("WSE.dataSources",function(e){var t={LocalStorage:e};return t}),MO5("MO5.EventBus","WSE.assets","WSE.commands","WSE.dataSources","WSE.functions").define("WSE",function(e,t,n,i,r){"use strict";var s={},o="2015.10.2-final.1510051136";return e.inject(s),s.dataSources=i,s.assets=t,s.commands=n,s.functions=r,s.getVersion=function(){return o},s}),MO5().define("WSE.Keys",function(){function e(e){e=e||{},this.keys={},this.keys.BACKSPACE={kc:8},this.keys.TAB={kc:9},this.keys.ENTER={kc:13,which:13},this.keys.SHIFT={kc:16},this.keys.CTRL={kc:17},this.keys.ALT={kc:18},this.keys.PAUSE={kc:19},this.keys.CAPS_LOCK={kc:20},this.keys.ESCAPE={kc:27},this.keys.SPACE={kc:32},this.keys.PAGE_UP={kc:33},this.keys.PAGE_DOWN={kc:20},this.keys.END={kc:20},this.keys.HOME={kc:20},this.keys.LEFT_ARROW={kc:37},this.keys.UP_ARROW={kc:38},this.keys.RIGHT_ARROW={kc:39},this.keys.DOWN_ARROW={kc:40},this.keys.INSERT={kc:45},this.keys.DELETE={kc:46},this.keys.NUM_0={kc:48},this.keys.NUM_1={kc:49},this.keys.NUM_2={kc:50},this.keys.NUM_3={kc:51},this.keys.NUM_4={kc:52},this.keys.NUM_5={kc:53},this.keys.NUM_6={kc:54},this.keys.NUM_7={kc:55},this.keys.NUM_8={kc:56},this.keys.NUM_9={kc:57},this.keys.A={kc:65},this.keys.B={kc:66},this.keys.C={kc:67},this.keys.D={kc:68},this.keys.E={kc:69},this.keys.F={kc:70},this.keys.G={kc:71},this.keys.H={kc:72},this.keys.I={kc:73},this.keys.J={kc:74},this.keys.K={kc:75},this.keys.L={kc:76},this.keys.M={kc:77},this.keys.N={kc:78},this.keys.O={kc:79},this.keys.P={kc:80},this.keys.Q={kc:81},this.keys.R={kc:82},this.keys.S={kc:83},this.keys.T={kc:84},this.keys.U={kc:85},this.keys.V={kc:86},this.keys.W={kc:87},this.keys.X={kc:88},this.keys.Y={kc:89},this.keys.Z={kc:90},this.keys.LEFT_WIN={kc:91},this.keys.RIGHT_WIN={kc:92},this.keys.SELECT={kc:93},this.keys.NUMPAD_0={kc:96},this.keys.NUMPAD_1={kc:97},this.keys.NUMPAD_2={kc:98},this.keys.NUMPAD_3={kc:99},this.keys.NUMPAD_4={kc:100},this.keys.NUMPAD_5={kc:101},this.keys.NUMPAD_6={kc:102},this.keys.NUMPAD_7={kc:103},this.keys.NUMPAD_8={kc:104},this.keys.NUMPAD_9={kc:105},this.keys.MULTIPLY={kc:106},this.keys.ADD={kc:107},this.keys.SUBSTRACT={kc:109},this.keys.DECIMAL_POINT={kc:110},this.keys.DIVIDE={kc:111},this.keys.F1={kc:112},this.keys.F2={kc:113},this.keys.F3={kc:114},this.keys.F4={kc:115},this.keys.F5={kc:116},this.keys.F6={kc:117},this.keys.F7={kc:118},this.keys.F8={kc:119},this.keys.F9={kc:120},this.keys.F10={kc:121},this.keys.F11={kc:122},this.keys.F12={kc:123},this.keys.NUM_LOCK={kc:144},this.keys.SCROLL_LOCK={kc:145},this.keys.SEMI_COLON={kc:186},this.keys.EQUALS={kc:187},this.keys.COMMA={kc:188},this.keys.DASH={kc:189},this.keys.PERIOD={kc:190},this.keys.SLASH={kc:191},this.keys.GRAVE={kc:192},this.keys.OPEN_BRACKET={kc:219},this.keys.BACK_SLASH={kc:220},this.keys.CLOSE_BRACKET={kc:221},this.keys.SINGLE_QUOTE={kc:222},this.listeners=[]; var t,n,i,r,s,o,a=e.log||!1,u=e.element||window,c=this;t=function(e){null!=e&&"undefined"!=typeof e&&(e.addEventListener?(e.addEventListener("keyup",i,!1),e.addEventListener("keydown",r,!1),e.addEventListener("keypress",s,!1),a===!0&&(e.addEventListener("keyup",o,!1),e.addEventListener("keydown",o,!1),e.addEventListener("keypress",o,!1))):e.attachEvent&&(e.attachEvent("onkeyup",i),e.attachEvent("onkeydown",r),e.attachEvent("onkeypress",s),a===!0&&(e.attachEvent("onkeyup",o),e.attachEvent("onkeydown",o),e.attachEvent("onkeypress",o))))},n=function(e,t){var n,i,r,s,o=c.listeners.length;for(i=0;o>i;++i)n=c.listeners[i],"undefined"!=typeof n&&n.type==t&&(n.key=n.key||{},r=n.key.kc||null,s=n.key.which||null,(e.which==s||e.keyCode==r)&&n.callback(e))},i=function(e){n(e,"up")},r=function(e){n(e,"down")},s=function(e){n(e,"press")},o=function(e){console.log(e)},t(u)}return e.prototype.addListener=function(e,t,n){if(n=n||"up","up"!==n&&"down"!==n&&"press"!==n)throw new Error("Event type not recognized.");this.listeners.push({key:e,callback:t,type:n})},e.prototype.removeListener=function(e,t,n){n=n||null;for(var i,r=this.listeners.length,s=0;r>s;++s)i=this.listeners[s],(null===n||i.type==n)&&"undefined"!=typeof i&&i.key===e&&i.callback===t&&delete this.listeners[s]},e.prototype.forAll=function(e,t){if(t=t||"up","up"!==t&&"down"!==t&&"press"!==t)throw new Error("Event type not recognized.");for(var n in this.keys)this.keys.hasOwnProperty(n)&&this.addListener(this.keys[n],e,t)},e}),MO5("MO5.Timer").define("WSE.tools",function(e){"use strict";var t={};return t.attachEventListener=function(e,t,n){null!==e&&"undefined"!=typeof e&&(e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n))},t.applyAssetUnits=function(e,t){var n,i;n=t.getAttribute("x")||"",i=t.getAttribute("y")||"",e.xUnit=n.replace(/^.*(px|%)$/,"$1"),e.xUnit=e.xUnit||"px",e.yUnit=i.replace(/^.*(px|%)$/,"$1"),e.yUnit=e.yUnit||"px","px"!==e.xUnit&&"%"!==e.xUnit&&(e.xUnit="px"),"px"!==e.yUnit&&"%"!==e.yUnit&&(e.yUnit="px")},t.removeEventListener=function(e,t,n){"undefined"!=typeof e&&null!==e&&e.removeEventListener(t,n,!1)},t.replaceVariables=function(e,t){var n,i;return null===e?e:("string"!=typeof e&&(t.bus.trigger("wse.interpreter.error",{message:"Argument supplied to the replaceVariables function must be a string."}),e=""),n=function(){var e=arguments[1];return t.globalVars.has(e)?""+t.globalVars.get(e):""},i=function(){var e=arguments[1];return e in t.runVars?""+t.runVars[e]:""},e=e.replace(/\{\$\$([a-zA-Z0-9_]+)\}/g,n),e=e.replace(/\{\$([a-zA-Z0-9_]+)\}/g,i))},t.getSerializedNodes=function(e){var t,n,i=new XMLSerializer,r=e.childNodes,s="";for(t=0,n=r.length;n>t;t+=1)s+=i.serializeToString(r[t]);return s},t.getParsedAttribute=function(e,n,i,r){var s;return arguments.length<3&&(r=""),s=e.getAttribute(n)||""+r,t.replaceVariables(s,i)},t.textToHtml=function(e,t){return t=t||!1,String.prototype.trim?e=e.trim():(e=e.replace(/^\n/,""),e=e.replace(/\n$/,"")),e=t===!0?e.replace(/\n/g,"
"):e,e=e.replace(/\{/g,"<"),e=e.replace(/\}/g,">")},t.getUniqueId=function(){var e=0;return function(){return e+=1}}(),t.firstLetterUppercase=function(e){return e.length<1?"":""+e.charAt(0).toUpperCase()+e.replace(/^.{1}/,"")},t.mixin=function(e,t){var n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t.extractUnit=function(e){return"string"!=typeof e?"":e.replace(/^(-){0,1}[0-9]*/,"")},t.calculateValueWithAnchor=function(e,n,i){var r=0,s="px";return n?(s=t.extractUnit(n),n=parseInt(n,10),r="%"===s?e-i/100*n:e-n):e},t.createTimer=function(t){var n=new e;return t=t||0,t=0>t?0:t,n.start(),setTimeout(n.stop.bind(n),t),n},t.getWindowDimensions=function(){var e=window,t="inner";return"innerWidth"in e||(t="client",e=document.documentElement||document.body),{width:e[t+"Width"],height:e[t+"Height"]}},t.fitToWindow=function(e,n,i){var r,s,o,a,u,c;r=t.getWindowDimensions(),o=r.width,a=r.height,u=o/n,c=a/i,s=u>c?c:u,e.setAttribute("style",e.getAttribute("style")+" -moz-transform: scale("+s+","+s+") rotate(0.01deg); -ms-transform: scale("+s+","+s+"); -o-transform: scale("+s+","+s+"); -webkit-transform: scale("+s+","+s+"); transform: scale("+s+","+s+");")},t}),MO5("MO5.Map").define("WSE.dataSources.LocalStorage",function(e){"use strict";function t(){}var n,i="___wse_storage_test",r=!1;try{localStorage.setItem(i,"works"),"works"===localStorage.getItem(i)&&(r=!0)}catch(s){console.error("LocalStorage not available, using JS object as fallback."),n=new e}return t.prototype.set=function(e,t){r?localStorage.setItem(e,t):n.set(e,t)},t.prototype.get=function(e){return r?localStorage.getItem(e):n.has(e)?n.get(e):null},t.prototype.remove=function(e){if(!r){if(!n.has(e))return;return n.remove(e)}return localStorage.removeItem(e)},t}),MO5("WSE.commands","WSE.functions").define("WSE.Trigger",function(e,t){"use strict";function n(n,i){var r,s=this;if(this.name=n.getAttribute("name")||null,this.event=n.getAttribute("event")||null,this.special=n.getAttribute("special")||null,this.fnName=n.getAttribute("function")||null,this.scene=n.getAttribute("scene")||null,this.interpreter=i,this.isSubscribed=!1,null===this.name)return void i.bus.trigger("wse.interpreter.warning",{element:n,message:"No 'name' attribute specified on 'trigger' element."});if(null===this.event)return void i.bus.trigger("wse.interpreter.warning",{element:n,message:"No 'event' attribute specified on 'trigger' element '"+this.name+"'."});if(null===this.special&&null===this.fnName&&null===this.scene)return void i.bus.trigger("wse.interpreter.warning",{element:n,message:"No suitable action or function found for trigger element '"+this.name+"'."});if(this.scene&&(r=function(){console.log('Triggering event "'+s.event+'"...'),e.sub(n,i),i.index=0,i.currentElement=0,i.next()}),this.isKeyEvent=!1,this.key=null,null!==this.special&&"next"!==this.special)return void i.bus.trigger("wse.interpreter.warning",{element:n,message:"Unknown special specified on trigger element '"+this.name+"'."});if("next"===this.special&&(r=function(){"pause"===s.interpreter.state||s.interpreter.waitCounter>0||s.interpreter.next()}),null!==this.fnName){if("function"!=typeof t[this.fnName])return void i.bus.trigger("wse.interpreter.warning",{element:n,message:"Unknown function specified on trigger element '"+this.name+"'."});r=function(){t[s.fnName](s.interpreter,n)}}switch(this.event){case"keyup":case"keydown":case"keypress":return this.isKeyEvent=!0,this.key=n.getAttribute("key")||null,null===this.key?void i.bus.trigger("wse.interpreter.warning",{element:n,message:"No 'key' attribute specified on trigger element '"+this.name+"'."}):"undefined"==typeof i.game.keys.keys[this.key]||null===i.game.keys.keys[this.key]?void i.bus.trigger("wse.interpreter.warning",{element:n,message:"Unknown key '"+this.key+"' specified on trigger element '"+this.name+"'."}):void(this.fn=function(e){e.keys[s.key].kc===e.event.keyCode&&(i.keysDisabled>0||r())});default:this.fn=r}}return n.prototype.activate=function(){this.isSubscribed!==!0&&(this.interpreter.bus.subscribe(this.fn,this.event),this.isSubscribed=!0)},n.prototype.deactivate=function(){this.isSubscribed!==!1&&(this.interpreter.bus.unsubscribe(this.fn,this.event),this.isSubscribed=!1)},n}),MO5("MO5.EventBus","MO5.ajax","WSE.Keys","WSE.Interpreter","WSE.tools","WSE").define("WSE.Game",function(e,t,n,i,r,s){"use strict";function o(t){var r;s.trigger("wse.game.constructor",{args:t,game:this}),t=t||{},this.bus=new e,this.url=t.url||"game.xml",this.ws=null,this.debug=t.debug===!0?!0:!1,r=t.host||!1,this.host=r,r?(this.ws=function(e){var t,n;return n=new DOMParser,t=r.get(e),n.parseFromString(t,"application/xml")}(this.url),this.init()):this.load(this.url),this.interpreter=new i(this),this.keys=new n,this.listenersSubscribed=!1,this.bus.subscribe(function(e){console.log("Message: "+e)},"wse.interpreter.message"),this.bus.subscribe(function(e){console.log("Error: "+e.message)},"wse.interpreter.error"),this.bus.subscribe(function(e){console.log("Warning: "+e.message,e.element)},"wse.interpreter.warning")}return o.prototype.load=function(){var e,n;n=this,e=function(e){n.ws=e.responseXML,n.init()},t("GET",this.url,null,e)},o.prototype.init=function(){var e,t,n,i,s,o,a,u,c,l;u=this,e=this.ws;try{n=e.getElementsByTagName("stage")}catch(d){console.log(d)}if(s="800px",o="480px",a="Stage",!n||n.length<1)throw new Error("No stage definition found!");i=n[0],s=i.getAttribute("width")||s,o=i.getAttribute("height")||o,a=i.getAttribute("id")||a,"yes"===i.getAttribute("create")?(t=document.createElement("div"),t.setAttribute("id",a),document.body.appendChild(t)):t=document.getElementById(a),t.setAttribute("class","WSEStage"),t.style.width=s,t.style.height=o,c=function(){var e=r.getWindowDimensions();t.style.left=e.width/2-parseInt(s,10)/2+"px",t.style.top=e.height/2-parseInt(o,10)/2+"px"},"yes"===i.getAttribute("center")&&(r.attachEventListener(window,"resize",c),c()),l=function(){console.log("Resizing..."),r.fitToWindow(t,parseInt(s,10),parseInt(o,10))},"yes"===i.getAttribute("resize")&&(r.attachEventListener(window,"resize",l),l()),this.stage=t,this.applySettings(),this.host&&(this.host.window.width=parseInt(s,10),this.host.window.height=parseInt(o,10),function(e){var n="true"===e.getSetting("host.stage.resize")?!0:!1;n&&window.addEventListener("resize",function(){console.log("Resizing..."),r.fitToWindow(t,parseInt(s,10),parseInt(o,10))})}(this))},o.prototype.getSetting=function(e){var t,n,i,r,s,o;for(n=this.ws.getElementsByTagName("setting"),i=0,r=n.length;r>i;i+=1)if(s=n[i],o=s.getAttribute("name")||null,null!==o&&o===e)return t=s.getAttribute("value")||null;return null},o.prototype.applySettings=function(){this.webInspectorEnabled="true"===this.getSetting("host.inspector.enable")?!0:!1,this.host&&this.webInspectorEnabled===!0&&this.host.inspector.show()},o.prototype.start=function(){var e,t,n;return n=this,null===this.ws?setTimeout(function(){n.start()}):(e=function(){"pause"===n.interpreter.state||n.interpreter.waitCounter>0||(console.log("Next triggered by user..."),n.interpreter.next(!0))},t=function(e){return n.bus.trigger("contextmenu",{}),e&&"function"==typeof e.preventDefault&&e.preventDefault(),!1},this.subscribeListeners=function(){r.attachEventListener(this.stage,"contextmenu",t),r.attachEventListener(this.stage,"click",e),this.listenersSubscribed=!0},this.unsubscribeListeners=function(){r.removeEventListener(this.stage,"contextmenu",t),r.removeEventListener(this.stage,"click",e),this.listenersSubscribed=!1},void this.interpreter.start())},o}),MO5("MO5.transform","WSE.dataSources.LocalStorage","WSE.Trigger","WSE.tools","WSE.tools.ui","WSE").define("WSE.Interpreter",function(e,t,n,i,r,s){"use strict";function o(e){var n,i;s.trigger("wse.interpreter.constructor",{game:e,interpreter:this}),this.game=e,this.assets={},this.index=0,this.visitedScenes=[],this.log=[],this.waitForTimer=!1,this.assetsLoading=0,this.assetsLoadingMax=0,this.assetsLoaded=0,this.startTime=0,this.runVars={},this.callStack=[],this.keysDisabled=0,this.state="listen",this.waitCounter=0,this.debug=e.debug===!0?!0:!1,n=new t,this.datasource=n,i="wse_globals_"+location.pathname+"_"+this.game.url+"_",this.globalVars={set:function(e,t){n.set(i+e,t)},get:function(e){return n.get(i+e)},has:function(e){return null===n.get(i+e)?!1:!0}},this.debug===!0&&(this.game.bus.debug=!0)}return o.prototype.buildLoadingScreen=function(){var e,t,n;t=this,e=document.createElement("div"),e.setAttribute("id","WSELoadingScreen"),e.style.zIndex=1e4,e.style.width="100%",e.style.height="100%",e.innerHTML='
Loading assets...
',this.game.stage.appendChild(e),n=function(){var e,n,i;try{e=document.getElementById("WSELoadingScreenProgress"),n=document.getElementById("WSELoadingScreenPercentage"),i=parseInt(t.assetsLoaded/t.assetsLoadingMax*100,10),t.assetsLoadingMax<1&&(i=0),e.style.width=i+"%",n.innerHTML=""+t.assetsLoaded+"/"+t.assetsLoadingMax+" ("+i+"%)"}catch(r){console.log("Element missing.")}},this.bus.subscribe(n,"wse.assets.loading.increase"),this.bus.subscribe(n,"wse.assets.loading.decrease"),this.loadScreen=e},o.prototype.start=function(){var t,n,i,r;this.story=this.game.ws,this.stage=this.game.stage,this.bus=this.game.bus,this.index=0,this.currentElement=0,this.sceneId=null,this.scenePath=[],this.currentCommands=[],this.wait=!1,this.startTime=Math.round(+new Date/1e3),this.stopped=!1,t=this,r=this.bus,this.buildLoadingScreen(),n=function(e){var n,i,r;if(e=e||{},i=e.element||null,n=null,null!==i)try{n="asset"===e.element.tagName?"assets":null,n="settings"===e.element.parent.tagName?"settings":null}catch(s){}switch(n=n||"scenes"){case"assets":r=" Encountered in section 'assets'.";break;case"settings":r=" Encountered in section 'settings'.";break;default:r=" Encountered in scene '"+t.sceneId+"', element "+t.currentElement+"."}console.log(r)},r.subscribe(n,"wse.interpreter.error"),r.subscribe(n,"wse.interpreter.warning"),r.subscribe(n,"wse.interpreter.message"),r.subscribe(function(){console.log("Game over.")},"wse.interpreter.end"),r.subscribe(function(){t.numberOfFunctionsToWaitFor+=1},"wse.interpreter.numberOfFunctionsToWaitFor.increase"),r.subscribe(function(){t.numberOfFunctionsToWaitFor-=1},"wse.interpreter.numberOfFunctionsToWaitFor.decrease"),r.subscribe(function(){t.assetsLoading+=1,t.assetsLoadingMax+=1},"wse.assets.loading.increase"),r.subscribe(function(){t.assetsLoading-=1,t.assetsLoaded+=1},"wse.assets.loading.decrease"),function(){var n;n=function(){var n,i,r;n=function(e){t.loadScreen.style.opacity=e},i=function(){t.loadScreen.style.display="none"},r={duration:500,onFinish:i},document.getElementById("WSELoadingScreenProgress").style.width="100%",e(n,1,0,r)},r.subscribe(n,"wse.assets.loading.finished")}(),this.buildAssets(),this.createTriggers(),i=function(e){return function(n){r.trigger(e,{event:n,keys:t.game.keys.keys})}},this.game.keys.forAll(i("keyup"),"up"),this.game.keys.forAll(i("keydown"),"down"),this.game.keys.forAll(i("keypress"),"press"),this.game.subscribeListeners(),setTimeout(function(){t.runStory()},1e3)},o.prototype.runStory=function(){var e;return e=this,this.assetsLoading>0?void function(){var t;t=function(){e.runStory()},setTimeout(t,100)}():(this.bus.trigger("wse.assets.loading.finished"),this.startTime=Math.round(+new Date/1e3),void this.changeScene(this.getFirstScene()))},o.prototype.getFirstScene=function(){var e,t,n;return e=this.story.getElementsByTagName("scene"),this.scenes=e,t=e.length,n=this.getSceneById("start"),null!==n?n:1>t?(this.bus.trigger("wse.interpreter.error",{message:"No scenes found!"}),null):e[0]},o.prototype.changeScene=function(e){this.changeSceneNoNext(e),this.next()},o.prototype.changeSceneNoNext=function(e){var t,n,i=this.bus;if(i.trigger("wse.interpreter.changescene.before",{scene:e,interpreter:this},!1),"undefined"==typeof e||null===e)return void i.trigger("wse.interpreter.error",{message:"Scene does not exist."});if(n=e.getAttribute("id"),this.visitedScenes.push(n),null===n)return void i.trigger("wse.interpreter.error",{message:"Encountered scene without id attribute."});for(i.trigger("wse.interpreter.message","Entering scene '"+n+"'.");this.scenePath.length>0;)this.popFromCallStack();return this.currentCommands=e.childNodes,t=this.currentCommands.length,this.index=0,this.sceneId=n,this.scenePath=[],this.currentElement=0,1>t?void i.trigger("wse.interpreter.warning",{element:e,message:"Scene '"+n+"' is empty."}):(this.numberOfFunctionsToWaitFor=0,void i.trigger("wse.interpreter.changescene.after",{scene:e,interpreter:this},!1))},o.prototype.pushToCallStack=function(){var e={};e.index=this.index,e.sceneId=this.sceneId,e.scenePath=this.scenePath.slice(),e.currentElement=this.currentElement,this.callStack.push(e)},o.prototype.popFromCallStack=function(){var e=this.callStack.pop(),t=e.scenePath.slice();for(this.bus.trigger("wse.interpreter.message","Returning from sub scene '"+this.sceneId+"' to scene '"+e.sceneId+"'...",!1),this.index=e.index+1,this.sceneId=e.sceneId,this.scenePath=e.scenePath,this.currentScene=this.getSceneById(e.sceneId),this.currentElement=e.currentElement,this.currentCommands=this.currentScene.childNodes;t.length>0;)this.currentCommands=this.currentCommands[t.shift()].childNodes},o.prototype.getSceneById=function(e){var t,n,i,r;for(r=null,t=0,n=this.scenes.length;n>t;t+=1)if(i=this.scenes[t],i.getAttribute("id")===e){r=i;break}return null===r&&this.bus.trigger("wse.interpreter.warning",{message:"Scene '"+e+"' not found!"}),r},o.prototype.next=function(e){var t,n,i,r,s,o=this.bus;if(s={stop:!1},e=e===!0?!0:!1,o.trigger("wse.interpreter.next.before",this,!1),e===!0&&o.trigger("wse.interpreter.next.user",s,!1),s.stop!==!0&&(r=this,"pause"!==this.state)){if(this.waitForTimer===!0||this.wait===!0&&this.waitCounter>0)return void setTimeout(function(){r.next()},0);if(this.wait===!0&&this.numberOfFunctionsToWaitFor<1&&(this.wait=!1),this.stopped=!1,this.index>=this.currentCommands.length)return this.callStack.length>0?(this.popFromCallStack(),void setTimeout(function(){r.next()},0)):(o.trigger("wse.interpreter.next.after.end",this,!1),void o.trigger("wse.interpreter.end",this));if(n=this.currentCommands[this.index],t=n.nodeName,"#text"===t||"#comment"===t)return this.index+=1,setTimeout(function(){r.next()},0),void o.trigger("wse.interpreter.next.ignore",this,!1);if(o.trigger("wse.interpreter.next.command",n),this.currentElement+=1,i=this.runCommand(this.currentCommands[this.index]),i=i||{},i.doNext=i.doNext===!1?!1:!0,i.wait=i.wait===!0?!0:!1,i.changeScene=i.changeScene||null,i.wait===!0&&(this.wait=!0),this.index+=1,null!==i.changeScene)return void this.changeScene(i.changeScene);if(i.doNext===!0)return setTimeout(function(){r.next()},0),void o.trigger("wse.interpreter.next.after.donext",this,!1);this.stopped=!0,o.trigger("wse.interpreter.next.after.nonext",this,!1)}},o.prototype.checkIfvar=function(e){var t,n,i,r,s=this.bus;if(t=e.getAttribute("ifvar")||null,n=e.getAttribute("ifvalue"),i=e.getAttribute("ifnot"),null!==t||null!==n||null!==i){if(r=this.runVars,!(t in r))return s.trigger("wse.interpreter.warning",{element:e,message:"Unknown variable '"+t+"' used in condition. Ignoring command."}),s.trigger("wse.interpreter.runcommand.after.condition.error.key",{interpreter:this,command:e},!1),!1;if(null!==i&&""+r[t]==""+i)return s.trigger("wse.interpreter.message","Conidition not met. "+t+"=="+i),s.trigger("wse.interpreter.runcommand.after.condition.false",{interpreter:this,command:e},!1),!1;if(null!==n&&""+r[t]!=""+n)return s.trigger("wse.interpreter.message","Conidition not met."),s.trigger("wse.interpreter.runcommand.after.condition.false",{interpreter:this,command:e},!1),!1;s.trigger("wse.interpreter.runcommand.condition.met",{interpreter:this,command:e},!1),s.trigger("wse.interpreter.message","Conidition met.")}return!0},o.prototype.runCommand=function(e){var t,n,i=this.bus;return this.bus.trigger("wse.interpreter.runcommand.before",{interpreter:this,command:e},!1),t=e.tagName,n=e.getAttribute("asset")||null,this.checkIfvar(e)?t in s.commands?(i.trigger("wse.interpreter.runcommand.after.command",{interpreter:this,command:e},!1),i.trigger("game.commands."+t),s.commands[t](e,this)):null!==n&&n in this.assets&&"function"==typeof this.assets[n][t]&&t.match(/(show|hide|clear|flicker|flash|play|start|stop|pause|move|shake|set)/)?(i.trigger("game.assets."+n+"."+t),this.assets[n][t](e,this)):(i.trigger("wse.interpreter.warning",{element:e,message:"Unknown element '"+t+"'."}),i.trigger("wse.interpreter.runcommand.after.error",{interpreter:this,command:e},!1),{doNext:!0}):{doNext:!0}},o.prototype.createTriggers=function(){var e,t,i,r,s,o,a,u=this.bus;u.trigger("wse.interpreter.triggers.create",this,!1),o=this,this.triggers={};try{e=this.game.ws.getElementsByTagName("triggers")[0].getElementsByTagName("trigger")}catch(c){return void console.log(c)}for(t=0,i=e.length;i>t;t+=1)r=e[t],s=r.getAttribute("name")||null,null!==s?"undefined"==typeof this.triggers[s]||null===this.triggers[s]?(a=new n(r,this),"function"==typeof a.fn&&(this.triggers[s]=a)):u.trigger("wse.interpreter.warning",{element:r,message:"A trigger with the name '"+s+"' already exists."}):u.trigger("wse.interpreter.warning",{element:r,message:"No name specified for trigger."})},o.prototype.buildAssets=function(){var e,t,n,i,r=this.bus;r.trigger("wse.assets.loading.started");try{e=this.story.getElementsByTagName("assets")[0].childNodes}catch(s){r.trigger("wse.interpreter.error",{message:"Error while creating assets: "+s.getMessage()})}for(t=e.length,n=0;t>n;n+=1)i=e[n],1===i.nodeType&&this.createAsset(i)},o.prototype.createAsset=function(e){var t,n,r,o=this.bus;return o.trigger("wse.interpreter.createasset",{interpreter:this,asset:e},!1),t=e.getAttribute("name"),n=e.tagName,r=this,null===t?void o.trigger("wse.interpreter.error",{element:e,message:"Expected attribute 'name'."}):null===n?void o.trigger("wse.interpreter.warning",{element:e,message:"Expected attribute 'type' on asset '"+t+"'."}):("undefined"!=typeof this.assets[t]&&o.trigger("wse.interpreter.warning",{element:e,message:"Trying to override existing asset '"+t+"'."}),n=i.firstLetterUppercase(n),n in s.assets?void(this.assets[t]=new s.assets[n](e,this)):(console.log(s.assets),void o.trigger("wse.interpreter.warning",{element:e,message:"Unknown asset type '"+n+"'."})))},o.prototype.createSaveGame=function(){var e,t,n;n={},e=this.assets;for(t in e)if(e.hasOwnProperty(t))try{n[t]=e[t].save()}catch(i){console.log("WSE Internal Error: Asset '"+t+"' does not have a 'save' method!")}return n},o.prototype.restoreSaveGame=function(e){var t,n;t=this.assets;for(n in t)if(t.hasOwnProperty(n))try{t[n].restore(e[n])}catch(i){console.log(i),this.bus.trigger("wse.interpreter.warning",{message:"Could not restore asset state for asset '"+n+"'!"})}},o.prototype.save=function(e){e=e||"no name";var t,n,i,r,s,o,a=this.bus;t={},a.trigger("wse.interpreter.save.before",{interpreter:this,savegame:t},!1),t.saves=this.createSaveGame(),t.startTime=this.startTime,t.saveTime=Math.round(+new Date/1e3),t.screenContents=this.stage.innerHTML,t.runVars=this.runVars,t.name=e,t.log=this.log,t.visitedScenes=this.visitedScenes,t.gameUrl=this.game.url,t.index=this.index,t.wait=this.wait,t.waitForTimer=this.waitForTimer,t.currentElement=this.currentElement,t.sceneId=this.sceneId,t.scenePath=this.scenePath,t.listenersSubscribed=this.game.listenersSubscribed,t.callStack=this.callStack,t.waitCounter=this.waitCounter,t.pathname=location.pathname,i=this.buildSavegameId(e),n=JSON.stringify(t),s="wse_"+t.pathname+"_"+t.gameUrl+"_savegames_list",r=JSON.parse(this.datasource.get(s)),r=r||[],o=r.indexOf(i),o>=0&&r.splice(o,1),r.push(i);try{this.datasource.set(i,n),this.datasource.set(s,JSON.stringify(r))}catch(u){return a.trigger("wse.interpreter.warning",{message:"Savegame could not be created!"}),a.trigger("wse.interpreter.save.after.error",{interpreter:this,savegame:t},!1),!1}return a.trigger("wse.interpreter.save.after.success",{interpreter:this,savegame:t}),!0},o.prototype.getSavegameList=function(e){var t,n,i,r,s,o;if(n="wse_"+location.pathname+"_"+this.game.url+"_savegames_list",t=this.datasource.get(n),null===t)return[];for(i=JSON.parse(t),o=[],r=0,s=i.length;s>r;r+=1)e===!0?o.unshift(JSON.parse(this.datasource.get(i[r]))):o.push(JSON.parse(this.datasource.get(i[r])));return this.bus.trigger("wse.interpreter.getsavegamelist",{interpreter:this,list:o,names:i},!1),o},o.prototype.buildSavegameId=function(e){var t={};return t.name=e,t.id="wse_"+location.pathname+"_"+this.game.url+"_savegame_"+e,this.bus.trigger("wse.interpreter.save.before",{interpreter:this,vars:t},!1),t.id},o.prototype.load=function(e){var t,n,i,r,s,o,a,u,c,l,d=this.bus;if(c=this,l=this.buildSavegameId(e),t=this.datasource,n=t.get(l),d.trigger("wse.interpreter.load.before",{interpreter:this,savegame:n},!1),!n)return d.trigger("wse.interpreter.warning",{message:"Could not load savegame '"+l+"'!"}),!1;for(n=JSON.parse(n),this.stage.innerHTML=n.screenContents,this.restoreSaveGame(n.saves),this.startTime=n.startTime,this.runVars=n.runVars,this.log=n.log,this.visitedScenes=n.visitedScenes,this.index=n.index,this.wait=n.wait,this.waitForTimer=n.waitForTimer,this.currentElement=n.currentElement,this.callStack=n.callStack,this.waitCounter=n.waitCounter,this.state="listen",r=n.sceneId,this.sceneId=r,o=this.story.getElementsByTagName("scene"),this.scenes=o,a=0,u=this.scenes.length;u>a;a+=1)if(o[a].getAttribute("id")===r){i=o[a];break}if(!i)return d.trigger("wse.interpreter.error",{message:"Loading savegame '"+l+"' failed: Scene not found!"}),!1;for(s=n.scenePath,this.scenePath=s.slice(),this.currentCommands=i.childNodes;s.length>0;)this.currentCommands=this.currentCommands[s.shift()].childNodes;return function(e){var t,n,i,r,s,o,a,u;for(t=e.stage.getElementsByTagName("*"),n=0,i=t.length;i>n;n+=1)r=t[n],"undefined"!=typeof r&&null!==r&&(o=r.getAttribute("data-wse-type")||"",u="true"===r.getAttribute("data-wse-remove")?!0:!1,u===!0&&e.stage.removeChild(r),"choice"===o&&(s=parseInt(r.getAttribute("data-wse-index"),10)||null,null!==s?(a=e.currentCommands[s],"#text"!==a.nodeName&&"#comment"!==a.nodeName&&(e.stage.removeChild(r),e.commands.choice(a,e),e.waitCounter-=1)):e.bus.trigger("wse.interpreter.warning",{message:"No data-wse-index found on element."})))}(this),d.trigger("wse.interpreter.load.after",{interpreter:this,savegame:n},!1),!0},o.prototype.deleteSavegame=function(e){var t,n,i,r,s;return n="wse_"+location.pathname+"_"+this.game.url+"_savegames_list",r=this.datasource.get(n),null===r?!1:(t=JSON.parse(r),s=this.buildSavegameId(e),i=t.indexOf(s),i>=0?(t.splice(i,1),this.datasource.set("wse_"+location.pathname+"_"+this.game.url+"_savegames_list",JSON.stringify(t)),this.datasource.remove(s),!0):!1)},o.prototype.toggleSavegameMenu=function(){var e,t,n,i,s,o,a,u,c,l,d,h,p,f,m,g,y,b;if(s=this,d="WSESaveGameMenu_"+this.game.url,g=this.game.listenersSubscribed,e=document.getElementById(d)||null,null!==e){try{g="true"===e.getAttribute("data-wse-listener-status")?!0:!1,this.stage.removeChild(e)}catch(w){console.log(w)}return g===!0&&(this.savegameMenuVisible=!1),this.state=this.oldStateInSavegameMenu,void(this.waitCounter-=1)}if(this.stopped!==!0)return void setTimeout(function(){s.toggleSavegameMenu()},20);for(b=this.state,this.oldStateInSavegameMenu=b,this.state="pause",this.waitCounter+=1,this.savegameMenuVisible=!0,e=document.createElement("div"),e.innerHTML="",e.setAttribute("id",d),e.setAttribute("class","WSESavegameMenu"),e.setAttribute("data-wse-remove","true"),e.setAttribute("data-wse-listener-status",g),e.style.zIndex=1e5,e.style.position="absolute",o=this.getSavegameList(!0),t=document.createElement("input"),t.setAttribute("class","button delete"),t.setAttribute("type","button"),t.value="Delete",t.addEventListener("click",function(t){var n,i,o;t.stopPropagation(),t.preventDefault(),n=e.querySelector(".active")||null,null!==n&&(i=n.getAttribute("data-wse-savegame-name"),o=function(e){e!==!1&&(s.deleteSavegame(i),s.toggleSavegameMenu(),s.toggleSavegameMenu())},r.confirm(s,{title:"Delete game?",message:"Do you really want to delete savegame '"+i+"'?",callback:o}))},!1),i=document.createElement("input"),i.setAttribute("class","button save"),i.setAttribute("type","button"),i.value="Save",i.addEventListener("click",function(t){var n,i;return t.stopPropagation(),t.preventDefault(),n=e.querySelector(".active")||null,null===n?void r.prompt(s,{title:"New savegame",message:"Please enter a name for the savegame:",callback:function(e){if(null!==e){if(!e)return void r.alert(s,{title:"Error",message:"The savegame name cannot be empty!"});s.toggleSavegameMenu(),s.game.listenersSubscribed=g,s.save(e),s.toggleSavegameMenu(),s.game.listenersSubscribed=!1,r.alert(s,{title:"Game saved",message:"Your game has been saved."})}}}):(i=n.getAttribute("data-wse-savegame-name"),void r.confirm(s,{title:"Overwrite savegame?",message:"You are about to overwrite an old savegame. Are you sure?",trueText:"Yes",falseText:"No",callback:function(e){e!==!1&&(s.toggleSavegameMenu(),s.save(i),s.toggleSavegameMenu(),r.alert(s,{title:"Game saved",message:"Your game has been saved."}))}}))},!1),n=document.createElement("input"),n.setAttribute("class","button load"),n.setAttribute("type","button"),n.setAttribute("tabindex",1),n.value="Load",n.addEventListener("click",function(t){var n,i,o;t.stopPropagation(),t.preventDefault(),n=e.querySelector(".active")||null,null!==n&&(i=n.getAttribute("data-wse-savegame-name"),o=function(e){e!==!1&&(s.stage.removeChild(document.getElementById(d)),s.savegameMenuVisible=!1,s.waitCounter-=1,s.state=b,s.load(i))},r.confirm(s,{title:"Load game?",message:"Loading a savegame will discard all unsaved progress. Continue?",callback:o}))},!1),c=document.createElement("div"),c.setAttribute("class","panel"),l=document.createElement("input"),l.setAttribute("class","button resume"),l.setAttribute("type","button"),l.value="Resume",l.addEventListener("click",function(e){e.stopPropagation(),e.preventDefault(),s.stage.removeChild(document.getElementById(d)),s.bus.trigger("wse.interpreter.numberOfFunctionsToWaitFor.decrease",null,!1),s.savegameMenuVisible=!1,s.waitCounter-=1,s.state=b},!1),h=document.createElement("div"),h.setAttribute("class","list"),c.appendChild(n),c.appendChild(i),c.appendChild(t),c.appendChild(l),e.appendChild(c),m=function(e){return function(t){var i;t.stopPropagation(),t.preventDefault();try{i=h.querySelector(".active")||null,null!==i&&i.setAttribute("class",i.getAttribute("class").replace(/active/,""))}catch(r){console.log(r)}e.setAttribute("class",e.getAttribute("class")+" active"),n.focus()}},f=document.createElement("div"),f.setAttribute("class","button"),a=0,u=o.length;u>a;a+=1)p=o[a],f=document.createElement("div"),y=p.saveTime-p.startTime,f.setAttribute("class","button"),f.setAttribute("data-wse-savegame-name",p.name),f.innerHTML='

'+p.name+'

'+parseInt(y/60/60,10)+"h "+parseInt(y/60%60,10)+"m "+parseInt(y%60,10)+'s'+new Date(1e3*p.saveTime).toUTCString()+"

",f.addEventListener("click",m(f,p),!1),h.appendChild(f);e.addEventListener("click",function(t){var n;t.stopPropagation(),t.preventDefault(),n=e.querySelector(".active")||null,null!==n&&n.setAttribute("class",n.getAttribute("class").replace(/active/,""))},!1),e.appendChild(h),this.stage.appendChild(e)},o}),MO5().define("WSE.tools.ui",function(){"use strict";var e=13,t=27,n={confirm:function(e,t){var n,i,r,s,o,a,u,c,l,d,h,p,f,m,g;e.waitCounter+=1,t=t||{},n=t.title||"Confirm?",i=t.message||"Do you want to proceed?",r=t.trueText||"Yes",s=t.falseText||"No",o="function"==typeof t.callback?t.callback:function(){},a=t.parent||e.stage,f=t.pause===!0?!0:!1,m=e.state,g=t.doNext===!0?!0:!1,f===!0&&(e.state="pause"),p=document.createElement("div"),p.setAttribute("class","WSEUIContainer"),p.setAttribute("data-wse-remove","true"),u=document.createElement("div"),u.setAttribute("class","WSEUIDialog WSEUIConfirm"),c=document.createElement("div"),c.innerHTML=n,c.setAttribute("class","title"),l=document.createElement("div"),l.innerHTML=i,l.setAttribute("class","message"),d=document.createElement("input"),d.setAttribute("value",r),d.value=r,d.setAttribute("class","true button"),d.setAttribute("type","button"),d.addEventListener("click",function(t){t.stopPropagation(),t.preventDefault(),a.removeChild(p),e.waitCounter-=1,f===!0&&(e.state=m),o(!0),g===!0&&setTimeout(function(){e.next()},0)}),h=document.createElement("input"),h.setAttribute("value",s),h.value=s,h.setAttribute("class","false button"),h.setAttribute("type","button"),h.addEventListener("click",function(t){t.stopPropagation(),t.preventDefault(),a.removeChild(p),e.waitCounter-=1,f===!0&&(e.state=m),o(!1),g===!0&&setTimeout(function(){e.next() },0)}),u.appendChild(c),u.appendChild(l),u.appendChild(d),u.appendChild(h),p.appendChild(u),a.appendChild(p),d.focus()},alert:function(e,t){var n,i,r,s,o,a,u,c,l,d,h,p,f;e.waitCounter+=1,t=t||{},n=t.title||"Alert!",i=t.message||"Please take notice of this!",r=t.okText||"OK",s="function"==typeof t.callback?t.callback:function(){},o=t.parent||e.stage,h=t.pause===!0?!0:!1,p=e.state,f=t.doNext===!0?!0:!1,h===!0&&(e.state="pause"),d=document.createElement("div"),d.setAttribute("class","WSEUIContainer"),d.setAttribute("data-wse-remove","true"),a=document.createElement("div"),a.setAttribute("class","WSEUIDialog WSEUIConfirm"),u=document.createElement("div"),u.innerHTML=n,u.setAttribute("class","title"),c=document.createElement("div"),c.innerHTML=i,c.setAttribute("class","message"),l=document.createElement("input"),l.setAttribute("value",r),l.value=r,l.setAttribute("class","true button"),l.setAttribute("type","button"),l.addEventListener("click",function(t){t.stopPropagation(),t.preventDefault(),o.removeChild(d),e.waitCounter-=1,h===!0&&(e.state=p),s(!0),f===!0&&setTimeout(function(){e.next()},0)}),a.appendChild(u),a.appendChild(c),a.appendChild(l),d.appendChild(a),o.appendChild(d),l.focus()},prompt:function(n,i){var r,s,o,a,u,c,l,d,h,p,f,m,g,y,b,w,v,E,S;n.waitCounter+=1,i=i||{},r=i.title||"Input required",s=i.message||"Please enter something:",o=i.submitText||"Submit",a=i.cancelText||"Cancel",b=i.defaultValue||"",u="function"==typeof i.callback?i.callback:function(){},c=i.parent||n.stage,w=i.pause===!0?!0:!1,d=n.state,v=i.doNext===!0?!0:!1,E=i.allowEmptyInput,S=i.hideCancelButton,w===!0&&(n.state="pause"),y=document.createElement("div"),y.setAttribute("class","WSEUIContainer"),y.setAttribute("data-wse-remove","true"),l=document.createElement("div"),l.setAttribute("class","WSEUIDialog WSEUIPrompt"),h=document.createElement("div"),h.innerHTML=r,h.setAttribute("class","title"),p=document.createElement("div"),p.innerHTML=s,p.setAttribute("class","message"),g=document.createElement("input"),g.setAttribute("value",b),g.value=b,g.setAttribute("class","input text"),g.setAttribute("type","text"),g.addEventListener("keyup",function(n){function i(){n.keyCode===e&&f.click()}function r(){return n.keyCode!==t||S?!1:(m.click(),!0)}if(!r())return E?void i():void(g.value?(f.disabled=!1,i()):f.disabled=!0)}),f=document.createElement("input"),f.setAttribute("value",o),f.value=o,f.setAttribute("class","submit button"),f.setAttribute("type","button"),E||b||(f.disabled=!0),f.addEventListener("click",function(e){var t=g.value;(E||t)&&(e.stopPropagation(),e.preventDefault(),c.removeChild(y),n.waitCounter-=1,w===!0&&(n.state=d),u(t),v===!0&&setTimeout(function(){n.next()},0))}),m=document.createElement("input"),m.setAttribute("value",a),m.value=a,m.setAttribute("class","cancel button"),m.setAttribute("type","button"),m.addEventListener("click",function(e){e.stopPropagation(),e.preventDefault(),c.removeChild(y),n.waitCounter-=1,w===!0&&(n.state=d),u(null),v===!0&&setTimeout(function(){n.next()},0)}),l.appendChild(h),l.appendChild(p),l.appendChild(g),l.appendChild(f),S||l.appendChild(m),y.appendChild(l),c.appendChild(y),g.focus()}};return n.makeInputFn=function(e){return function(t,i){var r,s,o,a,u,c,l,d,h;return r=t.getAttribute("title")||"Input required...",s=t.getAttribute("message")||"Your input is required:",a=t.getAttribute("var")||null,u="false"===t.getAttribute("next")?!1:!0,c="yes"===t.getAttribute("hideCancelButton")?!0:!1,l="no"===t.getAttribute("allowEmptyInput")?!1:!0,d=t.getAttribute("submitText")||"",h=t.getAttribute("cancelText")||"",i.bus.trigger("wse.interpreter.commands."+e,t),null===a?(i.bus.trigger("wse.interpreter.warning",{element:t,message:"No 'var' attribute defined on "+e+" command. Command ignored."}),{doNext:!0}):(o=i.runVars,n[e](i,{title:r,message:s,pause:!0,doNext:u,callback:function(e){o[a]=""+e},allowEmptyInput:l,hideCancelButton:c,submitText:d,cancelText:h}),{doNext:!0})}},n}),MO5("MO5.CoreObject","MO5.transform","MO5.easing","WSE.tools").define("WSE.DisplayObject",function(e,t,n,i){function r(){e.call(this)}return r.prototype=new e,r.prototype.flash=function(e,r){var s,o,a,u,c,l,d,h,p,f=i.getParsedAttribute;return r=r||{},s=this,a="yes"===f(e,"wait",this.interpreter)?!0:!1,o=+f(e,"duration",this.interpreter,500),h=+f(e,"opacity",this.interpreter,1),(l=r.element||document.getElementById(this.cssid))?(u=r.bus||this.bus,c=r.stage||this.stage,d=r.animation===!0?!0:!1,p=+l.style.opacity.replace(/[^0-9\.]/,"")>0?!0:!1,d||(s.interpreter.waitCounter+=1),t(function(e){l.style.opacity=e},p?h:0,p?0:h,{duration:o/3,easing:n.easeInCubic}).promise().then(function(){function e(e){l.style.opacity=e}function i(){d||(s.interpreter.waitCounter-=1)}var r;r={duration:o/3*2,easing:n.easeOutCubic},t(e,p?0:h,p?h:0,r).promise().then(i)}),{doNext:!0}):void this.bus.trigger("wse.interpreter.warning",{element:e,message:"DOM Element for asset is missing!"})},r.prototype.flicker=function(e,i){var r,s,o,a,u,c,l,d,h,p,f,m,g,y,b;return i=i||{},r=this,s=e.getAttribute("duration")||500,u=e.getAttribute("times")||10,f=e.getAttribute("opacity")||1,l=i.element||document.getElementById(this.cssid),c=s/u,p=0,l?(parseInt(l.style.opacity,10)?(g=0,m=f,b=c/3,y=2*b):(m=0,g=f,y=c/3,b=2*y),o=i.bus||this.bus,a=i.stage||this.stage,d=i.animation===!0?!0:!1,d||(r.interpreter.waitCounter+=1),h=function(){p+=1,t(function(e){l.style.opacity=e},m,g,{duration:y,easing:n.easeInQuad}).promise().then(function(){t(function(e){l.style.opacity=e},g,m,{duration:b,easing:n.easeInQuad}).promise().then(function(){return u>=p?void setTimeout(h,0):void(d||(r.interpreter.waitCounter-=1))})})},h(),{doNext:!0}):void this.bus.trigger("wse.interpreter.warning",{element:e,message:"DOM Element for asset is missing!"})},r.prototype.hide=function(e,r){var s,o,a,u,c,l,d,h,p,f,m,g,y,b,w,v,E,S,O=i.getParsedAttribute;if(r=r||{},s=this,a="yes"===O(e,"wait",this.interpreter)?!0:!1,o=O(e,"duration",this.interpreter,500),u=O(e,"effect",this.interpreter,"fade"),c=O(e,"direction",this.interpreter,"left"),g=r.animation===!0?!0:!1,y=document.getElementById(this.cssid),b=O(e,"easing",this.interpreter,"sineEaseOut"),w=null!==typeof n[b]?n[b]:n.sineEaseOut,v=this.stage,E=this.xUnit||"px",S=this.yUnit||"px","slide"===u){switch(y.style.opacity=1,"%"===E?(h=y.offsetLeft/(v.offsetWidth/100),l=100):(h=y.offsetLeft,l=v.offsetWidth),"%"===S?(p=y.offsetTop/(v.offsetHeight/100),d=100):(p=y.offsetTop,d=v.offsetHeight),c){case"left":f=h-l,m="left";break;case"right":f=h+l,m="left";break;case"top":f=p-d,m="top";break;case"bottom":f=p+d,m="top";break;default:f=h-l,m="left"}g||(s.interpreter.waitCounter+=1),function(){var e,n,i,r;e=function(e){y.style[m]=e+("left"===m?E:S)},n="left"===m?h:p,i=function(){switch(g||(s.interpreter.waitCounter-=1),y.style.opacity=0,c){case"left":case"right":y.style.left=h+E,m="left";break;case"top":case"bottom":y.style.top=p+S,m="top";break;default:y.style.left=h+E,m="left"}},r={duration:o,easing:w},t(e,n,f,r).promise().then(i)}()}else g||(s.interpreter.waitCounter+=1),function(){var e,n,i;e=function(e){y.style.opacity=e},i=function(){g||(s.interpreter.waitCounter-=1),y.style.opacity=0},n={duration:o,easing:w},t(e,1,0,n).promise().then(i)}();return{doNext:!0}},r.prototype.move=function(e,r){var s,o,a,u,c,l,d,h,p,f,m,g,y,b,w,v,E,S,O,A,M,_,k,x=this.interpreter;return r=r||{},c=this,u=document.getElementById(this.cssid),s=e.getAttribute("x"),o=e.getAttribute("y"),a=e.getAttribute("z"),O=e.getAttribute("xAnchor")||"0",A=e.getAttribute("yAnchor")||"0",null===O&&null!==this.xAnchor&&(O=this.xAnchor),null===A&&null!==this.yAnchor&&(A=this.yAnchor),s=i.replaceVariables(s,this.interpreter),o=i.replaceVariables(o,this.interpreter),a=i.replaceVariables(a,this.interpreter),O=i.replaceVariables(O,this.interpreter),A=i.replaceVariables(A,this.interpreter),p=i.getParsedAttribute(e,"duration",x,500),f=i.getParsedAttribute(e,"easing",x,"sineEaseOut"),m=null!==typeof n[f]?n[f]:n.sineEaseOut,w=r.animation===!0?!0:!1,S=this.interpreter.stage,M=u.offsetLeft,_=u.offsetTop,null!==s&&(d=i.extractUnit(s)||"px",s=parseInt(s,10)),null!==o&&(h=i.extractUnit(o)||"px",o=parseInt(o,10)),k=u.style.display,u.style.display="","%"===d&&(s=S.offsetWidth/100*s,d="px"),"%"===h&&(o=S.offsetHeight/100*o,h="px"),s=i.calculateValueWithAnchor(s,O,u.offsetWidth),o=i.calculateValueWithAnchor(o,A,u.offsetHeight),u.style.display=k,l="yes"===i.getParsedAttribute(e,"wait",x)?!0:!1,g=!1,y=!1,b=!1,null===s&&null===o&&null===a&&this.bus.trigger("wse.interpreter.warning",{element:e,message:"Can't apply command 'move' to asset '"+this.name+"' because no x, y or z position has been supplied."}),null!==s&&(v="%"===d?M/(S.offsetWidth/100):M,w||(c.interpreter.waitCounter+=1),t(function(e){u.style.left=e+d},v,s,{duration:p,easing:m}).promise().then(function(){w||(c.interpreter.waitCounter-=1)})),null!==o&&(E="%"===h?_/(S.offsetHeight/100):_,w||(c.interpreter.waitCounter+=1),t(function(e){u.style.top=e+h},E,o,{duration:p,easing:m}).promise().then(function(){w||(c.interpreter.waitCounter-=1)})),null!==a&&(w||(c.interpreter.waitCounter+=1),t(function(e){u.style.zIndex=e},u.style.zIndex||0,parseInt(a,10),{duration:p,easing:m}).promise().then(function(){w||(c.interpreter.waitCounter-=1)})),this.bus.trigger("wse.assets.mixins.move",this),{doNext:!0}},r.prototype.shake=function(e,n){function r(e,t){for(var n=t/h;n>2;)n-=2;return n>1&&(n=2-n),n}var s,o,a,u,c,l,d,h,p,f,m,g;return n=n||{},u=this,a=document.getElementById(this.cssid),s=e.getAttribute("dx"),o=e.getAttribute("dy"),h=e.getAttribute("period")||50,d=e.getAttribute("duration")||275,p=n.animation===!0?!0:!1,g=this.interpreter.stage,null===s&&null===o&&(o="-10px"),null!==s&&(c=i.extractUnit(s),s=parseInt(s,10)),null!==o&&(l=i.extractUnit(o),o=parseInt(o,10)),null!==s&&(f="%"===c?a.offsetLeft/(g.offsetWidth/100):a.offsetLeft,u.interpreter.waitCounter+=1,t(function(e){a.style.left=e+c},f-s,f+s,{duration:d,easing:r}).then(function(){a.style.left=f+c,u.interpreter.waitCounter-=1})),null!==o&&(m="%"===l?a.offsetTop/(g.offsetHeight/100):a.offsetTop,u.interpreter.waitCounter+=1,t(function(e){a.style.top=e+l},m-o,m+o,{duration:d,easing:r}).promise().then(function(){a.style.top=m+l,u.interpreter.waitCounter-=1})),this.bus.trigger("wse.assets.mixins.shake",this),{doNext:!0}},r.prototype.show=function(e,r){var s,o,a,u,c,l,d,h,p,f,m,g,y,b,w,v,E,S,O,A,M,_=i.getParsedAttribute;if(r=r||{},s=this,a="yes"===_(e,"wait",this.interpreter)?!0:!1,o=_(e,"duration",this.interpreter,500),u=_(e,"effect",this.interpreter,"fade"),c=_(e,"direction",this.interpreter,"right"),y=r.element||document.getElementById(this.cssid),p=this.xUnit||"px",f=this.yUnit||"px",!y)return void this.bus.trigger("wse.interpreter.warning",{element:e,message:"DOM Element for asset is missing!"});if(E=r.interpreter||this.interpreter,m=r.bus||this.bus,g=r.stage||this.stage,v=_(e,"easing",this.interpreter,"sineEaseOut"),w=null!==typeof n[v]?n[v]:n.sineEaseOut,b=r.animation===!0?!0:!1,"slide"===u){switch("%"===p?(l=y.offsetLeft/(g.offsetWidth/100),S=100):(l=y.offsetLeft,S=g.offsetWidth),"%"===f?(d=y.offsetTop/(g.offsetHeight/100),O=100):(d=y.offsetTop,O=g.offsetHeight),c){case"left":y.style.left=l+S+p,h="left";break;case"right":y.style.left=l-S+p,h="left";break;case"top":y.style.top=d+O+f,h="top";break;case"bottom":y.style.top=d-O+f,h="top";break;default:y.style.left=l-S+p,h="left"}y.style.opacity=1,b||(E.waitCounter+=1),A="%"===p?y.offsetLeft/(g.offsetWidth/100):y.offsetLeft,M="%"===f?y.offsetTop/(g.offsetHeight/100):y.offsetTop,t(function(e){y.style[h]=e+("left"===h?p:f)},"left"===h?A:M,"left"===h?l:d,{duration:o,easing:w}).promise().then(function(){b||(E.waitCounter-=1)})}else b||(E.waitCounter+=1),t(function(e){y.style.opacity=e},0,1,{duration:o,easing:w}).promise().then(function(){b||(E.waitCounter-=1)});return{doNext:!0}},r}),MO5("MO5.transform","MO5.easing","MO5.Animation","WSE.tools","WSE.commands","MO5.TimerWatcher").define("WSE.assets.Animation",function(e,t,n,i,r,s){"use strict";function o(o,a){function u(t,n,i,r,s,o){return e(function(e){t.style[r]=e+s},n,i,o)}function c(e,t){var n,s;s=e,n=s.getAttribute("duration"),r["do"](s,a,{animation:!0}),null!==n&&t.addTimer(i.createTimer(n))}function l(e,n){var i;i=n.length,g=m.length,y.cbs.push(function(){var r,o,a,l,d,h,p,f,m,b,w,v,E;for(E=new s,m=0;g>m;m+=1)if(l=e[m],"undefined"!=typeof l&&null!==l){h=l.getAttribute("asset");try{d=document.getElementById(y.assets[h].cssid)||y.stage}catch(S){continue}b=l.getAttribute("easing"),r=parseInt(l.getAttribute("from"),10),o=parseInt(l.getAttribute("to"),10),a=l.getAttribute("unit")||"",p=l.getAttribute("duration")||500,f=l.getAttribute("property"),w={},w.duration=p,null!==b&&"undefined"!=typeof t[b]&&null!==t[b]&&(w.easing=t[b]),E.addTimer(u(d,r,o,f,a,w))}for(v=0;i>v;v+=1)c(n[v],E);return E})}var d,h,p,f,m,g,y,b;if(this.stage=a.stage,this.bus=a.bus,this.asset=o,this.name=o.getAttribute("name"),this.cbs=[],this.assets=a.assets,this.id=i.getUniqueId(),this.isRunning=!1,y=this,d=this.asset.getElementsByTagName("group"),p=d.length,1>p)return this.bus.trigger("wse.interpreter.warning",{element:o,message:"Animation asset '"+this.name+"' is empty."}),{doNext:!0};for(h=0;p>h;h+=1)f=d[h],m=f.getElementsByTagName("transform"),b=f.getElementsByTagName("do"),l(m,b);this.anim=new n,this.cbs.forEach(function(e){this.anim.addStep(e)}.bind(this)),this.bus.trigger("wse.assets.animation.constructor",this),function(){function e(){y.stop()}y.bus.subscribe(e,"wse.interpreter.restart"),y.bus.subscribe(e,"wse.interpreter.end"),y.bus.subscribe(e,"wse.interpreter.load.before")}()}return o.prototype.start=function(){this.anim.start(),this.isRunning=!0,this.bus.trigger("wse.assets.animation.started",this)},o.prototype.stop=function(){this.anim.isRunning()&&this.anim.stop(),this.isRunning=!1,this.bus.trigger("wse.assets.animation.stopped",this)},o.prototype.save=function(){var e={assetType:"Animation",isRunning:this.isRunning,index:this.anim.index};return this.bus.trigger("wse.assets.animation.save",{subject:this,saves:e}),e},o.prototype.restore=function(e){this.isRunning=e.isRunning,this.isRunning===!0&&(this.anim.index=e.index,this.start()),this.bus.trigger("wse.assets.animation.restore",{subject:this,saves:e})},o}),MO5("WSE.tools").define("WSE.assets.Audio",function(e){"use strict";function t(t,n){var i,r,s,o,a,u,c,l,d,h,p,f,m,g,y,b;if(y=n.bus,i=this,this.interpreter=n,this.bus=y,this.name=t.getAttribute("name"),this.tracks={},this.autopause="true"===t.getAttribute("autopause")?!0:!1,this.loop="true"===t.getAttribute("loop")?!0:!1,this.fade="true"===t.getAttribute("fade")?!0:!1,this.fadeinDuration=parseInt(t.getAttribute("fadein"))||1e3,this.fadeoutDuration=parseInt(t.getAttribute("fadeout"))||1e3,this.id=e.getUniqueId(),this._playing=!1,g=t.getElementsByTagName("track"),o=g.length,1>o)return this.bus.trigger("wse.interpreter.warning",{element:t,message:"No tracks defined for audio element '"+this.name+"'."}),{doNext:!0};for(s=0;o>s;s+=1)if(c=g[s],d=c.getAttribute("title"),null!==d)if(r=c.getElementsByTagName("source"),u=r.length,1>u)this.bus.trigger("wse.interpreter.warning",{element:t,message:"No sources defined for track '"+d+"' in audio element '"+this.name+"'."});else{for(b={urls:[],autoplay:!1,loop:this.loop||!1,onload:this.bus.trigger.bind(this.bus,"wse.assets.loading.decrease")},h={},a=0;u>a;a+=1)m=r[a],p=m.getAttribute("href"),f=m.getAttribute("type"),null!==p?null!==f?(h[f]=p,b.urls.push(p)):this.bus.trigger("wse.interpreter.warning",{element:t,message:"No type defined for source in track '"+d+"' in audio element '"+this.name+"'."}):this.bus.trigger("wse.interpreter.warning",{element:t,message:"No href defined for source in track '"+d+"' in audio element '"+this.name+"'."});this.bus.trigger("wse.assets.loading.increase"),l=new Howl(b),this.tracks[d]=l}else this.bus.trigger("wse.interpreter.warning",{element:t,message:"No title defined for track '"+d+"' in audio element '"+this.name+"'."});this.play=function(e){var t;return this._playing?{doNext:!0}:(this._playing=!0,this._paused=!1,e.getAttribute("fadein")?(this.interpreter.waitCounter+=1,t=+e.getAttribute("fadein"),this.tracks[this._currentTrack].volume(0),this.tracks[this._currentTrack].play(),this.tracks[this._currentTrack].fade(0,1,t,function(){this.interpreter.waitCounter-=1}.bind(this))):this.tracks[this._currentTrack].play(),{doNext:!0})},this.stop=function(e){var t;return this._currentTrack?(this._playing=!1,this._paused=!1,e&&e.getAttribute("fadeout")?(this.interpreter.waitCounter+=1,t=+e.getAttribute("fadeout"),this.tracks[this._currentTrack].fade(1,0,t,function(){this.tracks[this._currentTrack].stop(),this.interpreter.waitCounter-=1}.bind(this))):this.tracks[this._currentTrack].stop(),this.bus.trigger("wse.assets.audio.stop",this),{doNext:!0}):{doNext:!0}},this.pause=function(){return this._currentTrack&&this._playing?(this._paused=!0,this.tracks[this._currentTrack].pause(),{doNext:!0}):{doNext:!0}},this.bus.trigger("wse.assets.audio.constructor",this),this.bus.subscribe("wse.interpreter.restart",function(){this.stop()}.bind(this)),window.addEventListener("blur",function(){this._playing&&this.tracks[this._currentTrack].fade(1,0,200)}.bind(this)),window.addEventListener("focus",function(){this._playing&&this.tracks[this._currentTrack].fade(0,1,200)}.bind(this))}return t.prototype.set=function(e){var t=!1;return this._playing&&(t=!0),this.stop(),this._currentTrack=e.getAttribute("track"),t&&this.play(),{doNext:!0}},t.prototype.save=function(){var e={currentTrack:this._currentTrack,playing:this._playing,paused:this._paused};return this.bus.trigger("wse.assets.audio.save",this),e},t.prototype.restore=function(e){this._playing=e.playing,this._paused=e.paused,this._currentTrack=e.currentTrack,this._playing&&!this._paused&&this.tracks[this._currentTrack].play(),this.bus.trigger("wse.assets.audio.restore",this)},t}),MO5("WSE.DisplayObject","WSE.tools").define("WSE.assets.Character",function(e,t){"use strict";function n(e,n){this.asset=e,this.stage=n.stage,this.bus=n.bus,this.id=t.getUniqueId(),this.name=e.getAttribute("name"),this.bus.trigger("wse.assets.character.constructor",this)}return n.prototype.setTextbox=function(e){this.asset.setAttribute("textbox",e.getAttribute("textbox")),this.bus.trigger("wse.assets.character.settextbox",this)},n.prototype.save=function(){var e={assetType:"Character",textboxName:this.asset.getAttribute("textbox")};return this.bus.trigger("wse.assets.character.save",{subject:this,saves:e}),e},n.prototype.restore=function(e){this.asset.setAttribute("textbox",e.textboxName),this.bus.trigger("wse.assets.character.restore",{subject:this,saves:e})},n}),MO5("WSE.DisplayObject","WSE.tools").define("WSE.assets.Curtain",function(e,t){"use strict";function n(n,i){e.call(this),this.asset=n,this.interpreter=i,this.bus=i.bus,this.stage=i.stage,this.color=n.getAttribute("color")||"black",this.z=n.getAttribute("z")||2e4,this.cssid="WSECurtain_"+this.id,this.element=document.createElement("div"),this.name=n.getAttribute("name"),this.element.setAttribute("id",this.cssid),this.element.setAttribute("class","WSECurtain"),this.element.style.position="absolute",this.element.style.left=0,this.element.style.top=0,this.element.style.width=this.stage.offsetWidth+"px",this.element.style.height=this.stage.offsetHeight+"px",this.element.style.opacity=0,this.element.style.backgroundColor=this.color,this.element.style.zIndex=this.z,t.applyAssetUnits(this,n),this.stage.appendChild(this.element)}return n.prototype=new e,n.prototype.set=function(e){this.color=e.getAttribute("color")||"black",this.element.style.backgroundColor=this.color},n.prototype.save=function(){return{color:this.color,cssid:this.cssid,z:this.z}},n.prototype.restore=function(e){this.color=e.color,this.cssid=e.cssid,this.z=e.z;try{this.element=document.getElementById(this.cssid)}catch(t){return void this.bus.trigger("wse.interpreter.warning",{message:"Element with CSS ID '"+this.cssid+"' could not be found."})}this.element.style.backgroundColor=this.color,this.element.style.zIndex=this.z},n}),MO5("WSE.DisplayObject","WSE.tools","MO5.transform","MO5.easing").define("WSE.assets.Imagepack",function(e,t,n,i){"use strict";function r(n,i){var r,s,o,a,u,c,l,d,h,p,f,m,g,y,b,w,v;for(e.call(this),this.stage=i.stage,this.bus=i.bus,this.name=n.getAttribute("name"),this.cssid=n.getAttribute("cssid")||"wse_imagepack_"+this.name,this.interpreter=i,this.xAnchor=n.getAttribute("xAnchor"),this.yAnchor=n.getAttribute("yAnchor"),this.width=parseInt(n.getAttribute("width"),10)||100,this.height=parseInt(n.getAttribute("height"),10)||100,t.applyAssetUnits(this,n),p=this,s={},r=document.createElement("div"),m=n.getAttribute("width"),g=n.getAttribute("height"),r.style.opacity=0,r.draggable=!1,r.setAttribute("class","imagepack"),r.setAttribute("id",this.cssid),r.setAttribute("data-wse-asset-name",this.name),o=n.getElementsByTagName("image"),f=function(){p.bus.trigger("wse.assets.loading.decrease")},a=0,u=o.length;u>a;a+=1)c=o[a],l=c.getAttribute("name"),d=c.getAttribute("src"),null!==l?null!==d?(h=new Image,this.bus.trigger("wse.assets.loading.increase"),t.attachEventListener(h,"load",f),h.src=d,h.style.opacity=0,h.style.position="absolute",h.draggable=!1,h.setAttribute("data-wse-asset-image-name",l),null!==m&&h.setAttribute("width",m),null!==g&&h.setAttribute("height",g),s[l]=this.cssid+"_"+l,h.setAttribute("id",s[l]),r.appendChild(h)):this.bus.trigger("wse.interpreter.warning",{element:n,message:"Image without src in imagepack '"+this.name+"'."}):this.bus.trigger("wse.interpreter.warning",{element:n,message:"Image without name in imagepack '"+this.name+"'."});r.style.position="absolute",r.style.zIndex=n.getAttribute("z")||0,this.stage.appendChild(r),y=parseInt(n.getAttribute("x")||0,10),b=parseInt(n.getAttribute("y")||0,10),w=t.extractUnit(n.getAttribute("x"))||"px",v=t.extractUnit(n.getAttribute("y"))||"px","%"===w&&(y=this.stage.offsetWidth/100*y),"%"===v&&(b=this.stage.offsetHeight/100*b),y=t.calculateValueWithAnchor(y,this.xAnchor,this.width),b=t.calculateValueWithAnchor(b,this.yAnchor,this.height),"%"===w&&(y/=this.stage.offsetWidth/100),"%"===v&&(b/=this.stage.offsetHeight/100),r.style.left=""+y+w,r.style.top=""+b+v,this.images=s,this.current=null}return r.prototype=new e,r.prototype.set=function(e,t){var r,s,o,a,u,c,l,d=this.bus;if(t=t||{},o=this,s=e.getAttribute("image"),u=e.getAttribute("duration")||400,c=t.animation===!0?!0:!1,null===s)return d.trigger("wse.interpreter.warning",{element:e,message:"Missing attribute 'image' on 'do' element referencing imagepack '"+this.name+"'."}),{doNext:!0};try{r=document.getElementById(this.images[s])}catch(h){console.error("DOM Element for Image "+s+" on Imagepack "+this.name+" not found!",h)}if("undefined"==typeof r||null===r)return d.trigger("wse.interpreter.warning",{element:e,message:"Unknown image name on 'do' element referencing imagepack '"+this.name+"'."}),{doNext:!0};a=this.current;for(var p in this.images)if(this.images.hasOwnProperty(p)){if(p!==s)continue;if(p===a)return d.trigger("wse.interpreter.warning",{element:e,message:"Trying to set the image that is already set on imagepack '"+this.name+"'."}),{doNext:!0}}return c||(o.interpreter.waitCounter+=1),l=document.getElementById(this.cssid),l.style.width=r.offsetWidth+"px",l.style.height=r.offsetHeight+"px",function(){var e,t,s;e=function(e){r.style.opacity=e},t=function(){c||(o.interpreter.waitCounter-=1)},s={duration:u,easing:i.easeOutCubic},n(e,0,1,s).promise().then(t)}(),null!==this.current&&(c||(o.interpreter.waitCounter+=1),function(){var e;(e=function(){var e,t,r,s;e=document.getElementById(o.images[a]),t=function(t){e.style.opacity=t},r=function(){c||(o.interpreter.waitCounter-=1)},s={duration:u,easing:i.easeInCubic},n(t,1,0,s).promise().then(r)})()}()),this.current=s,{doNext:!0}},r.prototype.save=function(){var e,t,n,i,r;n=this.images,e=this.current||null,i=null;for(t in n)n.hasOwnProperty(t)&&n[t]===e&&(i=t);return r={assetType:"Imagepack",current:e,cssid:this.cssid,images:n,xAnchor:this.xAnchor,yAnchor:this.yAnchor,z:this.z},this.bus.trigger("wse.assets.imagepack.save",{subject:this,saves:r}),r},r.prototype.restore=function(e){var t;t=e.current,this.cssid=e.cssid,this.z=e.z,this.current=t,this.xAnchor=e.xAnchor,this.yAnchor=e.yAnchor,document.getElementById(this.cssid).style.zIndex=this.z,this.bus.trigger("wse.assets.imagepack.restore",{subject:this,saves:e})},r}),MO5("WSE.DisplayObject","WSE.tools","MO5.transform","MO5.dom.effects.typewriter","MO5.dom.Element").define("WSE.assets.Textbox",function(e,t,n,i,r){"use strict";function s(n,i){e.call(this);var r,s,o,a,u,c,l,d;this.interpreter=i,this.name=n.getAttribute("name"),this.stage=i.stage,this.bus=i.bus,this.type=n.getAttribute("behaviour")||"adv",this.z=n.getAttribute("z")||5e3,this.showNames="yes"===n.getAttribute("namebox")?!0:!1,this.nltobr="true"===n.getAttribute("nltobr")?!0:!1,this.cssid="wse_textbox_"+this.name,this.effectType=n.getAttribute("effect")||"typewriter",this.speed=n.getAttribute("speed")||0,this.speed=parseInt(this.speed,10),this.fadeDuration=n.getAttribute("fadeDuration")||0,t.applyAssetUnits(this,n),function(e){var t,i,r,s;try{for(s=n.childNodes,i=0,r=s.length;r>i;i+=1)if(1===s[i].nodeType&&"nameTemplate"===s[i].tagName){t=s[i];break}if(!t)throw new Error("No nameTemplate found.");e.nameTemplate=(new XMLSerializer).serializeToString(t)}catch(o){e.nameTemplate="{name}: "}}(this),"nvl"===this.type&&(this.showNames=!1),r=document.createElement("div"),s=document.createElement("div"),o=document.createElement("div"),r.setAttribute("class","textbox"),o.setAttribute("class","text"),s.setAttribute("class","name"),a=n.getAttribute("cssid")||this.cssid,r.setAttribute("id",a),this.cssid=a,u=n.getAttribute("x"),u&&(r.style.left=u),c=n.getAttribute("y"),c&&(r.style.top=c),r.style.zIndex=this.z,l=n.getAttribute("width"),d=n.getAttribute("height"),l&&(r.style.width=l),d&&(r.style.height=d),r.appendChild(s),r.appendChild(o),this.stage.appendChild(r),this.showNames===!1&&(s.style.display="none"),s.setAttribute("id",this.cssid+"_name"),o.setAttribute("id",this.cssid+"_text"),this.nameElement=this.cssid+"_name",this.textElement=this.cssid+"_text",r.style.opacity=0,this.bus.trigger("wse.assets.textbox.constructor",this)}return s.prototype=new e,s.prototype.put=function(e,s,o){function a(){"adv"===d.type&&(u.innerHTML=""),u.innerHTML+=l+e,c.innerHTML=d.nameTemplate.replace(/\{name\}/g,s)}var u,c,l,d,h,p="wse_no_character";return s=s||null,o=o||"_no_one",d=this,u=document.getElementById(this.textElement),c=document.getElementById(this.nameElement),h=r.fromDomElement(document.getElementById(this.cssid)),e=t.replaceVariables(e,this.interpreter),d.interpreter.waitCounter+=1,l="",this.showNames===!1&&s&&(l=this.nameTemplate.replace(/\{name\}/g,s)),null===s?(this.showNames&&(c.style.display="none"),s=""):(this.showNames&&(c.style.display=""),p="wse_character_"+o.split(" ").join("_")),this._lastCssClass&&h.removeCssClass(this._lastCssClass),this._lastCssClass=p,h.addCssClass(p),this.speed<1&&(this.fadeDuration>0?(d.interpreter.waitCounter+=1,function(){var e,t,i;e=function(e){u.style.opacity=e},t=function(){d.interpreter.waitCounter-=1},i={duration:d.fadeDuration},n(e,1,0,i).promise().then(t)}()):a()),this.speed>0?("adv"===d.type&&(u.innerHTML=""),function(){var t;t=document.createElement("div"),t.setAttribute("class","line"),u.appendChild(t),t.innerHTML=l+e,c.innerHTML=d.nameTemplate.replace(/\{name\}/g,s),d.interpreter.waitCounter+=1,i(t,{speed:d.speed,onFinish:function(){d.interpreter.waitCounter-=1}})}()):this.fadeDuration>0&&(d.interpreter.waitCounter+=1,setTimeout(function(){a(),"nvl"===d.type&&(u.innerHTML="
"+u.innerHTML+"
"),n(function(e){u.style.opacity=e},0,1,{duration:d.fadeDuration,onFinish:function(){d.interpreter.waitCounter-=1}})},d.fadeDuration)),this.bus.trigger("wse.assets.textbox.put",this,!1),d.interpreter.waitCounter-=1,{doNext:!1}},s.prototype.clear=function(){return document.getElementById(this.textElement).innerHTML="",document.getElementById(this.nameElement).innerHTML="",this.bus.trigger("wse.assets.textbox.clear",this),{doNext:!0}},s.prototype.save=function(){return{assetType:"Textbox",type:this.type,showNames:this.showNames,nltobr:this.nltobr,cssid:this.cssid,nameElement:this.nameElement,textElement:this.textElement,z:this.z}},s.prototype.restore=function(e){this.type=e.type,this.showNames=e.showNames,this.nltobr=e.nltobr,this.cssid=e.cssid,this.nameElement=e.nameElement,this.textElement=e.textElement,this.z=e.z,document.getElementById(this.cssid).style.zIndex=this.z},s}),MO5("WSE.tools","WSE.DisplayObject").define("WSE.assets.Background",function(e,t){"use strict";function n(e){e.element.setAttribute("width",e.stage.offsetWidth),e.element.setAttribute("height",e.stage.offsetHeight)}function i(e){var t=e.element.style;e.element.setAttribute("id",e.cssid),e.element.setAttribute("class","WSEBackground"),e.element.style.position="absolute",e.element.draggable=!1,t.left=0,t.top=0,t.opacity=0,t.zIndex=e.z}function r(r,s){t.call(this);var o=this;return this.asset=r,this.interpreter=s,this.bus=s.bus,this.stage=s.stage,this.z=r.getAttribute("z")||10,this.cssid="WSEBackground_"+this.id,this.element=document.createElement("img"),this.src=r.getAttribute("src"),this.name=r.getAttribute("name"),this.src?(e.applyAssetUnits(this,r),this.element.setAttribute("src",this.src),i(this),n(this),window.addEventListener("resize",function(){n(o)}),void this.stage.appendChild(this.element)):void this.bus.trigger("wse.interpreter.warning",{element:r,message:"No source defined on background asset."})}return r.prototype=new t,r.prototype.save=function(){return{cssid:this.cssid,z:this.z}},r.prototype.restore=function(e){this.cssid=e.cssid,this.z=e.z;try{this.element=document.getElementById(this.cssid)}catch(t){return void this.bus.trigger("wse.interpreter.warning",{message:"Element with CSS ID '"+this.cssid+"' could not be found."})}},r}),MO5("WSE.tools.ui","WSE.tools").define("WSE.commands.alert",function(e,t){function n(n,i){var r,s,o;return r=n.getAttribute("title")||"Alert!",s=n.getAttribute("message")||"Alert!",s=t.textToHtml(s),o="false"===n.getAttribute("next")?!1:!0,i.bus.trigger("wse.interpreter.commands.alert",n),e.alert(i,{title:r,message:s,pause:!0,doNext:o}),{doNext:!0}}return n}),MO5().define("WSE.commands.break",function(){"use strict";function e(e,t){return t.bus.trigger("wse.interpreter.commands.break",{interpreter:t,command:e},!1),{doNext:!1,wait:!0}}return e}),MO5("WSE.tools","WSE.DisplayObject").define("WSE.commands.choice",function(e,t){"use strict";function n(n,i){var r,s,o,a,u,c,l,d,h,p,f,m,g,y;for(i.bus.trigger("wse.interpreter.commands.choice",{interpreter:i,command:n},!1),g=i.state,i.state="pause",s=[],h=[],p=i,o=n.childNodes,a=o.length,l=n.getAttribute("duration")||500,l=parseInt(l,10),y=n.getAttribute("cssid")||"WSEChoiceMenu",m=function(e,t,n,r){return n=n||null,function(s){s.stopPropagation(),s.preventDefault(),setTimeout(function(){var t=e.childNodes?e.childNodes.length:0,s=i.index,o=i.sceneId,a=i.scenePath.slice(),u=i.currentScene;null!==n&&p.changeSceneNoNext(n),t>0&&(i.pushToCallStack(),i.currentCommands=e.childNodes,i.sceneId=o,i.scenePath=a,i.scenePath.push(s-1),i.scenePath.push(r),i.index=0,i.currentScene=u,i.currentElement=0),p.next()},0),p.stage.removeChild(t),i.waitCounter-=1,i.state=g}},1>a&&i.bus.trigger("wse.interpreter.warning",{element:n,message:"Element 'choice' is empty. Expected at least one 'option' element."}),r=document.createElement("div"),r.setAttribute("class","menu"),r.setAttribute("id",y),r.setAttribute("data-wse-index",i.index),r.setAttribute("data-wse-scene-id",i.sceneId),r.setAttribute("data-wse-game",i.game.url),r.setAttribute("data-wse-type","choice"),u=0;a>u;u+=1)c=o[u],c.tagName&&"option"===c.tagName&&i.checkIfvar(c)&&(d=document.createElement("input"),d.setAttribute("class","button"),d.setAttribute("type","button"),d.setAttribute("tabindex",u+1),d.setAttribute("value",c.getAttribute("label")),d.value=e.replaceVariables(c.getAttribute("label"),i),f=c.getAttribute("scene")||null,h[u]=f?i.getSceneById(f):null,e.attachEventListener(d,"click",m(c,r,h[u],u)),s.push(d),r.appendChild(d)); return r.style.opacity=0,i.stage.appendChild(r),t.prototype.show.call(void 0,n,{element:r,bus:i.bus,stage:i.stage,interpreter:i}),i.waitCounter+=1,{doNext:!1,wait:!0}}return n}),MO5("WSE.tools.ui").define("WSE.commands.confirm",function(e){return e.makeInputFn("confirm")}),MO5().define("WSE.commands.do",function(){"use strict";function e(e,t,n){var i,r,s,o=t.bus,a=t.assets;return n=n||{},o.trigger("wse.interpreter.commands.do",{interpreter:t,command:e},!1),i=e.getAttribute("asset"),r=e.getAttribute("action"),s=n.animation||!1,null===i?void o.trigger("wse.interpreter.warning",{element:e,message:"Element of type 'do' must have an attribute 'asset'. Element ignored."}):null===r?void o.trigger("wse.interpreter.warning",{element:e,message:"Element of type 'do' must have an attribute 'action'. Element ignored."}):"undefined"==typeof a[i]||null===a[i]?(o.trigger("wse.interpreter.warning",{element:e,message:"Reference to unknown asset '"+i+"'."}),{doNext:!0}):"undefined"==typeof a[i][r]?(o.trigger("wse.interpreter.warning",{element:e,message:"Action '"+r+"' is not defined for asset '"+i+"'."}),{doNext:!0}):a[i][r](e,n)}return e}),MO5("WSE.functions").define("WSE.commands.fn",function(e){"use strict";function t(t,n){var i,r,s;return i=t.getAttribute("name")||null,r=t.getAttribute("tovar")||null,"function"!=typeof e[i]?(n.bus.trigger("wse.interpreter.warning",{element:t,message:"No name supplied on fn element."}),{doNext:!0}):"function"!=typeof e[i]?(n.bus.trigger("wse.interpreter.warning",{element:t,message:"Unknown function '"+i+"'."}),{doNext:!0}):(s=e[i](n),null!==r&&(n.runVars[r]=""+s),{doNext:!0})}return t}),MO5().define("WSE.commands.global",function(){"use strict";function e(e,t){var n,i;return n=e.getAttribute("name")||null,i=e.getAttribute("value")||null,null===n?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"No name defined on element 'global'."}),{doNext:!0}):null===i?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"No value defined on element 'global'."}),{doNext:!0}):(t.globalVars.set(n,i),{doNext:!0})}return e}),MO5().define("WSE.commands.globalize",function(){"use strict";function e(e,t){var n;return n=e.getAttribute("name")||null,null===n?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"No variable name defined on globalize element."}),{doNext:!0}):"undefined"==typeof t.runVars[n]||null===t.runVars[n]?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"Undefined local variable."}),{doNext:!0}):(t.globalVars.set(n,t.runVars[n]),{doNext:!0})}return e}),MO5("WSE.tools").define("WSE.commands.goto",function(e){"use strict";function t(t,n){var i,r,s=n.bus;return s.trigger("wse.interpreter.commands.goto",{interpreter:n,command:t},!1),r=t.getAttribute("scene"),null===r&&s.trigger("wse.interpreter.error",{message:"Element 'goto' misses attribute 'scene'."}),r=e.replaceVariables(r,n),i=n.getSceneById(r),null===i?void s.trigger("wse.interpreter.error",{message:"Unknown scene '"+r+"'."}):{changeScene:i}}return t}),MO5("WSE.tools").define("WSE.commands.line",function(e){"use strict";function t(t,n){var i,r,s,o,a,u,c,l,d,h=n.bus;if(h.trigger("wse.interpreter.commands.line",{interpreter:n,command:t},!1),i=t.getAttribute("s"),d="false"===t.getAttribute("stop")?!0:!1,null===i)return h.trigger("wse.interpreter.warning",{element:t,message:"Element 'line' requires attribute 's'."}),{doNext:!0};for(c=n.story.getElementsByTagName("character"),a=c.length,o=0;a>o;o+=1)if(u=c[o],u.getAttribute("name")===i){if(s=u.getAttribute("textbox"),"undefined"==typeof s||null===s)return h.trigger("wse.interpreter.warning",{element:t,message:"No textbox defined for character '"+i+"'."}),{doNext:!0};try{r=e.getSerializedNodes(u.getElementsByTagName("displayname")[0])}catch(p){}break}return"undefined"==typeof n.assets[s]?(h.trigger("wse.interpreter.warning",{element:t,message:"Trying to use an unknown textbox or character."}),{doNext:!0}):(l=e.getSerializedNodes(t),n.log.push({speaker:i,text:l}),n.assets[s].put(l,r,i),{doNext:d,wait:!0})}return t}),MO5().define("WSE.commands.localize",function(){"use strict";function e(e,t){var n;return n=e.getAttribute("name")||null,null===n?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"No variable name defined on localize element."}),{doNext:!0}):t.globalVars.has(n)?(t.runVars[n]=t.globalVars.get(n),{doNext:!0}):(t.bus.trigger("wse.interpreter.warning",{element:e,message:"Undefined global variable."}),{doNext:!0})}return e}),MO5("WSE.tools.ui").define("WSE.commands.prompt",function(e){return e.makeInputFn("prompt")}),MO5().define("WSE.commands.restart",function(){"use strict";function e(e,t){for(t.bus.trigger("wse.interpreter.commands.restart",{interpreter:t,command:e},!1),t.bus.trigger("wse.interpreter.message","Restarting game...",!1),t.bus.trigger("wse.interpreter.restart",t,!1),t.runVars={},t.log=[],t.visitedScenes=[],t.startTime=Math.round(+new Date/1e3),t.waitCounter=0,t.state="listen",t.stage.innerHTML="",t.assets={},t.buildAssets();t.callStack.length>0;)t.callStack.shift();return{doNext:!0,changeScene:t.getFirstScene()}}return e}),MO5("WSE.tools","WSE.commands.set_vars").define("WSE.commands.sub",function(e,t){"use strict";function n(n,i){var r,s,o;return i.bus.trigger("wse.interpreter.commands.sub",{interpreter:i,command:n},!1),r=n.getAttribute("scene")||null,o=n.getAttribute("next")===!1?!1:!0,null===r?(i.bus.trigger("wse.interpreter.warning",{element:n,message:"Missing 'scene' attribute on 'sub' command!"}),{doNext:!0}):(r=e.replaceVariables(r,i),(s=i.getSceneById(r))?(i.bus.trigger("wse.interpreter.message","Entering sub scene '"+r+"'...",!1),i.pushToCallStack(),i.currentCommands=s.childNodes,i.index=-1,i.sceneId=r,i.scenePath=[],i.currentElement=-1,n.getAttribute("names")&&t(n,i),{doNext:o}):(i.bus.trigger("wse.interpreter.error",{message:"No such scene '"+r+"'!",command:n}),{doNext:!0}))}return n}),MO5().define("WSE.commands.trigger",function(){"use strict";function e(e,t){var n,i;return t.bus.trigger("wse.interpreter.commands.trigger",{interpreter:t,command:e},!1),n=e.getAttribute("name")||null,i=e.getAttribute("action")||null,null===n?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"No name specified on trigger command."}),{doNext:!0}):null===i?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"No action specified on trigger command referencing trigger '"+n+"'."}),{doNext:!0}):"undefined"==typeof t.triggers[n]||null===t.triggers[n]?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"Reference to unknown trigger '"+n+"'."}),{doNext:!0}):"function"!=typeof t.triggers[n][i]?(t.bus.trigger("wse.interpreter.warning",{element:e,message:"Unknown action '"+i+"' on trigger command referencing trigger '"+n+"'."}),{doNext:!0}):(t.triggers[n][i](e),{doNext:!0})}return e}),MO5("WSE.tools").define("WSE.commands.var",function(e){"use strict";function t(t,n){var i,r,s,o,a;if(n.bus.trigger("wse.interpreter.commands.var",{interpreter:n,command:t},!1),i=t.getAttribute("name")||null,r=t.getAttribute("value")||"1",o=t.getAttribute("action")||"set",null===i)return n.bus.trigger("wse.interpreter.warning",{element:t,message:"Command 'var' must have a 'name' attribute."}),{doNext:!0};if(a=n.runVars,"set"!==o&&!(i in a||t.getAttribute("lvalue")))return n.bus.trigger("wse.interpreter.warning",{element:t,message:"Undefined variable."}),{doNext:!0};if(r=e.replaceVariables(r,n),"set"===o)return a[i]=""+r,{doNext:!0};switch(s=t.getAttribute("lvalue")||a[i],s=e.replaceVariables(s,n),o){case"delete":delete a[i];break;case"increase":a[i]=""+(parseFloat(s)+parseFloat(r));break;case"decrease":a[i]=""+(parseFloat(s)-parseFloat(r));break;case"multiply":a[i]=""+parseFloat(s)*parseFloat(r);break;case"divide":a[i]=""+parseFloat(s)/parseFloat(r);break;case"modulus":a[i]=""+parseFloat(s)%parseFloat(r);break;case"and":a[i]=""+(parseFloat(s)&&parseFloat(r));break;case"or":a[i]=""+(parseFloat(s)||parseFloat(r));break;case"not":a[i]=parseFloat(s)?"0":"1";break;case"is_greater":a[i]=parseFloat(s)>parseFloat(r)?"1":"0";break;case"is_less":a[i]=parseFloat(s)=parseFloat(r)?"1":"0";break;case"not_equal":a[i]=parseFloat(s)!==parseFloat(r)?"1":"0";break;case"print":n.bus.trigger("wse.interpreter.message","Variable '"+i+"' is: "+a[i]);break;default:n.bus.trigger("wse.interpreter.warning",{element:t,message:"Unknown action '"+o+"' defined on 'var' command."})}return{doNext:!0}}return t}),MO5().define("WSE.commands.set_vars",function(){"use strict";function e(e,t){var n,i,r=t.runVars;return n=(e.getAttribute("names")||"").split(","),i=(e.getAttribute("values")||"").split(","),n.length!==i.length?(t.bus.trigger("wse.interpreter.error",{message:"Number of names does not match number of values in command."}),{doNext:!0}):(n.forEach(function(e,t){r[e.trim()]=""+i[t].trim()}),{doNext:!0})}return e}),MO5().define("WSE.commands.wait",function(){"use strict";function e(e,t){var n,i;return t.bus.trigger("wse.interpreter.commands.wait",{interpreter:t,command:e},!1),i=t,n=e.getAttribute("duration"),null!==n?(n=parseInt(n,10),t.waitForTimer=!0,setTimeout(function(){i.waitForTimer=!1},n),{doNext:!0,wait:!1}):{doNext:!0,wait:!0}}return e}),MO5("WSE.tools").define("WSE.commands.with",function(e){"use strict";function t(t,n){var i,r,s=n.runVars,o=t.childNodes,a=e.getParsedAttribute(t,"var",n),u=o.length;for(i=0;u>i;i+=1)if(r=o[i],r.tagName&&n.checkIfvar(r)&&("when"===r.tagName||"else"===r.tagName)&&("when"!==r.tagName||r.hasAttribute("is")||n.bus.trigger("wse.interpreter.warning",{message:"Element 'when' without a condition. Ignored.",command:t}),"else"===r.tagName&&r.hasAttribute("is")&&n.bus.trigger("wse.interpreter.warning",{message:"Element 'else' with a condition. Ignored.",command:t}),"else"===r.tagName||"when"===r.tagName&&r.hasAttribute("is")&&e.getParsedAttribute(r,"is")===s[a])){n.pushToCallStack(),n.currentCommands=r.childNodes,n.scenePath.push(n.index),n.scenePath.push(i),n.index=-1,n.currentElement=-1;break}return{doNext:!0}}return t}),MO5().define("WSE.commands.while",function(){"use strict";function e(e,t){return t.index-=1,t.currentElement-=1,t.pushToCallStack(),t.currentCommands=e.childNodes,t.scenePath.push(t.index+1),t.index=-1,t.currentElement=-1,{doNext:!0}}return e}); \ No newline at end of file diff --git a/js/WSE.js b/js/WSE.js index f94c710..fdc7def 100644 --- a/js/WSE.js +++ b/js/WSE.js @@ -5,7 +5,7 @@ define("WSE", function (EventBus, assets, commands, dataSources, functions) { "use strict"; - var WSE = {}, version = "2015.10.1-final.1510032031"; + var WSE = {}, version = "2015.10.2-final.1510051136"; EventBus.inject(WSE);