'use strict';window.DOMHandler=class{constructor(c,a){this._iRuntime=c;this._componentId=a;this._hasTickCallback=!1;this._tickCallback=()=>this.Tick()}Attach(){}PostToRuntime(c,a,b,e){this._iRuntime.PostToRuntimeComponent(this._componentId,c,a,b,e)}PostToRuntimeAsync(c,a,b,e){return this._iRuntime.PostToRuntimeComponentAsync(this._componentId,c,a,b,e)}_PostToRuntimeMaybeSync(c,a,b){this._iRuntime.UsesWorker()?this.PostToRuntime(c,a,b):this._iRuntime._GetLocalRuntime()._OnMessageFromDOM({type:"event",
component:this._componentId,handler:c,dispatchOpts:b||null,data:a,responseId:null})}AddRuntimeMessageHandler(c,a){this._iRuntime.AddRuntimeComponentMessageHandler(this._componentId,c,a)}AddRuntimeMessageHandlers(c){for(const [a,b]of c)this.AddRuntimeMessageHandler(a,b)}GetRuntimeInterface(){return this._iRuntime}GetComponentID(){return this._componentId}_StartTicking(){this._hasTickCallback||(this._iRuntime._AddRAFCallback(this._tickCallback),this._hasTickCallback=!0)}_StopTicking(){this._hasTickCallback&&
(this._iRuntime._RemoveRAFCallback(this._tickCallback),this._hasTickCallback=!1)}Tick(){}};
window.RateLimiter=class{constructor(c,a){this._callback=c;this._interval=a;this._timerId=-1;this._lastCallTime=-Infinity;this._timerCallFunc=()=>this._OnTimer();this._canRunImmediate=this._ignoreReset=!1}SetCanRunImmediate(c){this._canRunImmediate=!!c}Call(){if(-1===this._timerId){var c=Date.now(),a=c-this._lastCallTime,b=this._interval;a>=b&&this._canRunImmediate?(this._lastCallTime=c,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(b-a,4))}}_RunCallback(){this._ignoreReset=
!0;this._callback();this._ignoreReset=!1}Reset(){this._ignoreReset||(this._CancelTimer(),this._lastCallTime=Date.now())}_OnTimer(){this._timerId=-1;this._lastCallTime=Date.now();this._RunCallback()}_CancelTimer(){-1!==this._timerId&&(self.clearTimeout(this._timerId),this._timerId=-1)}Release(){this._CancelTimer();this._timerCallFunc=this._callback=null}};"use strict";
window.DOMElementHandler=class extends self.DOMHandler{constructor(c,a){super(c,a);this._elementMap=new Map;this._autoAttach=!0;this.AddRuntimeMessageHandlers([["create",b=>this._OnCreate(b)],["destroy",b=>this._OnDestroy(b)],["set-visible",b=>this._OnSetVisible(b)],["update-position",b=>this._OnUpdatePosition(b)],["update-state",b=>this._OnUpdateState(b)],["focus",b=>this._OnSetFocus(b)],["set-css-style",b=>this._OnSetCssStyle(b)],["set-attribute",b=>this._OnSetAttribute(b)],["remove-attribute",
b=>this._OnRemoveAttribute(b)]]);this.AddDOMElementMessageHandler("get-element",b=>b)}SetAutoAttach(c){this._autoAttach=!!c}AddDOMElementMessageHandler(c,a){this.AddRuntimeMessageHandler(c,b=>{const e=this._elementMap.get(b.elementId);return a(e,b)})}_OnCreate(c){const a=c.elementId,b=this.CreateElement(a,c);this._elementMap.set(a,b);c.isVisible||(b.style.display="none");c=this._GetFocusElement(b);c.addEventListener("focus",e=>this._OnFocus(a));c.addEventListener("blur",e=>this._OnBlur(a));this._autoAttach&&
document.body.appendChild(b)}CreateElement(c,a){throw Error("required override");}DestroyElement(c){}_OnDestroy(c){c=c.elementId;const a=this._elementMap.get(c);this.DestroyElement(a);this._autoAttach&&a.parentElement.removeChild(a);this._elementMap.delete(c)}PostToRuntimeElement(c,a,b){b||(b={});b.elementId=a;this.PostToRuntime(c,b)}_PostToRuntimeElementMaybeSync(c,a,b){b||(b={});b.elementId=a;this._PostToRuntimeMaybeSync(c,b)}_OnSetVisible(c){this._autoAttach&&(this._elementMap.get(c.elementId).style.display=
c.isVisible?"":"none")}_OnUpdatePosition(c){if(this._autoAttach){var a=this._elementMap.get(c.elementId);a.style.left=c.left+"px";a.style.top=c.top+"px";a.style.width=c.width+"px";a.style.height=c.height+"px";c=c.fontSize;null!==c&&(a.style.fontSize=c+"em")}}_OnUpdateState(c){const a=this._elementMap.get(c.elementId);this.UpdateState(a,c)}UpdateState(c,a){throw Error("required override");}_GetFocusElement(c){return c}_OnFocus(c){this.PostToRuntimeElement("elem-focused",c)}_OnBlur(c){this.PostToRuntimeElement("elem-blurred",
c)}_OnSetFocus(c){const a=this._GetFocusElement(this._elementMap.get(c.elementId));c.focus?a.focus():a.blur()}_OnSetCssStyle(c){this._elementMap.get(c.elementId).style[c.prop]=c.val}_OnSetAttribute(c){this._elementMap.get(c.elementId).setAttribute(c.name,c.val)}_OnRemoveAttribute(c){this._elementMap.get(c.elementId).removeAttribute(c.name)}GetElementById(c){return this._elementMap.get(c)}};"use strict";
{const c=/(iphone|ipod|ipad|macos|macintosh|mac os x)/i.test(navigator.userAgent);function a(r){if(r.isStringSrc){const g=document.createElement("script");g.async=!1;g.textContent=r.str;document.head.appendChild(g)}else return new Promise((g,k)=>{const d=document.createElement("script");d.onload=g;d.onerror=k;d.async=!1;d.src=r;document.head.appendChild(d)})}let b=new Audio;const e={"audio/webm; codecs=opus":!!b.canPlayType("audio/webm; codecs=opus"),"audio/ogg; codecs=opus":!!b.canPlayType("audio/ogg; codecs=opus"),
"audio/webm; codecs=vorbis":!!b.canPlayType("audio/webm; codecs=vorbis"),"audio/ogg; codecs=vorbis":!!b.canPlayType("audio/ogg; codecs=vorbis"),"audio/mp4":!!b.canPlayType("audio/mp4"),"audio/mpeg":!!b.canPlayType("audio/mpeg")};b=null;async function h(r){r=await m(r);return(new TextDecoder("utf-8")).decode(r)}function m(r){return new Promise((g,k)=>{const d=new FileReader;d.onload=f=>g(f.target.result);d.onerror=f=>k(f);d.readAsArrayBuffer(r)})}const q=[];let u=0;window.RealFile=window.File;const w=
[],z=new Map,v=new Map;let x=0;const A=[];self.runOnStartup=function(r){if("function"!==typeof r)throw Error("runOnStartup called without a function");A.push(r)};const y=new Set(["cordova","playable-ad","instant-games"]);function B(r){return y.has(r)}window.RuntimeInterface=class r{constructor(g){this._useWorker=g.useWorker;this._messageChannelPort=null;this._baseUrl="";this._scriptFolder=g.scriptFolder;this._workerScriptBlobURLs={};this._loadingElem=this._localRuntime=this._worker=null;this._domHandlers=
[];this._jobScheduler=this._canvas=this._runtimeDomHandler=null;this._rafId=-1;this._rafFunc=()=>this._OnRAFCallback();this._rafCallbacks=[];this._exportType=g.exportType;!this._useWorker||"undefined"!==typeof OffscreenCanvas&&navigator.userActivation||(this._useWorker=!1);B(this._exportType)&&this._useWorker&&(console.warn("[C3 runtime] Worker mode is enabled and supported, but is disabled in WebViews due to crbug.com/923007. Reverting to DOM mode."),this._useWorker=!1);this._localFileStrings=this._localFileBlobs=
null;"html5"!==this._exportType&&"playable-ad"!==this._exportType||"file"!==location.protocol.substr(0,4)||alert("Exported games won't work until you upload them. (When running on the file: protocol, browsers block many features from working for security reasons.)");this.AddRuntimeComponentMessageHandler("runtime","cordova-fetch-local-file",k=>this._OnCordovaFetchLocalFile(k));this.AddRuntimeComponentMessageHandler("runtime","create-job-worker",k=>this._OnCreateJobWorker(k));"cordova"===this._exportType?
document.addEventListener("deviceready",()=>this._Init(g)):this._Init(g)}Release(){this._CancelAnimationFrame();this._messageChannelPort&&(this._messageChannelPort=this._messageChannelPort.onmessage=null);this._worker&&(this._worker.terminate(),this._worker=null);this._localRuntime&&(this._localRuntime.Release(),this._localRuntime=null);this._canvas&&(this._canvas.parentElement.removeChild(this._canvas),this._canvas=null)}GetCanvas(){return this._canvas}GetBaseURL(){return this._baseUrl}UsesWorker(){return this._useWorker}GetExportType(){return this._exportType}GetScriptFolder(){return this._scriptFolder}IsiOSCordova(){return c&&
"cordova"===this._exportType}IsiOSWebView(){return c&&B(this._exportType)||navigator.standalone}async _Init(g){"preview"===this._exportType&&(this._loadingElem=document.createElement("div"),this._loadingElem.className="previewLoadingMessage",this._loadingElem.textContent=g.previewLoadingMessage,document.body.appendChild(this._loadingElem));if("playable-ad"===this._exportType){this._localFileBlobs=self.c3_base64files;this._localFileStrings={};await this._ConvertDataUrisToBlobs();for(let d=0,f=g.engineScripts.length;d<
f;++d){var k=g.engineScripts[d].toLowerCase();this._localFileStrings.hasOwnProperty(k)?g.engineScripts[d]={isStringSrc:!0,str:this._localFileStrings[k]}:this._localFileBlobs.hasOwnProperty(k)&&(g.engineScripts[d]=URL.createObjectURL(this._localFileBlobs[k]))}}g.baseUrl?this._baseUrl=g.baseUrl:(k=location.origin,this._baseUrl=("null"===k?"file:///":k)+location.pathname,k=this._baseUrl.lastIndexOf("/"),-1!==k&&(this._baseUrl=this._baseUrl.substr(0,k+1)));if(g.workerScripts)for(const [d,f]of Object.entries(g.workerScripts))this._workerScriptBlobURLs[d]=
URL.createObjectURL(f);k=new MessageChannel;this._messageChannelPort=k.port1;this._messageChannelPort.onmessage=d=>this._OnMessageFromRuntime(d.data);window.c3_addPortMessageHandler&&window.c3_addPortMessageHandler(d=>this._OnMessageFromDebugger(d));this._jobScheduler=new self.JobSchedulerDOM(this);await this._jobScheduler.Init();this.MaybeForceBodySize();"object"===typeof window.StatusBar&&window.StatusBar.hide();"object"===typeof window.AndroidFullScreen&&window.AndroidFullScreen.immersiveMode();
this._useWorker?await this._InitWorker(g,k.port2):await this._InitDOM(g,k.port2)}_GetWorkerURL(g){return this._workerScriptBlobURLs.hasOwnProperty(g)?this._workerScriptBlobURLs[g]:g.endsWith("/workermain.js")&&this._workerScriptBlobURLs.hasOwnProperty("workermain.js")?this._workerScriptBlobURLs["workermain.js"]:"playable-ad"===this._exportType&&this._localFileBlobs.hasOwnProperty(g.toLowerCase())?URL.createObjectURL(this._localFileBlobs[g.toLowerCase()]):g}async CreateWorker(g,k,d){if(g.startsWith("blob:"))return new Worker(g,
d);if(this.IsiOSCordova()&&"file:"===location.protocol)return g=await this.CordovaFetchLocalFileAsArrayBuffer(this._scriptFolder+g),g=new Blob([g],{type:"application/javascript"}),new Worker(URL.createObjectURL(g),d);g=new URL(g,k);if(location.origin!==g.origin){g=await fetch(g);if(!g.ok)throw Error("failed to fetch worker script");g=await g.blob();return new Worker(URL.createObjectURL(g),d)}return new Worker(g,d)}_GetWindowInnerWidth(){return Math.max(window.innerWidth,1)}_GetWindowInnerHeight(){return Math.max(window.innerHeight,
1)}MaybeForceBodySize(){if(this.IsiOSWebView()){const g=document.documentElement.style,k=document.body.style,d=window.innerWidth<window.innerHeight,f=d?window.screen.width:window.screen.height;k.height=g.height=(d?window.screen.height:window.screen.width)+"px";k.width=g.width=f+"px"}}_GetCommonRuntimeOptions(g){return{baseUrl:this._baseUrl,windowInnerWidth:this._GetWindowInnerWidth(),windowInnerHeight:this._GetWindowInnerHeight(),devicePixelRatio:window.devicePixelRatio,isFullscreen:r.IsDocumentFullscreen(),
projectData:g.projectData,previewImageBlobs:window.cr_previewImageBlobs||this._localFileBlobs,previewProjectFileBlobs:window.cr_previewProjectFileBlobs,exportType:g.exportType,isDebug:-1<self.location.search.indexOf("debug"),ife:!!self.ife,jobScheduler:this._jobScheduler.GetPortData(),supportedAudioFormats:e,opusWasmScriptUrl:window.cr_opusWasmScriptUrl||this._scriptFolder+"opus.wasm.js",opusWasmBinaryUrl:window.cr_opusWasmBinaryUrl||this._scriptFolder+"opus.wasm.wasm",isiOSCordova:this.IsiOSCordova(),
isiOSWebView:this.IsiOSWebView(),isFBInstantAvailable:"undefined"!==typeof self.FBInstant}}async _InitWorker(g,k){var d=this._GetWorkerURL(g.workerMainUrl);this._worker=await this.CreateWorker(d,this._baseUrl,{name:"Runtime"});this._canvas=document.createElement("canvas");this._canvas.style.display="none";d=this._canvas.transferControlToOffscreen();document.body.appendChild(this._canvas);window.c3canvas=this._canvas;this._worker.postMessage(Object.assign(this._GetCommonRuntimeOptions(g),{type:"init-runtime",
isInWorker:!0,messagePort:k,canvas:d,workerDependencyScripts:g.workerDependencyScripts||[],engineScripts:g.engineScripts,projectScripts:window.cr_allProjectScripts,projectScriptsStatus:self.C3_ProjectScriptsStatus}),[k,d,...this._jobScheduler.GetPortTransferables()]);this._domHandlers=w.map(f=>new f(this));this._FindRuntimeDOMHandler();self.c3_callFunction=(f,l)=>this._runtimeDomHandler._InvokeFunctionFromJS(f,l);"preview"===this._exportType&&(self.goToLastErrorScript=()=>this.PostToRuntimeComponent("runtime",
"go-to-last-error-script"))}async _InitDOM(g,k){this._canvas=document.createElement("canvas");this._canvas.style.display="none";document.body.appendChild(this._canvas);window.c3canvas=this._canvas;this._domHandlers=w.map(f=>new f(this));this._FindRuntimeDOMHandler();const d=g.engineScripts.map(f=>"string"===typeof f?(new URL(f,this._baseUrl)).toString():f);Array.isArray(g.workerDependencyScripts)&&d.unshift(...g.workerDependencyScripts);await Promise.all(d.map(f=>a(f)));if(g.projectScripts&&0<g.projectScripts.length){const f=
self.C3_ProjectScriptsStatus;try{if(await Promise.all(g.projectScripts.map(l=>a(l[1]))),Object.values(f).some(l=>!l)){self.setTimeout(()=>this._ReportProjectScriptError(f),100);return}}catch(l){console.error("[Preview] Error loading project scripts: ",l);self.setTimeout(()=>this._ReportProjectScriptError(f),100);return}}"preview"===this._exportType&&"object"!==typeof self.C3.ScriptsInEvents?(this._RemoveLoadingMessage(),console.error("[C3 runtime] Failed to load JavaScript code used in events. Check all your JavaScript code has valid syntax."),
alert("Failed to load JavaScript code used in events. Check all your JavaScript code has valid syntax.")):(g=Object.assign(this._GetCommonRuntimeOptions(g),{isInWorker:!1,messagePort:k,canvas:this._canvas,runOnStartupFunctions:A}),this._OnBeforeCreateRuntime(),this._localRuntime=self.C3_CreateRuntime(g),await self.C3_InitRuntime(this._localRuntime,g))}_ReportProjectScriptError(g){this._RemoveLoadingMessage();g=`Failed to load project script '${Object.entries(g).filter(k=>!k[1]).map(k=>k[0])[0]}'. Check all your JavaScript code has valid syntax.`;
console.error("[Preview] "+g);alert(g)}_OnBeforeCreateRuntime(){this._RemoveLoadingMessage()}_RemoveLoadingMessage(){this._loadingElem&&(this._loadingElem.parentElement.removeChild(this._loadingElem),this._loadingElem=null)}async _OnCreateJobWorker(g){g=await this._jobScheduler._CreateJobWorker();return{outputPort:g,transferables:[g]}}_GetLocalRuntime(){if(this._useWorker)throw Error("not available in worker mode");return this._localRuntime}PostToRuntimeComponent(g,k,d,f,l){this._messageChannelPort.postMessage({type:"event",
component:g,handler:k,dispatchOpts:f||null,data:d,responseId:null},l)}PostToRuntimeComponentAsync(g,k,d,f,l){const n=x++,p=new Promise((t,C)=>{v.set(n,{resolve:t,reject:C})});this._messageChannelPort.postMessage({type:"event",component:g,handler:k,dispatchOpts:f||null,data:d,responseId:n},l);return p}["_OnMessageFromRuntime"](g){const k=g.type;if("event"===k)return this._OnEventFromRuntime(g);if("result"===k)this._OnResultFromRuntime(g);else if("runtime-ready"===k)this._OnRuntimeReady();else if("alert-error"===
k)this._RemoveLoadingMessage(),alert(g.message);else if("creating-runtime"===k)this._OnBeforeCreateRuntime();else throw Error(`unknown message '${k}'`);}_OnEventFromRuntime(g){const k=g.component,d=g.handler,f=g.data,l=g.responseId;if(g=z.get(k))if(g=g.get(d)){var n=null;try{n=g(f)}catch(p){console.error(`Exception in '${k}' handler '${d}':`,p);null!==l&&this._PostResultToRuntime(l,!1,""+p);return}if(null===l)return n;n&&n.then?n.then(p=>this._PostResultToRuntime(l,!0,p)).catch(p=>{console.error(`Rejection from '${k}' handler '${d}':`,
p);this._PostResultToRuntime(l,!1,""+p)}):this._PostResultToRuntime(l,!0,n)}else console.warn(`[DOM] No handler '${d}' for component '${k}'`);else console.warn(`[DOM] No event handlers for component '${k}'`)}_PostResultToRuntime(g,k,d){let f;d&&d.transferables&&(f=d.transferables);this._messageChannelPort.postMessage({type:"result",responseId:g,isOk:k,result:d},f)}_OnResultFromRuntime(g){const k=g.responseId,d=g.isOk;g=g.result;const f=v.get(k);d?f.resolve(g):f.reject(g);v.delete(k)}AddRuntimeComponentMessageHandler(g,
k,d){let f=z.get(g);f||(f=new Map,z.set(g,f));if(f.has(k))throw Error(`[DOM] Component '${g}' already has handler '${k}'`);f.set(k,d)}static AddDOMHandlerClass(g){if(w.includes(g))throw Error("DOM handler already added");w.push(g)}_FindRuntimeDOMHandler(){for(const g of this._domHandlers)if("runtime"===g.GetComponentID()){this._runtimeDomHandler=g;return}throw Error("cannot find runtime DOM handler");}_OnMessageFromDebugger(g){this.PostToRuntimeComponent("debugger","message",g)}_OnRuntimeReady(){for(const g of this._domHandlers)g.Attach()}static IsDocumentFullscreen(){return!!(document.fullscreenElement||
document.webkitFullscreenElement||document.mozFullScreenElement)}async GetRemotePreviewStatusInfo(){return await this.PostToRuntimeComponentAsync("runtime","get-remote-preview-status-info")}_AddRAFCallback(g){this._rafCallbacks.push(g);this._RequestAnimationFrame()}_RemoveRAFCallback(g){g=this._rafCallbacks.indexOf(g);if(-1===g)throw Error("invalid callback");this._rafCallbacks.splice(g,1);this._rafCallbacks.length||this._CancelAnimationFrame()}_RequestAnimationFrame(){-1===this._rafId&&this._rafCallbacks.length&&
(this._rafId=requestAnimationFrame(this._rafFunc))}_CancelAnimationFrame(){-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1)}_OnRAFCallback(){this._rafId=-1;for(const g of this._rafCallbacks)g();this._RequestAnimationFrame()}TryPlayMedia(g){this._runtimeDomHandler.TryPlayMedia(g)}RemovePendingPlay(g){this._runtimeDomHandler.RemovePendingPlay(g)}_PlayPendingMedia(){this._runtimeDomHandler._PlayPendingMedia()}SetSilent(g){this._runtimeDomHandler.SetSilent(g)}IsAudioFormatSupported(g){return!!e[g]}async _WasmDecodeWebMOpus(g){g=
await this.PostToRuntimeComponentAsync("runtime","opus-decode",{arrayBuffer:g},null,[g]);return new Float32Array(g)}IsAbsoluteURL(g){return/^(?:[a-z]+:)?\/\//.test(g)||"data:"===g.substr(0,5)||"blob:"===g.substr(0,5)}IsRelativeURL(g){return!this.IsAbsoluteURL(g)}async _OnCordovaFetchLocalFile(g){const k=g.filename;switch(g.as){case "text":return await this.CordovaFetchLocalFileAsText(k);case "buffer":return await this.CordovaFetchLocalFileAsArrayBuffer(k);default:throw Error("unsupported type");}}_GetPermissionAPI(){const g=
window.cordova&&window.cordova.plugins&&window.cordova.plugins.permissions;if("object"!==typeof g)throw Error("Permission API is not loaded");return g}_MapPermissionID(g,k){g=g[k];if("string"!==typeof g)throw Error("Invalid permission name");return g}_HasPermission(g){const k=this._GetPermissionAPI();return new Promise((d,f)=>k.checkPermission(this._MapPermissionID(k,g),l=>d(!!l.hasPermission),f))}_RequestPermission(g){const k=this._GetPermissionAPI();return new Promise((d,f)=>k.requestPermission(this._MapPermissionID(k,
g),l=>d(!!l.hasPermission),f))}async RequestPermissions(g){if("cordova"!==this.GetExportType()||this.IsiOSCordova())return!0;for(const k of g)if(!await this._HasPermission(k)&&!1===await this._RequestPermission(k))return!1;return!0}async RequirePermissions(...g){if(!1===await this.RequestPermissions(g))throw Error("Permission not granted");}CordovaFetchLocalFile(g){const k=window.cordova.file.applicationDirectory+"www/"+g.toLowerCase();return new Promise((d,f)=>{window.resolveLocalFileSystemURL(k,
l=>{l.file(d,f)},f)})}async CordovaFetchLocalFileAsText(g){g=await this.CordovaFetchLocalFile(g);return await h(g)}_CordovaMaybeStartNextArrayBufferRead(){if(q.length&&!(8<=u)){u++;var g=q.shift();this._CordovaDoFetchLocalFileAsAsArrayBuffer(g.filename,g.successCallback,g.errorCallback)}}CordovaFetchLocalFileAsArrayBuffer(g){return new Promise((k,d)=>{q.push({filename:g,successCallback:f=>{u--;this._CordovaMaybeStartNextArrayBufferRead();k(f)},errorCallback:f=>{u--;this._CordovaMaybeStartNextArrayBufferRead();
d(f)}});this._CordovaMaybeStartNextArrayBufferRead()})}async _CordovaDoFetchLocalFileAsAsArrayBuffer(g,k,d){try{const f=await this.CordovaFetchLocalFile(g),l=await m(f);k(l)}catch(f){d(f)}}async _ConvertDataUrisToBlobs(){const g=[];for(const [k,d]of Object.entries(this._localFileBlobs))g.push(this._ConvertDataUriToBlobs(k,d));await Promise.all(g)}async _ConvertDataUriToBlobs(g,k){if("object"===typeof k)this._localFileBlobs[g]=new Blob([k.str],{type:k.type}),this._localFileStrings[g]=k.str;else{let d=
await this._FetchDataUri(k);d||(d=this._DataURIToBinaryBlobSync(k));this._localFileBlobs[g]=d}}async _FetchDataUri(g){try{return await (await fetch(g)).blob()}catch(k){return console.warn("Failed to fetch a data: URI. Falling back to a slower workaround. This is probably because the Content Security Policy unnecessarily blocked it. Allow data: URIs in your CSP to avoid this.",k),null}}_DataURIToBinaryBlobSync(g){g=this._ParseDataURI(g);return this._BinaryStringToBlob(g.data,g.mime_type)}_ParseDataURI(g){var k=
g.indexOf(",");if(0>k)throw new URIError("expected comma in data: uri");var d=g.substring(5,k);g=g.substring(k+1);k=d.split(";");d=k[0]||"";const f=k[2];g="base64"===k[1]||"base64"===f?atob(g):decodeURIComponent(g);return{mime_type:d,data:g}}_BinaryStringToBlob(g,k){var d=g.length;let f=d>>2,l=new Uint8Array(d),n=new Uint32Array(l.buffer,0,f),p,t;for(t=p=0;p<f;++p)n[p]=g.charCodeAt(t++)|g.charCodeAt(t++)<<8|g.charCodeAt(t++)<<16|g.charCodeAt(t++)<<24;for(d&=3;d--;)l[t]=g.charCodeAt(t),++t;return new Blob([l],
{type:k})}}}"use strict";
{const c=self.RuntimeInterface;function a(d){return d.sourceCapabilities&&d.sourceCapabilities.firesTouchEvents||d.originalEvent&&d.originalEvent.sourceCapabilities&&d.originalEvent.sourceCapabilities.firesTouchEvents}const b=new Map([["OSLeft","MetaLeft"],["OSRight","MetaRight"]]),e={dispatchRuntimeEvent:!0,dispatchUserScriptEvent:!0},h={dispatchUserScriptEvent:!0},m={dispatchRuntimeEvent:!0};function q(d){return new Promise((f,l)=>{const n=document.createElement("link");n.onload=()=>f(n);n.onerror=
p=>l(p);n.rel="stylesheet";n.href=d;document.head.appendChild(n)})}function u(d){return new Promise((f,l)=>{const n=new Image;n.onload=()=>f(n);n.onerror=p=>l(p);n.src=d})}async function w(d){d=URL.createObjectURL(d);try{return await u(d)}finally{URL.revokeObjectURL(d)}}function z(d){return new Promise((f,l)=>{let n=new FileReader;n.onload=p=>f(p.target.result);n.onerror=p=>l(p);n.readAsText(d)})}async function v(d,f,l){if(!/firefox/i.test(navigator.userAgent))return await w(d);var n=await z(d);n=
(new DOMParser).parseFromString(n,"image/svg+xml");const p=n.documentElement;if(p.hasAttribute("width")&&p.hasAttribute("height")){const t=p.getAttribute("width"),C=p.getAttribute("height");if(!t.includes("%")&&!C.includes("%"))return await w(d)}p.setAttribute("width",f+"px");p.setAttribute("height",l+"px");n=(new XMLSerializer).serializeToString(n);d=new Blob([n],{type:"image/svg+xml"});return await w(d)}function x(d){do{if(d.parentNode&&d.hasAttribute("contenteditable"))return!0;d=d.parentNode}while(d);
return!1}const A=new Set(["canvas","body","html"]);function y(d){const f=d.target.tagName.toLowerCase();A.has(f)&&d.preventDefault()}function B(d){(d.metaKey||d.ctrlKey)&&d.preventDefault()}self.C3_GetSvgImageSize=async function(d){d=await w(d);if(0<d.width&&0<d.height)return[d.width,d.height];{d.style.position="absolute";d.style.left="0px";d.style.top="0px";d.style.visibility="hidden";document.body.appendChild(d);const f=d.getBoundingClientRect();document.body.removeChild(d);return[f.width,f.height]}};
self.C3_RasterSvgImageBlob=async function(d,f,l,n,p){d=await v(d,f,l);const t=document.createElement("canvas");t.width=n;t.height=p;t.getContext("2d").drawImage(d,0,0,f,l);return t};let r=!1;document.addEventListener("pause",()=>r=!0);document.addEventListener("resume",()=>r=!1);function g(){try{return window.parent&&window.parent.document.hasFocus()}catch(d){return!1}}function k(){const d=document.activeElement;if(!d)return!1;const f=d.tagName.toLowerCase(),l=new Set("email number password search tel text url".split(" "));
return"textarea"===f?!0:"input"===f?l.has(d.type.toLowerCase()||"text"):x(d)}c.AddDOMHandlerClass(class extends self.DOMHandler{constructor(d){super(d,"runtime");this._isFirstSizeUpdate=!0;this._simulatedResizeTimerId=-1;this._targetOrientation="any";this._attachedDeviceMotionEvent=this._attachedDeviceOrientationEvent=!1;this._lastPointerRawUpdateEvent=this._pointerRawUpdateRateLimiter=this._debugHighlightElem=null;d.AddRuntimeComponentMessageHandler("canvas","update-size",n=>this._OnUpdateCanvasSize(n));
d.AddRuntimeComponentMessageHandler("runtime","invoke-download",n=>this._OnInvokeDownload(n));d.AddRuntimeComponentMessageHandler("runtime","raster-svg-image",n=>this._OnRasterSvgImage(n));d.AddRuntimeComponentMessageHandler("runtime","get-svg-image-size",n=>this._OnGetSvgImageSize(n));d.AddRuntimeComponentMessageHandler("runtime","set-target-orientation",n=>this._OnSetTargetOrientation(n));d.AddRuntimeComponentMessageHandler("runtime","register-sw",()=>this._OnRegisterSW());d.AddRuntimeComponentMessageHandler("runtime",
"post-to-debugger",n=>this._OnPostToDebugger(n));d.AddRuntimeComponentMessageHandler("runtime","go-to-script",n=>this._OnPostToDebugger(n));d.AddRuntimeComponentMessageHandler("runtime","before-start-ticking",()=>this._OnBeforeStartTicking());d.AddRuntimeComponentMessageHandler("runtime","debug-highlight",n=>this._OnDebugHighlight(n));d.AddRuntimeComponentMessageHandler("runtime","enable-device-orientation",()=>this._AttachDeviceOrientationEvent());d.AddRuntimeComponentMessageHandler("runtime","enable-device-motion",
()=>this._AttachDeviceMotionEvent());d.AddRuntimeComponentMessageHandler("runtime","add-stylesheet",n=>this._OnAddStylesheet(n));d.AddRuntimeComponentMessageHandler("runtime","alert",n=>this._OnAlert(n));d.AddRuntimeComponentMessageHandler("runtime","hide-cordova-splash",()=>this._OnHideCordovaSplash());const f=new Set(["input","textarea","datalist"]);window.addEventListener("contextmenu",n=>{const p=n.target,t=p.tagName.toLowerCase();f.has(t)||x(p)||n.preventDefault()});const l=d.GetCanvas();window.addEventListener("selectstart",
y);window.addEventListener("gesturehold",y);l.addEventListener("selectstart",y);l.addEventListener("gesturehold",y);window.addEventListener("touchstart",y,{passive:!1});"undefined"!==typeof PointerEvent?(window.addEventListener("pointerdown",y,{passive:!1}),l.addEventListener("pointerdown",y)):l.addEventListener("touchstart",y);this._mousePointerLastButtons=0;window.addEventListener("mousedown",n=>{1===n.button&&n.preventDefault()});window.addEventListener("mousewheel",B,{passive:!1});window.addEventListener("wheel",
B,{passive:!1});window.addEventListener("resize",()=>this._OnWindowResize());d.IsiOSWebView()&&window.addEventListener("focusout",()=>{k()||(document.scrollingElement.scrollTop=0)});this._mediaPendingPlay=new Set;this._mediaRemovedPendingPlay=new WeakSet;this._isSilent=!1}_OnBeforeStartTicking(){"cordova"===this._iRuntime.GetExportType()?(document.addEventListener("pause",()=>this._OnVisibilityChange(!0)),document.addEventListener("resume",()=>this._OnVisibilityChange(!1))):document.addEventListener("visibilitychange",
()=>this._OnVisibilityChange(document.hidden));return{isSuspended:!(!document.hidden&&!r)}}Attach(){window.addEventListener("focus",()=>this._PostRuntimeEvent("window-focus"));window.addEventListener("blur",()=>{this._PostRuntimeEvent("window-blur",{parentHasFocus:g()});this._mousePointerLastButtons=0});window.addEventListener("fullscreenchange",()=>this._OnFullscreenChange());window.addEventListener("webkitfullscreenchange",()=>this._OnFullscreenChange());window.addEventListener("mozfullscreenchange",
()=>this._OnFullscreenChange());window.addEventListener("fullscreenerror",f=>this._OnFullscreenError(f));window.addEventListener("webkitfullscreenerror",f=>this._OnFullscreenError(f));window.addEventListener("mozfullscreenerror",f=>this._OnFullscreenError(f));window.addEventListener("keydown",f=>this._OnKeyEvent("keydown",f));window.addEventListener("keyup",f=>this._OnKeyEvent("keyup",f));window.addEventListener("dblclick",f=>this._OnMouseEvent("dblclick",f,e));window.addEventListener("wheel",f=>
this._OnMouseWheelEvent("wheel",f));"undefined"!==typeof PointerEvent?(window.addEventListener("pointerdown",f=>{this._HandlePointerDownFocus(f);this._OnPointerEvent("pointerdown",f)}),this._iRuntime.UsesWorker()&&"undefined"!==typeof window.onpointerrawupdate&&self===self.top?(this._pointerRawUpdateRateLimiter=new self.RateLimiter(()=>this._DoSendPointerRawUpdate(),5),this._pointerRawUpdateRateLimiter.SetCanRunImmediate(!0),window.addEventListener("pointerrawupdate",f=>this._OnPointerRawUpdate(f))):
window.addEventListener("pointermove",f=>this._OnPointerEvent("pointermove",f)),window.addEventListener("pointerup",f=>this._OnPointerEvent("pointerup",f)),window.addEventListener("pointercancel",f=>this._OnPointerEvent("pointercancel",f))):(window.addEventListener("mousedown",f=>{this._HandlePointerDownFocus(f);this._OnMouseEventAsPointer("pointerdown",f)}),window.addEventListener("mousemove",f=>this._OnMouseEventAsPointer("pointermove",f)),window.addEventListener("mouseup",f=>this._OnMouseEventAsPointer("pointerup",
f)),window.addEventListener("touchstart",f=>{this._HandlePointerDownFocus(f);this._OnTouchEvent("pointerdown",f)}),window.addEventListener("touchmove",f=>this._OnTouchEvent("pointermove",f)),window.addEventListener("touchend",f=>this._OnTouchEvent("pointerup",f)),window.addEventListener("touchcancel",f=>this._OnTouchEvent("pointercancel",f)));const d=()=>this._PlayPendingMedia();window.addEventListener("pointerup",d,!0);window.addEventListener("touchend",d,!0);window.addEventListener("click",d,!0);
window.addEventListener("keydown",d,!0);window.addEventListener("gamepadconnected",d,!0)}_PostRuntimeEvent(d,f){this.PostToRuntime(d,f||null,m)}_GetWindowInnerWidth(){return this._iRuntime._GetWindowInnerWidth()}_GetWindowInnerHeight(){return this._iRuntime._GetWindowInnerHeight()}_OnWindowResize(){const d=this._GetWindowInnerWidth(),f=this._GetWindowInnerHeight();this._PostRuntimeEvent("window-resize",{innerWidth:d,innerHeight:f,devicePixelRatio:window.devicePixelRatio});this._iRuntime.IsiOSWebView()&&
(-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._OnSimulatedResize(d,f,0))}_ScheduleSimulatedResize(d,f,l){-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId);this._simulatedResizeTimerId=setTimeout(()=>this._OnSimulatedResize(d,f,l),48)}_OnSimulatedResize(d,f,l){const n=this._GetWindowInnerWidth(),p=this._GetWindowInnerHeight();this._simulatedResizeTimerId=-1;n!=d||p!=f?this._PostRuntimeEvent("window-resize",{innerWidth:n,innerHeight:p,
devicePixelRatio:window.devicePixelRatio}):10>l&&this._ScheduleSimulatedResize(n,p,l+1)}_OnSetTargetOrientation(d){this._targetOrientation=d.targetOrientation}_TrySetTargetOrientation(){const d=this._targetOrientation;if(screen.orientation&&screen.orientation.lock)screen.orientation.lock(d).catch(f=>console.warn("[Construct 3] Failed to lock orientation: ",f));else try{let f=!1;screen.lockOrientation?f=screen.lockOrientation(d):screen.webkitLockOrientation?f=screen.webkitLockOrientation(d):screen.mozLockOrientation?
f=screen.mozLockOrientation(d):screen.msLockOrientation&&(f=screen.msLockOrientation(d));f||console.warn("[Construct 3] Failed to lock orientation")}catch(f){console.warn("[Construct 3] Failed to lock orientation: ",f)}}_OnFullscreenChange(){const d=c.IsDocumentFullscreen();d&&"any"!==this._targetOrientation&&this._TrySetTargetOrientation();this.PostToRuntime("fullscreenchange",{isFullscreen:d,innerWidth:this._GetWindowInnerWidth(),innerHeight:this._GetWindowInnerHeight()})}_OnFullscreenError(d){console.warn("[Construct 3] Fullscreen request failed: ",
d);this.PostToRuntime("fullscreenerror",{isFullscreen:c.IsDocumentFullscreen(),innerWidth:this._GetWindowInnerWidth(),innerHeight:this._GetWindowInnerHeight()})}_OnVisibilityChange(d){d?this._iRuntime._CancelAnimationFrame():this._iRuntime._RequestAnimationFrame();this.PostToRuntime("visibilitychange",{hidden:d})}_OnKeyEvent(d,f){"Backspace"===f.key&&y(f);const l=b.get(f.code)||f.code;this._PostToRuntimeMaybeSync(d,{code:l,key:f.key,which:f.which,repeat:f.repeat,altKey:f.altKey,ctrlKey:f.ctrlKey,
metaKey:f.metaKey,shiftKey:f.shiftKey,timeStamp:f.timeStamp},e)}_OnMouseWheelEvent(d,f){this.PostToRuntime(d,{clientX:f.clientX,clientY:f.clientY,pageX:f.pageX,pageY:f.pageY,deltaX:f.deltaX,deltaY:f.deltaY,deltaZ:f.deltaZ,deltaMode:f.deltaMode,timeStamp:f.timeStamp},e)}_OnMouseEvent(d,f,l){a(f)||this._PostToRuntimeMaybeSync(d,{button:f.button,buttons:f.buttons,clientX:f.clientX,clientY:f.clientY,pageX:f.pageX,pageY:f.pageY,timeStamp:f.timeStamp},l)}_OnMouseEventAsPointer(d,f){if(!a(f)){var l=this._mousePointerLastButtons;
"pointerdown"===d&&0!==l?d="pointermove":"pointerup"===d&&0!==f.buttons&&(d="pointermove");this._PostToRuntimeMaybeSync(d,{pointerId:1,pointerType:"mouse",button:f.button,buttons:f.buttons,lastButtons:l,clientX:f.clientX,clientY:f.clientY,pageX:f.pageX,pageY:f.pageY,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,timeStamp:f.timeStamp},e);this._mousePointerLastButtons=f.buttons;this._OnMouseEvent(f.type,f,h)}}_OnPointerEvent(d,f){this._pointerRawUpdateRateLimiter&&"pointermove"!==
d&&this._pointerRawUpdateRateLimiter.Reset();var l=0;"mouse"===f.pointerType&&(l=this._mousePointerLastButtons);this._PostToRuntimeMaybeSync(d,{pointerId:f.pointerId,pointerType:f.pointerType,button:f.button,buttons:f.buttons,lastButtons:l,clientX:f.clientX,clientY:f.clientY,pageX:f.pageX,pageY:f.pageY,width:f.width||0,height:f.height||0,pressure:f.pressure||0,tangentialPressure:f.tangentialPressure||0,tiltX:f.tiltX||0,tiltY:f.tiltY||0,twist:f.twist||0,timeStamp:f.timeStamp},e);"mouse"===f.pointerType&&
(l="mousemove","pointerdown"===d?l="mousedown":"pointerup"===d&&(l="pointerup"),this._OnMouseEvent(l,f,h),this._mousePointerLastButtons=f.buttons)}_OnPointerRawUpdate(d){this._lastPointerRawUpdateEvent=d;this._pointerRawUpdateRateLimiter.Call()}_DoSendPointerRawUpdate(){this._OnPointerEvent("pointermove",this._lastPointerRawUpdateEvent);this._lastPointerRawUpdateEvent=null}_OnTouchEvent(d,f){for(let l=0,n=f.changedTouches.length;l<n;++l){const p=f.changedTouches[l];this._PostToRuntimeMaybeSync(d,
{pointerId:p.identifier,pointerType:"touch",button:0,buttons:0,lastButtons:0,clientX:p.clientX,clientY:p.clientY,pageX:p.pageX,pageY:p.pageY,width:2*(p.radiusX||p.webkitRadiusX||0),height:2*(p.radiusY||p.webkitRadiusY||0),pressure:p.force||p.webkitForce||0,tangentialPressure:0,tiltX:0,tiltY:0,twist:p.rotationAngle||0,timeStamp:f.timeStamp},e)}}_HandlePointerDownFocus(d){window!==window.top&&window.focus();this._IsElementCanvasOrDocument(d.target)&&document.activeElement&&!this._IsElementCanvasOrDocument(document.activeElement)&&
document.activeElement.blur()}_IsElementCanvasOrDocument(d){return!d||d===document||d===window||d===document.body||"canvas"===d.tagName.toLowerCase()}_AttachDeviceOrientationEvent(){this._attachedDeviceOrientationEvent||(this._attachedDeviceOrientationEvent=!0,window.addEventListener("deviceorientation",d=>this._OnDeviceOrientation(d)),window.addEventListener("deviceorientationabsolute",d=>this._OnDeviceOrientationAbsolute(d)))}_AttachDeviceMotionEvent(){this._attachedDeviceMotionEvent||(this._attachedDeviceMotionEvent=
!0,window.addEventListener("devicemotion",d=>this._OnDeviceMotion(d)))}_OnDeviceOrientation(d){this.PostToRuntime("deviceorientation",{absolute:!!d.absolute,alpha:d.alpha||0,beta:d.beta||0,gamma:d.gamma||0,timeStamp:d.timeStamp,webkitCompassHeading:d.webkitCompassHeading,webkitCompassAccuracy:d.webkitCompassAccuracy},e)}_OnDeviceOrientationAbsolute(d){this.PostToRuntime("deviceorientationabsolute",{absolute:!!d.absolute,alpha:d.alpha||0,beta:d.beta||0,gamma:d.gamma||0,timeStamp:d.timeStamp},e)}_OnDeviceMotion(d){let f=
null;var l=d.acceleration;l&&(f={x:l.x||0,y:l.y||0,z:l.z||0});l=null;var n=d.accelerationIncludingGravity;n&&(l={x:n.x||0,y:n.y||0,z:n.z||0});n=null;const p=d.rotationRate;p&&(n={alpha:p.alpha||0,beta:p.beta||0,gamma:p.gamma||0});this.PostToRuntime("devicemotion",{acceleration:f,accelerationIncludingGravity:l,rotationRate:n,interval:d.interval,timeStamp:d.timeStamp},e)}_OnUpdateCanvasSize(d){const f=this.GetRuntimeInterface(),l=f.GetCanvas();l.style.width=d.styleWidth+"px";l.style.height=d.styleHeight+
"px";l.style.marginLeft=d.marginLeft+"px";l.style.marginTop=d.marginTop+"px";f.MaybeForceBodySize();this._isFirstSizeUpdate&&(l.style.display="",this._isFirstSizeUpdate=!1)}_OnInvokeDownload(d){const f=d.url;d=d.filename;const l=document.createElement("a"),n=document.body;l.textContent=d;l.href=f;l.download=d;n.appendChild(l);l.click();n.removeChild(l)}async _OnRasterSvgImage(d){var f=d.imageBitmapOpts;d=await self.C3_RasterSvgImageBlob(d.blob,d.imageWidth,d.imageHeight,d.surfaceWidth,d.surfaceHeight);
f=f?await createImageBitmap(d,f):await createImageBitmap(d);return{imageBitmap:f,transferables:[f]}}async _OnGetSvgImageSize(d){return await self.C3_GetSvgImageSize(d.blob)}async _OnAddStylesheet(d){await q(d.url)}_PlayPendingMedia(){var d=[...this._mediaPendingPlay];this._mediaPendingPlay.clear();if(!this._isSilent)for(const f of d)(d=f.play())&&d.catch(l=>{this._mediaRemovedPendingPlay.has(f)||this._mediaPendingPlay.add(f)})}TryPlayMedia(d){if("function"!==typeof d.play)throw Error("missing play function");
this._mediaRemovedPendingPlay.delete(d);let f;try{f=d.play()}catch(l){this._mediaPendingPlay.add(d);return}f&&f.catch(l=>{this._mediaRemovedPendingPlay.has(d)||this._mediaPendingPlay.add(d)})}RemovePendingPlay(d){this._mediaPendingPlay.delete(d);this._mediaRemovedPendingPlay.add(d)}SetSilent(d){this._isSilent=!!d}_OnHideCordovaSplash(){navigator.splashscreen&&navigator.splashscreen.hide&&navigator.splashscreen.hide()}_OnDebugHighlight(d){if(d.show){this._debugHighlightElem||(this._debugHighlightElem=
document.createElement("div"),this._debugHighlightElem.id="inspectOutline",document.body.appendChild(this._debugHighlightElem));var f=this._debugHighlightElem;f.style.display="";f.style.left=d.left-1+"px";f.style.top=d.top-1+"px";f.style.width=d.width+2+"px";f.style.height=d.height+2+"px";f.textContent=d.name}else this._debugHighlightElem&&(this._debugHighlightElem.style.display="none")}_OnRegisterSW(){window.C3_RegisterSW&&window.C3_RegisterSW()}_OnPostToDebugger(d){window.c3_postToMessagePort&&
(d.from="runtime",window.c3_postToMessagePort(d))}_InvokeFunctionFromJS(d,f){return this.PostToRuntimeAsync("js-invoke-function",{name:d,params:f})}_OnAlert(d){alert(d.message)}})}"use strict";
self.JobSchedulerDOM=class{constructor(c){this._runtimeInterface=c;this._baseUrl=c.GetBaseURL();"preview"===c.GetExportType()?this._baseUrl+="c3/workers/":this._baseUrl+=c.GetScriptFolder();this._maxNumWorkers=Math.min(navigator.hardwareConcurrency||2,16);this._dispatchWorker=null;this._jobWorkers=[];this._outputPort=this._inputPort=null}async Init(){if(this._hasInitialised)throw Error("already initialised");this._hasInitialised=!0;var c=this._runtimeInterface._GetWorkerURL("dispatchworker.js");this._dispatchWorker=
await this._runtimeInterface.CreateWorker(c,this._baseUrl,{name:"DispatchWorker"});c=new MessageChannel;this._inputPort=c.port1;this._dispatchWorker.postMessage({type:"_init","in-port":c.port2},[c.port2]);this._outputPort=await this._CreateJobWorker()}async _CreateJobWorker(){const c=this._jobWorkers.length;var a=this._runtimeInterface._GetWorkerURL("jobworker.js");a=await this._runtimeInterface.CreateWorker(a,this._baseUrl,{name:"JobWorker"+c});const b=new MessageChannel,e=new MessageChannel;this._dispatchWorker.postMessage({type:"_addJobWorker",
port:b.port1},[b.port1]);a.postMessage({type:"init",number:c,"dispatch-port":b.port2,"output-port":e.port2},[b.port2,e.port2]);this._jobWorkers.push(a);return e.port1}GetPortData(){return{inputPort:this._inputPort,outputPort:this._outputPort,maxNumWorkers:this._maxNumWorkers}}GetPortTransferables(){return[this._inputPort,this._outputPort]}};"use strict";
window.C3_IsSupported&&(window.c3_runtimeInterface=new self.RuntimeInterface({useWorker:!0,workerMainUrl:"workermain.js",engineScripts:["scripts/c3runtime.js"],scriptFolder:"scripts/",workerDependencyScripts:[],exportType:"html5"}));"use strict";
{const c=180/Math.PI;self.AudioDOMHandler=class extends self.DOMHandler{constructor(a){super(a,"audio");this._destinationNode=this._audioContext=null;this._hasAttachedUnblockEvents=this._hasUnblocked=!1;this._unblockFunc=()=>this._UnblockAudioContext();this._audioBuffers=[];this._audioInstances=[];this._lastAudioInstance=null;this._lastPlayedTag="";this._lastTickCount=-1;this._pendingTags=new Map;this._masterVolume=1;this._isSilent=!1;this._timeScaleMode=0;this._timeScale=1;this._gameTime=0;this._panningModel=
"HRTF";this._distanceModel="inverse";this._refDistance=600;this._maxDistance=1E4;this._rolloffFactor=1;this._hasAnySoftwareDecodedMusic=this._playMusicAsSound=!1;this._supportsWebMOpus=this._iRuntime.IsAudioFormatSupported("audio/webm; codecs=opus");this._effects=new Map;this._analysers=new Set;this._isPendingPostFxState=!1;this._microphoneTag="";this._microphoneSource=null;self.C3Audio_OnMicrophoneStream=(b,e)=>this._OnMicrophoneStream(b,e);this._destMediaStreamNode=null;self.C3Audio_GetOutputStream=
()=>this._OnGetOutputStream();self.C3Audio_DOMInterface=this;this.AddRuntimeMessageHandlers([["create-audio-context",b=>this._CreateAudioContext(b)],["play",b=>this._Play(b)],["stop",b=>this._Stop(b)],["stop-all",()=>this._StopAll()],["set-paused",b=>this._SetPaused(b)],["set-volume",b=>this._SetVolume(b)],["fade-volume",b=>this._FadeVolume(b)],["set-master-volume",b=>this._SetMasterVolume(b)],["set-muted",b=>this._SetMuted(b)],["set-silent",b=>this._SetSilent(b)],["set-looping",b=>this._SetLooping(b)],
["set-playback-rate",b=>this._SetPlaybackRate(b)],["seek",b=>this._Seek(b)],["preload",b=>this._Preload(b)],["unload",b=>this._Unload(b)],["unload-all",()=>this._UnloadAll()],["set-suspended",b=>this._SetSuspended(b)],["add-effect",b=>this._AddEffect(b)],["set-effect-param",b=>this._SetEffectParam(b)],["remove-effects",b=>this._RemoveEffects(b)],["tick",b=>this._OnTick(b)],["load-state",b=>this._OnLoadState(b)]])}async _CreateAudioContext(a){a.isiOSCordova&&(this._playMusicAsSound=!0);this._timeScaleMode=
a.timeScaleMode;this._panningModel=["equalpower","HRTF","soundfield"][a.panningModel];this._distanceModel=["linear","inverse","exponential"][a.distanceModel];this._refDistance=a.refDistance;this._maxDistance=a.maxDistance;this._rolloffFactor=a.rolloffFactor;var b={latencyHint:a.latencyHint};if("undefined"!==typeof AudioContext)this._audioContext=new AudioContext(b);else if("undefined"!==typeof webkitAudioContext)this._audioContext=new webkitAudioContext(b);else throw Error("Web Audio API not supported");
this._AttachUnblockEvents();this._audioContext.onstatechange=()=>{"running"!==this._audioContext.state&&this._AttachUnblockEvents()};this._destinationNode=this._audioContext.createGain();this._destinationNode.connect(this._audioContext.destination);b=a.listenerPos;this._audioContext.listener.setPosition(b[0],b[1],b[2]);this._audioContext.listener.setOrientation(0,0,1,0,-1,0);self.C3_GetAudioContextCurrentTime=()=>this.GetAudioCurrentTime();try{await Promise.all(a.preloadList.map(e=>this._GetAudioBuffer(e.originalUrl,
e.url,e.type,!1)))}catch(e){console.error("[Construct 3] Preloading sounds failed: ",e)}return{sampleRate:this._audioContext.sampleRate}}_AttachUnblockEvents(){this._hasAttachedUnblockEvents||(this._hasUnblocked=!1,window.addEventListener("pointerup",this._unblockFunc,!0),window.addEventListener("touchend",this._unblockFunc,!0),window.addEventListener("click",this._unblockFunc,!0),window.addEventListener("keydown",this._unblockFunc,!0),this._hasAttachedUnblockEvents=!0)}_DetachUnblockEvents(){this._hasAttachedUnblockEvents&&
(this._hasUnblocked=!0,window.removeEventListener("pointerup",this._unblockFunc,!0),window.removeEventListener("touchend",this._unblockFunc,!0),window.removeEventListener("click",this._unblockFunc,!0),window.removeEventListener("keydown",this._unblockFunc,!0),this._hasAttachedUnblockEvents=!1)}_UnblockAudioContext(){if(!this._hasUnblocked){var a=this._audioContext;"suspended"===a.state&&a.resume&&a.resume();var b=a.createBuffer(1,220,22050),e=a.createBufferSource();e.buffer=b;e.connect(a.destination);
e.start(0);"running"===a.state&&this._DetachUnblockEvents()}}GetAudioContext(){return this._audioContext}GetAudioCurrentTime(){return this._audioContext.currentTime}GetDestinationNode(){return this._destinationNode}GetDestinationForTag(a){return(a=this._effects.get(a.toLowerCase()))?a[0].GetInputNode():this.GetDestinationNode()}AddEffectForTag(a,b){a=a.toLowerCase();let e=this._effects.get(a);e||(e=[],this._effects.set(a,e));b._SetIndex(e.length);b._SetTag(a);e.push(b);this._ReconnectEffects(a)}_ReconnectEffects(a){let b=
this.GetDestinationNode();const e=this._effects.get(a);if(e&&e.length){b=e[0].GetInputNode();for(let h=0,m=e.length;h<m;++h){const q=e[h];h+1===m?q.ConnectTo(this.GetDestinationNode()):q.ConnectTo(e[h+1].GetInputNode())}}for(const h of this.audioInstancesByTag(a))h.Reconnect(b);this._microphoneSource&&this._microphoneTag===a&&(this._microphoneSource.disconnect(),this._microphoneSource.connect(b))}GetMasterVolume(){return this._masterVolume}IsSilent(){return this._isSilent}GetTimeScaleMode(){return this._timeScaleMode}GetTimeScale(){return this._timeScale}GetGameTime(){return this._gameTime}IsPlayMusicAsSound(){return this._playMusicAsSound}SupportsWebMOpus(){return this._supportsWebMOpus}_SetHasAnySoftwareDecodedMusic(){this._hasAnySoftwareDecodedMusic=
!0}GetPanningModel(){return this._panningModel}GetDistanceModel(){return this._distanceModel}GetReferenceDistance(){return this._refDistance}GetMaxDistance(){return this._maxDistance}GetRolloffFactor(){return this._rolloffFactor}DecodeAudioData(a,b){return b?this._iRuntime._WasmDecodeWebMOpus(a).then(e=>{const h=this._audioContext.createBuffer(1,e.length,48E3);h.getChannelData(0).set(e);return h}):new Promise((e,h)=>{this._audioContext.decodeAudioData(a,e,h)})}TryPlayMedia(a){this._iRuntime.TryPlayMedia(a)}RemovePendingPlay(a){this._iRuntime.RemovePendingPlay(a)}ReleaseInstancesForBuffer(a){let b=
0;for(let e=0,h=this._audioInstances.length;e<h;++e){const m=this._audioInstances[e];this._audioInstances[b]=m;m.GetBuffer()===a?m.Release():++b}this._audioInstances.length=b}ReleaseAllMusicBuffers(){let a=0;for(let b=0,e=this._audioBuffers.length;b<e;++b){const h=this._audioBuffers[b];this._audioBuffers[a]=h;h.IsMusic()?h.Release():++a}this._audioBuffers.length=a}*audioInstancesByTag(a){if(a)for(const b of this._audioInstances)self.AudioDOMHandler.EqualsNoCase(b.GetTag(),a)&&(yield b);else this._lastAudioInstance&&
!this._lastAudioInstance.HasEnded()&&(yield this._lastAudioInstance)}async _GetAudioBuffer(a,b,e,h,m){for(const q of this._audioBuffers)if(q.GetUrl()===b)return await q.Load(),q;if(m)return null;h&&(this._playMusicAsSound||this._hasAnySoftwareDecodedMusic)&&this.ReleaseAllMusicBuffers();a=self.C3AudioBuffer.Create(this,a,b,e,h);this._audioBuffers.push(a);await a.Load();return a}async _GetAudioInstance(a,b,e,h,m){for(const q of this._audioInstances)if(q.GetUrl()===b&&(q.CanBeRecycled()||m))return q.SetTag(h),
q;a=(await this._GetAudioBuffer(a,b,e,m)).CreateInstance(h);this._audioInstances.push(a);return a}_AddPendingTag(a){let b=this._pendingTags.get(a);if(!b){let e=null;b={pendingCount:0,promise:new Promise(h=>e=h),resolve:e};this._pendingTags.set(a,b)}b.pendingCount++}_RemovePendingTag(a){const b=this._pendingTags.get(a);if(!b)throw Error("expected pending tag");b.pendingCount--;0===b.pendingCount&&(b.resolve(),this._pendingTags.delete(a))}TagReady(a){a||(a=this._lastPlayedTag);return(a=this._pendingTags.get(a))?
a.promise:Promise.resolve()}_MaybeStartTicking(){if(0<this._analysers.size)this._StartTicking();else for(const a of this._audioInstances)if(a.IsActive()){this._StartTicking();break}}Tick(){for(var a of this._analysers)a.Tick();a=this.GetAudioCurrentTime();for(var b of this._audioInstances)b.Tick(a);b=this._audioInstances.filter(e=>e.IsActive()).map(e=>e.GetState());this.PostToRuntime("state",{tickCount:this._lastTickCount,audioInstances:b,analysers:[...this._analysers].map(e=>e.GetData())});0===b.length&&
0===this._analysers.size&&this._StopTicking()}PostTrigger(a,b,e){this.PostToRuntime("trigger",{type:a,tag:b,aiid:e})}async _Play(a){const b=a.originalUrl,e=a.url,h=a.type,m=a.isMusic,q=a.tag,u=a.isLooping,w=a.vol,z=a.pos,v=a.panning;let x=a.off;0<x&&!a.trueClock&&(this._audioContext.getOutputTimestamp?(a=this._audioContext.getOutputTimestamp(),x=x-a.performanceTime/1E3+a.contextTime):x=x-performance.now()/1E3+this._audioContext.currentTime);this._lastPlayedTag=q;this._AddPendingTag(q);try{this._lastAudioInstance=
await this._GetAudioInstance(b,e,h,q,m),v?(this._lastAudioInstance.SetPannerEnabled(!0),this._lastAudioInstance.SetPan(v.x,v.y,v.angle,v.innerAngle,v.outerAngle,v.outerGain),v.hasOwnProperty("uid")&&this._lastAudioInstance.SetUID(v.uid)):this._lastAudioInstance.SetPannerEnabled(!1),this._lastAudioInstance.Play(u,w,z,x)}catch(A){console.error("[Construct 3] Audio: error starting playback: ",A);return}finally{this._RemovePendingTag(q)}this._StartTicking()}_Stop(a){a=a.tag;for(const b of this.audioInstancesByTag(a))b.Stop()}_StopAll(){for(const a of this._audioInstances)a.Stop()}_SetPaused(a){const b=
a.tag;a=a.paused;for(const e of this.audioInstancesByTag(b))a?e.Pause():e.Resume();this._MaybeStartTicking()}_SetVolume(a){const b=a.tag;a=a.vol;for(const e of this.audioInstancesByTag(b))e.SetVolume(a)}async _FadeVolume(a){const b=a.tag,e=a.vol,h=a.duration;a=a.stopOnEnd;await this.TagReady(b);for(const m of this.audioInstancesByTag(b))m.FadeVolume(e,h,a);this._MaybeStartTicking()}_SetMasterVolume(a){this._masterVolume=a.vol;for(const b of this._audioInstances)b._UpdateVolume()}_SetMuted(a){const b=
a.tag;a=a.isMuted;for(const e of this.audioInstancesByTag(b))e.SetMuted(a)}_SetSilent(a){this._isSilent=a.isSilent;this._iRuntime.SetSilent(this._isSilent);for(const b of this._audioInstances)b._UpdateMuted()}_SetLooping(a){const b=a.tag;a=a.isLooping;for(const e of this.audioInstancesByTag(b))e.SetLooping(a)}async _SetPlaybackRate(a){const b=a.tag;a=a.rate;await this.TagReady(b);for(const e of this.audioInstancesByTag(b))e.SetPlaybackRate(a)}async _Seek(a){const b=a.tag;a=a.pos;await this.TagReady(b);
for(const e of this.audioInstancesByTag(b))e.Seek(a)}async _Preload(a){const b=a.originalUrl,e=a.url,h=a.type;a=a.isMusic;try{await this._GetAudioInstance(b,e,h,"",a)}catch(m){console.error("[Construct 3] Audio: error preloading: ",m)}}async _Unload(a){if(a=await this._GetAudioBuffer("",a.url,a.type,a.isMusic,!0))a.Release(),a=this._audioBuffers.indexOf(a),-1!==a&&this._audioBuffers.splice(a,1)}_UnloadAll(){for(const a of this._audioBuffers)a.Release();this._audioBuffers.length=0}_SetSuspended(a){a=
a.isSuspended;!a&&this._audioContext.resume&&this._audioContext.resume();for(const b of this._audioInstances)b.SetSuspended(a);a&&this._audioContext.suspend&&this._audioContext.suspend()}_OnTick(a){this._timeScale=a.timeScale;this._gameTime=a.gameTime;this._lastTickCount=a.tickCount;if(0!==this._timeScaleMode)for(var b of this._audioInstances)b._UpdatePlaybackRate();(b=a.listenerPos)&&this._audioContext.listener.setPosition(b[0],b[1],b[2]);for(const e of a.instPans){a=e.uid;for(const h of this._audioInstances)h.GetUID()===
a&&h.SetPanXYA(e.x,e.y,e.angle)}}async _AddEffect(a){var b=a.type;const e=a.tag;var h=a.params;if("filter"===b)h=new self.C3AudioFilterFX(this,...h);else if("delay"===b)h=new self.C3AudioDelayFX(this,...h);else if("convolution"===b){b=null;try{b=await this._GetAudioBuffer(a.bufferOriginalUrl,a.bufferUrl,a.bufferType,!1)}catch(m){console.log("[Construct 3] Audio: error loading convolution: ",m);return}h=new self.C3AudioConvolveFX(this,b.GetAudioBuffer(),...h);h._SetBufferInfo(a.bufferOriginalUrl,a.bufferUrl,
a.bufferType)}else if("flanger"===b)h=new self.C3AudioFlangerFX(this,...h);else if("phaser"===b)h=new self.C3AudioPhaserFX(this,...h);else if("gain"===b)h=new self.C3AudioGainFX(this,...h);else if("tremolo"===b)h=new self.C3AudioTremoloFX(this,...h);else if("ringmod"===b)h=new self.C3AudioRingModFX(this,...h);else if("distortion"===b)h=new self.C3AudioDistortionFX(this,...h);else if("compressor"===b)h=new self.C3AudioCompressorFX(this,...h);else if("analyser"===b)h=new self.C3AudioAnalyserFX(this,
...h);else throw Error("invalid effect type");this.AddEffectForTag(e,h);this._PostUpdatedFxState()}_SetEffectParam(a){const b=a.index,e=a.param,h=a.value,m=a.ramp,q=a.time;a=this._effects.get(a.tag);!a||0>b||b>=a.length||(a[b].SetParam(e,h,m,q),this._PostUpdatedFxState())}_RemoveEffects(a){a=a.tag.toLowerCase();const b=this._effects.get(a);if(b&&b.length){for(const e of b)e.Release();this._effects.delete(a);this._ReconnectEffects(a)}}_AddAnalyser(a){this._analysers.add(a);this._MaybeStartTicking()}_RemoveAnalyser(a){this._analysers.delete(a)}_PostUpdatedFxState(){this._isPendingPostFxState||
(this._isPendingPostFxState=!0,Promise.resolve().then(()=>this._DoPostUpdatedFxState()))}_DoPostUpdatedFxState(){const a={};for(const [b,e]of this._effects)a[b]=e.map(h=>h.GetState());this.PostToRuntime("fxstate",{fxstate:a});this._isPendingPostFxState=!1}async _OnLoadState(a){const b=a.saveLoadMode;if(3!==b)for(var e of this._audioInstances)e.IsMusic()&&1===b||(e.IsMusic()||2!==b)&&e.Stop();for(const h of this._effects.values())for(const m of h)m.Release();this._effects.clear();this._timeScale=a.timeScale;
this._gameTime=a.gameTime;e=a.listenerPos;this._audioContext.listener.setPosition(e[0],e[1],e[2]);this._isSilent=a.isSilent;this._iRuntime.SetSilent(this._isSilent);this._masterVolume=a.masterVolume;e=[];for(const h of Object.values(a.effects))e.push(Promise.all(h.map(m=>this._AddEffect(m))));await Promise.all(e);await Promise.all(a.playing.map(h=>this._LoadAudioInstance(h,b)));this._MaybeStartTicking()}async _LoadAudioInstance(a,b){if(3!==b){var e=a.bufferOriginalUrl,h=a.bufferUrl,m=a.bufferType,
q=a.isMusic,u=a.tag,w=a.isLooping,z=a.volume,v=a.playbackTime;if(!q||1!==b)if(q||2!==b){b=null;try{b=await this._GetAudioInstance(e,h,m,u,q)}catch(x){console.error("[Construct 3] Audio: error loading audio state: ",x);return}b.LoadPanState(a.pan);b.Play(w,z,v,0);a.isPlaying||b.Pause();b._LoadAdditionalState(a)}}}_OnMicrophoneStream(a,b){this._microphoneSource&&this._microphoneSource.disconnect();this._microphoneTag=b.toLowerCase();this._microphoneSource=this._audioContext.createMediaStreamSource(a);
this._microphoneSource.connect(this.GetDestinationForTag(this._microphoneTag))}_OnGetOutputStream(){this._destMediaStreamNode||(this._destMediaStreamNode=this._audioContext.createMediaStreamDestination(),this._destinationNode.connect(this._destMediaStreamNode));return this._destMediaStreamNode.stream}static EqualsNoCase(a,b){return a.length!==b.length?!1:a===b?!0:a.toLowerCase()===b.toLowerCase()}static ToDegrees(a){return a*c}static DbToLinearNoCap(a){return Math.pow(10,a/20)}static DbToLinear(a){return Math.max(Math.min(self.AudioDOMHandler.DbToLinearNoCap(a),
1),0)}static LinearToDbNoCap(a){return Math.log(a)/Math.log(10)*20}static LinearToDb(a){return self.AudioDOMHandler.LinearToDbNoCap(Math.max(Math.min(a,1),0))}static e4(a,b){return 1-Math.exp(-b*a)}};self.RuntimeInterface.AddDOMHandlerClass(self.AudioDOMHandler)}"use strict";
self.C3AudioBuffer=class{constructor(c,a,b,e,h){this._audioDomHandler=c;this._originalUrl=a;this._url=b;this._type=e;this._isMusic=h;this._api="";this._loadState="not-loaded";this._loadPromise=null}Release(){this._loadState="not-loaded";this._loadPromise=this._audioDomHandler=null}static Create(c,a,b,e,h){const m="audio/webm; codecs=opus"===e&&!c.SupportsWebMOpus();h&&m&&c._SetHasAnySoftwareDecodedMusic();return!h||c.IsPlayMusicAsSound()||m?new self.C3WebAudioBuffer(c,a,b,e,h,m):new self.C3Html5AudioBuffer(c,
a,b,e,h)}CreateInstance(c){return"html5"===this._api?new self.C3Html5AudioInstance(this._audioDomHandler,this,c):new self.C3WebAudioInstance(this._audioDomHandler,this,c)}_Load(){}Load(){this._loadPromise||(this._loadPromise=this._Load());return this._loadPromise}IsLoaded(){}IsLoadedAndDecoded(){}HasFailedToLoad(){return"failed"===this._loadState}GetAudioContext(){return this._audioDomHandler.GetAudioContext()}GetApi(){return this._api}GetOriginalUrl(){return this._originalUrl}GetUrl(){return this._url}GetContentType(){return this._type}IsMusic(){return this._isMusic}GetDuration(){}};
"use strict";
self.C3Html5AudioBuffer=class extends self.C3AudioBuffer{constructor(c,a,b,e,h){super(c,a,b,e,h);this._api="html5";this._audioElem=new Audio;this._audioElem.crossOrigin="anonymous";this._audioElem.autoplay=!1;this._audioElem.preload="auto";this._loadReject=this._loadResolve=null;this._reachedCanPlayThrough=!1;this._audioElem.addEventListener("canplaythrough",()=>this._reachedCanPlayThrough=!0);this._outNode=this.GetAudioContext().createGain();this._mediaSourceNode=null;this._audioElem.addEventListener("canplay",()=>
{this._loadResolve&&(this._loadState="loaded",this._loadResolve(),this._loadReject=this._loadResolve=null);!this._mediaSourceNode&&this._audioElem&&(this._mediaSourceNode=this.GetAudioContext().createMediaElementSource(this._audioElem),this._mediaSourceNode.connect(this._outNode))});this.onended=null;this._audioElem.addEventListener("ended",()=>{if(this.onended)this.onended()});this._audioElem.addEventListener("error",m=>this._OnError(m))}Release(){this._audioDomHandler.ReleaseInstancesForBuffer(this);
this._outNode.disconnect();this._outNode=null;this._mediaSourceNode.disconnect();this._mediaSourceNode=null;this._audioElem&&!this._audioElem.paused&&this._audioElem.pause();this._audioElem=this.onended=null;super.Release()}_Load(){this._loadState="loading";return new Promise((c,a)=>{this._loadResolve=c;this._loadReject=a;this._audioElem.src=this._url})}_OnError(c){console.error(`[Construct 3] Audio '${this._url}' error: `,c);this._loadReject&&(this._loadState="failed",this._loadReject(c),this._loadReject=
this._loadResolve=null)}IsLoaded(){const c=4<=this._audioElem.readyState;c&&(this._reachedCanPlayThrough=!0);return c||this._reachedCanPlayThrough}IsLoadedAndDecoded(){return this.IsLoaded()}GetAudioElement(){return this._audioElem}GetOutputNode(){return this._outNode}GetDuration(){return this._audioElem.duration}};"use strict";
self.C3WebAudioBuffer=class extends self.C3AudioBuffer{constructor(c,a,b,e,h,m){super(c,a,b,e,h);this._api="webaudio";this._audioBuffer=this._audioData=null;this._needsSoftwareDecode=!!m}Release(){this._audioDomHandler.ReleaseInstancesForBuffer(this);this._audioBuffer=this._audioData=null;super.Release()}async _Fetch(){if(this._audioData)return this._audioData;var c=this._audioDomHandler.GetRuntimeInterface();if("cordova"===c.GetExportType()&&c.IsRelativeURL(this._url)&&"file:"===location.protocol)this._audioData=
await c.CordovaFetchLocalFileAsArrayBuffer(this._url);else{c=await fetch(this._url);if(!c.ok)throw Error(`error fetching audio data: ${c.status} ${c.statusText}`);this._audioData=await c.arrayBuffer()}}async _Decode(){if(this._audioBuffer)return this._audioBuffer;this._audioBuffer=await this._audioDomHandler.DecodeAudioData(this._audioData,this._needsSoftwareDecode);this._audioData=null}async _Load(){try{this._loadState="loading",await this._Fetch(),await this._Decode(),this._loadState="loaded"}catch(c){this._loadState=
"failed",console.error(`[Construct 3] Failed to load audio '${this._url}': `,c)}}IsLoaded(){return!(!this._audioData&&!this._audioBuffer)}IsLoadedAndDecoded(){return!!this._audioBuffer}GetAudioBuffer(){return this._audioBuffer}GetDuration(){return this._audioBuffer?this._audioBuffer.duration:0}};"use strict";
{let c=0;self.C3AudioInstance=class{constructor(a,b,e){this._audioDomHandler=a;this._buffer=b;this._tag=e;this._aiId=c++;this._gainNode=this.GetAudioContext().createGain();this._gainNode.connect(this.GetDestinationNode());this._pannerNode=null;this._isPannerEnabled=!1;this._isStopped=!0;this._isLooping=this._resumeMe=this._isPaused=!1;this._volume=1;this._isMuted=!1;this._playbackRate=1;a=this._audioDomHandler.GetTimeScaleMode();this._isTimescaled=1===a&&!this.IsMusic()||2===a;this._fadeEndTime=this._instUid=
-1;this._stopOnFadeEnd=!1}Release(){this._buffer=this._audioDomHandler=null;this._pannerNode&&(this._pannerNode.disconnect(),this._pannerNode=null);this._gainNode.disconnect();this._gainNode=null}GetAudioContext(){return this._audioDomHandler.GetAudioContext()}GetDestinationNode(){return this._audioDomHandler.GetDestinationForTag(this._tag)}GetMasterVolume(){return this._audioDomHandler.GetMasterVolume()}GetCurrentTime(){return this._isTimescaled?this._audioDomHandler.GetGameTime():performance.now()/
1E3}GetOriginalUrl(){return this._buffer.GetOriginalUrl()}GetUrl(){return this._buffer.GetUrl()}GetContentType(){return this._buffer.GetContentType()}GetBuffer(){return this._buffer}IsMusic(){return this._buffer.IsMusic()}SetTag(a){this._tag=a}GetTag(){return this._tag}GetAiId(){return this._aiId}HasEnded(){}CanBeRecycled(){}IsPlaying(){return!this._isStopped&&!this._isPaused&&!this.HasEnded()}IsActive(){return!this._isStopped&&!this.HasEnded()}GetPlaybackTime(a){}GetDuration(a){let b=this._buffer.GetDuration();
a&&(b/=this._playbackRate||.001);return b}Play(a,b,e,h){}Stop(){}Pause(){}IsPaused(){return this._isPaused}Resume(){}SetVolume(a){this._volume=a;this._gainNode.gain.cancelScheduledValues(0);this._fadeEndTime=-1;this._gainNode.gain.value=this.GetOverallVolume()}FadeVolume(a,b,e){if(!this.IsMuted()){a*=this.GetMasterVolume();var h=this._gainNode.gain;h.cancelScheduledValues(0);var m=this._audioDomHandler.GetAudioCurrentTime();b=m+b;h.setValueAtTime(h.value,m);h.linearRampToValueAtTime(a,b);this._volume=
a;this._fadeEndTime=b;this._stopOnFadeEnd=e}}_UpdateVolume(){this.SetVolume(this._volume)}Tick(a){-1!==this._fadeEndTime&&a>=this._fadeEndTime&&(this._fadeEndTime=-1,this._stopOnFadeEnd&&this.Stop(),this._audioDomHandler.PostTrigger("fade-ended",this._tag,this._aiId))}GetOverallVolume(){const a=this._volume*this.GetMasterVolume();return isFinite(a)?a:0}SetMuted(a){a=!!a;this._isMuted!==a&&(this._isMuted=a,this._UpdateMuted())}IsMuted(){return this._isMuted}IsSilent(){return this._audioDomHandler.IsSilent()}_UpdateMuted(){}SetLooping(a){}IsLooping(){return this._isLooping}SetPlaybackRate(a){this._playbackRate!==
a&&(this._playbackRate=a,this._UpdatePlaybackRate())}_UpdatePlaybackRate(){}GetPlaybackRate(){return this._playbackRate}Seek(a){}SetSuspended(a){}SetPannerEnabled(a){a=!!a;this._isPannerEnabled!==a&&((this._isPannerEnabled=a)?(this._pannerNode||(this._pannerNode=this.GetAudioContext().createPanner(),this._pannerNode.panningModel=this._audioDomHandler.GetPanningModel(),this._pannerNode.distanceModel=this._audioDomHandler.GetDistanceModel(),this._pannerNode.refDistance=this._audioDomHandler.GetReferenceDistance(),
this._pannerNode.maxDistance=this._audioDomHandler.GetMaxDistance(),this._pannerNode.rolloffFactor=this._audioDomHandler.GetRolloffFactor()),this._gainNode.disconnect(),this._gainNode.connect(this._pannerNode),this._pannerNode.connect(this.GetDestinationNode())):(this._pannerNode.disconnect(),this._gainNode.disconnect(),this._gainNode.connect(this.GetDestinationNode())))}SetPan(a,b,e,h,m,q){this._isPannerEnabled&&(this.SetPanXYA(a,b,e),a=self.AudioDOMHandler.ToDegrees,this._pannerNode.coneInnerAngle=
a(h),this._pannerNode.coneOuterAngle=a(m),this._pannerNode.coneOuterGain=q)}SetPanXYA(a,b,e){this._isPannerEnabled&&(this._pannerNode.setPosition(a,b,0),this._pannerNode.setOrientation(Math.cos(e),Math.sin(e),0))}SetUID(a){this._instUid=a}GetUID(){return this._instUid}GetResumePosition(){}Reconnect(a){const b=this._pannerNode||this._gainNode;b.disconnect();b.connect(a)}GetState(){return{aiid:this.GetAiId(),tag:this._tag,duration:this.GetDuration(),volume:this._volume,isPlaying:this.IsPlaying(),playbackTime:this.GetPlaybackTime(),
playbackRate:this.GetPlaybackRate(),uid:this._instUid,bufferOriginalUrl:this.GetOriginalUrl(),bufferUrl:"",bufferType:this.GetContentType(),isMusic:this.IsMusic(),isLooping:this.IsLooping(),isMuted:this.IsMuted(),resumePosition:this.GetResumePosition(),pan:this.GetPanState()}}_LoadAdditionalState(a){this.SetPlaybackRate(a.playbackRate);this.SetMuted(a.isMuted)}GetPanState(){if(!this._pannerNode)return null;const a=this._pannerNode;return{pos:[a.positionX.value,a.positionY.value,a.positionZ.value],
orient:[a.orientationX.value,a.orientationY.value,a.orientationZ.value],cia:a.coneInnerAngle,coa:a.coneOuterAngle,cog:a.coneOuterGain,uid:this._instUid}}LoadPanState(a){a?(this.SetPannerEnabled(!0),a=this._pannerNode,a.setPosition(...a.pos),a.setOrientation(...a.orient),a.coneInnerAngle=a.cia,a.coneOuterAngle=a.coa,a.coneOuterGain=a.cog,this._instUid=a.uid):this.SetPannerEnabled(!1)}}}"use strict";
self.C3Html5AudioInstance=class extends self.C3AudioInstance{constructor(c,a,b){super(c,a,b);this._buffer.GetOutputNode().connect(this._gainNode);this._buffer.onended=()=>this._OnEnded()}Release(){this.Stop();this._buffer.GetOutputNode().disconnect();super.Release()}GetAudioElement(){return this._buffer.GetAudioElement()}_OnEnded(){this._isStopped=!0;this._instUid=-1;this._audioDomHandler.PostTrigger("ended",this._tag,this._aiId)}HasEnded(){return this.GetAudioElement().ended}CanBeRecycled(){return this._isStopped?
!0:this.HasEnded()}GetPlaybackTime(c){let a=this.GetAudioElement().currentTime;c&&(a*=this._playbackRate);this._isLooping||(a=Math.min(a,this.GetDuration()));return a}Play(c,a,b,e){e=this.GetAudioElement();1!==e.playbackRate&&(e.playbackRate=1);e.loop!==c&&(e.loop=c);this.SetVolume(a);e.muted&&(e.muted=!1);if(e.currentTime!==b)try{e.currentTime=b}catch(h){console.warn(`[Construct 3] Exception seeking audio '${this._buffer.GetUrl()}' to position '${b}': `,h)}this._audioDomHandler.TryPlayMedia(e);this._isPaused=
this._isStopped=!1;this._isLooping=c;this._playbackRate=1}Stop(){const c=this.GetAudioElement();c.paused||c.pause();this._audioDomHandler.RemovePendingPlay(c);this._isStopped=!0;this._isPaused=!1;this._instUid=-1}Pause(){if(!(this._isPaused||this._isStopped||this.HasEnded())){var c=this.GetAudioElement();c.paused||c.pause();this._audioDomHandler.RemovePendingPlay(c);this._isPaused=!0}}Resume(){!this._isPaused||this._isStopped||this.HasEnded()||(this._audioDomHandler.TryPlayMedia(this.GetAudioElement()),
this._isPaused=!1)}_UpdateMuted(){this.GetAudioElement().muted=this._isMuted||this.IsSilent()}SetLooping(c){c=!!c;this._isLooping!==c&&(this._isLooping=c,this.GetAudioElement().loop=c)}_UpdatePlaybackRate(){let c=this._playbackRate;this._isTimescaled&&(c*=this._audioDomHandler.GetTimeScale());try{this.GetAudioElement().playbackRate=c}catch(a){console.warn(`[Construct 3] Unable to set playback rate '${c}':`,a)}}Seek(c){if(!this._isStopped&&!this.HasEnded())try{this.GetAudioElement().currentTime=c}catch(a){console.warn(`[Construct 3] Error seeking audio to '${c}': `,
a)}}GetResumePosition(){return this.GetPlaybackTime()}SetSuspended(c){c?this.IsPlaying()?(this.GetAudioElement().pause(),this._resumeMe=!0):this._resumeMe=!1:this._resumeMe&&(this._audioDomHandler.TryPlayMedia(this.GetAudioElement()),this._resumeMe=!1)}};"use strict";
self.C3WebAudioInstance=class extends self.C3AudioInstance{constructor(c,a,b){super(c,a,b);this._bufferSource=null;this._onended_handler=e=>this._OnEnded(e);this._hasPlaybackEnded=!0;this._activeSource=null;this._resumePosition=this._startTime=0;this._muteVol=1}Release(){this.Stop();this._ReleaseBufferSource();this._onended_handler=null;super.Release()}_ReleaseBufferSource(){this._bufferSource&&this._bufferSource.disconnect();this._activeSource=this._bufferSource=null}_OnEnded(c){this._isPaused||
this._resumeMe||c.target!==this._activeSource||(this._isStopped=this._hasPlaybackEnded=!0,this._instUid=-1,this._ReleaseBufferSource(),this._audioDomHandler.PostTrigger("ended",this._tag,this._aiId))}HasEnded(){return!this._isStopped&&this._bufferSource&&this._bufferSource.loop||this._isPaused?!1:this._hasPlaybackEnded}CanBeRecycled(){return!this._bufferSource||this._isStopped?!0:this.HasEnded()}GetPlaybackTime(c){let a;a=this._isPaused?this._resumePosition:this.GetCurrentTime()-this._startTime;c&&
(a*=this._playbackRate);this._isLooping||(a=Math.min(a,this.GetDuration()));return a}Play(c,a,b,e){this._muteVol=1;this.SetVolume(a);this._ReleaseBufferSource();this._bufferSource=this.GetAudioContext().createBufferSource();this._bufferSource.buffer=this._buffer.GetAudioBuffer();this._bufferSource.connect(this._gainNode);this._activeSource=this._bufferSource;this._bufferSource.onended=this._onended_handler;this._bufferSource.loop=c;this._bufferSource.start(e,b);this._isPaused=this._isStopped=this._hasPlaybackEnded=
!1;this._isLooping=c;this._playbackRate=1;this._startTime=this.GetCurrentTime()-b}Stop(){if(this._bufferSource)try{this._bufferSource.stop(0)}catch(c){}this._isStopped=!0;this._isPaused=!1;this._instUid=-1}Pause(){this._isPaused||this._isStopped||this.HasEnded()||(this._resumePosition=this.GetPlaybackTime(!0),this._isLooping&&(this._resumePosition%=this.GetDuration()),this._isPaused=!0,this._bufferSource.stop(0))}Resume(){!this._isPaused||this._isStopped||this.HasEnded()||(this._ReleaseBufferSource(),
this._bufferSource=this.GetAudioContext().createBufferSource(),this._bufferSource.buffer=this._buffer.GetAudioBuffer(),this._bufferSource.connect(this._gainNode),this._activeSource=this._bufferSource,this._bufferSource.onended=this._onended_handler,this._bufferSource.loop=this._isLooping,this._UpdateVolume(),this._UpdatePlaybackRate(),this._startTime=this.GetCurrentTime()-this._resumePosition/(this._playbackRate||.001),this._bufferSource.start(0,this._resumePosition),this._isPaused=!1)}GetOverallVolume(){return super.GetOverallVolume()*
this._muteVol}_UpdateMuted(){this._muteVol=this._isMuted||this.IsSilent()?0:1;this._UpdateVolume()}SetLooping(c){c=!!c;this._isLooping!==c&&(this._isLooping=c,this._bufferSource&&(this._bufferSource.loop=c))}_UpdatePlaybackRate(){let c=this._playbackRate;this._isTimescaled&&(c*=this._audioDomHandler.GetTimeScale());this._bufferSource&&(this._bufferSource.playbackRate.value=c)}Seek(c){this._isStopped||this.HasEnded()||(this._isPaused?this._resumePosition=c:(this.Pause(),this._resumePosition=c,this.Resume()))}GetResumePosition(){return this._resumePosition}SetSuspended(c){c?
this.IsPlaying()?(this._resumeMe=!0,this._resumePosition=this.GetPlaybackTime(!0),this._isLooping&&(this._resumePosition%=this.GetDuration()),this._bufferSource.stop(0)):this._resumeMe=!1:this._resumeMe&&(this._ReleaseBufferSource(),this._bufferSource=this.GetAudioContext().createBufferSource(),this._bufferSource.buffer=this._buffer.GetAudioBuffer(),this._bufferSource.connect(this._gainNode),this._activeSource=this._bufferSource,this._bufferSource.onended=this._onended_handler,this._bufferSource.loop=
this._isLooping,this._UpdateVolume(),this._UpdatePlaybackRate(),this._startTime=this.GetCurrentTime()-this._resumePosition/(this._playbackRate||.001),this._bufferSource.start(0,this._resumePosition),this._resumeMe=!1)}_LoadAdditionalState(c){super._LoadAdditionalState(c);this._resumePosition=c.resumePosition}};"use strict";
{class c{constructor(a){this._audioDomHandler=a;this._audioContext=a.GetAudioContext();this._index=-1;this._type=this._tag="";this._params=null}Release(){this._audioContext=null}_SetIndex(a){this._index=a}GetIndex(){return this._index}_SetTag(a){this._tag=a}GetTag(){return this._tag}CreateGain(){return this._audioContext.createGain()}GetInputNode(){}ConnectTo(a){}SetAudioParam(a,b,e,h){a.cancelScheduledValues(0);if(0===h)a.value=b;else{var m=this._audioContext.currentTime;h+=m;switch(e){case 0:a.setValueAtTime(b,
h);break;case 1:a.setValueAtTime(a.value,m);a.linearRampToValueAtTime(b,h);break;case 2:a.setValueAtTime(a.value,m),a.exponentialRampToValueAtTime(b,h)}}}GetState(){return{type:this._type,tag:this._tag,params:this._params}}}self.C3AudioFilterFX=class extends c{constructor(a,b,e,h,m,q,u){super(a);this._type="filter";this._params=[b,e,h,m,q,u];this._inputNode=this.CreateGain();this._wetNode=this.CreateGain();this._wetNode.gain.value=u;this._dryNode=this.CreateGain();this._dryNode.gain.value=1-u;this._filterNode=
this._audioContext.createBiquadFilter();this._filterNode.type=b;this._filterNode.frequency.value=e;this._filterNode.detune.value=h;this._filterNode.Q.value=m;this._filterNode.gain.vlaue=q;this._inputNode.connect(this._filterNode);this._inputNode.connect(this._dryNode);this._filterNode.connect(this._wetNode)}Release(){this._inputNode.disconnect();this._filterNode.disconnect();this._wetNode.disconnect();this._dryNode.disconnect();super.Release()}ConnectTo(a){this._wetNode.disconnect();this._wetNode.connect(a);
this._dryNode.disconnect();this._dryNode.connect(a)}GetInputNode(){return this._inputNode}SetParam(a,b,e,h){switch(a){case 0:b=Math.max(Math.min(b/100,1),0);this._params[5]=b;this.SetAudioParam(this._wetNode.gain,b,e,h);this.SetAudioParam(this._dryNode.gain,1-b,e,h);break;case 1:this._params[1]=b;this.SetAudioParam(this._filterNode.frequency,b,e,h);break;case 2:this._params[2]=b;this.SetAudioParam(this._filterNode.detune,b,e,h);break;case 3:this._params[3]=b;this.SetAudioParam(this._filterNode.Q,
b,e,h);break;case 4:this._params[4]=b,this.SetAudioParam(this._filterNode.gain,b,e,h)}}};self.C3AudioDelayFX=class extends c{constructor(a,b,e,h){super(a);this._type="delay";this._params=[b,e,h];this._inputNode=this.CreateGain();this._wetNode=this.CreateGain();this._wetNode.gain.value=h;this._dryNode=this.CreateGain();this._dryNode.gain.value=1-h;this._mainNode=this.CreateGain();this._delayNode=this._audioContext.createDelay(b);this._delayNode.delayTime.value=b;this._delayGainNode=this.CreateGain();
this._delayGainNode.gain.value=e;this._inputNode.connect(this._mainNode);this._inputNode.connect(this._dryNode);this._mainNode.connect(this._wetNode);this._mainNode.connect(this._delayNode);this._delayNode.connect(this._delayGainNode);this._delayGainNode.connect(this._mainNode)}Release(){this._inputNode.disconnect();this._wetNode.disconnect();this._dryNode.disconnect();this._mainNode.disconnect();this._delayNode.disconnect();this._delayGainNode.disconnect();super.Release()}ConnectTo(a){this._wetNode.disconnect();
this._wetNode.connect(a);this._dryNode.disconnect();this._dryNode.connect(a)}GetInputNode(){return this._inputNode}SetParam(a,b,e,h){const m=self.AudioDOMHandler.DbToLinear;switch(a){case 0:b=Math.max(Math.min(b/100,1),0);this._params[2]=b;this.SetAudioParam(this._wetNode.gain,b,e,h);this.SetAudioParam(this._dryNode.gain,1-b,e,h);break;case 4:this._params[1]=m(b);this.SetAudioParam(this._delayGainNode.gain,m(b),e,h);break;case 5:this._params[0]=b,this.SetAudioParam(this._delayNode.delayTime,b,e,h)}}};
self.C3AudioConvolveFX=class extends c{constructor(a,b,e,h){super(a);this._type="convolution";this._params=[e,h];this._bufferType=this._bufferUrl=this._bufferOriginalUrl="";this._inputNode=this.CreateGain();this._wetNode=this.CreateGain();this._wetNode.gain.value=h;this._dryNode=this.CreateGain();this._dryNode.gain.value=1-h;this._convolveNode=this._audioContext.createConvolver();this._convolveNode.normalize=e;this._convolveNode.buffer=b;this._inputNode.connect(this._convolveNode);this._inputNode.connect(this._dryNode);
this._convolveNode.connect(this._wetNode)}Release(){this._inputNode.disconnect();this._convolveNode.disconnect();this._wetNode.disconnect();this._dryNode.disconnect();super.Release()}ConnectTo(a){this._wetNode.disconnect();this._wetNode.connect(a);this._dryNode.disconnect();this._dryNode.connect(a)}GetInputNode(){return this._inputNode}SetParam(a,b,e,h){switch(a){case 0:b=Math.max(Math.min(b/100,1),0),this._params[1]=b,this.SetAudioParam(this._wetNode.gain,b,e,h),this.SetAudioParam(this._dryNode.gain,
1-b,e,h)}}_SetBufferInfo(a,b,e){this._bufferOriginalUrl=a;this._bufferUrl=b;this._bufferType=e}GetState(){const a=super.GetState();a.bufferOriginalUrl=this._bufferOriginalUrl;a.bufferUrl="";a.bufferType=this._bufferType;return a}};self.C3AudioFlangerFX=class extends c{constructor(a,b,e,h,m,q){super(a);this._type="flanger";this._params=[b,e,h,m,q];this._inputNode=this.CreateGain();this._dryNode=this.CreateGain();this._dryNode.gain.value=1-q/2;this._wetNode=this.CreateGain();this._wetNode.gain.value=
q/2;this._feedbackNode=this.CreateGain();this._feedbackNode.gain.value=m;this._delayNode=this._audioContext.createDelay(b+e);this._delayNode.delayTime.value=b;this._oscNode=this._audioContext.createOscillator();this._oscNode.frequency.value=h;this._oscGainNode=this.CreateGain();this._oscGainNode.gain.value=e;this._inputNode.connect(this._delayNode);this._inputNode.connect(this._dryNode);this._delayNode.connect(this._wetNode);this._delayNode.connect(this._feedbackNode);this._feedbackNode.connect(this._delayNode);
this._oscNode.connect(this._oscGainNode);this._oscGainNode.connect(this._delayNode.delayTime);this._oscNode.start(0)}Release(){this._oscNode.stop(0);this._inputNode.disconnect();this._delayNode.disconnect();this._oscNode.disconnect();this._oscGainNode.disconnect();this._dryNode.disconnect();this._wetNode.disconnect();this._feedbackNode.disconnect();super.Release()}ConnectTo(a){this._wetNode.disconnect();this._wetNode.connect(a);this._dryNode.disconnect();this._dryNode.connect(a)}GetInputNode(){return this._inputNode}SetParam(a,
b,e,h){switch(a){case 0:b=Math.max(Math.min(b/100,1),0);this._params[4]=b;this.SetAudioParam(this._wetNode.gain,b/2,e,h);this.SetAudioParam(this._dryNode.gain,1-b/2,e,h);break;case 6:this._params[1]=b/1E3;this.SetAudioParam(this._oscGainNode.gain,b/1E3,e,h);break;case 7:this._params[2]=b;this.SetAudioParam(this._oscNode.frequency,b,e,h);break;case 8:this._params[3]=b/100,this.SetAudioParam(this._feedbackNode.gain,b/100,e,h)}}};self.C3AudioPhaserFX=class extends c{constructor(a,b,e,h,m,q,u){super(a);
this._type="phaser";this._params=[b,e,h,m,q,u];this._inputNode=this.CreateGain();this._dryNode=this.CreateGain();this._dryNode.gain.value=1-u/2;this._wetNode=this.CreateGain();this._wetNode.gain.value=u/2;this._filterNode=this._audioContext.createBiquadFilter();this._filterNode.type="allpass";this._filterNode.frequency.value=b;this._filterNode.detune.value=e;this._filterNode.Q.value=h;this._oscNode=this._audioContext.createOscillator();this._oscNode.frequency.value=q;this._oscGainNode=this.CreateGain();
this._oscGainNode.gain.value=m;this._inputNode.connect(this._filterNode);this._inputNode.connect(this._dryNode);this._filterNode.connect(this._wetNode);this._oscNode.connect(this._oscGainNode);this._oscGainNode.connect(this._filterNode.frequency);this._oscNode.start(0)}Release(){this._oscNode.stop(0);this._inputNode.disconnect();this._filterNode.disconnect();this._oscNode.disconnect();this._oscGainNode.disconnect();this._dryNode.disconnect();this._wetNode.disconnect();super.Release()}ConnectTo(a){this._wetNode.disconnect();
this._wetNode.connect(a);this._dryNode.disconnect();this._dryNode.connect(a)}GetInputNode(){return this._inputNode}SetParam(a,b,e,h){switch(a){case 0:b=Math.max(Math.min(b/100,1),0);this._params[5]=b;this.SetAudioParam(this._wetNode.gain,b/2,e,h);this.SetAudioParam(this._dryNode.gain,1-b/2,e,h);break;case 1:this._params[0]=b;this.SetAudioParam(this._filterNode.frequency,b,e,h);break;case 2:this._params[1]=b;this.SetAudioParam(this._filterNode.detune,b,e,h);break;case 3:this._params[2]=b;this.SetAudioParam(this._filterNode.Q,
b,e,h);break;case 6:this._params[3]=b;this.SetAudioParam(this._oscGainNode.gain,b,e,h);break;case 7:this._params[4]=b,this.SetAudioParam(this._oscNode.frequency,b,e,h)}}};self.C3AudioGainFX=class extends c{constructor(a,b){super(a);this._type="gain";this._params=[b];this._node=this.CreateGain();this._node.gain.value=b}Release(){this._node.disconnect();super.Release()}ConnectTo(a){this._node.disconnect();this._node.connect(a)}GetInputNode(){return this._node}SetParam(a,b,e,h){const m=self.AudioDOMHandler.DbToLinear;
switch(a){case 4:this._params[0]=m(b),this.SetAudioParam(this._node.gain,m(b),e,h)}}};self.C3AudioTremoloFX=class extends c{constructor(a,b,e){super(a);this._type="tremolo";this._params=[b,e];this._node=this.CreateGain();this._node.gain.value=1-e/2;this._oscNode=this._audioContext.createOscillator();this._oscNode.frequency.value=b;this._oscGainNode=this.CreateGain();this._oscGainNode.gain.value=e/2;this._oscNode.connect(this._oscGainNode);this._oscGainNode.connect(this._node.gain);this._oscNode.start(0)}Release(){this._oscNode.stop(0);
this._oscNode.disconnect();this._oscGainNode.disconnect();this._node.disconnect();super.Release()}ConnectTo(a){this._node.disconnect();this._node.connect(a)}GetInputNode(){return this._node}SetParam(a,b,e,h){switch(a){case 0:b=Math.max(Math.min(b/100,1),0);this._params[1]=b;this.SetAudioParam(this._node.gain.value,1-b/2,e,h);this.SetAudioParam(this._oscGainNode.gain.value,b/2,e,h);break;case 7:this._params[0]=b,this.SetAudioParam(this._oscNode.frequency,b,e,h)}}};self.C3AudioRingModFX=class extends c{constructor(a,
b,e){super(a);this._type="ringmod";this._params=[b,e];this._inputNode=this.CreateGain();this._wetNode=this.CreateGain();this._wetNode.gain.value=e;this._dryNode=this.CreateGain();this._dryNode.gain.value=1-e;this._ringNode=this.CreateGain();this._ringNode.gain.value=0;this._oscNode=this._audioContext.createOscillator();this._oscNode.frequency.value=b;this._oscNode.connect(this._ringNode.gain);this._oscNode.start(0);this._inputNode.connect(this._ringNode);this._inputNode.connect(this._dryNode);this._ringNode.connect(this._wetNode)}Release(){this._oscNode.stop(0);
this._oscNode.disconnect();this._ringNode.disconnect();this._inputNode.disconnect();this._wetNode.disconnect();this._dryNode.disconnect();super.Release()}ConnectTo(a){this._wetNode.disconnect();this._wetNode.connect(a);this._dryNode.disconnect();this._dryNode.connect(a)}GetInputNode(){return this._inputNode}SetParam(a,b,e,h){switch(a){case 0:b=Math.max(Math.min(b/100,1),0);this._params[1]=b;this.SetAudioParam(this._wetNode.gain,b,e,h);this.SetAudioParam(this._dryNode.gain,1-b,e,h);break;case 7:this._params[0]=
b,this.SetAudioParam(this._oscNode.frequency,b,e,h)}}};self.C3AudioDistortionFX=class extends c{constructor(a,b,e,h,m,q){super(a);this._type="distortion";this._params=[b,e,h,m,q];this._inputNode=this.CreateGain();this._preGain=this.CreateGain();this._postGain=this.CreateGain();this._SetDrive(h,m);this._wetNode=this.CreateGain();this._wetNode.gain.value=q;this._dryNode=this.CreateGain();this._dryNode.gain.value=1-q;this._waveShaper=this._audioContext.createWaveShaper();this._curve=new Float32Array(65536);
this._GenerateColortouchCurve(b,e);this._waveShaper.curve=this._curve;this._inputNode.connect(this._preGain);this._inputNode.connect(this._dryNode);this._preGain.connect(this._waveShaper);this._waveShaper.connect(this._postGain);this._postGain.connect(this._wetNode)}Release(){this._inputNode.disconnect();this._preGain.disconnect();this._waveShaper.disconnect();this._postGain.disconnect();this._wetNode.disconnect();this._dryNode.disconnect();super.Release()}_SetDrive(a,b){.01>a&&(a=.01);this._preGain.gain.value=
a;this._postGain.gain.value=Math.pow(1/a,.6)*b}_GenerateColortouchCurve(a,b){for(let e=0;32768>e;++e){let h=e/32768;h=this._Shape(h,a,b);this._curve[32768+e]=h;this._curve[32768-e-1]=-h}}_Shape(a,b,e){e=1.05*e*b-b;const h=0>a?-1:1;a=0>a?-a:a;return(a<b?a:b+e*self.AudioDOMHandler.e4(a-b,1/e))*h}ConnectTo(a){this._wetNode.disconnect();this._wetNode.connect(a);this._dryNode.disconnect();this._dryNode.connect(a)}GetInputNode(){return this._inputNode}SetParam(a,b,e,h){switch(a){case 0:b=Math.max(Math.min(b/
100,1),0),this._params[4]=b,this.SetAudioParam(this._wetNode.gain,b,e,h),this.SetAudioParam(this._dryNode.gain,1-b,e,h)}}};self.C3AudioCompressorFX=class extends c{constructor(a,b,e,h,m,q){super(a);this._type="compressor";this._params=[b,e,h,m,q];this._node=this._audioContext.createDynamicsCompressor();this._node.threshold.value=b;this._node.knee.value=e;this._node.ratio.value=h;this._node.attack.value=m;this._node.release.value=q}Release(){this._node.disconnect();super.Release()}ConnectTo(a){this._node.disconnect();
this._node.connect(a)}GetInputNode(){return this._node}SetParam(a,b,e,h){}};self.C3AudioAnalyserFX=class extends c{constructor(a,b,e){super(a);this._type="analyser";this._params=[b,e];this._node=this._audioContext.createAnalyser();this._node.fftSize=b;this._node.smoothingTimeConstant=e;this._freqBins=new Float32Array(this._node.frequencyBinCount);this._signal=new Uint8Array(b);this._rms=this._peak=0;this._audioDomHandler._AddAnalyser(this)}Release(){this._audioDomHandler._RemoveAnalyser(this);this._node.disconnect();
super.Release()}Tick(){this._node.getFloatFrequencyData(this._freqBins);this._node.getByteTimeDomainData(this._signal);const a=this._node.fftSize;let b=this._peak=0;for(var e=0;e<a;++e){let h=(this._signal[e]-128)/128;0>h&&(h=-h);this._peak<h&&(this._peak=h);b+=h*h}e=self.AudioDOMHandler.LinearToDb;this._peak=e(this._peak);this._rms=e(Math.sqrt(b/a))}ConnectTo(a){this._node.disconnect();this._node.connect(a)}GetInputNode(){return this._node}SetParam(a,b,e,h){}GetData(){return{tag:this.GetTag(),index:this.GetIndex(),
peak:this._peak,rms:this._rms,binCount:this._node.frequencyBinCount,freqBins:this._freqBins}}}}"use strict";
self.RuntimeInterface.AddDOMHandlerClass(class extends self.DOMHandler{constructor(c){super(c,"browser");this._exportType="";this.AddRuntimeMessageHandlers([["get-initial-state",a=>this._OnGetInitialState(a)],["ready-for-sw-messages",()=>this._OnReadyForSWMessages()],["alert",a=>this._OnAlert(a)],["close",()=>this._OnClose()],["set-focus",a=>this._OnSetFocus(a)],["vibrate",a=>this._OnVibrate(a)],["lock-orientation",a=>this._OnLockOrientation(a)],["unlock-orientation",()=>this._OnUnlockOrientation()],
["navigate",a=>this._OnNavigate(a)],["request-fullscreen",a=>this._OnRequestFullscreen(a)],["exit-fullscreen",()=>this._OnExitFullscreen()],["set-hash",a=>this._OnSetHash(a)]]);window.addEventListener("online",()=>this._OnOnlineStateChanged(!0));window.addEventListener("offline",()=>this._OnOnlineStateChanged(!1));window.addEventListener("hashchange",()=>this._OnHashChange());document.addEventListener("backbutton",()=>this._OnCordovaBackButton());"undefined"!==typeof Windows&&Windows.UI.Core.SystemNavigationManager.getForCurrentView().addEventListener("backrequested",
a=>this._OnWin10BackRequested(a))}_OnGetInitialState(c){this._exportType=c.exportType;return{location:location.toString(),isOnline:!!navigator.onLine,referrer:document.referrer,title:document.title,isCookieEnabled:!!navigator.cookieEnabled,screenWidth:screen.width,screenHeight:screen.height,windowOuterWidth:window.outerWidth,windowOuterHeight:window.outerHeight,isScirraArcade:"undefined"!==typeof window.is_scirra_arcade}}_OnReadyForSWMessages(){window.C3_RegisterSW&&window.OfflineClientInfo&&window.OfflineClientInfo.SetMessageCallback(c=>
this.PostToRuntime("sw-message",c.data))}_OnOnlineStateChanged(c){this.PostToRuntime("online-state",{isOnline:c})}_OnCordovaBackButton(){this.PostToRuntime("backbutton")}_OnWin10BackRequested(c){c.handled=!0;this.PostToRuntime("backbutton")}GetNWjsWindow(){return"nwjs"===this._exportType?nw.Window.get():null}_OnAlert(c){alert(c.message)}_OnClose(){navigator.app&&navigator.app.exitApp?navigator.app.exitApp():navigator.device&&navigator.device.exitApp?navigator.device.exitApp():window.close()}_OnSetFocus(c){c=
c.isFocus;if("nwjs"===this._exportType){const a=this.GetNWjsWindow();c?a.focus():a.blur()}else c?window.focus():window.blur()}_OnVibrate(c){navigator.vibrate&&navigator.vibrate(c.pattern)}_OnLockOrientation(c){c=c.orientation;if(screen.orientation&&screen.orientation.lock)screen.orientation.lock(c).catch(a=>console.warn("[Construct 3] Failed to lock orientation: ",a));else try{let a=!1;screen.lockOrientation?a=screen.lockOrientation(c):screen.webkitLockOrientation?a=screen.webkitLockOrientation(c):
screen.mozLockOrientation?a=screen.mozLockOrientation(c):screen.msLockOrientation&&(a=screen.msLockOrientation(c));a||console.warn("[Construct 3] Failed to lock orientation")}catch(a){console.warn("[Construct 3] Failed to lock orientation: ",a)}}_OnUnlockOrientation(){try{screen.orientation&&screen.orientation.unlock?screen.orientation.unlock():screen.unlockOrientation?screen.unlockOrientation():screen.webkitUnlockOrientation?screen.webkitUnlockOrientation():screen.mozUnlockOrientation?screen.mozUnlockOrientation():
screen.msUnlockOrientation&&screen.msUnlockOrientation()}catch(c){}}_OnNavigate(c){var a=c.type;if("back"===a)navigator.app&&navigator.app.backHistory?navigator.app.backHistory():window.back();else if("forward"===a)window.forward();else if("home"===a)window.home();else if("reload"===a)location.reload();else if("url"===a){a=c.url;var b=c.target;c=c.exportType;"windows-uwp"===c&&"undefined"!==typeof Windows?Windows.System.Launcher.launchUriAsync(new Windows.Foundation.Uri(a)):self.cordova&&self.cordova.InAppBrowser?
self.cordova.InAppBrowser.open(a,"_system"):"preview"===c?window.open(a,"_blank"):this._isScirraArcade||(2===b?window.top.location=a:1===b?window.parent.location=a:window.location=a)}else"new-window"===a&&(a=c.url,b=c.tag,"windows-uwp"===c.exportType&&"undefined"!==typeof Windows?Windows.System.Launcher.launchUriAsync(new Windows.Foundation.Uri(a)):self.cordova&&self.cordova.InAppBrowser?self.cordova.InAppBrowser.open(a,"_system"):window.open(a,b))}_OnRequestFullscreen(c){const a={navigationUI:"auto"};
c=c.navUI;1===c?a.navigationUI="hide":2===c&&(a.navigationUI="show");c=document.documentElement;c.requestFullscreen?c.requestFullscreen(a):c.mozRequestFullScreen?c.mozRequestFullScreen(a):c.msRequestFullscreen?c.msRequestFullscreen(a):c.webkitRequestFullScreen&&("undefined"!==typeof Element.ALLOW_KEYBOARD_INPUT?c.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):c.webkitRequestFullScreen())}_OnExitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():
document.msExitFullscreen?document.msExitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen()}_OnSetHash(c){location.hash=c.hash}_OnHashChange(){this.PostToRuntime("hashchange",{location:location.toString()})}});"use strict";
self.RuntimeInterface.AddDOMHandlerClass(class extends self.DOMHandler{constructor(c){super(c,"touch");this.AddRuntimeMessageHandler("request-permission",a=>this._OnRequestPermission(a))}async _OnRequestPermission(c){c=c.type;let a=!0;0===c?a=await this._RequestOrientationPermission():1===c&&(a=await this._RequestMotionPermission());this.PostToRuntime("permission-result",{type:c,result:a})}async _RequestOrientationPermission(){if(!self.DeviceOrientationEvent||!self.DeviceOrientationEvent.requestPermission)return!0;
try{return"granted"===await self.DeviceOrientationEvent.requestPermission()}catch(c){return console.warn("[Touch] Failed to request orientation permission: ",c),!1}}async _RequestMotionPermission(){if(!self.DeviceMotionEvent||!self.DeviceMotionEvent.requestPermission)return!0;try{return"granted"===await self.DeviceMotionEvent.requestPermission()}catch(c){return console.warn("[Touch] Failed to request motion permission: ",c),!1}}});"use strict";
self.RuntimeInterface.AddDOMHandlerClass(class extends self.DOMHandler{constructor(c){super(c,"mouse");this.AddRuntimeMessageHandler("cursor",a=>this._OnChangeCursorStyle(a))}_OnChangeCursorStyle(c){document.documentElement.style.cursor=c}});"use strict";
self.RuntimeInterface.AddDOMHandlerClass(class extends self.DOMHandler{constructor(c){super(c,"nwjs");this._isNWjs=!1;this.AddRuntimeMessageHandlers([["init",()=>this.Init()],["show-open-dlg",a=>this._OnShowOpenDlg(a)],["show-folder-dlg",()=>this._OnShowFolderDlg()],["show-save-dlg",a=>this._OnShowSaveDlg(a)],["set-title",a=>this._OnSetTitle(a)],["set-window-x",a=>this._OnSetWindowX(a)],["set-window-y",a=>this._OnSetWindowY(a)],["set-window-width",a=>this._OnSetWindowWidth(a)],["set-window-height",
a=>this._OnSetWindowHeight(a)],["window-cmd",a=>this._OnWindowCommand(a)],["window-attention",a=>this._OnWindowRequestAttention(a)],["set-window-max-size",a=>this._OnSetWindowMaxSize(a)],["set-window-min-size",a=>this._OnSetWindowMinSize(a)],["set-window-resizable",a=>this._OnSetWindowResizable(a)],["set-window-always-top",a=>this._OnSetWindowAlwaysOnTop(a)],["shell-cmd",a=>this._OnShellCommand(a)],["set-clipboard",a=>this._OnSetClipboard(a)],["clear-clipboard",()=>this._OnClearClipboard()]])}GetWindow(){return nw.Window.get()}_CreateNwjsInputElem(c,
a){const b=document.createElement("input");b.type="file";b.style.display="none";b.id=c;a&&b.setAttribute(a,"");document.body.appendChild(b);return b}Init(){this._isNWjs=!0;nw.App.clearCache();window.addEventListener("dragover",m=>m.preventDefault());window.addEventListener("drop",m=>this._OnDrop(m));const c=this._CreateNwjsInputElem("c3nwOpenFileDialog");c.onchange=m=>{this.PostToRuntime("open-dlg",{chosenPath:c.value});try{c.value=null}catch(q){}};c.oncancel=()=>{this.PostToRuntime("open-dlg-cancel")};
const a=this._CreateNwjsInputElem("c3nwChooseFolderDialog","nwdirectory");a.onchange=m=>{this.PostToRuntime("folder-dlg",{chosenPath:a.value});try{a.value=null}catch(q){}};a.oncancel=()=>{this.PostToRuntime("folder-dlg-cancel")};const b=this._CreateNwjsInputElem("c3nwSaveDialog","nwsaveas");b.onchange=m=>{this.PostToRuntime("save-dlg",{chosenPath:b.value});try{b.value=null}catch(q){}};b.oncancel=()=>{this.PostToRuntime("save-dlg-cancel")};const e=this.GetWindow();e.on("move",m=>this._OnWindowChange(m));
e.on("resize",m=>this._OnWindowChange(m));let h=this._GetClipboardText();setInterval(()=>{const m=this._GetClipboardText();h!==m&&(h=m,this.PostToRuntime("clipboard-change",{"clipboard-text":m}))},1E3);return Object.assign({argv:nw.App.argv,"clipboard-text":h},this._GetWindowInfo())}_GetWindowInfo(){const c=this.GetWindow();return{"window-title":c.title||"","window-x":c.x,"window-y":c.y,"window-width":c.width,"window-height":c.height}}_OnWindowChange(c){this.PostToRuntime("window-change",this._GetWindowInfo())}_GetClipboardText(){return nw.Clipboard.get().get()||
""}_OnClipboardChange(){this.PostToRuntime("clipboard-change",this._GetClipboardInfo())}_OnSetWindowX(c){this.GetWindow().x=c.x}_OnSetWindowY(c){this.GetWindow().y=c.y}_OnSetWindowWidth(c){const a=this.GetWindow();c=c.width;a.setInnerWidth?a.setInnerWidth(c):a.width=c}_OnSetWindowHeight(c){const a=this.GetWindow();c=c.height;a.setInnerHeight?a.setInnerHeight(c):a.height=c}_OnWindowCommand(c){const a=c.method;setTimeout(()=>this.GetWindow()[a](),100)}_OnWindowRequestAttention(c){this.GetWindow().requestAttention(c.request)}_OnSetWindowMaxSize(c){this.GetWindow().setMaximumSize(c.width,
c.height)}_OnSetWindowMinSize(c){this.GetWindow().setMinimumSize(c.width,c.height)}_OnSetWindowResizable(c){this.GetWindow().setResizable(c.resizable)}_OnSetWindowAlwaysOnTop(c){this.GetWindow().setAlwaysOnTop(c.top)}_OnShellCommand(c){nw.Shell[c.method](c.arg)}_OnSetClipboard(c){nw.Clipboard.get().set(c.text)}_OnClearClipboard(){nw.Clipboard.get().clear()}_OnDrop(c){c.preventDefault();c=c.dataTransfer.files;const a=[];for(let b=0,e=c.length;b<e;++b)a.push(c[b].path);this.PostToRuntime("drop",{filePaths:a});
return!1}_OnShowOpenDlg(c){if(this._isNWjs){var a=document.getElementById("c3nwOpenFileDialog");a.setAttribute("accept",c.accept);a.click()}}_OnShowFolderDlg(){this._isNWjs&&document.getElementById("c3nwChooseFolderDialog").click()}_OnShowSaveDlg(c){if(this._isNWjs){var a=document.getElementById("c3nwSaveDialog");a.setAttribute("accept",c.accept);a.click()}}_OnSetTitle(c){c=c.title;document.title=c;this.GetWindow().title=c}});"use strict";
{function c(a){a.stopPropagation()}self.RuntimeInterface.AddDOMHandlerClass(class extends self.DOMElementHandler{constructor(a){super(a,"sliderbar")}CreateElement(a,b){const e=document.createElement("input");e.type="range";e.style.position="absolute";e.style.userSelect="none";e.style.webkitUserSelect="none";e.addEventListener("touchstart",c);e.addEventListener("touchmove",c);e.addEventListener("touchend",c);e.addEventListener("mousedown",c);e.addEventListener("mouseup",c);e.addEventListener("keydown",
c);e.addEventListener("keyup",c);e.addEventListener("click",()=>this._PostToRuntimeElementMaybeSync("click",a));e.addEventListener("change",()=>this.PostToRuntimeElement("change",a,{value:parseFloat(e.value)}));e.addEventListener("input",()=>this.PostToRuntimeElement("input",a,{value:parseFloat(e.value)}));b.id&&(e.id=b.id);this.UpdateState(e,b);return e}UpdateState(a,b){a.max=b.max;a.min=b.min;a.step=b.step;a.value=b.value;a.disabled=!b.isEnabled;a.title=b.title}})};