"use strict";var SC=SC||{},CoreDocs=CoreDocs||{},NO=!1,YES=!0;for(var key in CoreDocs.loc=function(e,t){return void 0===t&&CoreDocs.error('"'+e+'" needs a comment to be picked up for loc.'),e=(e=e.loc()).replace(/@@/g,"%@")},SC.String={fmt:function(){for(var e=this.replace(/%@([0-9]+)/,(function(e){return(arguments[parseInt(e[1],0)-1]||"").toString()})),t=[],i=-1,r=0,n=0;(i=e.indexOf("%@",r))>=0;){t.push(e.slice(r,i)),r=i+2;var a=arguments[n++];a&&a.toString&&(a=a.toString()),t.push(a)}return r1?t.join(""):t[0]},loc:function(){var e=String[String.currentLanguage()],t=e[this];return t||(t=String.English[this]||this),t.fmt.apply(t,arguments)}},SC.String)String.prototype[key]=SC.String[key];function getUrlParameter(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(window.location.href);return null==t?"":t[1]}function setElementProperty(e,t,i){"ms"===browserPrefix?e.style[t]=i:e.style.setProperty(t,i,null)}function setElementPosition(e,t,i,r,n){null!=e?(e.style.top=t+"px",e.style.left=i+"px",e.style.width=r+"px",e.style.height=n+"px"):window.console.log("null element passed to setElementPosition "+t+", "+i+", "+r+", "+n)}function showElement(e){null!=e&&(e.style.visibility="visible")}function hideElement(e){null!=e&&(e.style.visibility="hidden")}function runInNextEventLoop(e){setTimeout(e,100)}function ensureScaleFactorNotZero(e){return 0===e?1e-6:e}function scaleSizeWithinSize(e,t,i,r){var n={},a=e/t,o=i/r;return a>o?(n.width=i,n.height=t*(i/e)):a0)isEdge=!0,browserPrefix="webkit",browserVersion=12;else if(userAgentString.lastIndexOf("Trident/")>0){isIE=!0,browserPrefix="ms";var revisionStringIE=userAgentString.substring(userAgentString.lastIndexOf("rv"),userAgentString.lastIndexOf(")")),revisionIE=[];revisionStringIE.lastIndexOf(":")>0?(revisionIE=revisionStringIE.split(":"),browserVersion=parseFloat(revisionIE[1])):revisionStringIE.lastIndexOf(" ")>0?(revisionIE=revisionStringIE.split(" "),browserVersion=parseFloat(revisionIE[1])):browserVersion=11}else userAgentString.indexOf("AppleWebKit/")>-1?(browserPrefix="webkit",userAgentString.lastIndexOf("Chrome/")>0&&(isChrome=!0)):userAgentString.indexOf("Gecko")>-1&&-1===userAgentString.indexOf("KHTML")?(browserPrefix="moz",isFirefox=!0):window.attachEvent&&(isIE=!0,browserPrefix="ms",browserVersion=parseFloat(navigator.appVersion.split("MSIE")[1]));var kKeyframesPropertyName="@-"+browserPrefix+"-keyframes",kAnimationNamePropertyName="-"+browserPrefix+"-animation-name",kAnimationDurationPropertyName="-"+browserPrefix+"-animation-duration",kAnimationDelayPropertyName="-"+browserPrefix+"-animation-delay",kAnimationFillModePropertyName="-"+browserPrefix+"-animation-fill-mode",kAnimationTimingFunctionPropertyName="-"+browserPrefix+"-animation-timing-function",kAnimationIterationCountPropertyName="-"+browserPrefix+"-animation-iteration-count",kTransformPropertyName="-"+browserPrefix+"-transform",kTransformOriginPropertyName="-"+browserPrefix+"-transform-origin",kTransformOriginZPropertyName="-"+browserPrefix+"-transform-origin-z",kTransitionPropertyName="-"+browserPrefix+"-transition",kTransitionDurationName="-"+browserPrefix+"-transition-duration",kTransformStylePropertyName="-"+browserPrefix+"-transform-style",kTransitionEndEventName=browserPrefix+"TransitionEnd",kAnimationEndEventName=browserPrefix+"AnimationEnd",kPerspectivePropertyName="-"+browserPrefix+"-perspective",kPerspectiveOriginPropertyName="-"+browserPrefix+"-perspective-origin",kBackfaceVisibilityPropertyName="-"+browserPrefix+"-backface-visibility",kBoxShadowPropertyName="-"+browserPrefix+"-box-shadow",kBorderPropertyName="border",kBackgroundImagePropertyName="background-image",kEmphasisEffects=["apple:action-pop","apple:action-pulse","apple:action-blink","apple:action-flip","apple:action-bounce","apple:action-jiggle"],kActionBuildKeyAnimations={"apple:action-opacity":["opacity"],"apple:action-motion-path":["position"],"apple:action-rotation":["transform.rotation.z"],"apple:action-scale":["transform.scale.x","transform.scale.y","anchorPoint","contents","bounds"],"apple:action-blink":["opacity"],"apple:action-bounce":["anchorPoint","transform.scale.y","transform.translation.y","transform.scale.x"],"apple:action-flip":["transform.rotation.y","transform.scale.xy"],"apple:action-jiggle":["transform.rotation.z"],"apple:action-pop":["transform.scale.xy"],"apple:action-pulse":["transform.scale.xy"]},kSupportedWebGLEffects=["apple:wipe-iris","com.apple.iWork.Keynote.BUKAnvil","com.apple.iWork.Keynote.BUKTwist","com.apple.iWork.Keynote.BUKFlop","com.apple.iWork.Keynote.KLNColorPlanes","com.apple.iWork.Keynote.KLNFlame","com.apple.iWork.Keynote.KLNConfetti","com.apple.iWork.Keynote.KLNDiffuse","com.apple.iWork.Keynote.KNFireworks","com.apple.iWork.Keynote.KLNShimmer","com.apple.iWork.Keynote.KLNSparkle","apple:magic-move-implied-motion-path","apple:ca-text-shimmer","apple:ca-text-sparkle"],useWebGL=!0,usePDF=!0,pdfScaleFactor=1,kFullscreenChangeEventName=browserPrefix+"fullscreenchange";function static_url(e){return e}function extractDelegateFromUrlParameter(){var e,t=getUrlParameter("delegate");if(""==t||null==t||void 0===t)e=new NullDelegate;else{var i=t.indexOf(".");for(e=window;-1!=i;){e=e[t.substring(0,i)],i=(t=t.substring(i+1)).indexOf(".")}e=e[t]}return e}function urlParamsGet(e,t){var i=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null==i?"":i.length>1?decodeURIComponent(i[1]):""}window.addEventListener("load",setupShowController,!1);var NullDelegate=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"showDidLoad",value:function(){}},{key:"showExited",value:function(){history.go(-1)}},{key:"propertyChanged",value:function(e,t){}},{key:"setPlaybackReadyHandler",value:function(e){e()}}]),e}();function setupShowController(){(gShowController=new ShowController).displayManager.showWaitingIndicator(),gShowController.delegate.setPlaybackReadyHandler((function(){if(usePDF){"file:"===window.location.protocol&&(PDFJS.disableWorker=!0),PDFJS.workerSrc="./assets/player/pdfjs/pdf_worker.js",PDFJS.cMapUrl="./assets/player/pdfjs/cmaps/",PDFJS.cMapPacked=!0;var e=document.createElement("canvas");e.getContext("webgl")||e.getContext("experimental-webgl")||(useWebGL=!1)}gShowController.startShow()}))}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;ii.lastSceneIndex)break;if(r===kShowModeAutoplay)this.jumpToScene(t,!0);else{var l=1==(e=i.events[t]).automaticPlay||1==e.automaticPlay;this.jumpToScene(t,l)}}}},{key:"handleScriptDidNotDownloadEvent",value:function(e){this.promptUserToTryAgain(kUnableToReachiWorkTryAgain)?this.scriptManager.downloadScript():(this.displayManager.clearLaunchMode(),this.displayManager.hideWaitingIndicator())}},{key:"handleStageIsReadyEvent",value:function(e){this.isFullscreen?setTimeout(function(){this.displayManager.stageArea.style.opacity=1}.bind(this),50):setTimeout(function(){this.displayManager.stageArea.style.opacity=1}.bind(this),500),this.positionSlideNumberControl(),this.positionSlideNumberDisplay(),this.positionHelpPlacard()}},{key:"positionSlideNumberControl",value:function(){var e=(this.displayManager.usableDisplayWidth-this.slideNumberController.width)/2,t=this.displayManager.stageAreaTop+this.displayManager.stageAreaHeight-(this.slideNumberController.height+16);this.slideNumberController.setPosition(e,t)}},{key:"positionSlideNumberDisplay",value:function(){var e=(this.displayManager.usableDisplayWidth-this.slideNumberDisplay.width)/2,t=this.displayManager.stageAreaTop+this.displayManager.stageAreaHeight-(this.slideNumberDisplay.height+16);this.slideNumberDisplay.setPosition(e,t)}},{key:"positionHelpPlacard",value:function(){var e=(this.displayManager.usableDisplayWidth-this.helpPlacard.width)/2,t=(this.displayManager.usableDisplayHeight-this.helpPlacard.height)/2;this.helpPlacard.setPosition(e,t)}},{key:"handleFullscreenChangeEvent",value:function(){document.webkitIsFullScreen||document.mozFullScreen?this.isFullscreen=!0:this.isFullscreen=!1,setTimeout(function(){this.displayManager.layoutDisplay()}.bind(this),0)}},{key:"handleWindowResizeEvent",value:function(){clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(this.changeWindowSize.bind(this),1e3)}},{key:"changeWindowSize",value:function(){if(this.delegate.setViewScale){this.scriptManager.reapplyScaleFactor(),this.textureManager.slideCache=null,this.textureManager.slideCache={};var e=this.currentSceneIndex;this.state===kShowControllerState_IdleAtFinalState&&(this.currentSceneIndex=kKeyCode_Numeric_0&&e<=kKeyCode_Numeric_9&&(e=kKeyCode_0+(e-kKeyCode_Numeric_0)),e+=t.shiftKey?kKeyModifier_Shift:0,e+=t.altKey?kKeyModifier_Alt:0,e+=t.ctrlKey?kKeyModifier_Ctrl:0,e+=t.metaKey?kKeyModifier_Meta:0,!this.isRecording){switch(e){case kKeyCode_Escape:this.exitShow(!0);break;case kKeyCode_Slash:case kKeyCode_Slash+kKeyModifier_Shift:this.helpPlacard.isShowing?this.helpPlacard.hide():this.helpPlacard.show();break;case kKeyCode_Q:this.exitShow(!0);break;case kKeyCode_S:this.slideNumberController.isShowing&&(this.slideNumberTimeout&&clearTimeout(this.slideNumberTimeout),this.slideNumberTimeout=setTimeout(this.hideAndResetSlideNumberController.bind(this),0)),this.slideNumberDisplay.isShowing?this.slideNumberDisplay.hide():(this.slideNumberDisplay.setSlideNumber(this.currentSlideIndex+1),this.slideNumberDisplay.show());break;case kKeyCode_Return:if(this.accumulatingDigits){this.accumulatingDigits=!1,this.script.showMode!==kShowModeHyperlinksOnly&&(this.digitAccumulator>this.script.slideCount?this.digitAccumulator=this.script.slideCount:this.digitAccumulator<1&&(this.digitAccumulator=1),this.slideNumberController.setSlideNumber(this.digitAccumulator),this.jumpToSlide(this.digitAccumulator));break}case kKeyCode_N:case kKeyCode_Space:case kKeyCode_DownArrow:case kKeyCode_RightArrow:case kKeyCode_PageDown:this.advanceToNextBuild("onKeyPress");break;case kKeyCode_RightArrow+kKeyModifier_Shift:case kKeyCode_CloseBracket:this.advanceAndSkipBuild("onKeyPress");break;case kKeyCode_DownArrow+kKeyModifier_Shift:case kKeyCode_PageDown+kKeyModifier_Shift:case kKeyCode_CloseBracket:case kKeyCode_Equal+kKeyModifier_Shift:case kKeyCode_Equal:case kKeyCode_Plus:this.advanceToNextSlide("onKeyPress");break;case kKeyCode_LeftArrow+kKeyModifier_Shift:case kKeyCode_PageUp+kKeyModifier_Shift:case kKeyCode_OpenBracket:this.goBackToPreviousBuild("onKeyPress");break;case kKeyCode_P:case kKeyCode_PageUp:case kKeyCode_LeftArrow:case kKeyCode_UpArrow:case kKeyCode_UpArrow+kKeyModifier_Shift:case kKeyCode_Hyphen:case kKeyCode_Minus:this.goBackToPreviousSlide("onKeyPress");break;case kKeyCode_Delete:if(!0,this.accumulatingDigits)if(this.digitAccumulator<10)this.slideNumberTimeout&&clearTimeout(this.slideNumberTimeout),this.slideNumberTimeout=setTimeout(this.hideAndResetSlideNumberController.bind(this),0);else{this.slideNumberTimeout&&clearTimeout(this.slideNumberTimeout),this.slideNumberTimeout=setTimeout(this.hideAndResetSlideNumberController.bind(this),7e3);var i=this.digitAccumulator.toString();this.digitAccumulator=parseInt(i.substring(0,i.length-1)),this.slideNumberController.setSlideNumber(this.digitAccumulator)}break;case kKeyCode_Home:this.script.showMode!==kShowModeHyperlinksOnly&&this.jumpToSlide(1);break;case kKeyCode_End:this.script.showMode!==kShowModeHyperlinksOnly&&this.jumpToSlide(this.script.slideCount);break;default:this.slideNumberTimeout&&clearTimeout(this.slideNumberTimeout),this.slideNumberTimeout=setTimeout(this.hideAndResetSlideNumberController.bind(this),7e3),e>=kKeyCode_0&&e<=kKeyCode_9?(this.slideNumberDisplay.isShowing&&this.slideNumberDisplay.hide(),!0,!1===this.accumulatingDigits&&(this.accumulatingDigits=!0,this.digitAccumulator=0),this.digitAccumulator.toString().length<4&&(this.digitAccumulator*=10,this.digitAccumulator+=e-kKeyCode_0,this.slideNumberController.setSlideNumber(this.digitAccumulator),this.slideNumberController.isShowing||this.slideNumberController.show())):!0}this.accumulatingDigits}}},{key:"hideAndResetSlideNumberController",value:function(){this.slideNumberTimeout&&clearTimeout(this.slideNumberTimeout),this.accumulatingDigits=!1,this.digitAccumulator=0,this.slideNumberController.hide()}},{key:"hideSlideNumberDisplay",value:function(){this.slideNumberDisplay.hide()}},{key:"toggleFullscreen",value:function(){isIE||(setTimeout(function(){this.displayManager.stageArea.style.opacity=0}.bind(this),0),this.displayManager.hideHUD(!0),document.webkitIsFullScreen||document.mozFullScreen?(this.isFullscreen=!1,document.webkitCancelFullScreen&&document.webkitCancelFullScreen()||document.mozCancelFullScreen&&document.mozCancelFullScreen()):(this.isFullscreen=!0,document.body.webkitRequestFullScreen&&document.body.webkitRequestFullScreen()||document.body.mozRequestFullScreen&&document.body.mozRequestFullScreen()))}},{key:"changeState",value:function(e){e!==this.state&&(this.leavingState(),this.state=e,this.enteringState())}},{key:"leavingState",value:function(){switch(this.state){case kShowControllerState_Stopped:case kShowControllerState_Starting:case kShowControllerState_SettingUpScene:case kShowControllerState_IdleAtFinalState:case kShowControllerState_IdleAtInitialState:case kShowControllerState_WaitingToJump:case kShowControllerState_ReadyToJump:break;case kShowControllerState_WaitingToPlay:this.displayManager.hideWaitingIndicator()}}},{key:"enteringState",value:function(){switch(this.state){case kShowControllerState_Stopped:break;case kShowControllerState_Starting:this.displayManager.showWaitingIndicator();break;case kShowControllerState_SettingUpScene:break;case kShowControllerState_IdleAtFinalState:this.unloadTextures();case kShowControllerState_IdleAtInitialState:this.updateSlideNumber(),runInNextEventLoop(this.doIdleProcessing.bind(this));break;case kShowControllerState_WaitingToJump:case kShowControllerState_ReadyToJump:break;case kShowControllerState_WaitingToPlay:this.displayManager.showWaitingIndicator()}}},{key:"preloadTextures",value:function(){var e=this.script,t=this.currentSceneIndex;this.state===kShowControllerState_IdleAtFinalState&&(ti+1){var a=r[n];for(var o in a.textureAssets){var s=a.textureAssets[o];if(s){var l=s.getContext("2d");l&&l.clearRect(0,0,s.width,s.height),delete a.textureAssets[o]}}delete this.textureManager.slideCache[n].textureAssets,delete this.textureManager.slideCache[n].textureRequests,delete this.textureManager.slideCache[n].requested,a.pdf&&(a.pdf.destroy(),delete this.textureManager.slideCache[n].pdf),delete this.textureManager.slideCache[n]}}},{key:"doIdleProcessing",value:function(){(this.preloadTextures(),null!==this.queuedUserAction&&void 0!==this.queuedUserAction)?(this.queuedUserAction(),this.queuedUserAction=null):0!==this.stageManager.stage.childNodes.length&&this.updateNavigationButtons();clearTimeout(this.createHyperlinksForCurrentStateTimeout),this.createHyperlinksForCurrentStateTimeout=setTimeout(function(){this.createHyperlinksForCurrentState("idle")}.bind(this),100)}},{key:"truncatedSlideIndex",value:function(e){return this.truncatedIndex(e,this.script.lastSlideIndex,this.script.loopSlideshow)}},{key:"truncatedSceneIndex",value:function(e){return this.truncatedIndex(e,this.script.lastSceneIndex,this.script.loopSlideshow)}},{key:"truncatedIndex",value:function(e,t,i){return e<0?e=i?e+t+1:-1:e>t&&(e=i?e-t-1:-1),e}},{key:"advanceToNextBuild",value:function(e){if(!this.script)return!1;if(this.script.showMode===kShowModeHyperlinksOnly&&"currentSceneDidComplete"!==e)return!1;if(this.displayManager.infoPanelIsShowing)return!1;var t=!1;switch(this.state){case kShowControllerState_IdleAtFinalState:if(-1===this.nextSceneIndex){if(!this.delegate.getKPFJsonStringForShow){this.stopSoundTrack();break}this.stopSoundTrack(),this.exitShow()}t=!0,this.jumpToScene(this.nextSceneIndex,!0);break;case kShowControllerState_IdleAtInitialState:if(this.currentSceneIndex>=this.script.numScenes)if(this.script.loopSlideshow)t=!0,this.jumpToScene(0,!1);else{if(!this.delegate.getKPFJsonStringForShow){this.stopSoundTrack();break}this.stopSoundTrack(),this.exitShow()}else t=!0,this.playCurrentScene();break;default:null!==this.queuedUserAction&&void 0!==this.queuedUserAction||(t=!0,this.queuedUserAction=this.advanceToNextBuild.bind(this,e))}return t}},{key:"advanceToNextSlide",value:function(e){if(!this.script)return!1;if(this.script.showMode!=kShowModeHyperlinksOnly&&!this.displayManager.infoPanelIsShowing){var t=this.currentSceneIndex;switch(this.state){case kShowControllerState_IdleAtFinalState:t+=1;case kShowControllerState_IdleAtInitialState:var i;if(this.scriptManager.slideIndexFromSceneIndex(t)===this.script.slideCount-1){if(!this.script.loopSlideshow)return;i=0}else i=this.currentSlideIndex+1;var r=this.scriptManager.sceneIndexFromSlideIndex(i),n=this.script.events[r],a=1==n.automaticPlay||1==n.automaticPlay;this.jumpToSlide(i+1,a);break;default:null!==this.queuedUserAction&&void 0!==this.queuedUserAction||(this.queuedUserAction=this.advanceToNextSlide.bind(this,e))}}}},{key:"goBackToPreviousBuild",value:function(e){if(!this.script)return!1;if(this.resetMediaCache(),this.script.showMode!==kShowModeHyperlinksOnly&&!this.displayManager.infoPanelIsShowing){var t=this.currentSceneIndex;switch(this.state){case kShowControllerState_IdleAtFinalState:t+=1;case kShowControllerState_Playing:case kShowControllerState_IdleAtInitialState:var i;if(0===t){if(!this.script.loopSlideshow)return;i=this.script.events.length-1}else i=t-1;this.jumpToScene(i,!1);break;default:null!==this.queuedUserAction&&void 0!==this.queuedUserAction||(this.queuedUserAction=this.goBackToPreviousBuild.bind(this,e))}}}},{key:"advanceAndSkipBuild",value:function(e){if(!this.script)return!1;if(this.script.showMode!==kShowModeHyperlinksOnly){var t=this.currentSceneIndex;switch(this.state){case kShowControllerState_IdleAtFinalState:t+=1;case kShowControllerState_IdleAtInitialState:var i;if(t>=this.script.numScenes-1){if(!this.script.loopSlideshow)return;i=0}else i=t+1;this.jumpToScene(i,!1);break;default:null==this.queuedUserAction&&(this.queuedUserAction=this.advanceAndSkipBuild.bind(this,e))}}}},{key:"goBackToPreviousSlide",value:function(e){if(!this.script)return!1;if(this.script.showMode!==kShowModeHyperlinksOnly&&!this.displayManager.infoPanelIsShowing){var t=this.currentSceneIndex;switch(this.state){case kShowControllerState_IdleAtFinalState:t+=1;case kShowControllerState_Playing:case kShowControllerState_IdleAtInitialState:var i,r=this.scriptManager.slideIndexFromSceneIndex(t),n=this.scriptManager.sceneIndexFromSlideIndex(r);i=0===r?t>0?0:this.script.loopSlideshow?this.script.slideCount-1:0:-1===r&&t>0?this.script.slideCount-1:t>n?this.currentSlideIndex:this.currentSlideIndex-1,this.jumpToSlide(i+1);break;default:null!==this.queuedUserAction&&void 0!==this.queuedUserAction||(this.queuedUserAction=this.goBackToPreviousSlide.bind(this,e))}}}},{key:"calculatePreviousSceneIndex",value:function(e){return previousSceneIndex=-1===e?-1:e-1,previousSceneIndex}},{key:"jumpToSlide",value:function(e,t){var i=e-1,r=this.scriptManager.sceneIndexFromSlideIndex(i);this.resetMediaCache(),null==t&&(t=!1),this.jumpToScene(r,t)}},{key:"jumpToScene",value:function(e,t){if(this.lastSlideViewedIndex=this.scriptManager.slideIndexFromSceneIndex(this.currentSceneIndex),-1!==e){switch(this.state){case kShowControllerState_Starting:var i="position:absolute;background-color:transparent; left:0px; top:0px; width:"+this.displayManager.usableDisplayWidth+"px; height:"+this.displayManager.usableDisplayHeight+"px;";this.starting=!0,this.maskElement=document.createElement("div"),this.maskElement.setAttribute("style",i),document.body.appendChild(this.maskElement);case kShowControllerState_IdleAtInitialState:case kShowControllerState_IdleAtFinalState:case kShowControllerState_ReadyToJump:break;default:return}if(!1===this.textureManager.isScenePreloaded(e)){this.changeState(kShowControllerState_WaitingToJump);var r={sceneIndex:e,automaticPlay:t};return this.waitForSceneToLoadTimeout=setTimeout(this.handleSceneDidNotLoad.bind(this,r),kMaxSceneDownloadWaitTime),void this.textureManager.loadScene(e,this.handleSceneDidLoad.bind(this,r))}this.changeState(kShowControllerState_SettingUpScene),runInNextEventLoop(this.jumpToScene_partThree.bind(this,e,t))}}},{key:"handleSceneDidLoad",value:function(e){switch(clearTimeout(this.waitForSceneToLoadTimeout),this.state){case kShowControllerState_WaitingToJump:this.changeState(kShowControllerState_ReadyToJump),this.jumpToScene_partTwo(e.sceneIndex,e.automaticPlay)}}},{key:"handleSceneDidNotLoad",value:function(e){if(clearTimeout(this.waitForSceneToLoadTimeout),this.queuedUserAction=null,this.promptUserToTryAgain(kUnableToReachiWorkTryAgain)){var t=window.location.href,i=t.indexOf("&restartingSceneIndex"),r=(-1===i?t:t.substring(0,i))+"&restartingSceneIndex="+e.sceneIndex;window.location.replace(r)}else this.changeState(kShowControllerState_IdleAtFinalState)}},{key:"jumpToScene_partTwo",value:function(e,t){this.changeState(kShowControllerState_SettingUpScene),runInNextEventLoop(this.jumpToScene_partThree.bind(this,e,t))}},{key:"jumpToScene_partThree",value:function(e,t){this.jumpToScene_partFour(e,t)}},{key:"jumpToScene_partFour",value:function(e,t){if(this.displayScene(e),this.starting&&(null!=this.maskElement&&(document.body.removeChild(this.maskElement),this.maskElement=null,this.starting=!1),window.focus()),this.helpPlacard.isShowing&&this.helpPlacard.hide(),this.slideNumberDisplay.isShowing&&this.slideNumberDisplay.hide(),this.slideNumberController.isShowing&&(this.slideNumberTimeout&&clearTimeout(this.slideNumberTimeout),this.slideNumberTimeout=setTimeout(this.hideAndResetSlideNumberController.bind(this),500)),t){var i=this.script;if(i.showMode===kShowModeAutoplay){var r=i.events[e].effects;if(r&&r.length>0){var n="transition"===r[0].type?i.autoplayTransitionDelay:i.autoplayBuildDelay;setTimeout(function(){this.playCurrentScene()}.bind(this),1e3*n)}else this.playCurrentScene()}else this.playCurrentScene()}else this.changeState(kShowControllerState_IdleAtInitialState),this.isRecording&&!this.isRecordingStarted&&(this.narrationManager.start(),this.isRecordingStarted=!0)}},{key:"displayScene",value:function(e,t){if(-1!==e){if(this.animationManager.deleteAllAnimations(),this.scriptManager.slideIndexFromSceneIndex(this.currentSceneIndex)!==(t?t.slideIndex:this.scriptManager.slideIndexFromSceneIndex(e))&&this.resetMediaCache(),this.setCurrentSceneIndexTo(e),t)this.playbackController.renderEvent(t);else{var i=this.script.slideIndexFromSceneIndexLookup[e],r=this.script.slideList[i],n=new KPFEvent({slideId:r,slideIndex:i,sceneIndex:e,event:this.script.events[e],animationSupported:this.animationSupported});this.playbackController.renderEvent(n)}this.updateNavigationButtons()}}},{key:"setCurrentSceneIndexTo",value:function(e){this.currentSceneIndex=e,this.assignNextSceneIndex(),this.updateSlideNumber(),this.updateNavigationButtons()}},{key:"assignNextSceneIndex",value:function(){this.nextSceneIndex=this.calculateNextSceneIndex(this.currentSceneIndex)}},{key:"calculateNextSceneIndex",value:function(e){return this.calculateNextSceneIndex_internal(e)}},{key:"calculateNextSceneIndex_internal",value:function(e){return e0&&!0,0===e&&0===this.script.lastSceneIndex||(this.currentSceneIndex0;t--){var i=this.activeHyperlinks[t-1],r=i.targetRectangle,n=Math.floor(r.x),a=Math.floor(r.y),o=n+Math.floor(r.width),s=a+Math.floor(r.height);if(e.pointX>=n&&e.pointX<=o&&e.pointY>=a&&e.pointY<=s)return i}return null}},{key:"createHyperlinksForCurrentState",value:function(e){var t=-1;switch(this.state){case kShowControllerState_IdleAtInitialState:t=this.currentSceneIndex;break;case kShowControllerState_IdleAtFinalState:this.currentSceneIndex0)for(var c=0;cthis.trackAreaRight)&&(!(e.clientYthis.trackAreaBottom))))}},{key:"handleTouchStartEvent",value:function(e){if(!1===this.swipeInProgress){var t=e.touches[0];this.isTouchWithinTrackArea(t)&&(this.preventDefault&&e.preventDefault(),this.swipeInProgress=!0,this.swipeFingerCount=e.touches.length,this.swipeStartTime=new Date,this.swipeStartX=t.clientX,this.swipeStartY=t.clientY)}else e.touches.length>this.swipeFingerCount&&(this.swipeFingerCount=e.touches.length)}},{key:"handleTouchMoveEvent",value:function(e){this.preventDefault&&e.preventDefault()}},{key:"handleTouchEndEvent",value:function(e){if(this.swipeInProgress&&(this.preventDefault&&e.preventDefault(),0===e.touches.length)){var t=e.changedTouches[0],i=window.innerHeight/3,r=window.innerWidth/3,n=t.clientX-this.swipeStartX,a=t.clientY-this.swipeStartY,o=Math.abs(n),s=Math.abs(a),l=new Date-this.swipeStartTime,h=!1,c=!1;if(l<400&&o<20&&s<20&&(h=!0),l<=800&&(o>s?s<=i&&(c=!0):o<=r&&(c=!0)),h)if(this.tapEventCallback){var u={detail:{fingers:this.swipeFingerCount,pointX:t.clientX,pointY:t.clientY,target:e.target}};this.tapEventCallback(u)}else document.dispatchEvent(new CustomEvent(kTapEvent,{detail:{fingers:this.swipeFingerCount,pointX:t.clientX,pointY:t.clientY}}));else if(c){var d;d=o>s?n<0?"left":"right":a<0?"up":"down",document.dispatchEvent(new CustomEvent(kSwipeEvent,{detail:{direction:d,fingers:this.swipeFingerCount,swipeStartX:this.swipeStartX}}))}this.swipeInProgress=!1,this.swipeFingerCount=0}}},{key:"handleTouchCancelEvent",value:function(e){this.swipeInProgress=!1}},{key:"handleGestureStartEvent",value:function(e){this.preventDefault&&e.preventDefault()}},{key:"handleGestureEndEvent",value:function(e){this.preventDefault&&e.preventDefault()}}]),e}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i10&&!1===this.cursorIsShowing?this.showCursor():this.navigatorIsShowing||this.setTimeoutForCursor(),this.lastMouseX=e.clientX,this.lastMouseY=e.clientY}},{key:"handleShowSizeDidChangeEvent",value:function(e){var t=e.detail;this.showWidth=t.width,this.showHeight=t.height,this.layoutDisplay()}},{key:"handleOrientationDidChangeEvent",value:function(e){this.orientation=e.detail.orientation,clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(this.handleOrientationDidChangeEvent_partTwo.bind(this),300)}},{key:"handleOrientationDidChangeEvent_partTwo",value:function(){this.layoutDisplay(),!1===this.inLaunchMode&&this.showApplicableControls()}},{key:"showCursor",value:function(){this.inLaunchMode||(this.body.style.cursor="default",this.cursorIsShowing=!0,this.setTimeoutForCursor())}},{key:"hideCursor",value:function(){this.body.style.cursor="none",this.cursorIsShowing=!1}},{key:"setTimeoutForCursor",value:function(){this.cursorTimeout&&clearTimeout(this.cursorTimeout),this.cursorTimeout=setTimeout(this.handleTimeoutForCursor.bind(this),kTimeoutValueForCursor)}},{key:"clearTimeoutForCursor",value:function(){this.cursorTimeout&&clearTimeout(this.cursorTimeout)}},{key:"handleTimeoutForCursor",value:function(){this.hideCursor()}},{key:"updateUsableDisplayArea",value:function(){this.usableDisplayWidth=window.innerWidth,this.usableDisplayHeight=window.innerHeight}},{key:"clearLaunchMode",value:function(){this.inLaunchMode=!1;runInNextEventLoop(this.showAll.bind(this))}},{key:"positionWaitingIndicator",value:function(){var e=(this.usableDisplayWidth-110)/2,t=(this.usableDisplayHeight-110)/2;setElementPosition(this.waitingIndicator,t,e,110,110)}},{key:"hideWaitingIndicator",value:function(){this.waitingIndicator.style.display="none"}},{key:"showWaitingIndicator",value:function(){this.waitingIndicator.style.display="block"}},{key:"convertDisplayCoOrdsToShowCoOrds",value:function(e){var t={},i=this.stageAreaLeft+this.stageAreaWidth,r=this.stageAreaTop+this.stageAreaHeight;return e.pointXi||e.pointYr?(t.pointX=-1,t.pointY=-1):(t.pointX=(e.pointX-this.stageAreaLeft)/this.stageAreaWidth*this.showWidth,t.pointY=(e.pointY-this.stageAreaTop)/this.stageAreaHeight*this.showHeight),t}},{key:"layoutDisplay",value:function(){this.updateUsableDisplayArea();var e=this.usableDisplayWidth,t=this.usableDisplayHeight;gShowController.isFullscreen||e>this.showWidth&&(e=this.showWidth);var i=scaleSizeWithinSize(this.showWidth,this.showHeight,e,t);this.stageAreaWidth=i.width,this.stageAreaHeight=i.height,this.stageAreaLeft=(this.usableDisplayWidth-this.stageAreaWidth)/2,this.stageAreaTop=(t-this.stageAreaHeight)/2,setElementPosition(this.stageArea,this.stageAreaTop,this.stageAreaLeft,this.stageAreaWidth,this.stageAreaHeight);this.usableDisplayWidth,this.stageAreaTop,this.stageAreaTop,this.stageAreaHeight,this.usableDisplayWidth,this.usableDisplayHeight,this.stageAreaTop,this.stageAreaHeight,this.stageAreaTop;var r=this.stageAreaLeft;this.stageAreaHeight,this.stageAreaLeft,this.stageAreaWidth,this.stageAreaTop,this.usableDisplayWidth,this.stageAreaWidth,this.stageAreaHeight;this.positionWaitingIndicator(),this.hideAddressBar(),document.dispatchEvent(new CustomEvent(kStageSizeDidChangeEvent,{detail:{left:this.stageAreaLeft,top:this.stageAreaTop,width:this.stageAreaWidth,height:this.stageAreaHeight}}))}},{key:"showApplicableControls",value:function(){this.hideAddressBar()}},{key:"showAll",value:function(){this.hideWaitingIndicator(),!1===this.inLaunchMode&&this.showApplicableControls(),showElement(this.stageArea),showElement(this.hyperlinkPlane)}},{key:"hideAddressBar",value:function(){this.inLaunchMode}}]),e}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i0;)this.hyperlinkPlane.removeChild(this.hyperlinkPlane.firstChild);this.audioTrackOffset=this.audioTrackSpacer}},{key:"handleStageSizeDidChangeEvent",value:function(e){var t=e.detail;this.stageWidth=t.width,this.stageHeight=t.height,this.adjustStageToFit(this.stage),this.adjustStageToFit(this.hyperlinkPlane)}},{key:"handleShowSizeDidChangeEvent",value:function(e){var t=e.detail;this.showWidth=t.width,this.showHeight=t.height,this.adjustStageToFit(this.stage),this.adjustStageToFit(this.hyperlinkPlane),this.audioTrackIconSize=this.showHeight/4,this.audioTrackSpacer=this.audioTrackIconSize/4,this.audioTrackOffset=this.audioTrackSpacer}},{key:"adjustStageToFit",value:function(e){if(0!==this.showWidth&&0!==this.stageWidth){var t=this.stageHeight/this.showHeight,i=this.stageWidth/this.showWidth,r="scaleX("+i+") scaleY("+t+")",n=15*Math.tan(Math.PI/180*20/2)*(this.showWidth>this.showHeight?this.showHeight:this.showWidth);this.perspective=n,setElementProperty(e,kTransformOriginPropertyName,kTransformOriginCenterPropertyValue),setElementProperty(e,kTransformPropertyName,r),setElementProperty(e,kPerspectiveOriginPropertyName,kTransformOriginCenterPropertyValue),setElementProperty(e,kTransformStylePropertyName,kTransformStylePreserve3DPropertyValue),setElementPosition(e,(t-1)*this.showHeight/2,(i-1)*this.showWidth/2,this.showWidth,this.showHeight),document.dispatchEvent(new CustomEvent(kStageIsReadyEvent,{detail:{}}))}}}]),e}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i0;)this.styleSheet.deleteRule(0);this.createdAnimations=new Object}},{key:"markAnimationsCreated",value:function(e){this.createdAnimations[e]=!0}},{key:"animationsCreated",value:function(e){return this.createdAnimations[e]}}]),e}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;ithis.script.numScenes)){t&&this.setSceneDidLoadCallbackHandler(t,e);var i=this.script.slideIndexFromSceneIndexLookup[e];usePDF?this.requestPdfDocument(i):this.requestSlideSvgmap(i)}}},{key:"preloadScenes",value:function(e){for(var t in e){var i=this.script.slideIndexFromSceneIndexLookup[t];null!=i&&(!1===this.slideCache.hasOwnProperty(i)&&this.loadScene(t))}}},{key:"isSlidePreloaded",value:function(e){var t=!1;if(this.slideCache[e])for(var i in t=!0,this.slideCache[e].textureRequests)if(!1===this.slideCache[e].textureRequests[i]){t=!1;break}return t}},{key:"isScenePreloaded",value:function(e){var t=this.script.slideIndexFromSceneIndexLookup[e];return this.isSlidePreloaded(t)}},{key:"handleScriptDidDownloadEvent",value:function(e){var t=e.detail;this.script=t.script,this.delegate=t.delegate}},{key:"requestPdfDocument",value:function(e){this.slideCache[e]||(this.slideCache[e]={textureAssets:{},textureRequests:{},pdf:null,requested:!1});var t=this.script.slideList[e];if(this.slideCache[e].requested)this.isSlidePreloaded(e)&&this.processSlideDidLoadCallback(e);else{var i=this.script.slides[t].assets;for(var r in i){"texture"===i[r].type&&(this.slideCache[e].textureRequests[r]=!1)}var n=this.showUrl+t+"/assets/"+t+".pdf",a={slideId:t,slideIndex:e};if(this.slideCache[e].requested=!0,"file:"===window.location.protocol){n+="p",null!==window.local_pdf&&void 0!==window.local_pdf||(window.local_pdf=function(e){this.handleRequestLocalPdfCallback(e)}.bind(this));var o=document.createElement("script");o.setAttribute("src",n),document.head.appendChild(o)}else PDFJS.getDocument(n).then(this.handleRequestPdfDocumentCompleted.bind(this,a))}}},{key:"handleRequestLocalPdfCallback",value:function(e){var t=e.slide,i=this.script.slideList.indexOf(t),r=atob(e.pdf),n={slideId:t,slideIndex:i};PDFJS.getDocument({data:r}).then(this.handleRequestPdfDocumentCompleted.bind(this,n))}},{key:"handleRequestPdfDocumentCompleted",value:function(e,t){var i=e.slideId,r=e.slideIndex,n=this.script.slides[i].assets;for(var a in this.slideCache[r].pdf=t,n){var o=n[a];if("texture"===o.type){var s=this.urlForTexture(a,i);if("pdf"===/(?:\.([^.]+))?$/.exec(s)[1].toLowerCase()){var l=o.index+1;t.getPage(l).then(this.handleRequestPdfPageCompleted.bind(this,a,r))}else{var h=new Image;h.addEventListener("load",this.handleImageOnloadEvent.bind(this,a,r)),h.src=s}}}}},{key:"handleRequestPdfPageCompleted",value:function(e,t,i){var r=i.getViewport(pdfScaleFactor),n=document.createElement("canvas"),a=n.getContext("2d");n.height=r.height,n.width=r.width;var o={canvasContext:a,background:"rgba(0, 0, 0, 0)",viewport:r},s=this,l=i.render(o),h=l._internalRenderTask.callback;l._internalRenderTask.callback=function(i){h.call(this,i),s.slideCache[t].textureAssets[e]=n,s.slideCache[t].textureRequests[e]=!0,s.processTextureDidLoadCallback(e,t)}}},{key:"requestSlideSvgmap",value:function(e){this.slideCache[e]||(this.slideCache[e]={},this.slideCache[e].textureAssets={},this.slideCache[e].textureRequests={});var t=this.script.slideList[e];if(this.slideCache[e].svgmap)this.isSlidePreloaded(e)&&this.processSlideDidLoadCallback(e);else{var i=this.script.slides[t].assets;for(var r in i){"texture"===i[r].type&&(this.slideCache[e].textureRequests[r]=!1)}var n=this.showUrl+t+"/assets/"+t+".svgmap";if("file:"===window.location.protocol){n+="p",null!==window.svgmap&&void 0!==window.svgmap||(window.svgmap=this.handleRequestSlideSvgmapCompleted.bind(this,null,!0));var a=document.createElement("script");a.setAttribute("src",n),document.head.appendChild(a)}else{var o={slideId:t,slideIndex:e};new Ajax.Request(n,{method:"get",onSuccess:this.handleRequestSlideSvgmapCompleted.bind(this,o,!1)})}}}},{key:"handleRequestSlideSvgmapCompleted",value:function(e,t,i){var r,n;t?(r=i.slide,n=i.svg):(r=e.slideId,n=JSON.parse(i.responseText));var a=this.script.slideList.indexOf(r),o=this.script.slides[r].assets;for(var s in this.slideCache[a].svgmap=n,o){var l=o[s];if("texture"===l.type){var h=this.urlForTexture(s,r),c=h.split("/"),u=c[c.length-1].split(".");if("svgmap"===u[u.length-1]){var d=n[l.index];e={textureId:s,slideId:r,slideIndex:a};this.handleFetchCompleted(e,d)}else{var f=new Image;f.addEventListener("load",this.handleImageOnloadEvent.bind(this,s,a)),f.src=h}}}}},{key:"handleFetchCompleted",value:function(e,t){this.viewScale;for(var i=e.textureId,r=e.slideId,n=e.slideIndex,a=new DOMParser,o=this.showUrl+r+"/assets/",s=a.parseFromString(t,"text/xml"),l=s.documentElement.getAttribute("viewBox").split(" "),h=l[2],c=l[3],u=s.getElementsByTagName("image"),d=0,f=u.length;d0){var l=i.layers[0];i.layers[0]=i.layers[1],i.layers[1]=l,i.layers[1].initialState.hidden=!0;var h=r.layers[0];r.layers[0]=r.layers[1],r.layers[1]=h,r.layers[1].initialState.hidden=!0;n=i.layers[1].animations[0].beginTime,a=i.layers[1].animations[0].duration;var c,u=i.layers[1].animations[0].animations[0].beginTime,d=i.layers[1].animations[0].animations[0].duration;if(n===u){for(var f=0,m=i.layers[1].animations[0].animations.length;f1){for(f=0,m=i.layers[1].animations[0].animations.length;f0){var n=i.layers[0];i.layers[0]=i.layers[1],i.layers[1]=n,i.layers[1].initialState.hidden=!0;var a=r.layers[0];r.layers[0]=r.layers[1],r.layers[1]=a,r.layers[1].initialState.hidden=!0;var o,s=i.layers[1].animations[0].beginTime,l=i.layers[1].animations[0].duration,h=i.layers[1].animations[0].animations[0].beginTime,c=i.layers[1].animations[0].animations[0].duration;if(s===h){for(var u=0,d=i.layers[1].animations[0].animations.length;u1){for(u=0,d=i.layers[1].animations[0].animations.length;u0){var n=i.layers[0];i.layers[0]=i.layers[1],i.layers[1]=n,i.layers[1].initialState.hidden=!0;var a=r.layers[0];r.layers[0]=r.layers[1],r.layers[1]=a,r.layers[1].initialState.hidden=!0;var o=i.layers[1].animations[0].beginTime,s=i.layers[1].animations[0].duration,l=i.layers[1].animations[0].animations[0].beginTime,h=i.layers[1].animations[0].animations[0].duration;if(o===l){for(var c=0,u=i.layers[1].animations[0].animations.length;c1){for(c=0,u=i.layers[1].animations[0].animations.length;c0){n=JSON.parse(JSON.stringify(i.layers[1]));i.layers.splice(0,0,n);a=JSON.parse(JSON.stringify(r.layers[1]));r.layers.splice(0,0,a);var A;o=i.layers[1].animations[0].beginTime,s=i.layers[1].animations[0].duration,l=i.layers[1].animations[0].animations[0].beginTime,h=i.layers[1].animations[0].animations[0].duration;if(o===l){for(c=0,u=i.layers[1].animations[0].animations.length;cp&&(p=M),(I=Math.round(y.y/y.height))>A&&(A=I)}m.particleCount={x:p+1,y:A+1}}this.applyScaleFactorForLayer(d.baseLayer,f.baseLayer,r,d.name,h,m)}c=0;for(var b=o.hyperlinks.length;cp&&(p=M),(I=Math.round(y.y/y.height))>A&&(A=I)}m.particleCount={x:p+1,y:A+1}}this.applyScaleFactorForLayer(E.baseLayer,B.baseLayer,r,E.name,h,m)}}}}for(var F in this.script.slides)if(this.script.slides.hasOwnProperty(F)){var L=this.script.slides[F],N=this.script.originalSlides[F];for(var G in L.assets)if(L.assets.hasOwnProperty(G)){var R=L.assets[G],W=N.assets[G];R.width=W.width*r,R.height=W.height*r}}}},{key:"adjustForCropAnimation",value:function(e,t,i,r){var n=this.script.slideWidth,a=this.script.slideHeight,o=Math.floor(n/i),s=Math.floor(a/r),l=Math.round(t.x/t.width),h=Math.round(t.y/t.height);1===t.width&&1===t.height||(e.width=l!==i-1?o:n-o*(i-1),e.height=h!==r-1?s:a-s*(r-1),e.position.pointX=o*l+e.width/2,e.position.pointY=s*h+e.height/2,e.contentsRect.x=o*l/n,e.contentsRect.y=s*h/a,e.contentsRect.width=e.width/n,e.contentsRect.height=e.height/a)}},{key:"downloadScript",value:function(e){if(this.delegate=e,this.delegate.getKPFJsonStringForShow){if(this.script=JSON.parse(this.delegate.getKPFJsonStringForShow()),null==this.script)return;return this.slideManager=new SlideManager({header:this.script}),void this.slideManager.getSlides(this.script.slideList,this.delegate)}this.downloadTimeout=setTimeout(this.scriptDidNotDownload.bind(this),kMaxScriptDownloadWaitTime),this.downloadAlreadyFailed=!1;var t=this.showUrl+"header.json";if("file:"===window.location.protocol){t+="p",window.local_header=function(e){this.scriptDidDownload(e,!0)}.bind(this);var i=document.createElement("script");i.setAttribute("src",t),document.head.appendChild(i)}else{var r=new XMLHttpRequest;r.open("GET",t,!0),r.send(),r.onreadystatechange=function(){4===r.readyState&&(200===r.status?this.scriptDidDownload(r):this.scriptDidNotDownload())}.bind(this)}}},{key:"scriptDidDownload",value:function(e,t){clearTimeout(this.downloadTimeout),this.script=t?e:JSON.parse(e.responseText),this.slideManager=new SlideManager({header:this.script}),this.slideManager.downloadSlides(this.script.slideList)}},{key:"scriptDidNotDownload",value:function(e){this.downloadAlreadyFailed=!0,e&&clearTimeout(this.downloadTimeout),document.dispatchEvent(new CustomEvent(kScriptDidNotDownloadEvent,{detail:{}}))}},{key:"sceneIndexFromSlideIndex",value:function(e){return null===this.script||void 0===this.script||e<0||e>=this.script.slideList.length?-1:this.script.sceneIndexFromSlideIndexLookup[e]}},{key:"slideIndexFromSceneIndex",value:function(e){return null===this.script||void 0===this.script||e<0||e>=this.script.events.length?-1:this.script.slideIndexFromSceneIndexLookup[e]}}]),e}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i-1&&(this.isEmphasisBuild=!0),t.movie&&(this.movie=t.movie),this.effects=[],this.addSubEffect(t.effects,i)}return _createClass(e,[{key:"destroy",value:function(){for(var e=0,t=this.effects.length;ethis.overallEndTime&&(this.overallEndTime=p),"custom"===m&&(o=u.timingControlPoint1x,s=u.timingControlPoint1y,l=u.timingControlPoint2x,h=u.timingControlPoint2y),null!==u.animations&&void 0!==u.animations&&u.animations.length>0){var A=u.animations,v=d;null!==A[0].property&&void 0!==A[0].property||(v=A[0].beginTime,A=A[0].animations);for(var g=0,y=A.length;gL.latestEndTime&&(L.latestEndTime=v+b.beginTime+b.duration);var x=b.additive&&("transform.rotation"===b.property||"transform.rotation.z"===b.property);if(b.path)for(var C=u.path.length,w=0;nL.latestEndTime&&(L.latestEndTime=u.beginTime+u.duration);x=u.additive&&("transform.rotation"===u.property||"transform.rotation.z"===u.property);if(u.path)for(C=u.path.length,w=0;w0&&(l=100*r/this.overallEndTime,h=100*n/this.overallEndTime),h>99.9999&&(h=100);var c={startKeyframe:l,endKeyframe:h,from:i.from,to:i.to,timingFunction:i.timingFunction};i.fillMode&&(c.fillMode=i.fillMode),"custom"===i.timingFunction&&(c.timingControlPoint1x=i.timingControlPoint1x,c.timingControlPoint1y=i.timingControlPoint1y,c.timingControlPoint2x=i.timingControlPoint2x,c.timingControlPoint2y=i.timingControlPoint2y),s.push(c),s.sort(this.sortAction)}}},{key:"sortAction",value:function(e,t){return e.startKeyframe-t.startKeyframe}},{key:"roundNum",value:function(e){return Math.round(e*this.kRoundingFactor)/this.kRoundingFactor}},{key:"createAnimationRules",value:function(e){var t=this.kDelta;for(var i in this.keyAnimations)if("playing"!==i){var r=this.keyAnimations[i],n=r.keyActions,a=!1;r.keyframes=[];var o=n[0],s=this.roundNum(o.startKeyframe),l=this.roundNum(100*r.groupBeginTime/this.overallEndTime);if("anchorPoint"!==i)if("anchorPointZ"!==i){if(null!=o){var h=0,c=null,u=null;0!==s&&("hidden"===i?(u={scalar:e.hidden},this.insertInitialKeyframes(r,s-t,i,u)):"opacity"===i?(u="both"===o.fillMode||"backwards"===o.fillMode?o.from:{scalar:e.opacity},this.insertInitialKeyframes(r,s-t,i,u)):"position"===i?(u=e.isBuildIn||e.isBuildOut?l>0&&"both"!==o.fillMode&&"backwards"!==o.fillMode?{pointX:0,pointY:0}:{pointX:this.roundNum(o.from.pointX-e.initialState.position.pointX),pointY:this.roundNum(o.from.pointY-e.initialState.position.pointY)}:{pointX:0,pointY:0},this.insertInitialKeyframes(r,s-t,i,u)):(u=this.createInitialKeyframeValue(e,i,o.from,a),l>0&&this.insertInitialKeyframes(r,l-t,i,u),s-l>t&&("both"!==o.fillMode&&"backwards"!==o.fillMode||(u=o.from),"transform.translation"===i&&(u.pointX=this.roundNum(u.pointX),u.pointY=this.roundNum(u.pointY)),r.keyframes.push({keyframe:l,keyName:i,value:u,timingFunction:"linear"}),r.keyframes.push({keyframe:s-t,keyName:i,value:u,timingFunction:"linear"}))),h=o.startKeyframe,c=u);for(var d=0,f=n.length;dt&&r.keyframes.push({keyframe:this.roundNum(o.startKeyframe)-t,keyName:i,value:c,timingFunction:"linear"}),"transform.translation"===i&&(o.from.pointX=this.roundNum(o.from.pointX),o.from.pointY=this.roundNum(o.from.pointY),o.to.pointX=this.roundNum(o.to.pointX),o.to.pointY=this.roundNum(o.to.pointY));var m=this.createTimingFunctionForAction(o);r.keyframes.push({keyframe:this.roundNum(o.startKeyframe),keyName:i,value:o.from,timingFunction:m}),r.keyframes.push({keyframe:this.roundNum(o.endKeyframe)-(100===o.endKeyframe?0:t),keyName:i,value:o.to,timingFunction:m}),c=o.to,h=o.endKeyframe}100!==h&&"hidden"!==i&&(r.keyframes.push({keyframe:this.roundNum(h),keyName:i,value:c,timingFunction:"linear"}),r.keyframes.push({keyframe:100,keyName:i,value:c,timingFunction:"linear"}))}}else{if(a=!0,0!==s){S=this.createInitialKeyframeValue(e,i,o.from,!0);r.keyframes.push({keyframe:0,keyName:"zPosition",value:S,timingFunction:"linear"}),r.keyframes.push({keyframe:s-t,keyName:"zPosition",value:S,timingFunction:"linear"})}r.keyframes.push({keyframe:s,keyName:"zPosition",value:o.from,timingFunction:"linear"}),r.keyframes.push({keyframe:100,keyName:"zPosition",value:o.to,timingFunction:"linear"}),e.transformOriginZValue=o.to.scalar}else{var p={};p.x=o.to.pointX,p.y=o.to.pointY;var A={pointX:-(o.from.pointX-e.anchorPoint.pointX)*e.bounds.width,pointY:-(o.from.pointY-e.anchorPoint.pointY)*e.bounds.height};if(e.isMagicMove){var v=this.anchorPointOffset(e,{x:o.from.pointX,y:o.from.pointY}),g={pointX:v.x,pointY:v.y},y=this.anchorPointOffset(e,{x:o.to.pointX,y:o.to.pointY}),b={pointX:y.x,pointY:y.y};g.pointX===b.pointX&&g.pointY===b.pointY||(A={pointX:b.pointX-g.pointX,pointY:b.pointY-g.pointY},e.magicMoveOffsetValue=A)}if(0!==s){var S={pointX:0,pointY:0};l>0&&this.insertInitialKeyframes(r,l-t,"position",S),s-l>t&&("both"!==o.fillMode&&"backwards"!==o.fillMode||(S=A),r.keyframes.push({keyframe:l,keyName:"position",value:S,timingFunction:"linear"}),r.keyframes.push({keyframe:s-t,keyName:"position",value:S,timingFunction:"linear"}))}r.keyframes.push({keyframe:s,keyName:"position",value:A,timingFunction:"linear"}),r.keyframes.push({keyframe:100,keyName:"position",value:A,timingFunction:"linear"}),e.transformOriginValue=100*p.x+"% "+100*p.y+"%"}}}},{key:"insertInitialKeyframes",value:function(e,t,i,r){e.keyframes.push({keyframe:0,keyName:i,value:r,timingFunction:"linear"}),e.keyframes.push({keyframe:t,keyName:i,value:r,timingFunction:"linear"})}},{key:"anchorPointOffset",value:function(e,t){var i={},r={},n={},a=e.bounds;return i.x=a.width/2,i.y=a.height/2,r.x=t.x*a.width,r.y=t.y*a.height,n.x=i.x-r.x,n.y=i.y-r.y,n}},{key:"createInitialKeyframeValue",value:function(e,t,i,r){var n={};switch(t){case"anchorPoint":n.pointX=(e.anchorPoint.pointX-.5)*e.bounds.width,n.pointY=(e.anchorPoint.pointY-.5)*e.bounds.height;break;case"anchorPointZ":n.scalar=isFirefox||isChrome||isIE||isEdge?0:i.scalar+i.scalar;break;case"opacity":case"opacityMultiplier":n.scalar=e.opacity;break;case"hidden":n.scalar=e.hidden;break;case"position":n.pointX=e.affineTransform[4],n.pointY=e.affineTransform[5];break;case"zPosition":n.scalar=0;break;case"transform.scale":case"transform.scale.xy":case"transform.scale.x":case"transform.scale.y":n.scalar=e.initialState.scale;break;case"transform.rotation.z":n.scalar=e.initialState.rotation;break;case"transform":n.transform=i.transform;break;case"bounds":n.pointX=0,n.pointY=0,n.width=e.initialState.width,n.height=e.initialState.height;break;default:n.scalar=0,n.pointX=0,n.pointY=0}return n}},{key:"createTimingFunctionForAction",value:function(e){var t="",i=e.timingFunction,r=e;switch("object"===_typeof(i)&&(i=i.timingFunction,r=e.timingFunction),i.toLowerCase()){case"easein":t="ease-in";break;case"easeout":t="ease-out";break;case"easeinout":case"easeineaseout":t="ease-in-out";break;case"custom":t="cubic-bezier("+r.timingControlPoint1x+","+r.timingControlPoint1y+","+r.timingControlPoint2x+","+r.timingControlPoint2y+")";break;case"linear":default:t="linear"}return t}},{key:"createAnimationRuleForKeyframes",value:function(e){for(var t in this.keyAnimations){var i,r,n=this.keyAnimations[t],a="layer"+e.layerId+"-"+escapeTextureId(t),o="";if("contents"!==t)if(isIE){if(browserVersion>=10){for(s=0,l=n.keyframes.length;s-1&&(this.isEmphasisBuild=!0),this.animations.length>0&&(this.cssAnimation=new KPFCssAnimation(this.animations,this)),this.divNames=[],this.objectID&&(this.isRenderMovie||this.isRenderWebVideo))this.divNames=["opacity","position","transform.rotation.z","transform.scale.x","transform.scale.y","bounds","contents"];else if(this.cssAnimation){for(var C in this.cssAnimation.keyAnimations)x.indexOf(C)>0||("opacity"===C?t=!0:"anchorPoint"===C?i=!0:"anchorPointZ"===C?r=!0:g||"transform.translation.x"!==C?g||"transform.translation.y"!==C?g||"transform.translation.z"!==C?g||"transform.translation"!==C?g||"transform.rotation.x"!==C?g||"transform.rotation.y"!==C?g||"transform.rotation.z"!==C?g||"transform.rotation"!==C?"transform.scale.x"===C?d=!0:"transform.scale.y"===C?f=!0:"transform.scale.xy"===C?m=!0:"transform.scale"===C?p=!0:"transform"===C?A=!0:"doubleSided"===C?e=!0:"contents"===C?this.hasContentsAnimation=!0:"bounds"===C?this.hasBoundsAnimation=!0:"position"===C?this.hasPosition=!0:v.push(C):u=!0:c=!0:h=!0:l=!0:s=!0:o=!0:a=!0:n=!0);if(t&&this.isActionBuild&&!this.isEmphasisBuild){this.divNames.push("opacity");for(var w=0,P=this.layers.length;w-1?i="youtube":n.indexOf("vimeo")>-1&&(i="vimeo"),"youtube"===i)r="https://www.youtube.com/embed/"+(t=urlParamsGet("v",n));else if("vimeo"===i){var a=n.match(/https:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/);a&&(t=a[2]),r="https://player.vimeo.com/video/"+t}e.style.border="none",e.setAttribute("src",r+"?autoplay=1")}},{key:"handleMouseOver",value:function(){this.setAttribute("controls","controls")}},{key:"handleMouseLeave",value:function(){this.removeAttribute("controls")}},{key:"setInsertBeforeOrAfterTextureId",value:function(){for(var e=this.parentLayer.layers,t=0,i=e.length;t=0&&(this.insertAfterTextureId=e[t-1].textureId))}}},{key:"observeEvents",value:function(e){var t=this.videoElement;t&&(t.removeEventListener("canplay",this.handleMovieDidStart),t.removeEventListener("ended",this.handleMovieDidEnd),t.addEventListener("canplay",this.handleMovieDidStart.bind(this,e)),t.addEventListener("ended",this.handleMovieDidEnd.bind(this,e)));var i=this.iframe;i&&(i.textureElement=e,i.addEventListener("load",(function(){i.style.visibility="visible",i.textureElement.style.visibility="hidden"})))}},{key:"setLoop",value:function(e){this.videoElement&&(this.videoElement.loop=e)}},{key:"setVolume",value:function(e){this.videoElement&&(this.videoElement.volume=e)}},{key:"removeControls",value:function(){this.videoElement&&this.videoElement.hasAttribute("controls")&&this.videoElement.removeAttribute("controls")}},{key:"handleMovieDidStart",value:function(e){this.videoElement&&(this.videoElement.style.visibility="visible",e&&setTimeout(this.hideMoviePoster.bind(this,e),120))}},{key:"handleMovieDidEnd",value:function(e){this.videoElement&&(this.videoElement.loop||(this.isEnded=!0))}},{key:"startMovie",value:function(){this.videoElement&&(this.videoElement.play(),this.isPlaying=!0)}},{key:"stopMovie",value:function(){this.videoElement&&this.videoElement.pause()}},{key:"hideMoviePoster",value:function(e){var t=e.style;t.visibility="hidden",t.display="none",e.parentNode&&e.parentNode.removeChild(e)}}]),e}(),KPFPlaybackController=function(){function e(t,i){_classCallCheck(this,e),this.domNode=i,this.kpfEvent=null}return _createClass(e,[{key:"destroy",value:function(){this.removeEvent(),this.domNode=null}},{key:"removeEvent",value:function(){if(this.kpfEvent)for(this.kpfEvent.destroy(),delete this.kpfEvent,this.kpfEvent=null;this.domNode.childNodes.length>0;)this.domNode.removeChild(this.domNode.childNodes[0])}},{key:"renderEvent",value:function(e){this.removeEvent(),this.kpfEvent=e,this.kpfEvent.renderEvent(this.domNode)}},{key:"renderEffects",value:function(){return this.kpfEvent.renderEffects(this.kpfEvent.event.effects)}},{key:"animateEffects",value:function(e){this.kpfEvent.animateEffects(e)}},{key:"eventOverallEndTime",value:function(){return this.kpfEvent.eventOverallEndTime}}]),e}(),KPFCssRenderer=function(){function e(t,i,r,n){_classCallCheck(this,e),this.textureId=t.textureId,this.nativeWidth=t.bounds.width,this.nativeHeight=t.bounds.height,this.opacity=t.opacity,this.visibility=!0===t.hidden?"hidden":"visible",this.textureTransform=t.textureTransform,this.affineTransform=t.affineTransform,this.anchorPoint=t.anchorPoint,this.contentsRect=t.contentsRect,this.layer=t,this.sceneIndex=i,this.animationSupported=r,this.enableCompositingUsingBackface=!1,this.enablePreserve3DFromParent=!1,n.length>0&&this.initRendererFlags(n[0]),this.glContentsRenderer={},this.domNode=document.createElement("div"),this.domNode.setAttribute("id","layer"+t.layerId)}return _createClass(e,[{key:"initRendererFlags",value:function(e){"transition"===e.type&&"apple:ca-swing"!==e.name&&"com.apple.iWork.Keynote.BLTSwoosh"!==e.name?(this.enableCompositingUsingBackface=!0,this.enablePreserve3DFromParent=!0,!isChrome||"apple:ca-push"!==e.name&&"com.apple.iWork.Keynote.BLTFadeThruColor"!==e.name||(this.enableCompositingUsingBackface=!1,this.enablePreserve3DFromParent=!1)):(this.enableCompositingUsingBackface=!1,this.enablePreserve3DFromParent=!1),"apple:apple-grid"===e.name?this.isGridTransition=!0:"com.apple.iWork.Keynote.BLTMosaicFlip"===e.name?this.isMosaicTransition=!0:"com.apple.iWork.Keynote.BLTSwoosh"===e.name&&"transition"===e.type&&(this.isSwooshTransition=!0)}},{key:"destroy",value:function(){this.textureId=null,this.nativeWidth=null,this.nativeHeight=null,this.opacity=null,this.visibility=null,this.textureTransform=null,this.affineTransform=null,this.anchorPoint=null,this.textureAnimation=null,this.contentsRect=null,this.requiresPerspectiveTransform=null,this.sceneIndex=null;for(var e=this.domNode.getElementsByTagName("canvas"),t=e.length;t--;){var i=e[t];if(i){var r=i.getContext("2d");r&&(r.clearRect(0,0,i.width,i.height),e[t].remove())}}if(this.domNode.hasChildNodes())for(;this.domNode.childNodes.length>0;)this.domNode.removeChild(this.domNode.firstChild);this.domNode=null}},{key:"addAnimationNode",value:function(e,t,i,r){if(null==t)return e;var n=t.shift();if(null==n)return e;var a=document.createElement("div"),o=i+"-"+escapeTextureId(n);a.setAttribute("id",o),r.initialState.masksToBounds&&setElementProperty(a,"overflow","hidden"),this.enableCompositingUsingBackface?setElementProperty(a,kBackfaceVisibilityPropertyName,"hidden"):this.isSwooshTransition&&setElementProperty(a,kTransformPropertyName,"translateZ(0px)"),this.setStyle(a,"0px","0px",e.style.width,e.style.height,kPositionAbsolutePropertyValue,null,null),setElementProperty(a,kTransformStylePropertyName,kTransformStylePreserve3DPropertyValue),.5===r.anchorPoint.pointX&&.5===r.anchorPoint.pointY||setElementProperty(a,kTransformOriginPropertyName,100*r.anchorPoint.pointX+"% "+100*r.anchorPoint.pointY+"%");var s=["opacity","doubleSided","anchorPointZ"];return r.transformOriginValue&&r.transformOriginZValue&&("apple:ca-revolve"===r.animationInfo.name?s.push("anchorPoint","position","zPosition"):"apple:3D-cube"===r.animationInfo.name&&s.push("anchorPoint","position","zPosition","transform.rotation.x","transform.rotation.y")),r.transformOriginZValue&&-1===s.indexOf(n)&&(isFirefox?setElementProperty(a,kTransformOriginPropertyName,100*r.anchorPoint.pointX+"% "+100*r.anchorPoint.pointY+"% "+r.transformOriginZValue+"px"):(setElementProperty(a,kTransformOriginZPropertyName,r.transformOriginZValue+"px"),navigator.userAgent.lastIndexOf("Chrome/")<=0&&setElementProperty(a,kTransformPropertyName,"translateZ("+r.transformOriginZValue+"px)"))),e.appendChild(a),this.addAnimationNode(a,t,i,r)}},{key:"createNodes",value:function(e,t,i){var r=gShowController.movieCache;return r&&"renderMovie"!==i.animationInfo.name&&this.setVideoLayer(i,r),this.addNode(e,t,i)}},{key:"setVideoLayer",value:function(e,t){var i=e.objectID,r=t[i+"-video"];if(r)if(1===e.layers.length)e.layers[0].textureId?(e.layers[0].isVideoLayer=!0,e.layers[0].movieObjectID=i):e.layers[0].layers[0].textureId&&(e.layers[0].layers[0].isVideoLayer=!0,e.layers[0].layers[0].movieObjectID=i);else{var n,a=!1;for(u=0,d=e.layers.length;u0&&D>0&&T.drawImage(w,0,0),this.setStyle(P,"0px","0px",b+"px",S+"px",kPositionAbsolutePropertyValue,null,null);else{var E=o*D,B=(a+s)*k,M=(o+l)*D,I=a*k,F=P.width=B-I,L=P.height=M-E;T.drawImage(w,I*pdfScaleFactor,E*pdfScaleFactor,F*pdfScaleFactor,L*pdfScaleFactor,0,0,F,L),this.setStyle(P,"0px","0px",F+"px",L+"px",kPositionAbsolutePropertyValue,null,null)}var N=P;N.setAttribute("id",x),"webkit"!==browserPrefix||null!==i.isTransition&&void 0!==i.isTransition||setElementProperty(N,kTransformPropertyName,A?"rotateY(180deg) translateZ(0px)":"translateZ(0px)"),i.isTransition&&(isChrome?this.enableCompositingUsingBackface?this.isGridTransition||this.isMosaicTransition||setElementProperty(N,kBackfaceVisibilityPropertyName,"hidden"):this.isSwooshTransition&&setElementProperty(N,kTransformPropertyName,"translateZ(0px)"):this.enableCompositingUsingBackface?setElementProperty(N,kBackfaceVisibilityPropertyName,"hidden"):setElementProperty(N,kTransformPropertyName,"translateZ(0px)"));var G,R,W=p.objectID,O=p&&"buildOut"===p.type;if(i.isVideoLayer||i.isWebVideoPosterLayer)if("renderMovie"===p.name||"renderWebVideo"===p.name){var U;if(p.movie){var K=C.getMovieUrl(this.sceneIndex,p.movie.asset);U=/(?:\.([^.]+))?$/.exec(K)[1]}if("gif"===U)R=new Image,this.setStyle(R,"0px","0px",b+"px",S+"px",kPositionAbsolutePropertyValue,null,null),R.addEventListener("load",this.hideElement.bind(this,N)),R.src=K;else{null!==gShowController.movieCache&&void 0!==gShowController.movieCache||(gShowController.movieCache={});var V=W+"-video";if(i.hasMovie=!0,i.movieId=V,null==(G=gShowController.movieCache[V])){var Q={objectID:W,movieId:V,width:b,height:S,sceneIndex:this.sceneIndex,textureId:x,src:K,showControls:!1===gShowController.isRecording,movieDiv:n,parentLayer:t,webVideo:p.webVideo};G=new KPFMovie(Q),gShowController.movieCache[V]=G,G.observeEvents(N)}}}else{var z=gShowController.movieCache;if(z)G=z[V=i.movieObjectID+"-video"]}if(i.hasContentsAnimation){for(var Y,X,H=i.cssAnimation.animations,j=0,_=H.length;j<_;j++)if("contents"===H[j].property){Y=H[j].to.texture,X=H[j].from.texture;break}var q=C.getTextureObject(this.sceneIndex,Y),J=document.createElement("canvas"),Z=J.getContext("2d"),$=(k=J.width=q.width)/b,ee=(D=J.height=q.height)/S;Z.drawImage(q,0,0),J.setAttribute("id",Y),$>1&&ee>1&&0!==$&&0!==ee?(this.setStyle(J,"0px","0px",k+"px",D+"px",kPositionAbsolutePropertyValue,null,null),setElementProperty(J,kTransformOriginPropertyName,"0% 0%"),setElementProperty(J,kTransformPropertyName,"scale("+1/$+","+1/ee+")")):this.setStyle(J,"0px","0px",b+"px",S+"px",kPositionAbsolutePropertyValue,null,null);var te=document.createElement("div");te.id=r+"-contents-to",this.setStyle(te,"0px","0px",b+"px",S+"px",kPositionAbsolutePropertyValue,null,null),te.appendChild(J),v.appendChild(te),setElementProperty(te,"opacity",0);var ie=C.getTextureObject(this.sceneIndex,X),re=document.createElement("canvas"),ne=re.getContext("2d");re.width=ie.width,re.height=ie.height,ne.drawImage(ie,0,0),re.setAttribute("id",X),this.setStyle(re,"0px","0px",b+"px",S+"px",kPositionAbsolutePropertyValue,null,null);var ae=document.createElement("div");ae.id=r+"-contents-from",this.setStyle(ae,"0px","0px",b+"px",S+"px",kPositionAbsolutePropertyValue,null,null),ae.appendChild(re),v.appendChild(ae)}else v.appendChild(N),R&&v.appendChild(R);G&&(G.isFirstRendered?(G.videoElement?v.insertBefore(G.videoElement,N):G.iframe&&v.insertBefore(G.iframe,N),G.isFirstRendered=!1):i.animationInfo&&"renderMovie"!==i.animationInfo.name&&"renderWebVideo"!==i.animationInfo.name&&(G.objectID===W&&O?(G.stopMovie(),G.removeControls(),G.isBuiltOut=!0):G.isBuiltOut||(v.parentNode.appendChild(G.movieDiv),v.style.visibility="hidden")))}else if(i.initialState.backgroundColor){var oe=i.initialState.backgroundColor;setElementProperty(v,"background-color","rgba("+parseInt(255*oe[0])+","+parseInt(255*oe[1])+","+parseInt(255*oe[2])+","+oe[3]+")")}for(var se=0,le=i.layers.length;set.duration&&(t.duration=e.cssAnimation.overallEndTime);for(var i=0,r=e.layers.length;i0){var a=i?"layer"+i.layerId:"layer"+t.layerId,o=document.getElementById(a);o?this.applyCssAnimation(o,t,i,e):e.currentKPFLayer&&(a="layer"+e.currentKPFLayer.layerId,e.currentKPFLayer.layers[0]&&(a="layer"+e.currentKPFLayer.layers[0].layerId),(o=document.getElementById(a))&&this.applyCssAnimation(o,t,e.currentKPFLayer,e))}else{if(t.isRenderMovie&&"renderMovie"===t.animationInfo.name){var s=gShowController.movieCache;if(s){var l=s[n];l&&(r.loopMode&&"looping"===r.loopMode&&l.setLoop(!0),r.volume&&l.setVolume(r.volume),l.startMovie())}}if(i){var h=document.getElementById("layer"+i.layerId),c=parseTransformMatrix(window.getComputedStyle(h,null).getPropertyValue(kTransformPropertyName)),u="matrix("+c[0]+","+c[1]+","+c[2]+","+c[3]+","+t.bounds.offset.pointX+","+t.bounds.offset.pointY+")";"apple:action-motion-path"===e.name&&setElementProperty(h,kTransformPropertyName,u)}}for(var d=0,f=t.layers.length;d0;)if(isIE)for(var d=0,f=u.cssRules.length;d0)for(var i=0,r=e.animations.length;i0)for(var n=0,a=e.layers.length;nt[n].beginTime+t[n].duration&&(t[n].duration=r.beginTime+r.duration);for(var l=0,h=r.effects.length;l0&&setTimeout(this.handleEffectDidComplete.bind(this,e),1e3*(e.beginTime+e.duration))}},{key:"animateEffectWillBegin",value:function(e){var t=e.canvasId,i=e.effect,r=this.glRenderer[t];r.draw(i),r.animationStarted||(r.animate(),r.animationStarted=!0);var n=document.getElementById(e.nodeToSwapId);n&&setTimeout(this.handleAnimateEffectDidBegin.bind(this,n),0)}},{key:"handleAnimateEffectDidBegin",value:function(e){e.style.opacity=0}},{key:"handleEffectDidComplete",value:function(e){for(var t=this.renderEffects(e.effects),i=0,r=t.length;ithis.eventOverallEndTime&&(this.eventOverallEndTime=i);for(var r=0,n=t.effects.length;rthis.thumbnailScroller.domNode.offsetHeight?this.thumbnailScroller.domNode.style.width="126px":this.thumbnailScroller.domNode.style.width="129px","ms"===browserPrefix&&(this.domNode.style.width="148px",this.thumbnailSidebar.domNode.style.left="-148px",this.thumbnailSidebar.domNode.style.width="137px",this.thumbnailScroller.domNode.style.width="137px")}},{key:"handleClickEvent",value:function(e){if(!gShowController.isRecording){var t=(e=e||window.event).target||e.srcElement;for("ms"===browserPrefix?e.cancelBubble=!0:e.stopPropagation();(null===t.slideNumber||void 0===t.slideNumber)&&"body"!==t.nodeName.toLowerCase();)t=t.parentNode;t.slideNumber&&(this.selectedSlideIndex=t.slideNumber,this.select(this.selectedSlideIndex))}}},{key:"select",value:function(e){gShowController.jumpToSlide(e)}},{key:"handleMouseOverEvent",value:function(e){var t=0,i=0;if((e=e||window.event).pageX||e.pageY?(t=e.pageX,i=e.pageY):(e.clientX||e.clientY)&&(t=e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)-document.documentElement.clientLeft,i=e.clientY+(document.documentElement.scrollTop||document.body.scrollTop)-document.documentElement.clientTop),0!==t||0!==i){var r=76*this.selectedSlideIndex,n=this.thumbnailScroller.domNode.scrollTop,a=this.thumbnailScroller.domNode.clientHeight;if(n>r)this.thumbnailScroller.domNode.scrollTop=r;else if(n+a=4/3?(r=88,n=Math.ceil(1/s*88)):(r=Math.ceil(66*s),n=66),this.slideThumbnail={width:r,height:n,top:Math.ceil((66-n)/2),left:Math.ceil((88-r)/2),scaleX:r/a,scaleY:n/o}}"svg"===t.nodeName.toLowerCase()&&t.firstElementChild.setAttribute("transform","matrix("+this.slideThumbnail.scaleX+",0,0,"+this.slideThumbnail.scaleY+",0,0)"),t.setAttribute("style",kTransitionPropertyName+":opacity; "+kTransitionDurationName+":500; width:"+this.slideThumbnail.width+"px; height:"+this.slideThumbnail.height+"px; left:"+this.slideThumbnail.left+"px; top:"+this.slideThumbnail.top+"px; opacity: 0; position: absolute;"),t.setAttribute("draggable",!1),"moz"===browserPrefix&&t.addEventListener("dragstart",(function(e){e.preventDefault()})),i.appendChild(t),t.style.opacity=1}}]),e}(),NavigatorLeftSidebar=function e(){_classCallCheck(this,e),this.domNode=document.createElement("div"),this.domNode.setAttribute("class","navigatorLeftSidebar")},NavigatorThumbnailSidebar=function(){function e(){_classCallCheck(this,e),this.domNode=document.createElement("div"),this.domNode.setAttribute("class","navigatorThumbnailSidebar")}return _createClass(e,[{key:"show",value:function(e){e.domNode.style.visibility="hidden",this.domNode.style.left="0px",gShowController.displayManager.navigatorIsShowing=!0,gShowController.displayManager.clearTimeoutForCursor()}},{key:"hide",value:function(e){e.domNode.style.visibility="visible",this.domNode.style.left="-140px",gShowController.displayManager.navigatorIsShowing=!1,gShowController.displayManager.setTimeoutForCursor()}}]),e}(),NavigatorThumbnailScroller=function e(){_classCallCheck(this,e),this.domNode=document.createElement("div"),this.domNode.setAttribute("class","navigatorThumbnailScroller")},NavigatorThumbnailSelection=function(){function e(t){_classCallCheck(this,e),this.domNode=document.createElement("div"),this.domNode.setAttribute("class","navigatorThumbnailSelection")}return _createClass(e,[{key:"select",value:function(e){this.domNode.style.top=76*e+"px",this.domNode.style.display="block"}}]),e}(),NavigatorThumbnailContainer=function(){function e(){_classCallCheck(this,e),this.domNode=document.createElement("div"),this.domNode.setAttribute("class","navigatorThumbnailContainer"),this.thumbnailItems=[]}return _createClass(e,[{key:"addItem",value:function(e){this.thumbnailItems.push(e),this.domNode.appendChild(e.domNode)}}]),e}(),NavigatorThumbnailItem=function e(){_classCallCheck(this,e),this.domNode=document.createElement("div"),this.domNode.setAttribute("class","navigatorThumbnailItem"),this.thumbnailContentNode=document.createElement("div"),this.thumbnailContentNode.setAttribute("style","position: absolute; height: 76px; width: 119px;"),this.numberNode=document.createElement("div"),this.numberNode.setAttribute("style","position: absolute; bottom: 1px; width: 20px; height: 20px; text-align: right; font-weight: bold; color: white;"),this.imageNode=document.createElement("div"),this.imageNode.setAttribute("style","position: absolute; left: 24px; width: 95px; height: 76px;"),this.thumb=document.createElement("div"),this.thumb.setAttribute("style","position: absolute; top: 4px; width: 90px; height: 68px;"),this.canvasContainer=document.createElement("div"),this.canvasContainer.setAttribute("class","navigatorThumbnailItemCanvasContainer"),this.thumb.appendChild(this.canvasContainer),this.imageNode.appendChild(this.thumb),this.thumbnailContentNode.appendChild(this.numberNode),this.thumbnailContentNode.appendChild(this.imageNode),this.domNode.appendChild(this.thumbnailContentNode)};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i-1}function KNEffectIsEmphasisEffect(e){return[KNActionPopName,KNActionPulseName,KNActionBlinkName,KNActionFlipName,KNActionBounceName,KNActionJiggleName].indexOf(e)>-1}var TSDTextureType={Unknown:0,Background:1,Shadow:2,ContactShadow:3,GroupedShadow:4,Object:5,Text:6,StrokeParameterized:7,Stroke:8,StrokeLineEndForHead:9,StrokeLineEndForTail:10,Reflection:11,FrameMask:12,ReflectionMask:13},KNWebGLShader={defaultTexture:{attribNames:["Position","TexCoord"],uniformNames:["MVPMatrix","Texture"],vertex:" #ifdef GL_ES\n precision highp float;\n #endif\n uniform mat4 MVPMatrix;\n attribute vec4 Position;\n attribute vec2 TexCoord;\n varying vec2 v_TexCoord;\n void main()\n {\n v_TexCoord = TexCoord;\n gl_Position = (MVPMatrix * Position);\n } ",fragment:" #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D Texture;\n varying vec2 v_TexCoord;\n void main()\n {\n gl_FragColor = texture2D(Texture, v_TexCoord);\n } "},defaultTextureAndOpacity:{attribNames:["Position","TexCoord"],uniformNames:["MVPMatrix","Texture","Opacity"],vertex:" #ifdef GL_ES\n precision highp float;\n #endif\n uniform mat4 MVPMatrix;\n attribute vec4 Position;\n attribute vec2 TexCoord;\n varying vec2 v_TexCoord;\n void main()\n {\n v_TexCoord = TexCoord;\n gl_Position = (MVPMatrix * Position);\n } ",fragment:" #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D Texture;\n uniform float Opacity;\n varying vec2 v_TexCoord;\n void main()\n {\n vec4 texColor = texture2D(Texture, v_TexCoord);\n gl_FragColor = vec4(Opacity) * texColor;\n } "},contentsAndOpacity:{attribNames:["Position","TexCoord"],uniformNames:["MVPMatrix","Texture","Texture2","mixFactor","Opacity"],vertex:" #ifdef GL_ES\n precision highp float;\n #endif\n uniform mat4 MVPMatrix;\n attribute vec4 Position;\n attribute vec2 TexCoord;\n varying vec2 v_TexCoord;\n void main()\n {\n v_TexCoord = TexCoord;\n gl_Position = (MVPMatrix * Position);\n } ",fragment:" #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D Texture;\n uniform sampler2D Texture2;\n uniform float mixFactor;\n uniform float Opacity;\n varying vec2 v_TexCoord;\n void main()\n {\n vec4 outgoingColor = texture2D(Texture2, v_TexCoord);\n vec4 incomingColor = texture2D(Texture, v_TexCoord);\n vec4 result = mix(outgoingColor, incomingColor, mixFactor);\n\t gl_FragColor = vec4(Opacity) * result;\n } "},contents:{attribNames:["Position","TexCoord"],uniformNames:["MVPMatrix","Texture","Texture2","mixFactor"],vertex:" #ifdef GL_ES\n precision highp float;\n #endif\n uniform mat4 MVPMatrix;\n attribute vec4 Position;\n attribute vec2 TexCoord;\n varying vec2 v_TexCoord;\n void main()\n {\n v_TexCoord = TexCoord;\n gl_Position = (MVPMatrix * Position);\n } ",fragment:" #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D Texture;\n uniform sampler2D Texture2;\n uniform float mixFactor;\n varying vec2 v_TexCoord;\n void main()\n {\n vec4 outgoingColor = texture2D(Texture2, v_TexCoord);\n vec4 incomingColor = texture2D(Texture, v_TexCoord);\n vec4 result = mix(outgoingColor, incomingColor, mixFactor);\n gl_FragColor = result;\n } "},iris:{attribNames:["Position","TexCoord"],uniformNames:["PercentForAlpha","Scale","Mix","Texture","MVPMatrix","Opacity"],vertex:" #ifdef GL_ES\n precision highp float;\n #endif\n uniform mat4 MVPMatrix;\n attribute vec4 Position;\n attribute vec2 TexCoord;\n varying vec2 v_TexCoord;\n void main()\n {\n v_TexCoord = TexCoord;\n gl_Position = MVPMatrix * Position;\n } ",fragment:" #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D Texture;\n uniform float Opacity;\n uniform float PercentForAlpha;\n uniform float Scale;\n uniform float Mix;\n varying vec2 v_TexCoord;\n void main()\n {\n vec4 incomingTexColor = texture2D(Texture, v_TexCoord);\n vec4 clear = vec4(0.0, 0.0, 0.0, 0.0);\n float tolerance = PercentForAlpha/5.0;\n vec2 powers = vec2((v_TexCoord.x - 0.5) * Scale,v_TexCoord.y - 0.5);\n powers *= powers;\n float radiusSqrd = PercentForAlpha * PercentForAlpha;\n float dist = (powers.x+powers.y)/((0.5*Scale)*(0.5*Scale)+0.25);\n float gradient = smoothstep(radiusSqrd, radiusSqrd+tolerance, dist);\n gl_FragColor = vec4(Opacity) * mix(clear, incomingTexColor, abs(Mix - gradient));\n } "},twist:{attribNames:["Position","TexCoord","Normal"],uniformNames:["TextureMatrix","SpecularColor","FlipNormals","MVPMatrix","Texture"],vertex:" #ifdef GL_ES\n precision highp float;\n #endif\n uniform mat4 MVPMatrix;\n uniform mat3 TextureMatrix;\n uniform float SpecularColor;\n uniform mediump float FlipNormals;\n attribute vec3 Position;\n attribute vec3 Normal;\n attribute vec2 TexCoord;\n varying vec2 v_TexCoord;\n varying vec3 v_DiffuseColor;\n varying vec3 v_SpecularColor;\n const vec3 c_AmbientColor = vec3(0.2);\n const vec3 c_DiffuseColor = vec3(1);\n const float c_LightExponent = 32.0;\n const vec3 c_LightDirection = vec3(0.1580, +0.5925, 0.7900);\n const vec3 c_LightHalfPlane = vec3(0.0835, +0.3131, 0.9460);\n void main()\n {\n vec3 thisNormal = Normal * FlipNormals;\n // Lighting\n float ndotl = max(0.0, dot(thisNormal, c_LightDirection));\n float ndoth = max(0.0, dot(thisNormal, c_LightHalfPlane));\n v_DiffuseColor = (c_AmbientColor + ndotl * c_DiffuseColor);\n v_SpecularColor = (ndoth <= 0.0) ? vec3(0) : (pow(ndoth, c_LightExponent) * vec3(SpecularColor));\n gl_Position = MVPMatrix * vec4(Position, 1.0);\n v_TexCoord = (TextureMatrix * vec3(TexCoord,1.0)).xy;\n } ",fragment:" #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D Texture;\n varying vec2 v_TexCoord;\n varying vec3 v_DiffuseColor;\n varying vec3 v_SpecularColor;\n void main()\n {\n vec4 texColor = texture2D(Texture, v_TexCoord);\n // Lighting\n texColor.xyz = texColor.xyz * v_DiffuseColor + v_SpecularColor;\n gl_FragColor = texColor;\n } "},colorPlanes:{attribNames:["Position","TexCoord"],uniformNames:["MVPMatrix","FlipTexCoords","Texture","ColorMask"],vertex:" #ifdef GL_ES\n precision highp float;\n #endif\n uniform mat4 MVPMatrix;\n uniform vec2 FlipTexCoords;\n attribute vec2 Position;\n attribute vec2 TexCoord;\n varying vec2 v_TexCoord;\n void main()\n {\n v_TexCoord = vec2(FlipTexCoords.x == 0.0 ? TexCoord.x : 1.0-TexCoord.x, FlipTexCoords.y == 0.0 ? TexCoord.y : 1.0-TexCoord.y);\n gl_Position = MVPMatrix * vec4(Position, 0,1);\n } ",fragment:" #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D Texture;\n uniform vec4 ColorMask;\n varying vec2 v_TexCoord;\n void main()\n {\n vec4 texColor = texture2D(Texture, v_TexCoord);\n texColor *= ColorMask;\n gl_FragColor = texColor;\n } "},flop:{attribNames:["Position","TexCoord","Normal"],uniformNames:["TextureMatrix","FlipNormals","MVPMatrix","Texture"],vertex:" \n #ifdef GL_ES\n precision highp float;\n #endif\n \n uniform mat4 MVPMatrix;\n uniform mat3 TextureMatrix;\n uniform float FlipNormals;\n \n attribute vec3 Position;\n attribute vec3 Normal;\n attribute vec2 TexCoord;\n \n varying vec2 v_TexCoord;\n varying vec3 v_DiffuseColor;\n \n const vec3 c_AmbientColor = vec3(0.1);\n const vec3 c_DiffuseColor = vec3(1);\n const float c_LightExponent = 32.0;\n \n const vec3 c_LightDirection = vec3(0.000, +0.000, 0.900);\n \n void main()\n {\n vec3 thisNormal = Normal * FlipNormals;\n \n // Lighting\n vec3 lightDirection = vec3(c_LightDirection.x,c_LightDirection.y,c_LightDirection.z);\n \n float ndotl = max(0.0, dot(thisNormal, lightDirection));\n \n v_DiffuseColor = (c_AmbientColor + ndotl * c_DiffuseColor);\n \n gl_Position = MVPMatrix * vec4(Position, 1);\n v_TexCoord = (TextureMatrix * vec3(TexCoord,1)).xy;\n } ",fragment:" \n #ifdef GL_ES\n precision mediump float;\n #endif\n \n uniform sampler2D Texture;\n \n varying vec2 v_TexCoord;\n varying vec3 v_DiffuseColor;\n \n void main()\n {\n vec4 texColor = texture2D(Texture, v_TexCoord);\n \n // Lighting\n texColor.xyz = texColor.xyz * v_DiffuseColor;\n gl_FragColor = texColor;\n } "},anvilsmoke:{attribNames:["Rotation","Speed","Scale","LifeSpan","ParticleTexCoord","Center","Position"],uniformNames:["Percent","Opacity","ParticleTexture","MVPMatrix"],vertex:" \n uniform mat4 MVPMatrix;\n uniform float Percent;\n uniform float Opacity;\n \n attribute vec2 Position;\n attribute vec2 Center;\n attribute vec2 ParticleTexCoord;\n attribute vec3 Rotation;\n attribute vec3 Speed;\n attribute float Scale;\n attribute vec2 LifeSpan;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n const float Pi = 3.1415926;\n const float Pi_2 = 1.5707963;\n const float TwoPi = 6.2831852;\n \n const float sineConstB = 1.2732396; /* = 4./Pi; */\n const float sineConstC = -0.40528476; /* = -4./(Pi*Pi); */\n \n vec3 fastSine(vec3 angle)\n {\n vec3 theAngle = mod(angle + Pi, TwoPi) - Pi;\n return sineConstB * theAngle + sineConstC * theAngle * abs(theAngle);\n }\n \n mat3 fastRotationMatrix(vec3 theRotation)\n {\n vec3 sinXYZ = fastSine(theRotation);\n vec3 cosXYZ = fastSine(Pi_2 - theRotation);\n mat3 rotMatrix = mat3( cosXYZ.y*cosXYZ.z, sinXYZ.x*sinXYZ.y*cosXYZ.z+cosXYZ.x*sinXYZ.z, -cosXYZ.x*sinXYZ.y*cosXYZ.z+sinXYZ.x*sinXYZ.z,\n -cosXYZ.y*sinXYZ.z, -sinXYZ.x*sinXYZ.y*sinXYZ.z+cosXYZ.x*cosXYZ.z, cosXYZ.x*sinXYZ.y*sinXYZ.z+sinXYZ.x*cosXYZ.z,\n sinXYZ.y, -sinXYZ.x*cosXYZ.y, cosXYZ.x*cosXYZ.y);\n return rotMatrix;\n }\n \n void main()\n {\n float realPercent = (Percent-LifeSpan.x)/LifeSpan.y;\n realPercent = clamp(realPercent, 0.0, 1.0);\n realPercent = sqrt(realPercent);\n \n /* SCALE */\n vec4 originalPosition = vec4(Position,0,1);\n vec4 center = vec4(Center, 0,1);\n vec3 scaleDirectionVec = vec3(originalPosition.xy-center.xy,0) * Scale * mix(0.1, 1.0, realPercent);\n \n /* ROTATE */\n mat3 rotMatrix = fastRotationMatrix(Rotation * realPercent);\n vec3 rotatedVec = rotMatrix * scaleDirectionVec;\n vec4 position = center + vec4(rotatedVec,0);\n \n float speedAdjust = realPercent;\n vec3 thisSpeed = Speed;\n thisSpeed.x *= sqrt(realPercent);\n thisSpeed.y *= realPercent*realPercent;\n position += vec4(thisSpeed, 0);\n \n float thisOpacity = Opacity;\n thisOpacity *= (1.0 - realPercent); /* fade out gradually */\n thisOpacity *= min(1.0, realPercent*20.0); /* fade in quickly */\n \n /* output */\n gl_Position = MVPMatrix * position;\n //v_Color = vec4(1.0, 1.0, 1.0, thisOpacity); //we applied a fix here, might not work everywhere\n v_Color = vec4(thisOpacity);\n v_TexCoord = ParticleTexCoord;\n }\n ",fragment:" \n #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D ParticleTexture;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n void main()\n {\n vec4 texColor = texture2D(ParticleTexture, v_TexCoord);\n \n texColor *= v_Color;\n \n gl_FragColor = texColor;\n }\n "},anvilspeck:{attribNames:["Speed","Scale","LifeSpan","ParticleTexCoord","Center","Position"],uniformNames:["Percent","Opacity","ParticleTexture","MVPMatrix"],vertex:" \n uniform mat4 MVPMatrix;\n uniform float Percent;\n uniform float Opacity;\n \n attribute vec2 Position;\n attribute vec2 Center;\n attribute vec2 ParticleTexCoord;\n attribute vec3 Speed;\n attribute float Scale;\n attribute vec2 LifeSpan;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n const float Pi = 3.1415926;\n const float Pi_2 = 1.5707963;\n const float TwoPi = 6.2831852;\n \n const float sineConstB = 1.2732396; /* = 4./Pi; */\n const float sineConstC = -0.40528476; /* = -4./(Pi*Pi); */\n \n vec3 fastSine(vec3 angle)\n {\n vec3 theAngle = mod(angle + Pi, TwoPi) - Pi;\n return sineConstB * theAngle + sineConstC * theAngle * abs(theAngle);\n }\n \n void main()\n {\n float realPercent = (Percent-LifeSpan.x)/LifeSpan.y;\n realPercent = clamp(realPercent, 0.0, 1.0);\n \n /* SCALE */\n vec4 originalPosition = vec4(Position,0,1);\n vec4 center = vec4(Center, 0,1);\n vec3 thisScale = Scale * vec3(1, Speed.z, 1) * mix(0.1, 1.0, realPercent);\n vec3 scaleDirectionVec = vec3(originalPosition.xy-center.xy,0) * thisScale;\n \n vec4 position = center + vec4(scaleDirectionVec,0);\n \n float speedAdjust = realPercent;\n vec3 thisPos = vec3(Speed.x * realPercent,\n Speed.y * fastSine(Pi*0.85*vec3(realPercent,0,0)).x, /* arc with gravity */\n 0);\n position += vec4(thisPos, 0);\n \n float thisOpacity = Opacity;\n thisOpacity *= (1.0 - realPercent); /* fade out gradually */\n thisOpacity *= min(1.0, realPercent*20.0); /* fade in quickly */\n \n /* output */\n gl_Position = MVPMatrix * position;\n v_Color = vec4(thisOpacity);\n v_TexCoord = ParticleTexCoord;\n } ",fragment:" \n #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D ParticleTexture;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n void main()\n {\n vec4 texColor = texture2D(ParticleTexture, v_TexCoord);\n \n texColor *= v_Color;\n \n gl_FragColor = texColor;\n } "},flame:{attribNames:["Rotation","Speed","LifeSpan","ParticleTexCoord","Center","Position"],uniformNames:["Percent","Duration","Opacity","RotationMax","SpeedMax","ParticleTexture","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n uniform float Percent;\n uniform float Duration;\n \n attribute vec3 Rotation;\n attribute vec3 Speed;\n uniform float Opacity;\n attribute vec2 LifeSpan;\n attribute vec2 ParticleTexCoord;\n attribute vec2 Position;\n attribute vec2 Center;\n \n uniform mediump float RotationMax;\n uniform mediump float SpeedMax;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n const float Pi = 3.1415926;\n const float Pi_2 = 1.5707963;\n const float TwoPi = 6.2831852;\n \n const float sineConstB = 1.2732396; /* = 4./Pi; */\n const float sineConstC = -0.40528476; /* = -4./(Pi*Pi); */\n \n float fastSine(float angle)\n {\n float theAngle = mod(angle + Pi, TwoPi) - Pi;\n return sineConstB * theAngle + sineConstC * theAngle * abs(theAngle);\n }\n \n const vec4 kStartColor = vec4( 1.0, 1.0, 1.0, 0.0 ); /* white */\n const vec4 kMidColor = vec4( 0.97, 1.0, 0.32, 0.0 ); /* yellow */\n const vec4 kEndColor = vec4( 0.9, 0.0, 0.0, 0.0 ); /* red */\n const float kColorMidPoint = 0.1;\n \n vec4 flameColor(float aPercent)\n {\n float thePercent = aPercent;\n /* CONSTANTS */\n float beginCutoff = 0.4/Duration; /* start slow (not bright white) */\n float smokeCutoff = 1.0 - (0.95/Duration); /* end with black, basically */\n float alphaCutoff = 1.0 - 0.5/Duration; /* fade out towards the end */\n \n float alpha = (thePercent < alphaCutoff) ? 1.0 : (1.0-(thePercent-alphaCutoff)/(1.0-alphaCutoff));\n vec4 theColor = vec4(0,0,0, alpha * 0.75);\n \n if (Percent < beginCutoff) {\n float colorCutoff = beginCutoff*3.0;\n thePercent += mix(colorCutoff, 0.0, Percent/beginCutoff);\n }\n \n if (thePercent < kColorMidPoint) {\n float newPercent = thePercent/kColorMidPoint;\n theColor += mix(kStartColor, kMidColor, newPercent);\n } else {\n float newPercent = (thePercent-kColorMidPoint)/(1.0-kColorMidPoint);\n theColor += mix(kMidColor, kEndColor, newPercent);\n }\n \n if (Percent > smokeCutoff) {\n /* smoke */\n float smokeAmount = (Percent - smokeCutoff)/(1.0 - smokeCutoff);\n smokeAmount = sqrt(smokeAmount);\n smokeAmount *= (0.25+thePercent*thePercent);\n theColor = vec4(theColor.rgb * max(0.0, 1.0-smokeAmount), theColor.a);\n }\n \n return theColor;\n }\n \n void main()\n {\n float realPercent = (Percent-LifeSpan.x)/LifeSpan.y;\n bool shouldDiscard = realPercent < 0.0 || realPercent > 1.0;\n realPercent = clamp(realPercent, 0.0, 1.0);\n \n vec4 scaleDirectionVec = vec4(Position-Center,0,0);\n \n /* ROTATE */\n float halfPercent = realPercent/2.0;\n vec3 thisRotation = Rotation * RotationMax;\n float theRotation = thisRotation.x + thisRotation.z * (halfPercent * (halfPercent + 1.0));\n float sinRot = fastSine(theRotation);\n float cosRot = fastSine(Pi_2 - theRotation);\n mat3 rotMatrix = mat3(cosRot,-sinRot,0, sinRot,cosRot,0, 0,0,1);\n vec3 rotatedVec = rotMatrix * scaleDirectionVec.xyz;\n \n /* SCALE */\n float scaleAdjust = (0.1 + 1.0-(1.0-realPercent)*(1.0-realPercent));\n vec4 position = vec4(Center,0,1) + vec4(rotatedVec * scaleAdjust * (shouldDiscard ? 0.001 : 1.0), 0);\n \n /* POSITION */\n vec3 thisSpeed = Speed * SpeedMax;\n vec4 upVector = vec4(0.0, realPercent*realPercent * -thisSpeed.y, 0.0, 0.0);\n position += upVector;\n \n v_Color = flameColor(realPercent)*Opacity;\n gl_Position = MVPMatrix * position;\n v_TexCoord = ParticleTexCoord;\n } ",fragment:" \n #ifdef GL_ES\n precision mediump float;\n #endif\n uniform sampler2D ParticleTexture;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n void main()\n {\n vec4 texColor = texture2D(ParticleTexture, v_TexCoord);\n \n texColor *= v_Color;\n \n gl_FragColor = texColor;\n }\n "},confetti:{attribNames:["Rotation","Speed","TexCoord","Center","Position"],uniformNames:["Percent","Opacity","ParticleTexture","MVPMatrix"],vertex:" \n precision highp float;\n uniform mat4 MVPMatrix;\n \n uniform float Percent;\n uniform mediump float Opacity;\n \n attribute vec2 Position;\n attribute vec2 Center;\n attribute vec2 TexCoord;\n attribute vec3 Rotation;\n attribute vec3 Speed;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n const float Pi = 3.1415926;\n const float Pi_2 = 1.5707963;\n const float TwoPi = 6.2831852;\n \n const float sineConstB = 1.2732396;\n const float sineConstC = -0.40528476;\n \n vec3 fastSine(vec3 angle)\n {\n vec3 theAngle = mod(angle + Pi, TwoPi) - Pi;\n return sineConstB * theAngle + sineConstC * theAngle * abs(theAngle);\n }\n \n mat3 fastRotationMatrix(vec3 theRotation)\n {\n vec3 sinXYZ = fastSine(theRotation);\n vec3 cosXYZ = fastSine(Pi_2 - theRotation);\n mat3 rotMatrix = mat3( cosXYZ.y*cosXYZ.z, sinXYZ.x*sinXYZ.y*cosXYZ.z+cosXYZ.x*sinXYZ.z, -cosXYZ.x*sinXYZ.y*cosXYZ.z+sinXYZ.x*sinXYZ.z,\n -cosXYZ.y*sinXYZ.z, -sinXYZ.x*sinXYZ.y*sinXYZ.z+cosXYZ.x*cosXYZ.z, cosXYZ.x*sinXYZ.y*sinXYZ.z+sinXYZ.x*cosXYZ.z,\n sinXYZ.y, -sinXYZ.x*cosXYZ.y, cosXYZ.x*cosXYZ.y);\n return rotMatrix;\n }\n \n void main()\n {\n /* SCALE */\n vec4 originalPosition = vec4(Position, 0, 1);\n vec3 scaleDirectionVec = vec3(Position-Center,0);\n \n /* ROTATE */\n mat3 rotMatrix = fastRotationMatrix(Rotation * Percent);\n vec3 rotatedVec = scaleDirectionVec * rotMatrix;\n vec4 position = vec4(Center,0,1) + vec4(rotatedVec,0);\n \n float colorAdjust = abs((rotMatrix * vec3(0,0,1)).z);\n \n float speedAdjust = Percent;\n position += vec4(Speed, 0) * speedAdjust;\n \n /* output */\n gl_Position = MVPMatrix * position;\n v_Color = vec4(vec3(colorAdjust), Opacity);\n v_TexCoord = TexCoord;\n } ",fragment:" \n precision mediump float;\n \n uniform sampler2D ParticleTexture;\n //uniform float Opacity;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n void main()\n {\n vec4 texColor = texture2D(ParticleTexture, v_TexCoord);\n \n texColor *= v_Color;\n //texColor.a = Opacity;\n \n gl_FragColor = texColor;\n } "},diffuse:{attribNames:["Rotation","Speed","TexCoord","Center","Position","LifeSpan"],uniformNames:["Percent","Opacity","ParticleTexture","MVPMatrix","RotationMax","SpeedMax"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n \n uniform float Percent;\n uniform mediump float Opacity;\n \n attribute vec2 Position;\n attribute vec2 Center;\n attribute vec2 TexCoord;\n \n attribute mediump vec3 Rotation;\n uniform mediump float RotationMax;\n attribute mediump vec3 Speed;\n uniform mediump float SpeedMax;\n attribute mediump vec2 LifeSpan;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n const float Pi = 3.1415926;\n const float Pi_2 = 1.5707963;\n const float TwoPi = 6.2831852;\n \n const float sineConstB = 1.2732396;\n const float sineConstC = -0.40528476;\n \n vec3 fastSine(vec3 angle)\n {\n vec3 theAngle = mod(angle + Pi, TwoPi) - Pi;\n return sineConstB * theAngle + sineConstC * theAngle * abs(theAngle);\n }\n \n mat3 fastRotationMatrix(vec3 theRotation)\n {\n vec3 sinXYZ = fastSine(theRotation);\n vec3 cosXYZ = fastSine(Pi_2 - theRotation);\n mat3 rotMatrix = mat3( cosXYZ.y*cosXYZ.z, sinXYZ.x*sinXYZ.y*cosXYZ.z+cosXYZ.x*sinXYZ.z, -cosXYZ.x*sinXYZ.y*cosXYZ.z+sinXYZ.x*sinXYZ.z,\n -cosXYZ.y*sinXYZ.z, -sinXYZ.x*sinXYZ.y*sinXYZ.z+cosXYZ.x*cosXYZ.z, cosXYZ.x*sinXYZ.y*sinXYZ.z+sinXYZ.x*cosXYZ.z,\n sinXYZ.y, -sinXYZ.x*cosXYZ.y, cosXYZ.x*cosXYZ.y);\n return rotMatrix;\n }\n \n void main()\n {\n float realPercent = (Percent-LifeSpan.x)/LifeSpan.y;\n float doDiscard = (realPercent > 1.0) ? 0.0 : 1.0;\n realPercent = clamp(realPercent, 0.0,1.0);\n float revPercent = 1.0-realPercent;\n \n //SCALE\n vec4 originalPosition = vec4(Position, 0, 1);\n vec3 scaleDirectionVec = vec3(Position-Center,0);\n \n //ROTATE\n vec3 thisRotation = Rotation * RotationMax;\n mat3 rotMatrix = fastRotationMatrix(thisRotation * realPercent);\n vec3 rotatedVec = scaleDirectionVec * rotMatrix;\n vec4 position = vec4(Center,0,1) + vec4(rotatedVec,0) * doDiscard;\n \n vec3 thisSpeed = Speed * SpeedMax;\n float l2r = -thisSpeed.x/abs(thisSpeed.x);\n float reverseVector = l2r*(thisSpeed.x+abs(thisSpeed.y)) * realPercent/8.0;\n \n float speedMultiplier = 1.-pow(revPercent, 2.0);\n vec3 dist = thisSpeed * speedMultiplier;\n dist.x += reverseVector;\n position.xyz += dist;\n \n float colorAdjust = abs((rotMatrix * vec3(0,0,1)).z);\n \n //output\n gl_Position = MVPMatrix * position;\n v_Color = vec4(vec3(colorAdjust), 1) * (revPercent*Opacity);\n v_TexCoord = TexCoord;\n } ",fragment:" \n precision mediump float;\n \n uniform sampler2D Texture;\n uniform float Opacity;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n void main()\n {\n vec4 texColor = texture2D(Texture, v_TexCoord);\n \n texColor *= v_Color;\n \n gl_FragColor = texColor;\n } "},fireworks:{attribNames:["Color","Speed","LifeSpan","Scale","ParticleTexCoord","Center","Position"],uniformNames:["Percent","PreviousPercent","Gravity","StartScale","ShouldSparkle","SparklePeriod","ParticleBurstTiming","PreviousParticleBurstTiming","SpeedMax","ParticleTexture","Opacity","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n \n uniform float Percent;\n uniform float PreviousPercent;\n uniform float Gravity;\n uniform float StartScale;\n uniform float ShouldSparkle;\n uniform float SparklePeriod;\n uniform float ParticleBurstTiming;\n uniform float PreviousParticleBurstTiming;\n uniform float SpeedMax;\n \n attribute vec2 Position;\n attribute vec2 Center;\n attribute vec2 ParticleTexCoord;\n \n attribute vec4 Color;\n attribute vec3 Speed;\n attribute vec2 LifeSpan;\n attribute float Scale;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n void main()\n {\n float realPercent = (Percent-LifeSpan.x)/LifeSpan.y;\n realPercent = clamp(realPercent, 0.0, 1.0);\n \n float prevRealPercent = (PreviousPercent-LifeSpan.x)/LifeSpan.y;\n prevRealPercent = clamp(prevRealPercent, 0.0,1.0);\n \n vec4 center = vec4(Center,0,1);\n vec4 scaleDirectionVec = vec4(Position-Center,0,0);\n \n // TRANSLATE\n vec3 translation = Speed * (SpeedMax * ParticleBurstTiming); // (1.0-pow(1.0-realPercent, ExplosionPower));\n translation.y -= Gravity * (Percent - LifeSpan.x); // Gravity is in terms of global percent, not particle system percent\n \n vec3 prevTranslation = Speed * (SpeedMax * PreviousParticleBurstTiming);\n prevTranslation.y -= Gravity * (PreviousPercent - LifeSpan.x); // Gravity is in terms of global percent, not particle system percent\n \n vec3 blurOffset = translation - prevTranslation; // Blur in direction of velocity\n \n // project centerVec onto translationOffset to get direction\n blurOffset *= (dot(blurOffset, scaleDirectionVec.xyz) >= 0.0 ? 1.0 : -1.0);\n \n center.xyz += translation;\n \n // SCALE\n float scalePercent = (1.0-(1.0-realPercent)*(1.0-realPercent));\n float scaleAdjust = mix(StartScale, Scale, scalePercent);\n // scale down to zero, unless we're sparkling\n scaleAdjust *= (ShouldSparkle>0.5 ? 0.25 : 1.0-scalePercent);\n vec4 position = center + scaleDirectionVec * scaleAdjust;\n position += vec4(blurOffset,0);\n \n // SPARKLE\n float sparkleOpacity = fract(realPercent*realPercent * SparklePeriod);\n sparkleOpacity = smoothstep(0.0, 1.0, sparkleOpacity);\n \n // COLOR\n vec4 color = mix(vec4(1), Color, scalePercent * (ShouldSparkle<0.5 ? 1.0 : 0.5)); // white to color\n color *= (ShouldSparkle<0.5 ? 1.0 : sparkleOpacity); // apply sparkle opacity\n color *= (realPercent>=1.0 ? 0.0 : 1.0);\n v_Color = color;\n \n gl_Position = MVPMatrix * position;\n v_TexCoord = ParticleTexCoord;\n } ",fragment:" \n precision mediump float;\n \n uniform sampler2D ParticleTexture;\n uniform float Opacity;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n //varying float particleTexPercent;\n \n void main()\n {\n vec4 texColor = texture2D(ParticleTexture, v_TexCoord);\n \n texColor *= v_Color * Opacity;\n //texColor.a *= Opacity;\n \n //texColor = vec4(v_TexCoord, 0, 1);\n \n gl_FragColor = texColor;\n } "},fireworkstrails:{attribNames:["Position","TexCoord"],uniformNames:["Texture","Opacity","NoiseAmount","NoiseSeed","NoiseMax","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n \n attribute vec2 Position;\n attribute vec2 TexCoord;\n \n varying vec2 v_TexCoord;\n \n void main()\n {\n gl_Position = MVPMatrix * vec4(Position, 0,1);\n v_TexCoord = TexCoord;\n } ",fragment:" precision mediump float;\n \n uniform sampler2D Texture;\n uniform float Opacity;\n uniform float NoiseAmount;\n uniform vec2 NoiseSeed;\n uniform float NoiseMax;\n \n //varying vec4 v_Color;\n varying vec2 v_TexCoord;\n //varying float particleTexPercent;\n \n float rand(vec2 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n }\n \n float inverseSquare(float a) {\n return 1.0-(1.0-a)*(1.0-a);\n }\n \n void main()\n {\n vec4 texColor = texture2D(Texture, v_TexCoord);\n \n //texColor = bloom(texColor);\n \n // Dither transparency to add noise\n float randomNoise = NoiseMax*rand(v_TexCoord*NoiseSeed);\n float randomAmount = NoiseAmount * 1.5*max(0.0, texColor.a-0.3333);\n \n float thisOpacity = Opacity * mix(1.0, randomNoise, randomAmount);\n texColor *= thisOpacity;\n \n //texColor = vec4(v_TexCoord, 0, 1);\n \n gl_FragColor = texColor;\n } "},horizontalGaussianBlur:{attribNames:["Position"],uniformNames:["Texture","TextureSize","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n \n attribute vec2 Position;\n \n void main()\n {\n gl_Position = MVPMatrix * vec4(Position, 0, 1);\n } ",fragment:" precision highp float;\n \n uniform sampler2D Texture;\n uniform vec2 TextureSize;\n \n const vec2 offset1 = vec2(1.3846153846, 0);\n const vec2 offset2 = vec2(3.2307692308, 0);\n const float weight0 = 0.2270270270;\n const float weight1 = 0.3162162162;\n const float weight2 = 0.0702702703;\n \n void main()\n {\n vec4 color = texture2D(Texture, gl_FragCoord.xy*TextureSize) * weight0;\n \n color += texture2D(Texture, (gl_FragCoord.xy + offset1)*TextureSize) * weight1;\n color += texture2D(Texture, (gl_FragCoord.xy - offset1)*TextureSize) * weight1;\n \n color += texture2D(Texture, (gl_FragCoord.xy + offset2)*TextureSize) * weight2;\n color += texture2D(Texture, (gl_FragCoord.xy - offset2)*TextureSize) * weight2;\n \n gl_FragColor = color;\n } "},verticalGaussianBlur:{attribNames:["Position"],uniformNames:["Texture","TextureSize","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n \n attribute vec2 Position;\n \n void main()\n {\n gl_Position = MVPMatrix * vec4(Position, 0, 1);\n } ",fragment:" precision highp float;\n \n uniform sampler2D Texture;\n uniform vec2 TextureSize;\n \n const vec2 offset1 = vec2(0, 1.3846153846);\n const vec2 offset2 = vec2(0, 3.2307692308);\n const float weight0 = 0.2270270270;\n const float weight1 = 0.3162162162;\n const float weight2 = 0.0702702703;\n \n void main()\n {\n vec4 color = texture2D(Texture, gl_FragCoord.xy*TextureSize) * weight0;\n \n color += texture2D(Texture, (gl_FragCoord.xy + offset1)*TextureSize) * weight1;\n color += texture2D(Texture, (gl_FragCoord.xy - offset1)*TextureSize) * weight1;\n \n color += texture2D(Texture, (gl_FragCoord.xy + offset2)*TextureSize) * weight2;\n color += texture2D(Texture, (gl_FragCoord.xy - offset2)*TextureSize) * weight2;\n \n gl_FragColor = color;\n } "},bloom:{attribNames:["Position","TexCoord"],uniformNames:["Texture","BlurTexture","BloomAmount","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n \n attribute vec2 Position;\n attribute vec2 TexCoord;\n \n varying vec2 v_TexCoord;\n \n void main()\n {\n v_TexCoord = TexCoord;\n gl_Position = MVPMatrix * vec4(Position, 0, 1);\n } ",fragment:" precision mediump float;\n \n uniform sampler2D Texture;\n uniform sampler2D BlurTexture;\n uniform float BloomAmount;\n \n varying vec2 v_TexCoord;\n \n void main()\n {\n vec4 color = texture2D(Texture, v_TexCoord);\n vec4 blurColor = texture2D(BlurTexture, v_TexCoord);\n \n color += (blurColor + color) * BloomAmount;\n gl_FragColor = color;\n } "},shimmerObject:{attribNames:["Position","Center","TexCoord","Color","Speed"],uniformNames:["Percent","Opacity","RotationMatrix","SpeedMax","Texture","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n uniform float Percent;\n uniform float Opacity;\n \n uniform mat3 RotationMatrix;\n \n attribute vec2 Position;\n attribute vec2 Center;\n attribute vec2 TexCoord;\n attribute vec4 Color;\n \n attribute vec3 Speed;\n uniform float SpeedMax;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n void main()\n {\n float thisPercent = Percent;\n float invPercent = 1.0-thisPercent;\n float thisPercent2 = thisPercent*thisPercent;\n \n /* CENTER */\n vec3 scaleDirectionVec = vec3((Position.x-Center.x),(Position.y-Center.y),0);\n \n /* ROTATE */\n vec3 rotatedVec = RotationMatrix * scaleDirectionVec.xyz;\n \n /* SCALE */\n float scale = invPercent;\n vec4 position = vec4(Center.xy,0,1) + vec4(rotatedVec,0) * scale;\n \n vec3 thisSpeed = Speed * SpeedMax;\n position.xyz += thisSpeed * thisPercent*(3.0 + mix(thisPercent2*thisPercent, 1.0-invPercent*invPercent, thisPercent2));\n \n vec4 outColor = Color;\n outColor = vec4(Opacity);\n \n /* output */\n gl_Position = MVPMatrix * position;\n v_Color = outColor;\n v_TexCoord = TexCoord;\n }\n ",fragment:" precision mediump float;\n \n uniform sampler2D Texture;\n \n varying vec4 v_Color;\n\t\tvarying vec2 v_TexCoord;\n \n void main()\n {\n vec4 color = texture2D(Texture, v_TexCoord);\n \n color *= v_Color;\n \n gl_FragColor = color;\n } "},shimmerParticle:{attribNames:["Position","Center","ParticleTexCoord","Color","LifeSpan","Speed","Scale"],uniformNames:["Percent","Opacity","ParticleScalePercent","RotationMatrix","SpeedMax","ParticleTexture","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n uniform float Percent;\n uniform float Opacity;\n \n uniform float ParticleScalePercent;\n uniform mat3 RotationMatrix;\n \n attribute vec2 Position;\n attribute vec2 Center;\n attribute vec2 ParticleTexCoord;\n attribute vec4 Color;\n attribute vec2 LifeSpan;\n \n attribute vec3 Speed;\n uniform float SpeedMax;\n attribute float Scale;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n float scaleUpDown(float x) {\n float result = 1.0 - abs(2.0*(x-0.5));\n result *= result;\n return result;\n }\n \n void main()\n {\n /* LIFESPAN */\n float realPercent = (Percent-LifeSpan.x)/LifeSpan.y;\n float doDiscard = (realPercent > 1.0 || realPercent < 0.0) ? 0.0 : 1.0;\n realPercent = clamp(realPercent, 0.0,1.0);\n float realPercent2 = realPercent*realPercent;\n float invPercent2 = 1.0-realPercent;\n invPercent2 *= invPercent2;\n \n vec3 scaleDirectionVec = vec3((Position.x-Center.x),(Position.y-Center.y),0);\n \n /* ROTATE */\n vec3 rotatedVec = RotationMatrix * scaleDirectionVec.xyz;\n \n /* SCALE */\n float scalePercent = (LifeSpan.x <= 0.001 ? ParticleScalePercent : scaleUpDown(realPercent));\n float scale = scalePercent * Scale * doDiscard;\n vec4 position = vec4(Center,0,1) + vec4(rotatedVec,0) * scale;\n \n vec3 thisSpeed = Speed * SpeedMax;\n position.xyz += thisSpeed * realPercent*(3.0 + mix(realPercent*realPercent2, 1.0-invPercent2, realPercent2));\n \n // Only adjust opacity on particles that last the duration of the animation\n float thisOpacity = (LifeSpan.x <= 0.001 ? Opacity : 1.0);\n vec4 color = vec4(Color.rgb, 1) * thisOpacity;\n \n\t v_Color = color;\n v_TexCoord = ParticleTexCoord;\n\t gl_Position = MVPMatrix * position;\n }\n ",fragment:" precision mediump float;\n \n uniform sampler2D ParticleTexture;\n \n varying vec4 v_Color;\n\t\tvarying vec2 v_TexCoord;\n \n void main()\n {\n vec4 color = texture2D(ParticleTexture, v_TexCoord);\n \n color *= v_Color;\n \n gl_FragColor = color;\n } "},sparkle:{attribNames:["Scale","LifeSpan","Speed","ParticleTexCoord","Center","Position"],uniformNames:["Percent","Opacity","Color","SpeedMax","ParticleTexture","MVPMatrix"],vertex:" \n precision highp float;\n \n uniform mat4 MVPMatrix;\n uniform float Percent;\n \n attribute vec2 Position;\n attribute vec2 Center;\n uniform float Opacity;\n attribute vec2 ParticleTexCoord;\n uniform vec4 Color;\n \n attribute mediump vec3 Speed;\n uniform mediump float SpeedMax;\n attribute mediump float Scale;\n attribute mediump vec2 LifeSpan;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n float ReverseSquareOfFloat(float f) {\n return 1.0 - (1.0-f)*(1.0-f);\n }\n \n void main()\n {\n float doDiscard = 0.0;\n float realPercent = (Percent-LifeSpan.x)/LifeSpan.y;\n if (realPercent < 0.0 || realPercent > 1.0) {\n doDiscard = 1.0;\n realPercent = 1.0;\n }\n \n vec4 position;\n vec4 scaleDirectionVec = vec4((Position.x-Center.x),(Position.y-Center.y),0,0);\n \n // SCALE\n float scaleAdjust = realPercent;\n if (scaleAdjust < 0.1) {\n scaleAdjust /= 0.1;\n scaleAdjust = sqrt(scaleAdjust);\n } else {\n scaleAdjust = 1.0-(scaleAdjust-0.1)/0.9;\n scaleAdjust = scaleAdjust*scaleAdjust*scaleAdjust;\n }\n scaleAdjust *= (doDiscard==0.0 ? 1.0 : 0.0);\n position = vec4(Center,0,1) + scaleDirectionVec * scaleAdjust * Scale;\n \n // POSITION\n vec3 thisSpeed = Speed * SpeedMax;\n position += vec4(thisSpeed, 0) * realPercent;\n \n float invPercent = 1.0 - realPercent;\n vec3 rgbColor = mix(Color.rgb, vec3(1,1,1), invPercent*invPercent*invPercent);\n \n /* output */\n gl_Position = MVPMatrix * position;\n v_Color = vec4(rgbColor, (1.0-realPercent*realPercent)*Opacity);\n v_TexCoord = ParticleTexCoord;\n } ",fragment:" \n precision mediump float;\n \n uniform sampler2D ParticleTexture;\n \n varying vec4 v_Color;\n varying vec2 v_TexCoord;\n \n void main()\n {\n vec4 texColor = texture2D(ParticleTexture, v_TexCoord);\n \n texColor *= v_Color;\n \n gl_FragColor = texColor;\n } "}},KNWebGLUtil={setupProgram:function(e,t){for(var i=KNWebGLShader[t],r=this.loadShader(e,e.VERTEX_SHADER,i.vertex),n=this.loadShader(e,e.FRAGMENT_SHADER,i.fragment),a=this.createShaderProgram(e,r,n),o={},s={},l=0,h=i.uniformNames.length;l=0==r>=0?(n=o-s,n+=i):(n=o+i,n-=s),n},mix:function(e,t,i){return e*(1-i)+t*i},clamp:function(e,t,i){return Math.min(Math.max(e,t),i)},sineMap:function(e){return.5*(Math.sin(e*Math.PI-Math.PI/2)+1)},createMatrix4:function(){var e=new Float32Array(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},makeIdentityMatrix4:function(){return WebGraphics.createMatrix4()},makeOrthoMatrix4:function(e,t,i,r,n,a){var o=new Float32Array(16),s=t-e,l=r-i,h=a-n;return o[0]=2/s,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2/l,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=-2/h,o[11]=0,o[12]=-(t+e)/s,o[13]=-(r-i)/l,o[14]=-(a+n)/h,o[15]=1,o},makeFrustumMatrix4:function(e,t,i,r,n,a){var o=t-e,s=r-i,l=a-n,h=new Float32Array(16);return h[0]=2*n/o,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=2*n/s,h[6]=0,h[7]=0,h[8]=(t+e)/o,h[9]=(r+i)/s,h[10]=-(a+n)/l,h[11]=-1,h[12]=0,h[13]=0,h[14]=-2*a*n/l,h[15]=0,h},makePerspectiveMatrix4:function(e,t,i,r){var n=i*Math.tan(e*Math.PI/360),a=n*t;return WebGraphics.makeFrustumMatrix4(-a,a,-n,n,i,r)},multiplyMatrix4:function(e,t){var i=new Float32Array(16),r=e[0],n=e[4],a=e[8],o=e[12],s=e[1],l=e[5],h=e[9],c=e[13],u=e[2],d=e[6],f=e[10],m=e[14],p=e[3],A=e[7],v=e[11],g=e[15],y=t[0],b=t[4],S=t[8],x=t[12],C=t[1],w=t[5],P=t[9],T=t[13],k=t[2],D=t[6],E=t[10],B=t[14],M=t[3],I=t[7],F=t[11],L=t[15];return i[0]=r*y+n*C+a*k+o*M,i[4]=r*b+n*w+a*D+o*I,i[8]=r*S+n*P+a*E+o*F,i[12]=r*x+n*T+a*B+o*L,i[1]=s*y+l*C+h*k+c*M,i[5]=s*b+l*w+h*D+c*I,i[9]=s*S+l*P+h*E+c*F,i[13]=s*x+l*T+h*B+c*L,i[2]=u*y+d*C+f*k+m*M,i[6]=u*b+d*w+f*D+m*I,i[10]=u*S+d*P+f*E+m*F,i[14]=u*x+d*T+f*B+m*L,i[3]=p*y+A*C+v*k+g*M,i[7]=p*b+A*w+v*D+g*I,i[11]=p*S+A*P+v*E+g*F,i[15]=p*x+A*T+v*B+g*L,i},scaleMatrix4:function(e,t,i,r){var n=WebGraphics.createMatrix4();return n[0]=t,n[5]=i,n[10]=r,WebGraphics.multiplyMatrix4(e,n)},translateMatrix4:function(e,t,i,r){var n=WebGraphics.createMatrix4();return n[12]=t,n[13]=i,n[14]=r,WebGraphics.multiplyMatrix4(e,n)},rotateMatrix4AboutXYZ:function(e,t,i,r,n){var a=WebGraphics.makePoint3D(i,r,n),o=(a=WebGraphics.point3DNormalize(a)).x,s=a.y,l=a.z,h=Math.cos(t),c=1-h,u=Math.sin(t),d=WebGraphics.createMatrix4();return d[0]=h+o*o*c,d[1]=o*s*c+l*u,d[2]=l*o*c-s*u,d[4]=o*s*c-l*u,d[5]=h+s*s*c,d[6]=l*s*c+o*u,d[8]=o*s*c+s*u,d[9]=s*l*c-o*u,d[10]=h+l*l*c,WebGraphics.multiplyMatrix4(e,d)},colorWithHSBA:function(e,t,i,r){var n,a,o,s,l,h,c,u,d={hue:e,saturation:t,brightness:i,alpha:r};switch(1===e&&(e=0),o=i*(1-t),s=i*(1-t*(a=(n=6*e)-Math.floor(n))),l=i*(1-t*(1-a)),parseInt(n)){case 0:h=i,u=l,c=o;break;case 1:h=s,u=i,c=o;break;case 2:h=o,u=i,c=l;break;case 3:h=o,u=s,c=i;break;case 4:h=l,u=o,c=i;break;case 5:h=i,u=o,c=s}return d.red=h,d.blue=c,d.green=u,d},makeMat3WithAffineTransform:function(e){var t=new Float32Array(9);return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t}},Vector3=function(e){this.create(e)};Vector3.prototype={create:function(e){var t=this.$matrix={};e?(t.m11=e[0],t.m12=e[1],t.m13=e[2]):(t.m11=0,t.m12=0,t.m13=0)},subtract:function(e){var t=this.$matrix,i=e.$matrix;t.m11-=i.m11,t.m12-=i.m12,t.m13-=i.m13},add:function(e){var t=this.$matrix,i=e.$matrix;t.m11+=i.m11,t.m12+=i.m12,t.m13+=i.m13},normalize:function(){var e=this.$matrix,t=Math.sqrt(e.m11*e.m11+e.m12*e.m12+e.m13*e.m13);t>0&&(e.m11/=t,e.m12/=t,e.m13/=t)},scale:function(e){var t=this.$matrix;t.m11*=e,t.m12*=e,t.m13*=e},cross:function(e){var t=this.$matrix,i=e.$matrix,r=i.m11,n=i.m12,a=i.m13,o=t.m11,s=t.m12,l=t.m13;t.m11=s*a-l*n,t.m12=l*r-o*a,t.m13=o*n-s*r},getArray:function(){var e=this.$matrix;return[e.m11,e.m12,e.m13]}};var Matrix3=function(){this.identity()};Matrix3.prototype={identity:function(){this.$matrix={m11:1,m12:0,m13:0,m21:0,m22:1,m23:0,m31:0,m32:0,m33:1}},affineScale:function(e,t){var i=this.$matrix;i.m11=e,i.m22=t},affineTranslate:function(e,t){var i=this.$matrix;i.m13=e,i.m23=t},transformTranslate:function(e,t){var i=new Matrix3;i.affineTranslate(e,t),this.multiply(i.getArray())},multiply:function(e){var t=this.$matrix,i=t.m11,r=t.m12,n=t.m13,a=t.m21,o=t.m22,s=t.m23,l=t.m31,h=t.m32,c=t.m33;t.m11=i*e[0]+r*e[3]+n*e[6],t.m12=i*e[1]+r*e[4]+n*e[7],t.m13=i*e[2]+r*e[5]+n*e[8],t.m21=a*e[0]+o*e[3]+s*e[6],t.m22=a*e[1]+o*e[4]+s*e[7],t.m23=a*e[2]+o*e[5]+s*e[8],t.m31=l*e[0]+h*e[3]+c*e[6],t.m32=l*e[1]+h*e[4]+c*e[7],t.m33=l*e[2]+h*e[5]+c*e[8]},getArray:function(){var e=this.$matrix;return[e.m11,e.m12,e.m13,e.m21,e.m22,e.m23,e.m31,e.m32,e.m33]},getFloat32Array:function(){return new Float32Array(this.getArray())},getColumnMajorArray:function(){var e=this.$matrix;return[e.m11,e.m21,e.m31,e.m12,e.m22,e.m32,e.m13,e.m23,e.m33]},getColumnMajorFloat32Array:function(){return new Float32Array(this.getColumnMajorArray())}};var Matrix4=function(){this.identity()};function TSUMix(e,t,i){return e+(t-e)*i}function TSUSineMap(e){return.5*(Math.sin(e*Math.PI-Math.PI/2)+1)}function TwistFX(e,t){var i=(1+4/10.25)*t-4/10.25*e;return i<0?0:i>1?1:TSUSineMap(i)}function CGAffineTransformMakeRotation(e){var t,i;return t=Math.sin(e),[i=Math.cos(e),t,-t,i,0,0]}function CGAffineTransformEqualToTransform(e,t){return e.a===t.a&&e.b===t.b&&e.c===t.c&&e.d===t.d&&e.tx===t.tx&&e.ty===t.ty}function CATransform3DEqualToTransform(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function CGPointMake(e,t){return{x:e,y:t}}function CGRectIntersection(e,t){var i,r,n,a,o={origin:{x:0,y:0},size:{width:0,height:0}};return(i=Math.max(e.origin.x,t.origin.x))>(r=Math.min(e.origin.x+e.size.width,t.origin.x+t.size.width))||(n=Math.max(e.origin.y,t.origin.y))>(a=Math.min(e.origin.y+e.size.height,t.origin.y+t.size.height))||(o.origin.x=i,o.size.width=r-i,o.origin.y=n,o.size.height=a-n),o}function CGRectIntegral(e){var t={origin:{x:0,y:0},size:{width:0,height:0}};return t.origin.x=Math.floor(e.origin.x),t.origin.y=Math.floor(e.origin.y),t.size.width=Math.ceil(e.origin.x+e.size.width)-t.origin.x,t.size.height=Math.ceil(e.origin.y+e.size.height)-t.origin.y,t}function CGRectGetMinX(e){return e.origin.x}function CGRectGetMinY(e){return e.origin.y}function CGRectGetMidX(e){return e.origin.x+e.size.width/2}function CGRectGetMidY(e){return e.origin.y+e.size.height/2}function CGRectGetMaxX(e){return e.origin.x+e.size.width}function CGRectGetMaxY(e){return e.origin.y+e.size.height}function CGRectEqualToRect(e,t){return e.origin.x===t.origin.x&&e.origin.y===t.origin.y&&e.size.width===t.size.width&&e.size.height===t.size.height}function CGRectMake(e,t,i,r){return{origin:{x:e,y:t},size:{width:i,height:r}}}function CGSizeMake(e,t){var i={};return i.width=e,i.height=t,i}function CGSizeEqualToSize(e,t){return e.width===t.width&&e.height===t.height}Matrix4.prototype={identity:function(){this.$matrix={m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:0,m42:0,m43:0,m44:1}},translate:function(e,t,i){var r=new Matrix4,n=r.$matrix;n.m14=e,n.m24=t,n.m34=i,this.multiply(r)},scale:function(e,t,i){var r=new Matrix4,n=r.$matrix;n.m11=e,n.m22=t,n.m33=i,this.multiply(r)},multiply:function(e){var t=this.$matrix,i=e.$matrix,r=i.m11*t.m11+i.m21*t.m12+i.m31*t.m13+i.m41*t.m14,n=i.m12*t.m11+i.m22*t.m12+i.m32*t.m13+i.m42*t.m14,a=i.m13*t.m11+i.m23*t.m12+i.m33*t.m13+i.m43*t.m14,o=i.m14*t.m11+i.m24*t.m12+i.m34*t.m13+i.m44*t.m14,s=i.m11*t.m21+i.m21*t.m22+i.m31*t.m23+i.m41*t.m24,l=i.m12*t.m21+i.m22*t.m22+i.m32*t.m23+i.m42*t.m24,h=i.m13*t.m21+i.m23*t.m22+i.m33*t.m23+i.m43*t.m24,c=i.m14*t.m21+i.m24*t.m22+i.m34*t.m23+i.m44*t.m24,u=i.m11*t.m31+i.m21*t.m32+i.m31*t.m33+i.m41*t.m34,d=i.m12*t.m31+i.m22*t.m32+i.m32*t.m33+i.m42*t.m34,f=i.m13*t.m31+i.m23*t.m32+i.m33*t.m33+i.m43*t.m34,m=i.m14*t.m31+i.m24*t.m32+i.m34*t.m33+i.m44*t.m34,p=i.m11*t.m41+i.m21*t.m42+i.m31*t.m43+i.m41*t.m44,A=i.m12*t.m41+i.m22*t.m42+i.m32*t.m43+i.m42*t.m44,v=i.m13*t.m41+i.m23*t.m42+i.m33*t.m43+i.m43*t.m44,g=i.m14*t.m41+i.m24*t.m42+i.m34*t.m43+i.m44*t.m44;t.m11=r,t.m12=n,t.m13=a,t.m14=o,t.m21=s,t.m22=l,t.m23=h,t.m24=c,t.m31=u,t.m32=d,t.m33=f,t.m34=m,t.m41=p,t.m42=A,t.m43=v,t.m44=g},perspective:function(e,t,i,r){var n=i*Math.tan(e*Math.PI/360),a=n*t;return this.frustum(-a,a,-n,n,i,r)},ortho:function(e,t,i,r,n,a){var o=t-e,s=r-i,l=a-n,h=this.$matrix;h.m11=2/o,h.m12=0,h.m13=0,h.m14=-(t+e)/o,h.m21=0,h.m22=2/s,h.m23=0,h.m24=-(r+i)/s,h.m31=0,h.m32=0,h.m33=-2/l,h.m34=-(a+n)/l,h.m41=0,h.m42=0,h.m43=0,h.m44=1},frustum:function(e,t,i,r,n,a){var o=t-e,s=r-i,l=a-n,h=this.$matrix;h.m11=2*n/o,h.m12=0,h.m13=(t+e)/o,h.m14=0,h.m21=0,h.m22=2*n/s,h.m23=(r+i)/s,h.m24=0,h.m31=0,h.m32=0,h.m33=-(a+n)/l,h.m34=-2*a*n/l,h.m41=0,h.m42=0,h.m43=-1,h.m44=0},getArray:function(){var e=this.$matrix;return[e.m11,e.m12,e.m13,e.m14,e.m21,e.m22,e.m23,e.m24,e.m31,e.m32,e.m33,e.m34,e.m41,e.m42,e.m43,e.m44]},getFloat32Array:function(){return new Float32Array(this.getArray())},getColumnMajorArray:function(){var e=this.$matrix;return[e.m11,e.m21,e.m31,e.m41,e.m12,e.m22,e.m32,e.m42,e.m13,e.m23,e.m33,e.m43,e.m14,e.m24,e.m34,e.m44]},getColumnMajorFloat32Array:function(){return new Float32Array(this.getColumnMajorArray())}};var CGSizeZero={width:0,height:0},CGRectZero={origin:{x:0,y:0},size:{width:0,height:0}},TSDRectUnit={origin:{x:0,y:0},size:{width:1,height:1}};function TSDMixFloats(e,t,i){return e*(1-i)+t*i}function TSDCenterOfRect(e){return WebGraphics.makePoint(CGRectGetMidX(e),CGRectGetMidY(e))}function TSDPointFromNormalizedRect(e,t){return WebGraphics.makePoint(t.origin.x+e.x*t.size.width,t.origin.y+e.y*t.size.height)}function TSDRectWithPoints(e,t){var i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),n=Math.min(e.y,t.y);return CGRectMake(i,n,r-i,Math.max(e.y,t.y)-n)}function TSDGLColor(e,t,i,r){return{r:e,g:t,b:i,a:r}}var TSD8bitColorDenominator=.003906402593851;function TSDGLColor4fMakeWithUInt(e){return WebGraphics.makePoint4D(((16711680&e)>>16)*TSD8bitColorDenominator,((65280&e)>>8)*TSD8bitColorDenominator,(255&e)*TSD8bitColorDenominator,((4278190080&e)>>24)*TSD8bitColorDenominator)}function TSUReverseSquare(e){var t=1-e;return 1-t*t}function mvpMatrixWithInitialStateAffineTransform(e,t){var i=e.width,r=e.height,n={x:i/2,y:r/2},a=e.anchorPoint;.5===a.pointX&&.5===a.pointY||(n.x=a.pointX*i,n.y=(1-a.pointY)*r),t=WebGraphics.translateMatrix4(t,n.x,n.y,0);var o=e.rotation;0!==o&&(t=WebGraphics.rotateMatrix4AboutXYZ(t,-o,0,0,1));var s=e.scale;return 1!==s&&(t=WebGraphics.scaleMatrix4(t,s,s,1)),t=WebGraphics.translateMatrix4(t,-n.x,-n.y,0)}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var i,r=_getPrototypeOf(e);if(t){var n=_getPrototypeOf(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return _possibleConstructorReturn(this,i)}}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i0){var s=o[0];if("contents"===s.property)a.toTextureId=s.to.texture;else if(!s.property){var l=s.animations;if(l)for(var h=0,c=l.length;h=1&&(r=1,this.isCompleted=!0),this.percentfinished=r,this.p_drawContents(r)}},{key:"p_drawContents",value:function(e){var t=this.gl,i=this.textures,r=i[0].texture,n=i[1].texture,a=TSUSineMap(e);e>=1&&(a=1),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,r),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n),this.contentsShader.setGLFloat(a,"mixFactor"),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),this.contentsDataBuffer.drawWithShader(this.contentsShader,!0)}}]),i}(),KNWebGLDrawable=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a={name:"WebDrawable",programNames:["defaultTextureAndOpacity"],effect:r.effect,textures:r.textures};return(n=t.call(this,e,a)).programData=a,n.Opacity=1,n.animationWillBeginWithContext(),n}return _createClass(i,[{key:"animationWillBeginWithContext",value:function(){var e=this.renderer,t=this.gl,i=this.program.defaultTextureAndOpacity,r=(i.uniforms,i.attribs,this.textures[0]);t.useProgram(i.shaderProgram),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA);var n=this.textureCoordinateBuffer=t.createBuffer(),a=this.textureCoordinates=[0,0,0,1,1,0,1,1];t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,new Float32Array(a),t.STATIC_DRAW);var o=this.positionBuffer=t.createBuffer(),s=this.boxPosition=[0,0,0,0,r.height,0,r.width,0,0,r.width,r.height,0];t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,new Float32Array(s),t.STATIC_DRAW),this.MVPMatrix=WebGraphics.translateMatrix4(e.slideProjectionMatrix,r.offset.pointX,t.viewportHeight-r.offset.pointY-r.height,0)}},{key:"drawFrame",value:function(){this.renderer;var e=this.gl,t=this.program.defaultTextureAndOpacity,i=t.uniforms,r=t.attribs,n=this.textures[0].texture;e.useProgram(t.shaderProgram),e.bindBuffer(e.ARRAY_BUFFER,this.textureCoordinateBuffer),e.vertexAttribPointer(r.TexCoord,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(r.TexCoord),e.bindBuffer(e.ARRAY_BUFFER,this.positionBuffer),e.vertexAttribPointer(r.Position,3,e.FLOAT,!1,0,0),e.enableVertexAttribArray(r.Position),e.uniformMatrix4fv(i.MVPMatrix,!1,this.MVPMatrix),e.uniform1f(i.Opacity,this.Opacity),e.activeTexture(e.TEXTURE0),e.uniform1i(i.Texture,0),e.bindTexture(e.TEXTURE_2D,n),e.drawArrays(e.TRIANGLE_STRIP,0,4)}}]),i}(),KNWebGLFramebufferDrawable=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a=e.gl,o=r.frameRect,s=a.createTexture();a.bindTexture(a.TEXTURE_2D,s),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,o.size.width,o.size.height,0,a.RGBA,a.UNSIGNED_BYTE,null),a.bindTexture(a.TEXTURE_2D,null);var l={width:o.size.width,height:o.size.height,offset:{pointX:0,pointY:0},texture:s},h={name:"FramebufferDrawable",programNames:["defaultTexture"],effect:r.effect,textures:[l]};return(n=t.call(this,e,h)).frameRect=o,n.texture=s,n.programData=h,n.buffer=n.createFramebuffer(a,s),n.drawableFrame=r.drawableFrame,n.animationWillBeginWithContext(),n}return _createClass(i,[{key:"createFramebuffer",value:function(e,t){var i=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),i}},{key:"animationWillBeginWithContext",value:function(){var e=this.renderer,t=this.gl,i=this.program.defaultTexture,r=(i.uniforms,i.attribs,this.textures[0]);t.useProgram(i.shaderProgram),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA);var n=this.textureCoordinateBuffer=t.createBuffer(),a=this.textureCoordinates=[0,1,0,0,1,1,1,0];t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,new Float32Array(a),t.STATIC_DRAW);var o=this.positionBuffer=t.createBuffer(),s=this.boxPosition=[0,0,0,0,r.height,0,r.width,0,0,r.width,r.height,0];t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,new Float32Array(s),t.STATIC_DRAW),this.MVPMatrix=WebGraphics.translateMatrix4(e.slideProjectionMatrix,r.offset.pointX,t.viewportHeight-r.offset.pointY-r.height,0)}},{key:"drawFrame",value:function(){this.renderer;var e=this.gl,t=this.program.defaultTexture,i=t.uniforms,r=t.attribs,n=this.textures[0].texture;e.useProgram(t.shaderProgram),e.bindBuffer(e.ARRAY_BUFFER,this.textureCoordinateBuffer),e.vertexAttribPointer(r.TexCoord,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(r.TexCoord),e.bindBuffer(e.ARRAY_BUFFER,this.positionBuffer),e.vertexAttribPointer(r.Position,3,e.FLOAT,!1,0,0),e.enableVertexAttribArray(r.Position),e.uniformMatrix4fv(i.MVPMatrix,!1,this.MVPMatrix),e.activeTexture(e.TEXTURE0),e.uniform1i(i.Texture,0),e.bindTexture(e.TEXTURE_2D,n),e.drawArrays(e.TRIANGLE_STRIP,0,4)}}]),i}(),KNWebGLDissolve=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a={name:"dissolve",programNames:["defaultTextureAndOpacity"],effect:r.effect,textures:r.textures};return(n=t.call(this,e,a)).programData=a,n.percentfinished=0,n.animationWillBeginWithContext(),n}return _createClass(i,[{key:"animationWillBeginWithContext",value:function(){var e=this.renderer,t=this.gl,i=this.program.defaultTextureAndOpacity,r=(i.uniforms,i.attribs,this.textures[0]);t.useProgram(i.shaderProgram),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA);var n=this.textureCoordinateBuffer=t.createBuffer(),a=this.textureCoordinates=[0,0,0,1,1,0,1,1];t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,new Float32Array(a),t.STATIC_DRAW);var o=this.positionBuffer=t.createBuffer(),s=this.boxPosition=[0,0,0,0,r.height,0,r.width,0,0,r.width,r.height,0];t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,new Float32Array(s),t.STATIC_DRAW),this.MVPMatrix=WebGraphics.translateMatrix4(e.slideProjectionMatrix,r.offset.pointX,t.viewportHeight-(r.offset.pointY+r.height),0),this.drawFrame(0,0,4)}},{key:"drawFrame",value:function(e,t,i){var r=this.percentfinished;(r+=e/i)>1&&(r=1);var n=TSUSineMap(r);1===r&&(n=1),this.buildOut&&(n=1-n),this.percentfinished=r,this.percentAlpha=n,this.draw()}},{key:"draw",value:function(){this.renderer;var e,t=this.gl,i=this.program.defaultTextureAndOpacity,r=i.uniforms,n=i.attribs,a=this.textures,o=a[0].texture;a.length>1&&(e=a[1].texture),t.useProgram(i.shaderProgram),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.bindBuffer(t.ARRAY_BUFFER,this.textureCoordinateBuffer),t.vertexAttribPointer(n.TexCoord,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(n.TexCoord),t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.vertexAttribPointer(n.Position,3,t.FLOAT,!1,0,0),t.enableVertexAttribArray(n.Position),t.uniformMatrix4fv(r.MVPMatrix,!1,this.MVPMatrix),t.activeTexture(t.TEXTURE0),t.uniform1i(r.Texture,0),e&&(t.bindTexture(t.TEXTURE_2D,e),t.uniform1f(r.Opacity,1),t.drawArrays(t.TRIANGLE_STRIP,0,4)),t.bindTexture(t.TEXTURE_2D,o),t.uniform1f(r.Opacity,this.percentAlpha),t.drawArrays(t.TRIANGLE_STRIP,0,4)}}]),i}(),KNWebGLTransitionIris=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a={name:"apple:wipe-iris",programNames:["iris"],effect:r.effect,textures:r.textures};(n=t.call(this,e,a)).programData=a;var o=n.direction===KNDirection.KNDirectionOut,s=n.buildOut;return s&&o||!s&&!o?(n.mix=0,n.percentfinished=1):(n.mix=1,n.percentfinished=0),n.percentAlpha=0,n.animationWillBeginWithContext(),n}return _createClass(i,[{key:"animationWillBeginWithContext",value:function(){var e=this.renderer,t=this.gl,i=this.program.iris,r=(i.attribs,i.uniforms,this.textures[0]);t.useProgram(i.shaderProgram),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),this.scale=r.width/r.height;var n=this.textureCoordinatesBuffer=t.createBuffer(),a=this.textureCoordinates=[0,0,0,1,1,0,1,1];t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,new Float32Array(a),t.STATIC_DRAW);var o=this.positionBuffer=t.createBuffer(),s=this.boxPosition=[0,0,0,0,r.height,0,r.width,0,0,r.width,r.height,0];t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,new Float32Array(s),t.STATIC_DRAW),this.MVPMatrix=WebGraphics.translateMatrix4(e.slideProjectionMatrix,r.offset.pointX,t.viewportHeight-(r.offset.pointY+r.height),0),this.drawFrame(0,0,4)}},{key:"drawFrame",value:function(e,t,i){var r=this.buildOut,n=this.direction===KNDirection.KNDirectionOut,a=this.percentfinished;r&&n||!r&&!n?(a-=e/i)<0&&(a=0):(a+=e/i)>1&&(a=1);var o=TSUSineMap(a);1===a&&(o=1),r&&(o=1-o),this.percentAlpha=o,this.percentfinished=a,this.draw()}},{key:"draw",value:function(){this.renderer;var e,t=this.gl,i=this.program.iris,r=i.attribs,n=i.uniforms,a=this.textures,o=a[0].texture,s=(a[0],this.scale);a.length>1&&(e=a[1].texture),t.useProgram(i.shaderProgram),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.bindBuffer(t.ARRAY_BUFFER,this.textureCoordinatesBuffer),t.vertexAttribPointer(r.TexCoord,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(r.TexCoord),t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.vertexAttribPointer(r.Position,3,t.FLOAT,!1,0,0),t.enableVertexAttribArray(r.Position),t.uniformMatrix4fv(n.MVPMatrix,!1,this.MVPMatrix),t.activeTexture(t.TEXTURE0),t.uniform1i(n.Texture,0),t.uniform1f(n.Opacity,1),e&&(t.bindTexture(t.TEXTURE_2D,e),t.uniform1f(n.PercentForAlpha,0),t.uniform1f(n.Scale,s),t.uniform1f(n.Mix,0),t.drawArrays(t.TRIANGLE_STRIP,0,4)),t.bindTexture(t.TEXTURE_2D,o),t.uniform1f(n.PercentForAlpha,this.percentAlpha),t.uniform1f(n.Scale,s),t.uniform1f(n.Mix,this.mix),t.drawArrays(t.TRIANGLE_STRIP,0,4)}}]),i}(),KNWebGLBuildIris=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a=r.effect,o={name:"apple:wipe-iris",programNames:["iris"],effect:a,textures:r.textures};(n=t.call(this,e,o)).programData=o;var s=n.direction===KNDirection.KNDirectionOut,l=n.buildOut;l&&s||!l&&!s?(n.mix=0,n.percentfinished=1):(n.mix=1,n.percentfinished=0),n.percentAlpha=0,n.drawableObjects=[];for(var h=0,c=n.textures.length;h=1&&(o=1,this.isCompleted=!0);var s=TSUSineMap(o);1===o&&(s=1),n&&(s=1-s),this.percentAlpha=s,this.percentfinished=o,r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA);for(var l=0,h=this.textures.length;l0&&"opacity"===d[0].property){var m=d[0].from.scalar,p=d[0].to.scalar-m;f=n?m+p*(1-this.percentfinished):m+p*this.percentfinished}else f=c.initialState.opacity;this.drawableObjects[l].Opacity=this.parentOpacity*f,this.drawableObjects[l].drawFrame()}}else if(c.animations.length>0){if(this.isCompleted){n||(this.drawableObjects[l].Opacity=this.parentOpacity*c.initialState.opacity,this.drawableObjects[l].drawFrame());continue}var A=this.program.iris,v=A.attribs,g=A.uniforms,y=this.irisSystems[l],b=y.scale;r.useProgram(A.shaderProgram);var S=y.textureCoordinatesBuffer;r.bindBuffer(r.ARRAY_BUFFER,S),r.vertexAttribPointer(v.TexCoord,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(v.TexCoord);var x=y.positionBuffer;r.bindBuffer(r.ARRAY_BUFFER,x),r.vertexAttribPointer(v.Position,3,r.FLOAT,!1,0,0),r.enableVertexAttribArray(v.Position);var C=y.MVPMatrix;r.uniformMatrix4fv(g.MVPMatrix,!1,C),r.activeTexture(r.TEXTURE0),r.uniform1i(g.Texture,0),r.uniform1f(g.Opacity,this.parentOpacity*c.initialState.opacity),r.bindTexture(r.TEXTURE_2D,c.texture),r.uniform1f(g.PercentForAlpha,this.percentAlpha),r.uniform1f(g.Scale,b),r.uniform1f(g.Mix,this.mix),r.drawArrays(r.TRIANGLE_STRIP,0,4)}else c.initialState.hidden||(this.drawableObjects[l].Opacity=this.parentOpacity*c.initialState.opacity,this.drawableObjects[l].drawFrame())}}}]),i}(),KNWebGLTransitionTwist=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a={name:"com.apple.iWork.Keynote.BUKTwist",programNames:["twist"],effect:r.effect,textures:r.textures};(n=t.call(this,e,a)).programData=a;var o=n.gl;n.direction=n.effect.attributes.direction,n.percentfinished=0;var s,l,h=n.mNumPoints=24,c=o.viewportWidth/(h-1),u=o.viewportHeight/(h-1),d=1/(h-1),f=n.TexCoords=[],m=n.PositionCoords=[],p=n.NormalCoords=[];for(l=0;l1&&(s=1),this.specularcolor=.5*TSUSineMap(2*s);var l=a.viewportHeight/2,h=this.mNumPoints,c=this.TexCoords,u=this.PositionCoords,d=this.NormalCoords;for(r=0;r=h||n+S>=h||r+b>=h||r+x>=h)){var C=new Vector3([u[3*f],u[3*f+1],u[3*f+2]]),w=new Vector3([u[3*((r+b)*h+(n+y))],u[3*((r+b)*h+(n+y))+1],u[3*((r+b)*h+(n+y))+2]]),P=new Vector3([u[3*((r+x)*h+(n+S))],u[3*((r+x)*h+(n+S))+1],u[3*((r+x)*h+(n+S))+2]]);w.subtract(C),P.subtract(C),w.cross(P),v.add(w)}}v.normalize(),v.scale(-1),v=v.getArray(),d[3*f]=v[0],d[3*f+1]=v[1],d[3*f+2]=v[2]}a.bindBuffer(a.ARRAY_BUFFER,this.buffers.Position),a.bufferData(a.ARRAY_BUFFER,new Float32Array(u),a.DYNAMIC_DRAW),a.vertexAttribPointer(o.Position,3,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,this.buffers.Normal),a.bufferData(a.ARRAY_BUFFER,new Float32Array(d),a.DYNAMIC_DRAW),a.vertexAttribPointer(o.Normal,3,a.FLOAT,!1,0,0),this.percentfinished=s,this.draw()}},{key:"draw",value:function(){this.renderer;var e,t=this.gl,i=this.program.twist.uniforms,r=this.textures,n=r[0].texture,a=r[1].texture,o=this.mNumPoints,s=this.specularcolor,l=this.AffineTransform.getColumnMajorFloat32Array(),h=this.AffineIdentity.getColumnMajorFloat32Array(),c=this.elementIndicesBuffer;if(s||(s=0),t.uniform1f(i.SpecularColor,s),this.percentfinished<.5){for(t.cullFace(t.BACK),t.bindTexture(t.TEXTURE_2D,n),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,c),t.uniformMatrix3fv(i.TextureMatrix,!1,l),t.uniform1f(i.FlipNormals,1),e=0;e1&&(this.percentfinished=1);var h=this.percentfinished,c=this.direction,u=c===KNDirection.KNDirectionRightToLeft||c===KNDirection.KNDirectionBottomToTop,d=c===KNDirection.KNDirectionLeftToRight||c===KNDirection.KNDirectionRightToLeft,f=1-(1-h)*(1-h),m=d?s.width:s.height,p=TSUSineMap(2*h)*m*.25,A=Math.sin(2*-f*Math.PI);A*=f*m*1,h<.5?(r.bindTexture(r.TEXTURE_2D,l.texture),r.uniform2fv(a.FlipTexCoords,new Float32Array([0,0]))):(r.bindTexture(r.TEXTURE_2D,s.texture),c===KNDirection.KNDirectionTopToBottom||c===KNDirection.KNDirectionBottomToTop?r.uniform2fv(a.FlipTexCoords,new Float32Array([0,1])):r.uniform2fv(a.FlipTexCoords,new Float32Array([1,0])));for(var v=0,g=this.mNumColors;v1&&(this.percentfinished=1),this.updateFlopWithPercent(),this.draw()}},{key:"updateFlopWithPercent",value:function(){for(var e=this.gl,t=this.direction,i=e.viewportWidth,r=e.viewportHeight,n=this.percentfinished*Math.PI,a=this.percentfinished*this.percentfinished*this.percentfinished*Math.PI,o=r/2,s=i/2,l=0,h=this.mNumPoints,c=this.attributeBufferData,u=0;u=1&&(this.percentfinished=1,this.isCompleted=!0),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA);for(var a=0,o=this.textures.length;a0&&"opacity"===h[0].property){var u=h[0].from.scalar;c=u+(h[0].to.scalar-u)*this.percentfinished}else c=s.initialState.opacity;this.drawableObjects[a].Opacity=this.parentOpacity*c,this.drawableObjects[a].drawFrame()}}else if(s.animations.length>0){if(this.isCompleted){this.drawableObjects[a].Opacity=this.parentOpacity*s.initialState.opacity,this.drawableObjects[a].drawFrame();continue}s.width;var d=s.height,f=s.offset.pointX,m=s.offset.pointY,p=n.viewportWidth,A=n.viewportHeight;i/=1e3;var v=Math.min(.2,.4*i),g=Math.min(.25,.5*i),y=this.cameraShakePointsWithRandomGenerator(),b=(this.percentfinished*i-v)/g,S=WebGraphics.makePoint(0,0);if(0=1&&(s=1,this.isCompleted=!0),this.percentfinished=s,n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA);for(var l=0,h=this.textures.length;l0&&"opacity"===d[0].property){var m=d[0].from.scalar;f=m+(d[0].to.scalar-m)*this.percentfinished}else f=c.initialState.opacity;this.drawableObjects[l].Opacity=this.parentOpacity*f,this.drawableObjects[l].drawFrame()}}else if(c.animations.length>0){if(this.isCompleted){o||(this.drawableObjects[l].Opacity=this.parentOpacity*c.initialState.opacity,this.drawableObjects[l].drawFrame());continue}c.width;var p=c.height;c.offset.pointX,c.offset.pointY,n.viewportWidth,n.viewportHeight;i/=1e3;var A=s;o&&(A=1-A);var v=o?.25:.5,g=Math.min(v,1/i);if(A>g){var y=(A-g)/(1-g),b=TSUSineMap(Math.min(1,2*y));b*=this.parentOpacity*c.initialState.opacity;var S=this.drawableObjects[l];S.Opacity=b,S.drawFrame()}var x=this.framebufferDrawableObjects[l],C=x.drawableFrame,w=x.frameRect,P={x:c.offset.pointX-w.origin.x,y:c.offset.pointY+p-(w.origin.y+w.size.height)},T=C.origin.y-w.origin.y,k=w.origin.y+w.size.height-(C.origin.y+C.size.height);P.y+=k-T;var D=this.p_orthoTransformWithScale(1,P,w);n.viewport(0,0,w.size.width,w.size.height),n.bindFramebuffer(n.FRAMEBUFFER,x.buffer),n.clear(n.COLOR_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE);var E=0===s||1===s?0:1;n.bindTexture(n.TEXTURE_2D,x.texture);var B=this.flameSystems[l];B.setMVPMatrix(D),n.uniform1f(a.SpeedMax,B._speedMax),B.drawFrame(s,E),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindTexture(n.TEXTURE_2D,null),n.viewport(0,0,n.viewportWidth,n.viewportHeight),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),x.MVPMatrix=WebGraphics.translateMatrix4(r.slideProjectionMatrix,w.origin.x,n.viewportHeight-(w.origin.y+w.size.height),0),x.drawFrame()}else c.initialState.hidden||(this.drawableObjects[l].Opacity=this.parentOpacity*c.initialState.opacity,this.drawableObjects[l].drawFrame())}}}]),i}(),KNWebGLTransitionConfetti=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a={name:"com.apple.iWork.Keynote.KLNConfetti",programNames:["confetti","defaultTexture"],effect:r.effect,textures:r.textures};return(n=t.call(this,e,a)).programData=a,n.useGravity=n.direction===KNDirection.KNDirectionGravity,n.percentfinished=0,n.animationWillBeginWithContext(),n}return _createClass(i,[{key:"animationWillBeginWithContext",value:function(){var e=this.renderer,t=this.gl,i=this.textures,r=i[0],n=r.width,a=r.height,o=t.viewportWidth,s=t.viewportHeight;t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.confettiSystem=new KNWebGLBuildConfettiSystem(e,this.program.confetti,{width:n,height:a},{width:o,height:s},this.duration,1e4,i[1].texture),this.confettiSystem.setMVPMatrix(e.slideProjectionMatrix);var l=this.program.defaultTexture;KNWebGLUtil.enableAttribs(t,l);var h=[0,0,-1,0,s,-1,o,0,-1,o,s,-1];this.textureCoordinatesBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.textureCoordinatesBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,1]),t.STATIC_DRAW),t.vertexAttribPointer(l.attribs.TexCoord,2,t.FLOAT,!1,0,0),this.positionBuffer=t.createBuffer(),KNWebGLUtil.bindDynamicBufferWithData(t,l.attribs.Position,this.positionBuffer,h,3),t.uniformMatrix4fv(l.uniforms.MVPMatrix,!1,e.slideOrthoMatrix),t.activeTexture(t.TEXTURE0),t.uniform1i(l.uniforms.Texture,0),this.drawFrame(0,0,4)}},{key:"drawFrame",value:function(e,t,i){var r=this.gl,n=r.viewportWidth,a=r.viewportHeight,o=this.percentfinished;if((o+=e/i)>1&&(o=1,this.isCompleted=!0),this.isCompleted){var s=this.program.defaultTexture;return r.useProgram(s.shaderProgram),r.uniformMatrix4fv(s.uniforms.MVPMatrix,!1,this.renderer.slideProjectionMatrix),void this.draw()}var l=this.percentfinished=o,h=1-l,c=1-h*h*h;c=c*(1-l*l)+l*l*(1-h*h)+l,c*=.5,c*=c;var u=.75+.25*(1-Math.pow(h,4)),d=WebGraphics.translateMatrix4(this.renderer.slideProjectionMatrix,n/2,a/2,0);d=WebGraphics.scaleMatrix4(d,u,u,1),d=WebGraphics.translateMatrix4(d,-n/2,-a/2,0);s=this.program.defaultTexture;r.useProgram(s.shaderProgram),r.uniformMatrix4fv(s.uniforms.MVPMatrix,!1,d),this.draw();var f=1-l;if(f=WebGraphics.clamp(f,0,1),c=WebGraphics.clamp(c,0,1),this.useGravity){var m=this.renderer.slideProjectionMatrix;m=WebGraphics.translateMatrix4(m,0,2*-a*l*l*.5,0),this.confettiSystem.setMVPMatrix(m)}this.confettiSystem.drawFrame(c,f)}},{key:"draw",value:function(){var e=this.gl,t=this.program.defaultTexture,i=t.attribs,r=e.viewportWidth,n=e.viewportHeight;e.useProgram(t.shaderProgram);var a=[0,0,-1,0,n,-1,r,0,-1,r,n,-1];e.bindBuffer(e.ARRAY_BUFFER,this.textureCoordinatesBuffer),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,1]),e.STATIC_DRAW),e.vertexAttribPointer(i.TexCoord,2,e.FLOAT,!1,0,0),KNWebGLUtil.bindDynamicBufferWithData(e,i.Position,this.positionBuffer,a,3),e.bindTexture(e.TEXTURE_2D,this.textures[0].texture),e.drawArrays(e.TRIANGLE_STRIP,0,4)}}]),i}(),KNWebGLBuildConfetti=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a=r.effect,o={name:"com.apple.iWork.Keynote.KLNConfetti",programNames:["confetti"],effect:a,textures:r.textures};(n=t.call(this,e,o)).programData=o,n.useGravity=n.direction===KNDirection.KNDirectionGravity,n.percentfinished=0,n.drawableObjects=[];for(var s=0,l=n.textures.length;s1&&(s=1,this.isCompleted=!0),this.percentfinished=s;for(var l=0,h=this.textures.length;l0&&"opacity"===d[0].property){var m=d[0].from.scalar;f=m+(d[0].to.scalar-m)*s}else f=c.initialState.opacity;n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),this.drawableObjects[l].Opacity=this.parentOpacity*f,this.drawableObjects[l].drawFrame()}}else if(c.animations.length>0){if(this.isCompleted){o&&(this.drawableObjects[l].Opacity=this.parentOpacity*c.initialState.opacity,this.drawableObjects[l].drawFrame());continue}c.width;var p=c.height,A=o?1-s:s,v=1-A,g=1-v*v*v;g=g*(1-A*A)+A*A*(1-v*v)+A,g*=.5,o&&(g*=g);var y=this.confettiSystems[l],b=WebGraphics.translateMatrix4(r.slideProjectionMatrix,c.offset.pointX,a-(c.offset.pointY+p),0);0===(u=c.initialState).rotation&&1===u.scale||(b=mvpMatrixWithInitialStateAffineTransform(u,b));var S=1-A;if(S=WebGraphics.clamp(S,0,1),g=WebGraphics.clamp(g,0,1),this.useGravity){var x=y.ratio;b=WebGraphics.translateMatrix4(b,0,2*-a*A*A*(1-.5*x),0)}n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),y.setMVPMatrix(b),y.drawFrame(g,S)}else c.initialState.hidden||(n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),this.drawableObjects[l].Opacity=this.parentOpacity*c.initialState.opacity,this.drawableObjects[l].drawFrame())}}}]),i}(),KNWebGLBuildDiffuse=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a=r.effect,o={name:"com.apple.iWork.Keynote.KLNDiffuse",programNames:["diffuse"],effect:a,textures:r.textures};(n=t.call(this,e,o)).programData=o,n.percentfinished=0,n.drawableObjects=[];for(var s=0,l=n.textures.length;s1&&(o=1,this.isCompleted=!0),this.percentfinished=o,n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA);for(var s=0,l=this.textures.length;s0&&"opacity"===u[0].property){var f=u[0].from.scalar;d=f+(u[0].to.scalar-f)*o}else d=h.initialState.opacity;this.drawableObjects[s].Opacity=this.parentOpacity*d,this.drawableObjects[s].drawFrame()}}else if(h.animations.length>0){h.width;var m=h.height,p=h.offset.pointX,A=h.offset.pointY,v=this.diffuseSystems[s],g=WebGraphics.translateMatrix4(r.slideProjectionMatrix,p,a-(A+m),0);0===(c=h.initialState).rotation&&1===c.scale||(g=mvpMatrixWithInitialStateAffineTransform(c,g)),v.setMVPMatrix(g),v.drawFrame(this.percentfinished,this.parentOpacity*c.opacity)}else h.initialState.hidden||(this.drawableObjects[s].Opacity=this.parentOpacity*h.initialState.opacity,this.drawableObjects[s].drawFrame())}}}]),i}(),KNWebGLBuildFireworks=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a={name:"com.apple.iWork.Keynote.KNFireworks",programNames:["fireworks"],effect:r.effect,textures:r.textures};(n=t.call(this,e,a)).programData=a;var o=n.gl;n.animParameterGroup=new KNAnimParameterGroup("Fireworks"),n.fireworksTexture=KNWebGLUtil.bindTextureWithImage(o,fireworksImage),n.fireworksCenterBurstTexture=KNWebGLUtil.bindTextureWithImage(o,fireworksCenterBurstImage),n.percentfinished=0,n.prevpercentfinished=0,n.drawableObjects=[],n.frameRect=n.frameOfEffectWithFrame(),n.slideSize={width:o.viewportWidth,height:o.viewportHeight};for(var s=n.effect,l=0,h=n.textures.length;l=1&&(s=1,this.isCompleted=!0),this.percentfinished=s,r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA);for(var d=0,f=this.textures.length;d0&&"opacity"===A[0].property){var g=A[0].from.scalar;v=g+(A[0].to.scalar-g)*this.percentfinished}else v=m.initialState.opacity;this.drawableObjects[d].Opacity=this.parentOpacity*v,this.drawableObjects[d].drawFrame()}}else if(m.animations.length>0){if(this.isCompleted){o||(this.drawableObjects[d].Opacity=this.parentOpacity*m.initialState.opacity,this.drawableObjects[d].drawFrame());continue}m.width,m.height,m.offset.pointX,m.offset.pointY;var y=r.viewportWidth,b=r.viewportHeight;i/=1e3;var S=s,x=TSDGLFrameBuffer.currentGLFramebuffer(r),C=this.fireworksSystems[d],w=C.objectShader,P=C.objectDataBuffer;this.p_drawObject(S,m,w,P);var T=this.framebuffer,k=this.fboShader,D=this.fboDataBuffer,E=T.currentGLTexture();T.setCurrentTextureToNext(),T.bindFramebuffer(),r.clear(r.COLOR_BUFFER_BIT),r.viewport(0,0,T.size.width,T.size.height),r.bindTexture(r.TEXTURE_2D,E);var B=l.doubleForKey("FireworkDurationMin")/i;B=Math.min(B/2,1);var M=WebGraphics.clamp((s-B)/(1-B),0,1),I=1-WebGraphics.mix(l.doubleForKey("TrailsFadeOutMin"),l.doubleForKey("TrailsFadeOutMax"),Math.pow(M,2));k.setGLFloat(I,kTSDGLShaderUniformOpacity),k.setGLFloat(h,kShaderUniformNoiseAmount),k.setGLFloat(c,kShaderUniformNoiseMax);var F=WebGraphics.makePoint(WebGraphics.randomBetween(0,1),WebGraphics.randomBetween(0,1));k.setPoint2D(F,kShaderUniformNoiseSeed),D.drawWithShader(this.fboShader,!0),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.useProgram(n.shaderProgram);var L=l.doubleForKey("Gravity");L*=.001*Math.min(y,b),L*=i,r.uniform1f(a.Gravity,L);var N=Math.min(y,b)*l.doubleForKey("ParticleSizeStart")/100;r.uniform1f(a.StartScale,N),r.uniform1f(a.SparklePeriod,l.doubleForKey("SparklePeriod")),this.drawParticleSystemsWithPercent(s,!1,1,C),r.viewport(0,0,r.viewportWidth,r.viewportHeight),T.unbindFramebufferAndBindGLFramebuffer(x);var G=l.doubleForKey("FireworkDurationMax");G=Math.min(G,.999);var R=WebGraphics.clamp((s-G)/(1-G),0,1),W=1-l.doubleForAnimationCurve("ParticleTransparency",R);this._bloomEffect.bindFramebuffer(),r.clear(r.COLOR_BUFFER_BIT),k.setGLFloat(W,kTSDGLShaderUniformOpacity),k.setGLFloat(0,kShaderUniformNoiseAmount),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.bindTexture(r.TEXTURE_2D,T.currentGLTexture()),D.drawWithShader(k,!0),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.useProgram(n.shaderProgram),this.drawParticleSystemsWithPercent(s,!0,W,C),this._bloomEffect.unbindFramebufferAndBindGLFramebuffer(x),r.blendFunc(r.ONE,r.ONE),this._bloomEffect.drawBloomEffectWithMVPMatrix(C.baseOrthoTransform,u,x),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA)}else m.initialState.hidden||(this.drawableObjects[d].Opacity=this.parentOpacity*m.initialState.opacity,this.drawableObjects[d].drawFrame())}this.prevpercentfinished=this.percentfinished}},{key:"p_drawObject",value:function(e,t,i,r){var n=this.gl,a=this.animParameterGroup,o=a.doubleForKey("TextOpacityBeginTime"),s=a.doubleForKey("TextOpacityEndTime");e=WebGraphics.clamp((e-o)/(s-o),0,1);var l=this.parentOpacity*t.initialState.opacity;l*=a.doubleForAnimationCurve("TextOpacityTiming",e),i.setGLFloat(l,kTSDGLShaderUniformOpacity),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),n.bindTexture(n.TEXTURE_2D,t.texture),r.drawWithShader(i,!0)}},{key:"drawParticleSystemsWithPercent",value:function(e,t,i,r){this.renderer;var n=this.gl,a=this.program.fireworks,o=a.uniforms,s=this.animParameterGroup,l=r.systems,h=r.baseTransform,c=r.fireworksMVP;n.useProgram(a.shaderProgram),n.uniform1f(o.ShouldSparkle,t?1:0);for(var u=0,d=l.length;u=1)){var p=WebGraphics.clamp(p,0,1),A=(this.prevpercentfinished-m.start)/m.duration;A=WebGraphics.clamp(A,p/2,1);var v=i;t&&(v=1-s.doubleForAnimationCurve("ParticleTransparency",p));var g=s.doubleForAnimationCurve("ParticleBurstTiming",A),y=s.doubleForAnimationCurve("ParticleBurstTiming",p);if(n.uniform1f(o.ParticleBurstTiming,y),n.uniform1f(o.PreviousParticleBurstTiming,g),n.uniform1f(o.PreviousPercent,A),!t&&!f.didDrawCenterBurst){n.bindTexture(n.TEXTURE_2D,this.fireworksCenterBurstTexture);var b=n.viewportHeight/512;b*=WebGraphics.randomBetween(s.doubleForKey("CenterBurstScaleMin"),s.doubleForKey("CenterBurstScaleMax"));var S=f._startingPoint,x=WebGraphics.translateMatrix4(h,S.x,S.y,0),C=WebGraphics.makePoint(-256*b,-256*b);x=WebGraphics.translateMatrix4(x,C.x,C.y,0),x=WebGraphics.scaleMatrix4(x,b,b,1),this.centerBurstShader.setGLFloat(s.doubleForKey("CenterBurstOpacity"),kTSDGLShaderUniformOpacity),this.centerBurstShader.setMat4WithTransform3D(x,kTSDGLShaderUniformMVPMatrix),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),this.centerBurstDataBuffer.drawWithShader(this.centerBurstShader,!0),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),f.didDrawCenterBurst=!0}n.useProgram(a.shaderProgram),f.setMVPMatrix(c),f.drawFrame(p,v)}}}}]),i}(),KNWebGLBuildShimmerEffect=function(){function e(t,i,r,n,a,o,s,l,h,c){_classCallCheck(this,e),this.renderer=t,this.gl=t.gl,this.program=i,this._slideRect=r,this._texture=n,this._destinationRect=a,this._translate=o,this._duration=s,this._direction=l,this._buildType=h,this._baseTransform=new Float32Array(16),this._isSetup=!1,this.parentOpacity=c,this.shimmerTexture=KNWebGLUtil.bindTextureWithImage(this.gl,shimmerImage),this.setupEffectIfNecessary()}return _createClass(e,[{key:"setupEffectIfNecessary",value:function(){if(!this._isSetup){var e=this.gl,t=this._texture,i=(CGSizeMake(2,2),{origin:{x:0,y:0},size:{width:e.viewportWidth,height:e.viewportHeight}}),r={x:t.offset.pointX-i.origin.x,y:t.offset.pointY+t.height-(i.origin.y+i.size.height)},n=WebGraphics.makeOrthoMatrix4(0,i.size.width,0,i.size.height,-1,1),a=WebGraphics.translateMatrix4(n,r.x,-r.y,0),o=t.initialState;0===o.rotation&&1===o.scale||(a=mvpMatrixWithInitialStateAffineTransform(o,a)),this._objectSystem=this.objectSystemForTR(this._texture,this._slideRect,this._duration),this._objectSystem.setMVPMatrix(a),this._objectSystem.shouldDraw&&(this._particleSystem=this.particleSystemForTR(this._texture,this._slideRect,this._duration),this._particleSystem.setMVPMatrix(a)),this.baseTransform=a,this._isSetup=!0}}},{key:"p_numberOfParticlesForTR",value:function(e,t,i){var r=this._destinationRect,n=t.size,a=r.size.width/n.width*r.size.height/n.height,o=e.size.width/r.size.width*e.size.height/r.size.height;return parseInt(Math.min(a*o*2e3,3276))}},{key:"objectSystemForTR",value:function(e,t,i){var r=e.textureRect,n=this.p_numberOfParticlesForTR(r,t,i);return new KNWebGLBuildShimmerObjectSystem(this.renderer,this.program.shimmerObject,{width:r.size.width,height:r.size.height},{width:t.size.width,height:t.size.height},i,n,e.texture,this._direction)}},{key:"particleSystemForTR",value:function(e,t,i){var r=e.textureRect,n=this.p_numberOfParticlesForTR(r,t,i);n=Math.max(2,n/40);var a=this._objectSystem.particleCount;return a+=n,a=Math.min(a,3276),new KNWebGLBuildShimmerParticleSystem(this.renderer,this.program.shimmerParticle,{width:r.size.width,height:r.size.height},{width:t.size.width,height:t.size.height},i,CGSizeMake(a,1),this._objectSystem.particleSize,this._objectSystem,this.shimmerTexture,this._direction)}},{key:"p_drawObject",value:function(e,t,i,r){var n=this.gl,a=this.parentOpacity*t.initialState.opacity;a*=TSUSineMap(e),i.setGLFloat(a,kTSDGLShaderUniformOpacity),n.bindTexture(n.TEXTURE_2D,t.texture),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),r.drawWithShader(i,!0)}},{key:"renderEffectAtPercent",value:function(e){var t=this.gl,i=this._texture;"buildOut"===this._buildType&&(e=1-e);var r=(1-e)*(1-e),n="buildIn"===this._buildType,a=(TSUReverseSquare(e)*this._duration/1e3+e)*Math.PI/2;n||(a*=-1);var o=WebGraphics.makePoint(.2,.4),s=(e-o.x)/o.y;s=TSUSineMap(s=WebGraphics.clamp(s,0,1));var l=this.parentOpacity*i.initialState.opacity;s*=l,t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.useProgram(this.program.shimmerObject.shaderProgram),this._objectSystem.setMVPMatrix(this.baseTransform),this._objectSystem.drawGLSLWithPercent(r,s,a,n,i.texture),t.useProgram(this.program.shimmerParticle.shaderProgram),this._particleSystem.setMVPMatrix(this.baseTransform),this._particleSystem.drawGLSLWithPercent(r,.5*l,a,n,this.shimmerTexture)}}]),e}(),KNWebGLBuildShimmer=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a=r.effect,o={name:"com.apple.iWork.Keynote.KLNShimmer",programNames:["shimmerObject","shimmerParticle"],effect:a,textures:r.textures};(n=t.call(this,e,o)).programData=o;var s=n.gl;n.percentfinished=0,n.drawableObjects=[],n.slideOrigin={x:0,y:0},n.slideSize={width:s.viewportWidth,height:s.viewportHeight},n.slideRect={origin:n.slideOrigin,size:n.slideSize};for(var l=0,h=n.textures.length;l1&&(n=1,this.isCompleted=!0),this.percentfinished=n,r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA);for(var a=0,o=this.textures.length;a0&&"opacity"===h[0].property){var u=h[0].from.scalar;c=u+(h[0].to.scalar-u)*n}else c=s.initialState.opacity;this.drawableObjects[a].Opacity=this.parentOpacity*c,this.drawableObjects[a].drawFrame()}}else if(s.animations.length>0){if(this.isCompleted){this.buildIn&&(this.drawableObjects[a].Opacity=this.parentOpacity*s.initialState.opacity,this.drawableObjects[a].MVPMatrix=mvpMatrixWithInitialStateAffineTransform(l,this.drawableObjects[a].MVPMatrix),this.drawableObjects[a].drawFrame());continue}s.width,s.height,s.offset.pointX,s.offset.pointY;this.shimmerEffects[a].renderEffectAtPercent(this.percentfinished)}else s.initialState.hidden||(this.drawableObjects[a].Opacity=this.parentOpacity*s.initialState.opacity,this.drawableObjects[a].drawFrame())}}}]),i}(),KNWebGLBuildSparkleEffect=function(){function e(t,i,r,n,a,o,s,l,h,c){_classCallCheck(this,e),this.renderer=t,this.gl=t.gl,this.program=i,this._slideRect=r,this._texture=n,this._destinationRect=a,this._translate=o,this._duration=s,this._direction=l,this._buildType=h,this._baseTransform=new Float32Array(16),this._isSetup=!1,this.parentOpacity=c,this.sparkleTexture=KNWebGLUtil.bindTextureWithImage(this.gl,sparkleImage),this.setupEffectIfNecessary()}return _createClass(e,[{key:"setupEffectIfNecessary",value:function(){if(!this._isSetup){var e=this.gl,t=this._texture,i=CGSizeMake(2,2),r={origin:{x:0,y:0},size:{width:e.viewportWidth,height:e.viewportHeight}},n={x:t.offset.pointX-r.origin.x,y:t.offset.pointY+t.height-(r.origin.y+r.size.height)},a=WebGraphics.makeOrthoMatrix4(0,r.size.width,0,r.size.height,-1,1),o=WebGraphics.translateMatrix4(a,n.x,-n.y,0),s=t.initialState;0===s.rotation&&1===s.scale||(o=mvpMatrixWithInitialStateAffineTransform(s,o));var l=this._objectShader=new TSDGLShader(e);l.initWithDefaultTextureAndOpacityShader(),l.setMat4WithTransform3D(o,kTSDGLShaderUniformMVPMatrix),l.setGLint(0,kTSDGLShaderUniformTexture);var h=new TSDGLDataBufferAttribute(kTSDGLShaderAttributePosition,GL_STREAM_DRAW,GL_FLOAT,!1,2),c=new TSDGLDataBufferAttribute(kTSDGLShaderAttributeTexCoord,GL_STREAM_DRAW,GL_FLOAT,!1,2);(this._objectDataBuffer=new TSDGLDataBuffer(e)).newDataBufferWithVertexAttributes([h,c],i,!0),this.sparkleSystem=this.sparkleSystemForTR(this._texture,this._slideRect,this._duration),this.sparkleSystem.setMVPMatrix(o),this.sparkleSystem.setColor(new Float32Array([1,1,1,1])),this.baseTransform=o,this._isSetup=!0}}},{key:"p_numberOfParticlesForTR",value:function(e,t,i){var r=this._destinationRect,n=t.size,a=r.size.width/n.width*r.size.height/n.height,o=e.size.width/r.size.width*e.size.height/r.size.height;return parseInt(Math.min(a*o*2e3,3276))}},{key:"sparkleSystemForTR",value:function(e,t,i){var r=e.textureRect,n=this._slideRect.size,a=this._destinationRect,o=Math.min(a.size.width,n.width)/n.width*Math.min(a.size.height,n.height)/n.height,s=parseInt((2-Math.sqrt(o))/2*1500*this._duration/1e3);return new KNWebGLBuildSparkleSystem(this.renderer,this.program.sparkle,{width:r.size.width,height:r.size.height},{width:t.size.width,height:t.size.height},i,CGSizeMake(s,1),{width:128,height:128},this.sparkleTexture,this._direction)}},{key:"p_drawObject",value:function(e,t,i,r){var n=this.gl,a=this.parentOpacity*t.initialState.opacity;a*=TSUSineMap(e),i.setGLFloat(a,kTSDGLShaderUniformOpacity),n.bindTexture(n.TEXTURE_2D,t.texture),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),r.drawWithShader(i,!0)}},{key:"renderEffectAtPercent",value:function(e){var t=this.gl,i=this._texture,r=this._direction,n=i.textureRect,a=r===KNDirection.KNDirectionRightToLeft||r===KNDirection.KNDirectionTopToBottom,o=r===KNDirection.KNDirectionRightToLeft||r===KNDirection.KNDirectionLeftToRight,s=(this._translate,this.parentOpacity*i.initialState.opacity),l=this._duration/1e3,h=.2/l,c=n.size.width,u=n.size.height,d=e/(1-KNSparkleMaxParticleLife/Math.max(.75,l)),f=0,m=0,p=0,A=0,v=0,g=0,y=0,b=0;"buildOut"===this._buildType?(d-=h,f=o?a?0:c:0,m=o||a?0:u,p=o?a?c-c*WebGraphics.clamp(d,0,1):c*WebGraphics.clamp(d,0,1):c,A=o?u:a?u-u*WebGraphics.clamp(d,0,1):u*WebGraphics.clamp(d,0,1),v=o?a?0:1:0,g=o||a?0:1,y=o?a?1-1*WebGraphics.clamp(d,0,1):1*WebGraphics.clamp(d,0,1):1,b=o?1:a?1-1*WebGraphics.clamp(d,0,1):1*WebGraphics.clamp(d,0,1)):(d-=h,f=o&&a?c:0,m=o?0:a?u:0,p=o?a?c-c*WebGraphics.clamp(d,0,1):c*WebGraphics.clamp(d,0,1):c,A=o?u:a?u-u*WebGraphics.clamp(d,0,1):u*WebGraphics.clamp(d,0,1),v=o&&a?1:0,g=o?0:a?1:0,y=o?a?1-1*WebGraphics.clamp(d,0,1):1*WebGraphics.clamp(d,0,1):1,b=o?1:a?1-1*WebGraphics.clamp(d,0,1):1*WebGraphics.clamp(d,0,1)),t.bindTexture(t.TEXTURE_2D,i.texture),this._objectShader.setGLFloat(s,kTSDGLShaderUniformOpacity);var S=this._objectDataBuffer,x=S.vertexAttributeNamed(kTSDGLShaderAttributePosition),C=S.vertexAttributeNamed(kTSDGLShaderAttributeTexCoord);S.setGLPoint2D(WebGraphics.makePoint(f,m),x,0),S.setGLPoint2D(WebGraphics.makePoint(p,m),x,1),S.setGLPoint2D(WebGraphics.makePoint(f,A),x,2),S.setGLPoint2D(WebGraphics.makePoint(p,A),x,3),S.setGLPoint2D(WebGraphics.makePoint(v,g),C,0),S.setGLPoint2D(WebGraphics.makePoint(y,g),C,1),S.setGLPoint2D(WebGraphics.makePoint(v,b),C,2),S.setGLPoint2D(WebGraphics.makePoint(y,b),C,3),S.drawWithShader(this._objectShader,!0),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.useProgram(this.program.sparkle.shaderProgram),this.sparkleSystem.setMVPMatrix(this.baseTransform),this.sparkleSystem.drawFrame(e,1)}}]),e}(),KNWebGLBuildSparkle=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a=r.effect,o={name:"com.apple.iWork.Keynote.KLNSparkle",programNames:["sparkle"],effect:a,textures:r.textures};(n=t.call(this,e,o)).programData=o;var s=n.gl;n.percentfinished=0,n.drawableObjects=[],n.slideOrigin={x:0,y:0},n.slideSize={width:s.viewportWidth,height:s.viewportHeight},n.slideRect={origin:n.slideOrigin,size:n.slideSize};for(var l=0,h=n.textures.length;l1&&(a=1,this.isCompleted=!0),this.percentfinished=a,r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA);for(var o=0,s=this.textures.length;o0&&"opacity"===c[0].property){var d=c[0].from.scalar;u=d+(c[0].to.scalar-d)*a}else u=l.initialState.opacity;this.drawableObjects[o].Opacity=this.parentOpacity*u,this.drawableObjects[o].drawFrame()}}else if(l.animations.length>0){if(this.isCompleted){n&&(this.drawableObjects[o].Opacity=this.parentOpacity*l.initialState.opacity,this.drawableObjects[o].MVPMatrix=mvpMatrixWithInitialStateAffineTransform(h,this.drawableObjects[o].MVPMatrix),this.drawableObjects[o].drawFrame());continue}this.sparkleEffects[o].renderEffectAtPercent(this.percentfinished)}else l.initialState.hidden||(this.drawableObjects[o].Opacity=this.parentOpacity*l.initialState.opacity,this.drawableObjects[o].drawFrame())}}}]),i}(),KNWebGLTransitionMagicMove=function(e){_inherits(i,KNWebGLProgram);var t=_createSuper(i);function i(e,r){var n;_classCallCheck(this,i);var a=new KNWebGLCoreAnimationWrapperProgram(r);(n=t.call(this,e,a.data)).coreAnimationWrapperProgram=a;var o=n.gl;n.percentfinished=0,n.drawableObjects=[],n.slideOrigin={x:0,y:0},n.slideSize={width:o.viewportWidth,height:o.viewportHeight},n.slideRect={origin:n.slideOrigin,size:n.slideSize},n.frameRect=n.slideRect;var s=r.effect;return n.parentOpacity=s.baseLayer.initialState.opacity,n.animationWillBeginWithContext(),n}return _createClass(i,[{key:"animationWillBeginWithContext",value:function(){var e=this.renderer;this.coreAnimationWrapperBasedEffects=[];for(var t=this.program,i=this.slideRect,r=this.duration,n=this.direction,a=this.type,o=this.parentOpacity,s=(this.parameterGroupName,0),l=this.textures.length;s0)for(var b=y[0].animations,S=0,x=b.length;S1){var B=2*(k-b.origin.x)/b.size.width-1,M=2*(T-b.origin.y)/b.size.height-1;E=1-B*B+(1-M*M)}var I=r[D],F=r[D+1],L=r[D+2],N=r[D+3],G=WebGraphics.makePoint4D(I/255,F/255,L/255,N/255);0!==G.w&&(x.x+=E*G.x/G.w,x.y+=E*G.y/G.w,x.z+=E*G.z/G.w,x.w+=E*G.w,C+=E)}else{N=r[D+3]/255;x.w+=N}}if(S=x.w>0,this.particleSystemVisibilities.push(S),void 0!==i.Color){0===C&&(C=1);var R=1/C,W=WebGraphics.multiplyPoint4DByScalar(x,R),O=u.Color;KNWebGLUtil.setPoint4DAtIndexForAttribute(W,g,O),KNWebGLUtil.setPoint4DAtIndexForAttribute(W,g+1,O),KNWebGLUtil.setPoint4DAtIndexForAttribute(W,g+2,O),KNWebGLUtil.setPoint4DAtIndexForAttribute(W,g+3,O)}}this.willOverrideStartingPoints&&(y.origin=WebGraphics.setOrigin(y.origin,this.startingPointAtIndexPoint(v)));var U=[];U[0]=WebGraphics.makePoint(y.origin.x,y.origin.y),d>1&&(U[1]=WebGraphics.makePoint(y.origin.x+y.size.width,y.origin.y),U[2]=WebGraphics.makePoint(y.origin.x+y.size.width,y.origin.y+y.size.height),U[3]=WebGraphics.makePoint(y.origin.x,y.origin.y+y.size.height));for(var K=0;K=t.width*t.height)return t;if(e<1)return e=1,WebGraphics.makeSize(e,1);var n=0,a=0,o=Math.round(Math.sqrt(t.width*t.height));if((n=Math.ceil(t.width/o)*Math.ceil(t.height/o))===e)return WebGraphics.makeSize(o,o);if(n2);return o<=2?WebGraphics.makeSize(Math.ceil(t.width/2),Math.ceil(t.height/2)):Math.abs(n-e)e&&o>2);return o<=2?WebGraphics.makeSize(Math.ceil(t.width/2),Math.ceil(t.height/2)):Math.abs(n-e)=0;v--){var g=r-v;a[4*d+v*i*4+3]/255>.1&&(f=Math.min(g,f),m=Math.max(g,m),p=!0)}p&&(A.y=m/r,s.x=Math.min(s.x,d),l.x=Math.max(l.x,d),s.y=Math.min(s.y,f),l.y=Math.max(l.y,m)),h[d]=A}o={width:l.x-s.x,height:l.y-s.y},this._actualSize=o,this._bottomRow=h,this._bottomRowCount=c,t.bindFramebuffer(t.FRAMEBUFFER,null),this.animationWillBeginWithContext();for(var y=this.attributeBuffers.Position,b=this.attributeBuffers.Center,S=this._actualSize.height/2,x=this.numberOfVerticesPerParticle,C=0,w=this.particleCount;CR+W?1:(O-R)/W,I.timingFunction&&"Linear"!==I.timingFunction&&(k=a.doubleForAnimationCurve(I.timingFunction,k))}else k=G;break;case"contents":r=o.toTexture}}var U=l.hidden?0:o.parentOpacity*l.opacity;P!==T&&(U=P+(T-P)*k),e.setGLFloat(U,kTSDGLShaderUniformOpacity);var K=WebGraphics.translateMatrix4(c,m,-p,0);K=WebGraphics.translateMatrix4(K,A,-v,0);var V=l.anchorPoint;.5===V.pointX&&.5===V.pointY||(f.x=V.pointX*s.size.width,f.y=(1-V.pointY)*s.size.height),K=WebGraphics.translateMatrix4(K,f.x,f.y,0);var Q=l.rotation;x&&(C!==Q&&(Q=C),Q+=(w-C)*G),0!==Q&&(K=WebGraphics.rotateMatrix4AboutXYZ(K,-Q,0,0,1));var z=l.scale;1!==z&&(K=WebGraphics.scaleMatrix4(K,z,z,1)),g===b&&y===S||(K=WebGraphics.scaleMatrix4(K,(b-g)*G+g,(S-y)*G+y,1)),K=WebGraphics.translateMatrix4(K,-f.x,-f.y,0),e.setMat4WithTransform3D(K,kTSDGLShaderUniformMVPMatrix),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),d?(n.activeTexture(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,r),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,D),e.setGLFloat(G,"mixFactor")):n.bindTexture(n.TEXTURE_2D,D),t.drawWithShader(e,!0)}}]),e}(),KNWebGLCoreAnimationWrapperBasedEffect=function(){function e(t,i,r,n,a,o,s,l,h,c){_classCallCheck(this,e),this.renderer=t,this.gl=t.gl,this.program=i,this.slideRect=r,this.texture=n,this.frameRect=a,this.baseTransform=o,this.duration=s,this.direction=l,this.buildType=h,this.parentOpacity=c,this.animParameterGroup=new KNAnimParameterGroup("timingFunction"),this.percentfinished=0,this.prepareAnimationWithContext(),this.animationWillBeginWithContext()}return _createClass(e,[{key:"isOrthographicProjection",value:function(){return!0}},{key:"prepareAnimationWithContext",value:function(){this.coreAnimationWrapper=this.renderer.coreAnimationWrapper,(this.textureDrawOptions=new KNWebGLCoreAnimationWrapperTextureDrawOptions(this.texture,this.duration,this.baseTransform)).isBlending=!!this.texture.toTexture}},{key:"animationWillBeginWithContext",value:function(){this.renderer;var e=this.gl,t=(this.frameRect,CGSizeMake(2,2)),i=(this.texture,this.objectShader=new TSDGLShader(e));i.initWithContentsAndOpacityShader(),i.setMat4WithTransform3D(this.baseTransform,kTSDGLShaderUniformMVPMatrix),i.setGLint(0,kTSDGLShaderUniformTexture2),i.setGLint(1,kTSDGLShaderUniformTexture);var r=this.texture.textureRect,n=CGRectMake(0,0,r.size.width,r.size.height);(this.objectDataBuffer=new TSDGLDataBuffer(e)).initWithVertexRect(n,TSDRectUnit,t,!1,!1)}},{key:"drawFrame",value:function(e,t,i){this.renderer;var r=this.gl,n=(this.buildOut,this.percentfinished);(n+=e/i)>=1&&(n=1,this.isCompleted=!0),this.percentfinished=n,r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA);var a=this.texture,o=(a.initialState,a.animations,this.objectShader),s=this.objectDataBuffer;if(a.animations.length>0){var l=n,h=this.textureDrawOptions;h.percent=l,this.coreAnimationWrapper.renderFrameWithContext(o,s,h)}else{var c=a.initialState.hidden?0:this.parentOpacity*a.initialState.opacity;o.setGLFloat(c,kTSDGLShaderUniformOpacity),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.bindTexture(r.TEXTURE_2D,a.texture),s.drawWithShader(o,!0)}}}]),e}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i0}},{key:"doubleForAnimationCurve",value:function(e,t){return this.pathForAnimationCurve(e).yValueFromXValue(t)}},{key:"pathForAnimationCurve",value:function(e){var t=this.animationCurves[e];if(!t){var i=this.parameterGroup[e];t=new CubicBezierPath(i.controlPoints[0],i.controlPoints[1]),this.animationCurves[e]=t}return t}}]),e}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i0&&(this.mGLData=new ArrayBuffer(this.mVertexCount*this.GLDataBufferEntrySize)),this.bufferCount=i,this.mNeedsUpdateFirstIndex=[],this.mNeedsUpdateLastIndex=[];for(n=0;n1&&(o=this.GLDataBufferEntrySize);var s=TSDGLDataBufferDataTypeAsGLEnum(n.dataType);t.enableVertexAttribArray(a),t.vertexAttribPointer(a,n.componentCount,s,n.isNormalized?GL_TRUE:GL_FALSE,o,n.bufferOffset)}}},{key:"disableVertexAttributeArrayBuffersWithShader",value:function(e){for(var t=this.gl,i=0,r=this._vertexAttributes.length;i0;){for(var a=n[0],o=[],s=0,l=n.length;s0&&(this.mElementArrayCount=i,this.mGLElementData=new ArrayBuffer(2*this.mElementArrayCount))}},{key:"initWithVertexRect",value:function(e,t,i,r,n){this.gl;var a,o,s=!CGRectEqualToRect(t,CGRectZero),l=[],h=new TSDGLDataBufferAttribute("Position",GL_STATIC_DRAW,GL_FLOAT,!1,2);if(l.push(h),s){var c=GL_SHORT;CGRectEqualToRect(t,CGRectMake(0,0,1,1))&&CGSizeEqualToSize(i,CGSizeMake(2,2))&&(c=GL_UNSIGNED_BYTE),a=new TSDGLDataBufferAttribute("TexCoord",GL_STATIC_DRAW,c,!0,2),l.push(a)}n&&(o=new TSDGLDataBufferAttribute("Center",GL_STATIC_DRAW,GL_FLOAT,!1,2),l.push(o)),this.initWithVertexAttributes(l,i);for(var u=0,d=TSDCenterOfRect(e),f=parseInt(i.width-1),m=parseInt(i.height-1),p=0;p<=m;++p)for(var A=0;A<=f;++A){var v=WebGraphics.makePoint(A/f,p/m),g=TSDPointFromNormalizedRect(v,e);if(this.setGLPoint2D(g,h,u),s){var y=TSDPointFromNormalizedRect(v,t);r&&(y=WebGraphics.makePoint(y.x,1-y.y)),this.setGLPoint2D(y,a,u)}n&&this.setGLPoint2D(d,o,u),u++}}},{key:"setGLPoint2D",value:function(e,t,i){t.dataArrayBuffer.setGLPoint2D(e,t,i)}},{key:"setGLushort",value:function(e,t){var i=t;new Uint16Array(this.mGLElementData).set([e],i)}},{key:"enableElementArrayBuffer",value:function(){var e=this.gl;this.p_setupGLElementArrayBufferIfNecessary(),this.mGLElementDataBufferWasSetup&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.mGLElementDataBuffer)}},{key:"disableElementArrayBuffer",value:function(){var e=this.gl;this.mGLElementDataBufferWasSetup&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)}},{key:"enableDataBufferWithShader",value:function(e){e.isActive||e.activate();for(var t=0,i=this.mArrayBuffers.length;t0?this.mElementArrayCount:this._vertexCount};if(this.enableDataBufferWithShader(e),this.mGLElementDataBufferWasSetup&&this.mElementArrayCount>0)if(i.bufferData(i.ELEMENT_ARRAY_BUFFER,this.mGLElementData,i.STATIC_DRAW),CGSizeEqualToSize(this.mGLElementMeshSize,CGSizeZero))i.drawElements(this.drawMode,r.length,i.UNSIGNED_SHORT,2*r.location);else for(var n=this.mGLElementMeshSize.width,a=0;a0){var t=(this.currentTextureIndex+1)%e;this.currentTextureIndex=t,this.bindFramebuffer()}}},{key:"bindFramebuffer",value:function(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.buffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.textures[this.currentTextureIndex],0)}},{key:"unbindFramebufferAndBindGLFramebuffer",value:function(e){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e)}}],[{key:"currentGLFramebuffer",value:function(e){return e.getParameter(e.FRAMEBUFFER_BINDING)}}]),e}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i