/**
* visual-novel - v0.0.4 - build 2015-11-28 13:11:37
* Copyright (c) 2014-2015 Selcher;
* Distributed under the terms of the MIT license.
*/
!function(a){function b(a,c,d,e){return this instanceof b?(this.novelId=a,this.novelMode="dialog",this.imgPath=e?e:"",this.images=[],this.novelContainerId=null,this.defaultVal={},this.screenWidth=c,this.screenHeight=d,this.sceneFloorHeight=this.sceneFloorWidth=d>c?d:c,this):new b(c,d,e)}b.prototype.modules=[],b.prototype.init=function(a){var b=this.novelId;this.initNovelContainer(b),this.initModules(b),a&&setTimeout(a)},b.prototype.reset=function(){function a(){this.resetModules(),this.showStartScreen(!0)}this.createEvent("wait",a.bind(this))},b.prototype.initModules=function(a){for(var b=this.modules,c=b.length;c--;)b[c].init.call(this,a)},b.prototype.resetModules=function(){for(var a=this.modules,b=a.length;b--;)a[b].reset.call(this)},b.prototype.initNovelContainer=function(a){this.novelContainerId=document.getElementById(a);var b=this.buildNovelContainerContent(a);this.setNovelContainerContent(b)},b.prototype.attachToNovelContainer=function(a){var b=document.createElement("div");b.innerHTML=a;var c=b.firstChild;return this.novelContainerId.firstChild.appendChild(c),c},b.prototype.novelContainerTemplate="
",b.prototype.buildNovelContainerContent=function(a){var b="";return this.parser?b=this.parser.parseTemplate(this.novelContainerTemplate,{novelId:a,width:this.screenWidth,height:this.screenHeight}):this.log("[core]VisualNovelJS Error: parser module not found"),b},b.prototype.setNovelContainerContent=function(a){this.novelContainerId.innerHTML=a},b.prototype.log=function(a){console&&console.log&&console.log(a)},a.VisualNovel=b}(window),function(a){function b(a){return this.novelId=a,this.menuChoicesTaken={},this.menuChoices={},this.dialogMenuId=null,this.dialogMenuChoiceContainerId=null,this}a.prototype.choice=function(a,b,c){function d(){e.menuChoicesDialog.setMenuChoicesDisplay(!0),e.menuChoicesDialog.menuChoices[a]=b.slice(),e.menuChoicesDialog.setMenuChoices(h),e.menuChoicesDialog.updateMenuChoicesReference(),e.menuChoicesDialog.addMenuChoicesHandler(a,b,function(){e.resetMenuChoicesForEvent(a),e.eventTracker.startEvent()}),f&&e.menuChoicesDialog.setMenuChoicesPosition(i.x,i.y),e.eventTracker.addNewEventInProgress(a)}var e=this,f=(b.length,c.pos),g=c.img,h=this.buildMenuChoices(b,g),i=this.util.scalePosition({x:f.x,y:f.y},{x:this.screenWidth,y:this.screenHeight});this.createEvent("wait",d)},a.prototype.buildMenuChoices=function(a,b){var c=this.getMenuChoicesTemplate(a,{path:b?this.imgPath+b.image:"",width:b?b.width:0,height:b?b.height:0});return c},a.prototype.menuChoiceTemplate=[""].join(""),a.prototype.getMenuChoicesTemplate=function(a,b){var c="";if(this.parser){var d={novelId:this.novelId,choices:a,imgPath:b.path,imgWidth:b.width,imgHeight:b.height};c=this.parser.parseTemplate(this.menuChoiceTemplate,d)}else this.log("[dialog-choice]VisualNovelJS Error: parser module not found");return c},a.prototype.resetMenuChoicesForEvent=function(a){function b(){c.menuChoicesDialog.resetMenuChoicesForEvent(a)}var c=this;this.createEvent("nowait",b)},a.prototype.modules.push({init:function(a){this.menuChoicesDialog=new b(a);var c=this.parser.parseTemplate("",{novelId:a,width:this.screenWidth,height:this.screenHeight}),d=this.attachToNovelContainer(c);this.menuChoicesDialog.init(d)},reset:function(){this.menuChoicesDialog.resetMenuChoices()}}),b.prototype.init=function(a){this.dialogMenuId=a,this.hideDialogMenuContainer()},b.prototype.hideDialogMenuContainer=function(){this.dialogMenuId.style.display="none"},b.prototype.setMenuChoices=function(a){this.dialogMenuId.innerHTML=a},b.prototype.updateMenuChoicesReference=function(){this.dialogMenuChoiceContainerId=document.getElementById(this.novelId+"-dialogMenuChoiceContainer")},b.prototype.addMenuChoicesHandler=function(a,b,c){for(var d=this,e=document,f=this.novelId,g=function(b){var e=b;return function(){d.hideDialogMenuContainer(),d.performMenuChoice(a,e),c()}},h=b.length;h--;)e.getElementById(f+"-dialogMenuChoiceButton"+h).onclick=g(h)},b.prototype.performMenuChoice=function(a,b){var c=this.menuChoices[a][b];this.menuChoicesTaken[a]=c;var d=c.action;d()},b.prototype.resetMenuChoicesForEvent=function(a){this.menuChoices[a]=[]},b.prototype.resetMenuChoices=function(){this.menuChoices={},this.menuChoicesTaken={}},b.prototype.setMenuChoicesDisplay=function(a){this.dialogMenuId.style.display=a?"block":"none"},b.prototype.setMenuChoicesPosition=function(a,b){this.dialogMenuChoiceContainerId.style.cssText+=";left:"+a+"px;top:"+b+"px;"}}(window.VisualNovel=window.VisualNovel||{}),function(a){function b(a){this.novelId=a}a.prototype.userInput={},a.prototype.input=function(a,b){function c(){var c=d.getUserInputTemplate(b);d.inputDialog.input(a,c,function(){var b=d.inputDialog.getInput();d.setInput(a,b),d.inputDialog.setInputDialogDisplay(!1),d.eventTracker.nextEvent()})}var d=this;this.eventTracker.addEvent("wait",c)},a.prototype.userInputTemplate=[""].join(""),a.prototype.getUserInputTemplate=function(a){var b={novelId:this.novelId,message:a},c="";return this.parser?c=this.parser.parseTemplate(this.userInputTemplate,b):this.log("[dialog-input]VisualNovelJS Error: parser module not found"),c},a.prototype.setInput=function(a,b){a&&(this.userInput[a]=b)},a.prototype.setValue=function(a,b){function c(){d.setInput(a,b)}var d=this;this.eventTracker.addEvent("nowait",c)},a.prototype.getValue=function(a){return this.userInput[a]},a.prototype.modules.push({init:function(a){this.inputDialog=new b(a);var c=this.parser.parseTemplate("",{novelId:a,width:this.screenWidth,height:this.screenHeight}),d=this.attachToNovelContainer(c);this.inputDialog.init(d)},reset:function(){}}),b.prototype.init=function(a){this.novelId;this.inputDialogId=a,this.setInputDialogDisplay(!1)},b.prototype.input=function(a,b,c){this.setInputDialogDisplay(!0),this.setUserInputContainer(b),this.updateUserInputReference(),this.userInputButtonId.onclick=function(){c()}},b.prototype.setInputDialogDisplay=function(a){this.inputDialogId.style.display=a?"block":"none"},b.prototype.setUserInputContainer=function(a){this.inputDialogId.innerHTML=a},b.prototype.updateUserInputReference=function(){var a=this.novelId,b=document;this.userInputTextId=b.getElementById(a+"-userInputText"),this.userInputButtonId=b.getElementById(a+"-userInputButton")},b.prototype.getInput=function(){var a=this.userInputTextId;return a?a.value:""}}(window.VisualNovel=window.VisualNovel||{}),function(a){function b(a,c,d,e,f){return this instanceof b?(this.novelId=a,this.novelMode="dialog",this.novelModeId=null,this.dialogModeId=null,this.dialogButtonId=null,this.dialogImageId=null,this.dialogTextId=null,this.dialogWidth=c,this.dialogHeight=d,this.x=e,this.y=f,this.dialogPadding={top:10,right:10,bottom:10,left:10},this.dialogBorder={top:10,right:50,bottom:10,left:50},this.dialogTextColor="white",this.dialogBgColor="rgba(0,0,0,0.5)",this.dialogBgImage="",this.dialogBgImageWidth=0,this.dialogBgImageHeight=0,this.dialogButtonSize={width:40,height:30},this.dialogButtonPos={left:c-this.dialogPadding.right-this.dialogButtonSize.width,bottom:0},this.dialogCharacter=null,this.timers={text:null},this):new b}a.prototype.setDialogBgImage=function(a,b,c){this.dialog.setDialogBgImage(this.imgPath+a,b,c)},a.prototype.setDialogBgColor=function(a){this.dialog.setDialogBgColor(a)},a.prototype.setDialogTextColor=function(a){this.dialog.setDialogTextColor(a)},a.prototype.setDialogBorderStyle=function(a,b,c,d){this.dialog.setDialogBorderStyle(this.imgPath+a,b,c,d)},a.prototype.updateDialogBorderStyle=function(a,b,c,d){function e(){f.dialog.setDialogBorderStyle(g,b,c,d)}var f=this,g=this.imgPath+a;this.eventTracker.addEvent("nowait",e)},a.prototype.setNovelMode=function(a,b,c,d,e){function f(){g.dialog.setNovelMode(a,b,c,h.x,h.y)}var g=this,h=this.util.scalePosition({x:d?d:0,y:e?e:g.sceneHeight},{x:g.screenWidth,y:g.screenHeight});this.eventTracker.addEvent("nowait",f)},a.prototype.buildSayDialog=function(a,b,c,d){var e=this.getSayTemplate(a,b,c);this.dialog.setSayDialogContainer(e,d)},a.prototype.sayTemplate=["","{name}
","{dialogLine}
","",""].join(""),a.prototype.getSayTemplate=function(a,b,c){var d=this.getSayTemplateVariables(a,b,c),e="";return this.parser?e=this.parser.parseTemplate(this.sayTemplate,d):this.log("[dialog]VisualNovelJS Error: parser module not found"),e},a.prototype.getSayTemplateVariables=function(a,b,c){var d="object"==typeof a,e=d?a.name:a,f=d?a.nameStyle:"",g=this.parser.replaceVariablesInText(b,this.userInput),h=a.dialog,i=h?!0:!1,j="",k="",l="",m="",n="",o=c?!1:!0,p="OK",q=!1,r="",s="",t="";if(i){j=h.image?this.imgPath+h.image:"",k=h.width?"width:"+h.width+"px;":"",l=h.height?"height:"+h.height+"px;":"",m=h.location?"float:"+h.location+";":"",n=m?"left"===m?"margin-right:10px;":"margin-left:10px;":"";var u=h.button;q=c?!1:u&&u.image?u.image:!1,r=q?this.imgPath+u.image:"",s=q?"width:"+u.width+"px;":"",t=q?"height:"+u.height+"px;":"",o=c||q?!1:u&&u.text?u.text:!0,p=u&&u.text?u.text:"OK"}var v={novelId:this.novelId,name:e,dialogNameStyle:f,dialogLine:g,showDialogImage:i,dialogImage:j,dialogImageStyle:m+k+l+n,showButtonText:o,dialogButtonText:p,showButtonImage:q,dialogButtonImage:r,dialogButtonImageStyle:s+t};return v},a.prototype.showSayDialog=function(a){function b(){c.dialog.setSayDialogDisplay(a,c.novelMode)}var c=this;this.eventTracker.addEvent("nowait",b)},a.prototype.addCondition=function(a,b,c,d,e){function f(){var b=g.userInput,f=i?i(b[a],c):!1,h=g.eventTracker,j=h.eventsInProgress.length,k=h.eventsInProgress[j-1]+"-condition-"+j;h.addNewEventInProgress(k),f?d():e(),h.startEvent()}var g=this,h={"=":function(a,b){return a===b},">":function(a,b){return a>b},"<":function(a,b){return b>a},"!=":function(a,b){return a!=b}},i=h[b];this.eventTracker.addEvent("wait",f)},a.prototype.sayLine=function(a,b,c){function d(){var d=e.novelMode;if(e.dialog.setSayDialogDisplay(!0,d),e.buildSayDialog(a,j?"":b,i,d),e.dialog.updateSayDialogReference(),k&&e.dialog.updateDialogButton(h,f,function(){e.eventTracker.nextEvent()}),j){var g=e.parser.replaceVariablesInText(b,e.userInput);e.dialog.showTextByChar(g,0,c.interval)}}var e=this,f=this.imgPath,g="object"==typeof a,h=g&&a.dialog?a.dialog:null,i=(h&&h.button?h.button:null,c),j="object"==typeof c,k="undefined"==typeof c;j&&(i=c.interval*b.length+(c.delay?c.delay:0),c.button&&(i=0,k=!0)),this.eventTracker.addEvent(i?"nowait":"wait",d,i)},a.prototype.sayLineExtend=function(a,b){function c(){d.dialog.setSayDialogText(a,!0)}var d=this;this.eventTracker.addEvent(b?"nowait":"wait",c,b)},a.prototype.sayMultipleLines=function(a,b){var c=this.util,d=b.length,e=[],f=[],g=null;c.foreach(b,function(a,c){"string"==typeof a&&(f.push(a),g=c+1,d>g&&"number"==typeof b[g]&&f.push(b[g]),d>g&&"boolean"==typeof b[g]?f.push(0,b[g]):d>g+1&&"boolean"==typeof b[g+1]&&f.push(b[g+1]),d>g&&"object"==typeof b[g]&&f.push(b[g]),e.push(f)),f=[]}),c.foreach(e,function(b){if("boolean"==typeof b[b.length-1])if(0===b[1]){var c=f.join("")+b[0];f=[],this.sayLine(a,c)}else f.push(b[0]),this.sayLineExtend.apply(this,b);else"object"==typeof b[1]?this.sayLine(a,b[0],b[1]):(b[1]?f.push(b[0]):f=[],b.unshift(a),this.sayLine.apply(this,b))}.bind(this))},a.prototype.say=function(a,b,c){var d=arguments.length,e="object"==typeof a,f="string"==typeof a,g=e||f;g&&"string"==typeof b&&(this.dialogCharacter=a,this.sayLine(a,b,c)),g&&this.util.isArray(b)&&(this.dialogCharacter=a,this.sayMultipleLines(a,b)),f&&(1===d||2===d&&"number"==typeof b)&&this.sayLine(this.dialogCharacter,a,b)},a.prototype.modules.push({init:function(a){var c=this.dialog=new b(a,this.screenWidth,150,0,this.screenHeight-150),d=this.parser.parseTemplate("",{novelId:a,width:this.screenWidth,height:this.screenHeight}),e=this.attachToNovelContainer(d);d=this.parser.parseTemplate("",{novelId:a,width:this.screenWidth,height:this.screenHeight});var f=this.attachToNovelContainer(d);c.init(e,f)},reset:function(){}}),b.prototype.init=function(a,b){this.novelId;this.novelModeId=a,this.hideNovelModeContainer(),this.dialogModeId=b,this.setSayDialogDisplay(!1),this.setDialogModeContainerSize(this.dialogWidth,this.dialogHeight),this.setDialogModeContainerPosition(this.x,this.y),this.setDialogTextColor(this.dialogTextColor),this.setDialogBgColor(this.dialogBgColor)},b.prototype.hideNovelModeContainer=function(){this.novelModeId.style.display="none"},b.prototype.setDialogModeContainerSize=function(a,b){var c=this.calculateDialogModeContainerSize(a,b),d=";width:"+c.width+";height:"+c.height+";";this.dialogModeId.style.cssText+=d,this.dialogWidth=a,this.dialogHeight=b},b.prototype.calculateDialogModeContainerSize=function(a,b){var c=this.dialogPadding,d=a?a:this.dialogWidth,e=b?b:this.dialogHeight,f={width:d-c.left-c.right+"px",height:e-c.top-c.bottom+"px"};return f},b.prototype.setDialogModeContainerPosition=function(a,b){var c=";left:"+a+"px;top:"+b+"px;";this.dialogModeId.style.cssText+=c},b.prototype.setDialogBgImage=function(a,b,c){var d=a?";background-image:url('"+a+"');":";",e=b&&c?"width:"+b+"px;height: "+c+"px;":"",f=d+e;this.dialogModeId.style.cssText+=f},b.prototype.setDialogBgColor=function(a){this.dialogModeId.style["background-color"]=a?a:"black"},b.prototype.setDialogTextColor=function(a){this.dialogModeId.style.color=a?a:"white"},b.prototype.setDialogBorderStyle=function(a,b,c,d){var e=(this.dialogPadding,c?"string"==typeof c?c:c+"px":"");e=""===e?";":";border-width:"+e+";";var f="border-style:solid;",g=b?b:"rgba( 0, 0, 0, 0.5 )";g="border-color:"+g+";";var h=d?"string"==typeof d?d:d+"px":"";h=""===h?"":"border-radius:"+h+";";var i=e+f+g+h;this.dialogModeId.style.cssText+=i,this.setDialogModeContainerSize(this.dialogWidth,this.dialogHeight)},b.prototype.setDialogButtonPosition=function(a,b){var c=this.dialogButtonPos;"undefined"!=typeof a&&(c.left=a),"undefined"!=typeof b&&(c.bottom=b)},b.prototype.refreshDialogButtonPositionView=function(){var a=this.dialogButtonPos,b=";left:"+a.left+"px;bottom:"+a.bottom+"px;";this.dialogButtonId.style.cssText+=b},b.prototype.clearDialogImageAnimation=function(a,b){var c=function(){},d=null,e=a&&a.image?b+a.image:"",f=a&&a.nextImage?b+a.nextImage:"",g=a&&a.imageDelay?a.imageDelay:5e3;if(a&&a.nextImage){var h=this.dialogImageId;d=setInterval(function(){requestAnimationFrame(function(){h.setAttribute("src",f)}),setTimeout(function(){requestAnimationFrame(function(){h.setAttribute("src",e)})},200)},g),c=function(){window.clearInterval(d)}}return c},b.prototype.updateDialogButtonListeners=function(a,b,c){var d=this.dialogButtonId,e=a&&a.bgColor&&a.bgColorHover,f=a&&a.bgColorHover?a.bgColorHover:"transparent",g=e?function(){d.style["background-color"]=f}:function(){},h=a&&a.bgColor?a.bgColor:"transparent",i=e?function(){d.style["background-color"]=h}:function(){},j=a&&a.image&&a.imageHover,k=a&&a.imageHover?b+a.imageHover:"",l=j?function(){d.setAttribute("src",k)}:function(){},m=a&&a.image?b+a.image:"",n=j?function(){d.setAttribute("src",m)}:function(){};d.onmouseover=function(){g(),l()},d.onmouseleave=function(){i(),n()},d.onclick=function(){c()}},b.prototype.setNovelMode=function(a,b,c,d,e){var f="undefined"!=typeof b&&"undefined"!=typeof c,g="undefined"!=typeof d&&"undefined"!=typeof e;self.novelMode=a?a:"dialog",f&&(this.setDialogModeContainerSize(b,c),this.setDialogButtonPosition(b-this.dialogPadding.right-this.dialogButtonSize.width)),g&&this.setDialogModeContainerPosition(d,e)},b.prototype.setSayDialogContainer=function(a,b){var c=b?b:this.novelMode,d="novel"===c?"novelModeId":"dialogModeId";this[d].innerHTML=a},b.prototype.setSayDialogText=function(a,b){this.dialogTextId.innerHTML=b?this.dialogTextId.innerHTML+a:a},b.prototype.updateSayDialogReference=function(){var a=this.novelId,b=document;this.dialogImageId=b.getElementById(a+"-dialog-dialogImage"),this.dialogTextId=b.getElementById(a+"-dialog-dialogText")},b.prototype.updateSayDialogButtonReference=function(){this.dialogButtonId=document.getElementById(this.novelId+"-dialog-dialogButton")},b.prototype.setSayDialogDisplay=function(a,b){var c=b?b:this.novelMode,d=a?"block":"none";"dialog"===c?(this.dialogModeId.style.display=d,this.novelModeId.style.display="none"):"novel"===c&&(this.dialogModeId.style.display="none",this.novelModeId.style.display=d)},b.prototype.resetNovelDialogText=function(){this.novelModeId.innerHTML="",this.dialogModeId.innerHTML=""},b.prototype.showTextByChar=function(a,b,c){b0){var d=b,g=function(){c(),d--,h()},h=function(){e.timers[a].timer=d?setTimeout(g,f):null};e.timers[a]={type:"timeout",timer:null},h()}else c()};this.eventTracker.addEvent("nowait",g)}},a.prototype.clearLoop=function(a){function b(){c.clearTimer(a)}var c=this;this.eventTracker.addEvent("nowait",b)},a.prototype.clearTimer=function(a){var b=this.timers[a];b&&("timeout"===b.type?clearTimeout(b.timer):"interval"===b.type&&clearInterval(b.timer),this.timers[a]=null)},a.prototype.resetLoops=function(){var a=this.timers,b=null;for(var c in a)b=a[c]?a[c].type:null,!b||"timeout"!==b&&"interval"!==b||this.clearTimer(c)},a.prototype.modules.push({init:function(){},reset:function(){this.resetLoops()}})}(window.VisualNovel=window.VisualNovel||{}),function(a){function b(){var a=null;return a=this instanceof b?this:new b}b.prototype.foreach=function(a,b,c){for(var d=a.length;d--;)c?b.call(c,a[d],d):b(a[d],d)},b.prototype.replaceVariablesInText=function(a,b){var c=a+"",d="",e="",f=null;for(d in b)e=b[d],f=new RegExp("{"+d+"}","gi"),c=c.replace(f,e);return c},b.prototype.parseTemplate=function(a,b){return a=this.parseConditionsInTemplate(a,b),a=this.replaceVariablesInText(a,b),a=this.parseLoopsInTemplate(a,b)},b.prototype.parseConditionsInTemplate=function(a,b){var c=a.slice(),d=[],e=c.split(/(<\s*if\s*[^>]*>(.|\n)*?<\s*\/\s*if>)/i);return this.foreach(e,function(a){""!==a&&">"!==a&&d.unshift(a)}),d.length>1&&this.foreach(d,function(a,c){var e=a.replace(/.*<\/if>/i,"$1"),f=b[e],g=void 0===f?e:f?a.replace(/(.*)<\/if>/i,"$1"):"";d[c]=g.slice()},this),c=d.join("")},b.prototype.parseLoopsInTemplate=function(a,b){var c=a.slice(),d=c.match(/.*<\/foreach>/gi);if(d&&d.length>0){var e=[];this.foreach(d,function(a){var c=[],d=a.replace(/(.*)<\/foreach>/gi,"$1"),f=a.replace(/.*<\/foreach>/gi,"$1");f=f.split(" ");var g=f[2],h=f[0];this.foreach(b[g],function(a,b){var e=d.replace(/{index}/gi,b),f=new RegExp("{"+h+".(.*)}","gi");e=e.replace(f,"{$1}"),e=this.replaceVariablesInText(e,a),c.unshift(e)},this),e.push(c.join(""))},this),this.foreach(e,function(a){c=c.replace(/.*<\/foreach>/i,a)})}return c},a.prototype.parser=new b}(window.VisualNovel=window.VisualNovel||{}),function(a){a.prototype.createSceneContainer=function(a,b,c){var d=this.objectFactory,e=d("SpriteContainer",a),f=e.children[0],g=d("SceneFloor",b,c),h=d("SceneFloorContainer");h.addChild(g.sprite),f.addChild(h);var i={floorContainer:h,floor:g};return i},a.prototype.rotateScene=function(a,b,c,d){function e(){f.sceneFloor.rotate(a,b,c,d)}var f=this;this.eventTracker.addEvent("nowait",e)},a.prototype.moveScene=function(a,b,c,d){function e(){f.sceneFloor.move(a,b,c,d)}var f=this;this.eventTracker.addEvent("nowait",e)},a.prototype.modules.push({init:function(a){var b=this.parser.parseTemplate("",{novelId:a,width:this.screenWidth,height:this.screenHeight}),c=(this.screenSceneId=this.attachToNovelContainer(b),this.createSceneContainer(this.screenSceneId,this.sceneFloorWidth,this.sceneFloorHeight));this.sceneContainer=c.floorContainer,this.sceneFloor=c.floor},reset:function(){var a=this.sceneContainer?this.sceneContainer.children:[],b=a.length;if(b>1)for(var c=b-1;c--;)this.sceneContainer.removeChildAt(c+1)}})}(window.VisualNovel=window.VisualNovel||{}),function(a){a.prototype.screenCharacterId=null,a.prototype.characterContainer=null,a.prototype.characters=[],a.prototype.addCharacter=function(a,c,d){function e(){h.screenCharacterId.style.display="block";var c=a.width,d=a.height,e=c/2,f=h.screenHeight-d+h.screenHeight*a.pos.y,g=h.screenWidth*a.pos.x,i={x:Math.floor(g),y:Math.floor(f),z:0},j={x:e,y:0,z:0},k=b(h);return k=k(c,d,i,j),k.setBackground(c,d,h.getCharacterImage(a)),k.name=a.name,k}function f(a){h.characterContainer.addChild(a.sprite),h.characters.push(a)}function g(){var a=e();d&&a.fadeIn(c),f(a)}var h=this;this.eventTracker.addEvent("nowait",g,c)},a.prototype.getCharacter=function(a){var b=this.util.getObjectInList(this.characters,"name",a);return b.obj},a.prototype.getCharacterImage=function(a,b){var c=this.imgPath,d=a&&a.image?a.image:null;return d&&"object"==typeof d?(d=b?d[b]:d["default"],d="object"==typeof d?{src:c+d.src,position:d.position}:c+d):d&&(d=c+d),d},a.prototype.changeCharacterImage=function(a,b){function c(){d.setCharacterImage(a,b)}var d=this;this.eventTracker.addEvent("nowait",c)},a.prototype.setCharacterImage=function(a,b){var c=this.getCharacter(a.name),d=this.getCharacterImage(a,b);requestAnimationFrame("object"==typeof d?function(){c.sprite.setCSS("background-position",d.position),c.sprite.setCSS("background-image","url('"+d.src+"')")}:function(){c.sprite.setCSS("background-image","url('"+d+"')")})},a.prototype.removeCharacter=function(a,b,c){function d(){var b=f.util.getObjectInList(f.characters,"name",a.name),c=b.id;f.characterContainer.removeChildAt(c+1),f.characters.splice(c,1)}function e(){if(c){var e=f.getCharacter(a.name);e.fadeOut(b)}f.eventTracker.delayCallback(b,d)}var f=this;this.eventTracker.addEvent("nowait",e,b)},a.prototype.removeAllCharacter=function(a){function b(){d.resetCharacters()}function c(){d.eventTracker.delayCallback(a,b)}var d=this;this.eventTracker.addEvent("nowait",c,a)},a.prototype.resetCharacters=function(){for(var a=this.characterContainer?this.characterContainer.children:[],b=a.length,c=b-1;c>=1;c--)this.characterContainer.removeChildAt(c);this.characters=[]},a.prototype.moveCharacter=function(a,b,c,d){function e(){var e=f.getCharacter(a.name),g=e.sprite,h={x:"undefined"!=typeof b?b>1||-1>b?b:b*f.screenWidth:g.x,y:"undefined"!=typeof c?c>1||-1>c?c:c*f.screenHeight:g.y};d?e.move(h.x,h.y,0,d):requestAnimationFrame(function(){g.x=h.x,g.y=h.y,g.update()})}var f=this;this.eventTracker.addEvent("nowait",e)},a.prototype.fadeCharacter=function(a,b,c,d,e){function f(){var f=g.getCharacter(a.name);"in"==b?f.fadeIn(c,d,e):"out"==b&&f.fadeOut(c,d,e)}var g=this;this.eventTracker.addEvent("nowait",f)},a.prototype.flipCharacter=function(a){function b(){var b=c.getCharacter(a.name),d=b.sprite,e=d.scaleX>0?-1:1;d.setScaleX(e).update()}var c=this;this.eventTracker.addEvent("nowait",b)},a.prototype.modules.push({init:function(a){var b=this.parser.parseTemplate("",{novelId:a,width:this.screenWidth,height:this.screenHeight}),c=this.screenCharacterId=this.attachToNovelContainer(b);this.characterContainer=null,this.characters=[];var d=";display:none;width:"+this.screenWidth+"px;height:"+this.screenHeight+"px;";c.style.cssText+=d;var e=this.spritely,f=new e(c);f.addChild(e.createCenteredContainer()),this.characterContainer=f},reset:function(){this.resetCharacters()}});var b=function(a){function c(a,b,e,f,g){return this instanceof c?(d.apply(this,arguments),this.init(a,b,e,f,g),this):new c(a,b,e,f,g)}var d=a.sprite;return c.prototype=Object.create(d.prototype),c.prototype.constructor=c,b=function(){return c},c}}(window.VisualNovel=window.VisualNovel||{}),function(a){a.prototype.addObjectToScene=function(a,c,d,e,f){function g(){var e=c.width,g=c.height,i=h.util.scalePosition({x:d.x,y:d.y,z:d.z},{x:h.sceneFloorWidth,y:-h.sceneFloorHeight,z:h.sceneFloorHeight}),j=b(h);j=j(e,g,i),j.setBackground(e,g,c.path?h.imgPath+c.path:"",c.color),f&&j.fadeIn(f.duration,f.from,f.to),j.name=a,h.sceneFloor.sprite.addChild(j.sprite),h.scenes.object.push(j)}var h=this;this.eventTracker.addEvent("nowait",g,e)},a.prototype.moveSceneObject=function(a,b,c,d,e,f){function g(){h.setSceneObjectPosition(a,b,c,d,e)}var h=this;this.eventTracker.addEvent("nowait",g,f?f:0)},a.prototype.setSceneObjectPosition=function(a,b,c,d,e){var f=this.util,g=f.getObjectInList(this.scenes.object,"name",a),h=g.obj,i=h.sprite,j=f.scalePosition({x:"undefined"!=typeof b?b:i.x,y:"undefined"!=typeof c?c:i.y,z:"undefined"!=typeof d?d:i.z},{x:this.screenWidth,y:this.screenHeight,z:this.screenHeight});e?h.move(j.x,j.y,j.z,e):h.moveTo(j.x,j.y,j.z)},a.prototype.rotateSceneObject=function(a,b,c,d,e){function f(){g.setSceneObjectRotation(a,b,c,d,e)}var g=this;this.eventTracker.addEvent("nowait",f)},a.prototype.setSceneObjectRotation=function(a,b,c,d,e){var f=this.util.getObjectInList(this.scenes.object,"name",a),g=f.obj;e?g.rotate(b,c,e):g.rotateTo(b,c,d)},a.prototype.fadeSceneObject=function(a,b,c,d,e){function f(){g.setSceneObjectFade(a,b,c,d,e)}var g=this;this.eventTracker.addEvent("nowait",f)},a.prototype.setSceneObjectFade=function(a,b,c,d,e){var f=this.util.getObjectInList(this.scenes.object,"name",a),g=f.obj,h="string"==typeof b?b.toLowerCase():"";"in"===h?g.fadeIn(c,d,e):"out"===h&&g.fadeOut(c,d,e)},a.prototype.setSceneObjectStyle=function(a,b){var c=this.util.getObjectInList(this.scenes.object,"name",a),d=c.obj;d.sprite.children[0].style.cssText+=b},a.prototype.resetSceneObject=function(a,b){function c(){var c=d.util.getObjectInList(d.scenes.object,"name",a),e=c.obj,f=e?e.sprite.children[0].timer:null,g=f?f[b]:null;e&&g&&"rotate"===b&&(g=null)}var d=this;this.eventTracker.addEvent("nowait",c)},a.prototype.removeSceneObject=function(a){function b(){var b=c.util.getObjectInList(c.scenes.object,"name",a),d=b.id;c.sceneFloor.sprite.removeChildAt(d),c.scenes.object.splice(d,1)}var c=this;this.eventTracker.addEvent("nowait",b)},a.prototype.addTextToScene=function(a,c,d,e){function f(){var e=d.width?d.width:0,f=d.height?d.height:0,h=g.util.scalePosition({x:d.x,y:d.y,z:d.z},{x:g.sceneFloorWidth,y:-g.sceneFloorHeight,z:g.sceneFloorHeight}),i=b(g);i=i(e,f,h),i.sprite.children[0].setInnerHTML(c),d.size&&i.sprite.setCSS("font-size",d.size+"px"),d.color&&i.sprite.setCSS("color",d.color),(d.bgColor||d.bgImage)&&i.setBackground(e,f,d.bgImage?g.imgPath+d.bgImage:null,d.bgColor?d.bgColor:null),d.fade&&i.fadeIn(d.fade),i.name=a,g.sceneFloor.sprite.addChild(i.sprite),g.scenes.object.push(i)}var g=this;this.eventTracker.addEvent("nowait",f,e)},a.prototype.fadeSceneText=function(a,b,c){this.fadeSceneObject(a,b,c)},a.prototype.moveSceneText=function(a,b,c,d,e,f){this.moveSceneObject(a,b,c,d,e,f)},a.prototype.rotateSceneText=function(a,b,c,d,e){this.rotateSceneObject(a,b,c,d,e)},a.prototype.removeSceneText=function(a){this.removeSceneObject(a)},a.prototype.modules.push({init:function(){this.scenes={text:[],object:[]}},reset:function(){this.scenes={text:[],object:[]}}});var b=function(a){function c(a,b,e,f,g){return this instanceof c?(d.apply(this,arguments),this.init(a,b,e,f,g),this):new c(a,b,e,f,g)}var d=a.sprite;return c.prototype=Object.create(d.prototype),c.prototype.constructor=c,c.prototype.init=function(a,b,c){var d={x:c.x-25,y:c.z,z:c.y},e={x:c.x+a/2,y:0},f=this.createSprite(50,50,d,e);f.addClassName("sceneObjectContainer"),d={x:-(a/2)+25,y:-b,z:0},e={x:25,y:0,z:0};var g={x:90,y:0,z:0},h=this.createSprite(a,b,d,e,g);h.addClassName("sceneObject").update(),f.addChild(h),this.sprite=f},c.prototype.setBackground=function(a,b,c,d){var e=this.sprite.children[0],f=a&&b?"background-size:"+a+"px "+b+"px;":"",g=c?"background-image:url('"+c+"');":"",h=d?"background-color:"+d+";":"",i=f||g||h?";":"";
e.style.cssText+=i+f+g+h},c.prototype.rotate=function(a,b,c){var e=this.sprite.children[0];d.prototype.rotate.call(this,a,b,c,e)},c.prototype.rotateTo=function(a,b,c){var e=this.sprite.children[0];d.prototype.rotateTo.call(this,a,b,c,e)},b=function(){return c},c}}(window.VisualNovel=window.VisualNovel||{}),function(a){function b(a){return this.screenBgId=a,this}a.prototype.setBgImage=function(a,b,c,d,e,f){function g(){h.setBgImage(i,b,c,d,e,f)}var h=this.screenBgId,i=this.imgPath+a;this.eventTracker.addEvent("nowait",g)},a.prototype.setBgColor=function(a){function b(){c.setBgColor(a)}var c=this.screenBgId;this.eventTracker.addEvent("nowait",b)},a.prototype.setBgSize=function(a,b,c,d){function e(){f.setBgSize(a,b,c)}var f=this.screenBgId;this.eventTracker.addEvent("nowait",e,d)},a.prototype.getBgSize=function(){return this.screenBgId.getBgSize()},a.prototype.setBgSizeTo=function(a,b){this.screenBgId.setBgSizeTo(a,b)},a.prototype.setBgScale=function(a,b,c,d){function e(){f.setBgScale(a,b,c)}var f=this.screenBgId;this.eventTracker.addEvent("nowait",e,d)},a.prototype.setBgPosition=function(a,b,c,d){function e(){f.setBgPosition(a,b,c)}var f=this.screenBgId;this.eventTracker.addEvent("nowait",e,d)},a.prototype.getBgPosition=function(){return this.screenBgId.getBgPosition()},a.prototype.rotateBg=function(a,b,c,d,e){function f(){g.rotateBg(a,b,c,d,e)}var g=this.screenBgId;this.eventTracker.addEvent("nowait",f,0)},a.prototype.rotateBgTo=function(a,b,c,d,e){function f(){g.rotateBgTo(a,b,c,d,e)}var g=this.screenBgId;this.eventTracker.addEvent("nowait",f,0)},a.prototype.stopRotateBg=function(a){function b(){}this.eventTracker.addEvent("nowait",b,a)},a.prototype.fadeBg=function(a,b){function c(){d.fadeBg(a,b)}var d=this.screenBgId;this.eventTracker.addEvent("nowait",c)},a.prototype.resetBg=function(a,b){function c(){d.resetBg(a)}var d=this.screenBgId;this.eventTracker.addEvent("nowait",c,b)},a.prototype.modules.push({init:function(a){var c=this.parser.parseTemplate("",{novelId:a,width:this.screenWidth,height:this.screenHeight}),d=this.attachToNovelContainer(c);this.screenBgId=new b(this.objectFactory("ScreenBg",d))},reset:function(){}}),b.prototype.setBgImage=function(a,b,c,d,e,f){var g=this.screenBgId;g.setPosition(0,0,0).setSize(b,c).setCSS("background-image","url('"+a+"')"),e&&f&&g.setCSS("background-size",e+"px "+f+"px"),requestAnimationFrame(function(){g.update()})},b.prototype.setBgColor=function(a){this.screenBgId.style["background-color"]=a},b.prototype.setBgSize=function(a,b,c){if(c){var d=this,e=this.getBgSize(),f={width:a-e.width,height:b-e.height},g=Date.now(),h=c,i=function(){var a=Date.now(),b=(a-g)/h;d.setBgSizeTo(e.width+b*f.width,e.height+b*f.height),1>=b&&requestAnimationFrame(i)};requestAnimationFrame(i)}else this.setBgSizeTo(a,b);this.screenBgId.update()},b.prototype.getBgSize=function(){var a=this.screenBgId;return{width:a.width,height:a.height}},b.prototype.setBgSizeTo=function(a,b){this.screenBgId.setSize(a,b).setCSS("background-size",a+"px "+b+"px")},b.prototype.setBgScale=function(a,b,c){var d=this.screenBgId;if(c){var e=d.scaleX,f=d.scaleY,g={width:a-e,height:b-f},h=Date.now(),i=c,j=function(){var a=Date.now(),b=(a-h)/i;1>=b&&(d.setScale(e+b*g.width,f+b*g.height,1).update(),requestAnimationFrame(j))};requestAnimationFrame(j)}else d.setScale(a,b,1).update()},b.prototype.setBgPosition=function(a,b,c){var d=this.getBgPosition(),e={x:a-d.x,y:b-d.y},f=this.screenBgId;if(c){var g=Date.now(),h=c,i=function(){var a=Date.now(),b=(a-g)/h;f.x=d.x+b*e.x,f.y=d.y+b*e.y,f.update(),1>=b&&requestAnimationFrame(i)};requestAnimationFrame(i)}else requestAnimationFrame(function(){f.x=d.x+e.x,f.y=d.y+e.y,f.update()})},b.prototype.getBgPosition=function(){var a=this.screenBgId,b={x:a.x,y:a.y};return b},b.prototype.rotateBg=function(a,b,c,d,e){this.screenBgId.rotate(a,b,c,d,e)},b.prototype.rotateBgTo=function(a,b,c,d,e){this.screenBgId.rotateTo(a,b,c,d,e)},b.prototype.fadeBg=function(a,b){var c=this.screenBgId;"in"===a&&c.fadeIn(b),"out"===a&&c.fadeOut(b)},b.prototype.resetBg=function(a){var b=this.screenBgId;"rotate"==a&&b.setRotation(0,0,0).update(),"fade"==a&&b.fadeIn(0)}}(window.VisualNovel=window.VisualNovel||{}),function(a){function b(a){return this instanceof b?("undefined"==typeof a&&(a=document.createElement("div")),""===a.innerHTML&&(a.innerHTML=" "),a.style[this._browserPrefix+"TransformStyle"]="preserve-3d",a.style.margin="0px",a.style.padding="0px",a.style.position="absolute",a.style[this._transformProperty]="translateZ(0px)",this.style=a.style,this.domElement=a,this.children=[],this.numChildren=0,this.width=0,this.height=0,this.x=0,this.y=0,this.z=0,this.regX=0,this.regY=0,this.regZ=0,this.alpha=1,this.rotationX=0,this.rotationY=0,this.rotationZ=0,this.rotateFirst=!1,this.scaleX=1,this.scaleY=1,this.scaleZ=1,this.tileWidth=0,this.tileHeight=0,this.transformString="_p _rx _ry _rz _s",this.pos="",this.rx="",this.ry="",this.rz="",this.scale="",this):new b(a)}var c=function(){var a,b=document.createElement("div"),c="webkit",d=["ms","o","Moz","webkit",""],e=d.length;for(a=e;a--&&(c=d[a],!(c+"Perspective"in b.style)););return c}();b.prototype._browserPrefix=c,b.prototype._transformProperty=c+"Transform",b.prototype.setTransformString=function(a){return this.transformString=a,this},b.prototype.setX=function(a){return this.x=a,this},b.prototype.setY=function(a){return this.y=a,this},b.prototype.setZ=function(a){return this.z=a,this},b.prototype.setPosition=function(a,b,c){return this.x=a,this.y=b,this.z=c,this},b.prototype.moveX=function(a){return this.x+=a,this},b.prototype.moveY=function(a){return this.y+=a,this},b.prototype.moveZ=function(a){return this.z+=a,this},b.prototype.move=function(a,b,c){return this.x+=a,this.y+=b,this.z+=c,this},b.prototype.setRotationX=function(a){return this.rotationX=a,this},b.prototype.setRotationY=function(a){return this.rotationY=a,this},b.prototype.setRotationZ=function(a){return this.rotationZ=a,this},b.prototype.setRotation=function(a,b,c){return this.rotationX=a,this.rotationY=b,this.rotationZ=c,this},b.prototype.rotateX=function(a){return this.rotationX+=a,this},b.prototype.rotateY=function(a){return this.rotationY+=a,this},b.prototype.rotateZ=function(a){return this.rotationZ+=a,this},b.prototype.rotate=function(a,b,c){return this.rotationX+=a,this.rotationY+=b,this.rotationZ+=c,this},b.prototype.setScaleX=function(a){return this.scaleX=a,this},b.prototype.setScaleY=function(a){return this.scaleY=a,this},b.prototype.setScaleZ=function(a){return this.scaleZ=a,this},b.prototype.setScale=function(a,b,c){return 1==arguments.length?(this.scaleX=a,this.scaleY=a,this.scaleZ=a):(this.scaleX=a,this.scaleY=b,this.scaleZ=c),this},b.prototype.setRegistrationPoint=function(a,b,c){return this.regX=a,this.regY=b,this.regZ=c,this},b.prototype.setTransformOrigin=function(a,b){return this.style[this._browserPrefix+"TransformOrigin"]=a+" "+b,this},b.prototype.setSize=function(a,b){return this.style.width=(this.width=a)+"px",this.style.height=(this.height=b)+"px",this},b.prototype.setOpacity=function(a){return this.style.opacity=this.alpha=a,this},b.prototype.getOpacity=function(){return this.alpha},b.prototype.setClassName=function(a){return this.domElement.className=a,this},b.prototype.getClassName=function(){return this.domElement.className},b.prototype.addClassName=function(a){return this.domElement.className+=" "+a+" ",this},b.prototype.removeClassName=function(a){return this.domElement.className=this.domElement.className.replace(a,""),this},b.prototype.setId=function(a){return this.domElement.id=a,this},b.prototype.getId=function(){return this.domElement.id},b.prototype.setCSS=function(a,b){return this.domElement.style[a]=b,this},b.prototype.getCSS=function(a){return this.domElement.style[a]},b.prototype.setInnerHTML=function(a){return this.domElement.innerHTML=a,this},b.prototype.setTileSize=function(a,b){return this.tileWidth=a,this.tileHeight=b,this},b.prototype.setTilePosition=function(a,b){return this.style.backgroundPosition="-"+a*this.tileWidth+"px -"+b*this.tileHeight+"px",this},b.prototype.setProperty=function(a,b){return this[a]=b,this},b.prototype.setRotateFirst=function(a){return this.rotateFirst=a,this.transformString=a?"_rx _ry _rz _p _s":"_p _rz _ry _rx _s",this},b.prototype.update=function(){this.pos="translate3d("+(this.x-this.regX)+"px,"+(this.y-this.regY)+"px,"+(this.z-this.regZ)+"px) ",this.rx="rotateX("+this.rotationX+"deg) ",this.ry="rotateY("+this.rotationY+"deg) ",this.rz="rotateZ("+this.rotationZ+"deg) ",this.scale="scale3d("+this.scaleX+", "+this.scaleY+", "+this.scaleZ+") ";var a=this.transformString;return a=a.replace("_p",this.pos),a=a.replace("_rx",this.rx),a=a.replace("_ry",this.ry),a=a.replace("_rz",this.rz),a=a.replace("_s",this.scale),this.style[this._transformProperty]=a,this},b.prototype.updateAll=function(){return this.style.opacity=this.alpha,this.style.width=this.width+"px",this.style.height=this.height+"px",this.update()},b.prototype.updateChildren=function(){for(var a=this.numChildren;a--;)this.children[a].update();return this},b.prototype.updateChildrenAll=function(){for(var a=this.numChildren;a--;)this.children[a].updateAll();return this},b.prototype.updateWithChildren=function(a){this.update();for(var b=this.children,c=a?function(c){b[c].updateWithChildren(a)}:function(a){b[a].update()},d=this.numChildren;d--;)c(d);return this},b.prototype.addChild=function(a){return this.numChildren=this.children.push(a),this.domElement.appendChild(a.domElement),a},b.prototype.removeChild=function(a){var b=this.children.indexOf(a);return b>-1?this.removeChildAt(b):null},b.prototype.removeChildAt=function(a){return--this.numChildren,this.domElement.removeChild(this.children[a].domElement),this.children.splice(a,1)[0]},b.prototype.findFromDOMElement=function(a){for(var b=this.numChildren;b--;)if(a==this.children[b].domElement)return this.children[b];return null},b.prototype.addEventListener=function(a,b){var c=a+"_"+b.name;if("undefined"==typeof this.listeners[c]||null===this.listeners[c]){var d=this,e=function(a){b(a,d)};this.listeners[c]=e,this.domElement.addEventListener(a,e,!1)}return this},b.prototype.removeEventListener=function(a,b){var c=a+"_"+b.name;return this.listeners[c]&&(this.domElement.removeEventListener(a,this.listeners[c],!1),delete this.listeners[c]),this},b.createCenteredContainer=function(){var a=document,c=a.createElement("div"),d=c.style,e=this._browserPrefix;d[e+"Perspective"]="800"+("Moz"===e?"px":""),d[e+"PerspectiveOrigin"]="0 0",d[e+"TransformOrigin"]="0 0",d[e+"Transform"]="translateZ(0px)",d.position="absolute",d.top="50%",d.left="50%",d.margin="0px",d.padding="0px";var f=new b(c);return a.body.appendChild(c),f},b.createTopLeftCenteredContainer=function(){var a=document.createElement("div"),c=a.style,d=this._browserPrefix;c[d+"Perspective"]="800"+("Moz"==d?"px":""),c[d+"Transform"]="translateZ(0px)",c.position="absolute";var e=new b(a);return document.body.appendChild(a),e},a.Spritely=b}(window),function(a){function b(a,c,d,e,f){return this instanceof b?(this.sprite=null,this.init(a,c,d,e,f),this):new b(a,c,d,e,f)}function c(a){var c=null;if("SpriteContainer"===a&&(c=new Spritely(arguments[1]),c.addChild(Spritely.createCenteredContainer())),"ScreenBg"===a&&(c=new Spritely(arguments[1]),c.addChild(Spritely.createCenteredContainer()),c.sprite=c,c.timer={},c.rotate=b.prototype.rotate,c.rotateTo=b.prototype.rotateTo,c.fade=b.prototype.fade,c.fadeIn=b.prototype.fadeIn,c.fadeOut=b.prototype.fadeOut),"SceneFloor"===a){var d=arguments[1],e=arguments[2],f={x:-(d/2),y:-(e/2),z:-50},g={x:0,y:0},h={x:-90,y:0,z:0};c=new b(d,e,f,g,h),c.sprite.addClassName("sceneFloor")}return"SceneFloorContainer"===a&&(c=(new Spritely).setClassName("sceneFloorContainer").setZ(0).update()),c}b.prototype.init=function(a,b,c,d,e){var f=this.createSprite(a,b,c,d,e);this.sprite=f},b.prototype.createSprite=function(a,b,c,d,e){var f=c,g=d.x,h=d.y,i=d.z,j=(new Spritely).setClassName("sprite").setSize(a,b).setTransformOrigin(g,h,i).setPosition(f.x,f.y,f.z).rotateX(e&&e.x?e.x:0).rotateY(e&&e.y?e.y:0).rotateZ(e&&e.z?e.z:0).setRotateFirst(!0);return j.setCSS("-webkit-transform-origin",g+"px "+h+"px").update(),j.timer={},j},b.prototype.setBackground=function(a,b,c,d){var e="",f="";"object"==typeof c?(f=c&&c.src?"background-image:url('"+c.src+"');":"",f+=f&&c.position?"background-position:"+c.position+";":""):(e=a&&b?"background-size:"+a+"px "+b+"px;":"",f=c?"background-image:url('"+c+"');":f);var g=d?"background-color:"+d+";":"",h=e||f||g?";":"";this.sprite.style.cssText+=h+e+f+g},b.prototype.move=function(a,b,c,d){var e=this.sprite,f={x:e.x,y:e.y,z:e.z},g={x:a-e.x,y:b-e.y,z:c-e.z},h=Date.now(),i=d,j=function(){var a=Date.now(),b=(a-h)/i;e.x=f.x+Math.floor(b*g.x),e.y=f.y+Math.floor(b*g.y),e.z=f.z+Math.floor(b*g.z),e.update(),1>=b&&requestAnimationFrame(j)};requestAnimationFrame(j)},b.prototype.moveTo=function(a,b,c,d){var e=d?d:this.sprite;e.x=a,e.y=b,e.z=c,e.update()},b.prototype.rotate=function(a,b,c,d){var e=d?d:this.sprite,f=function(){};a&&(f=function(){e["rotate"+a.toUpperCase()](b).update()}),c?(e.timer.rotate=!0,requestAnimationFrame(function g(){f(),e.timer.rotate&&requestAnimationFrame(g)})):requestAnimationFrame(function(){f()})},b.prototype.rotateTo=function(a,b,c,d){var e=d?d:this.sprite,f=a.toUpperCase(),g="setRotation"+f;if(c){var h=Date.now(),i=c,j=e["rotation"+f],k=b-j,l=function(){var a=Date.now(),b=(a-h)/i;e[g](j+b*k).update(),1>=b&&requestAnimationFrame(l)};requestAnimationFrame(l)}else requestAnimationFrame(function(){e[g](b).update()})},b.prototype.fade=function(a,b,c){var d=b-a,e=this.sprite,f=Date.now(),g=c,h=function(){var b=Date.now(),c=(b-f)/g,i=a+c*d;e.setOpacity(i),1>=c&&requestAnimationFrame(h)};requestAnimationFrame(h)},b.prototype.fadeIn=function(a,b,c){var d=b&&b>0?b:0,e=c&&c>0?c:1;this.fade(d,e,a)},b.prototype.fadeOut=function(a,b,c){var d=b&&b>0?b:1,e=c&&c>0?c:0;this.fade(d,e,a)},a.prototype.objectFactory=c,a.prototype.spritely=Spritely,a.prototype.sprite=b}(window.VisualNovel=window.VisualNovel||{}),function(a){function b(a){this.novelId=a,this.novelTitleContainerId=null,this.novelTitle="",this.novelTitleTextId=null,this.novelSubtitle="",this.novelSubtitleTextId=null,this.screenStartId=null,this.screenStartMenuButtonContainerId=null,this.screenStartMenuStartButtonId=null}a.prototype.initScreenStart=function(a){var c=this,d=(this.screenStart=new b(a),this.parser.parseTemplate("",{novelId:a,width:this.screenWidth,height:this.screenHeight}));this.screenStart.screenStartId=this.attachToNovelContainer(d),this.buildStartMenu(a),this.screenStart.updateStartMenuReference(),this.screenStart.showStartScreen(!0),this.screenStart.addStartMenuButtonHandler(function(){c.startNovel()})},a.prototype.startNovel=function(){this.screenStart.showStartScreen(!1),this.eventTracker.startEvent()},a.prototype.startMenuTemplate=["",""].join(""),a.prototype.buildStartMenu=function(a){var b=this.screenStart,c={novelId:a,novelTitle:b.novelTitle,novelSubtitle:b.novelSubtitle},d="";this.parser?d=this.parser.parseTemplate(this.startMenuTemplate,c):this.log("[start]VisualNovelJS Error: parser module not found"),b.setContent(d)},a.prototype.showStartScreen=function(a){this.screenStart.showStartScreen(a)},a.prototype.setStartScreenBgImage=function(a,b,c){this.screenStart.setStartScreenBgImage(this.imgPath+a,b,c)},a.prototype.setStartScreenBgColor=function(a){this.screenStart.setStartScreenBgColor(a)},a.prototype.setStartScreenMenuBgImage=function(a,b,c){this.screenStart.setStartScreenBgImage(this.imgPath+a,b,c)},a.prototype.setStartScreenMenuBgColor=function(a){this.screenStart.setStartScreenMenuBgColor(a)},a.prototype.setStartScreenMenuPos=function(a,b){var c=a>1?a:a*this.screenHeight,d=b>1?b:b*this.screenWidth;this.screenStart.setStartScreenMenuPos(c,d)},a.prototype.setNovelTitle=function(a,b){this.screenStart.updateNovelTitle(a,b)},a.prototype.setNovelTitlePosition=function(a,b){var c=this.util.scalePosition({x:a,y:b},{x:this.screenWidth,y:this.screenHeight});this.screenStart.setNovelTitlePosition(c.x,c.y)},a.prototype.modules.push({init:function(a){this.initScreenStart(a)},reset:function(){}}),b.prototype.setContent=function(a){this.screenStartId.innerHTML=a},b.prototype.showStartScreen=function(a){var b=a?"block":"none";this.screenStartId.style.display=b},b.prototype.updateStartMenuReference=function(){var a=document,b=this.novelId;this.novelTitleContainerId=a.getElementById(b+"-startMenuTitleContainer"),this.novelTitleTextId=a.getElementById(b+"-startMenuTitleText"),this.novelSubtitleTextId=a.getElementById(b+"-startMenuSubtitleText"),this.screenStartMenuButtonContainerId=a.getElementById(b+"-startMenuButtonContainer"),this.screenStartMenuStartButtonId=a.getElementById(b+"-startMenuButton")},b.prototype.addStartMenuButtonHandler=function(a){this.screenStartMenuStartButtonId.onclick=a},b.prototype.setStartScreenBgImage=function(a,b,c){var d=";background-image:url('"+a+"');background-size:"+b+"px "+c+"px;";this.screenStartId.style.cssText+=d},b.prototype.setStartScreenBgColor=function(a){this.screenStartId.style["background-color"]=a},b.prototype.setStartScreenMenuBgImage=function(a,b,c){var d=";background-image:url('"+a+"');background-size:"+b+"px "+c+"px;";this.screenStartMenuButtonContainerId.style.cssText+=d},b.prototype.setStartScreenMenuBgColor=function(a){this.screenStartMenuButtonContainerId.style["background-color"]=a},b.prototype.setStartScreenMenuPos=function(a,b){var c=";left:"+a+"px;top:"+b+"px;";this.screenStartMenuButtonContainerId.style.cssText+=c},b.prototype.updateNovelTitle=function(a,b){this.novelTitleTextId.innerHTML=this.novelTitle=a,this.novelSubtitleTextId.innerHTML=this.novelSubtitle=b},b.prototype.setNovelTitlePosition=function(a,b){var c=";left:"+a+"px;top:"+b+"px;";this.novelTitleContainerId.style.cssText+=c}}(window.VisualNovel=window.VisualNovel||{}),function(a){function b(){var a=null;return a=this instanceof b?this:new b}b.prototype.getObjectInList=function(a,b,c){for(var d={id:null,obj:null},e=a?a:[],f=e.length;f--;)e[f][b]==c&&(d={id:f,obj:e[f]});return d},b.prototype.scalePosition=function(a,b){var c=a.x,d=a.y,e=a.z,f={x:c>1||-1>c?c:c*b.x,y:d>1||-1>d?d:d*b.y,z:e>1||-1>e?e:e*b.z};return f},b.prototype.foreach=function(a,b,c){for(var d=a.length;d--;)c?b.call(c,a[d],d):b(a[d],d)},b.prototype.replaceVariablesInText=function(a,b){var c=a+"",d="",e="",f=null;for(d in b)e=b[d],f=new RegExp("{"+d+"}","gi"),c=c.replace(f,e);return c},b.prototype.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a.prototype.util=new b}(window.VisualNovel=window.VisualNovel||{});