// Generated by Construct, the game and animation creation tool
// Visit: https://www.construct.net

// workers/domHandler.js
"use strict";window.DOMHandler=class{constructor(t,i){this._iRuntime=t,this._componentId=i,this._hasTickCallback=!1,this._tickCallback=()=>this.Tick()}Attach(){}PostToRuntime(t,i,e,s){this._iRuntime.PostToRuntimeComponent(this._componentId,t,i,e,s)}PostToRuntimeAsync(t,i,e,s){return this._iRuntime.PostToRuntimeComponentAsync(this._componentId,t,i,e,s)}_PostToRuntimeMaybeSync(t,i,e){this._iRuntime.UsesWorker()?this.PostToRuntime(t,i,e):this._iRuntime._GetLocalRuntime()["_OnMessageFromDOM"]({"type":"event","component":this._componentId,"handler":t,"dispatchOpts":e||null,"data":i,"responseId":null})}AddRuntimeMessageHandler(t,i){this._iRuntime.AddRuntimeComponentMessageHandler(this._componentId,t,i)}AddRuntimeMessageHandlers(t){for(const[i,e]of t)this.AddRuntimeMessageHandler(i,e)}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(t,i){this._callback=t,this._interval=i,this._timerId=-1,this._lastCallTime=-1/0,this._timerCallFunc=()=>this._OnTimer(),this._ignoreReset=!1,this._canRunImmediate=!1}SetCanRunImmediate(t){this._canRunImmediate=!!t}Call(){if(-1===this._timerId){const t=Date.now(),i=t-this._lastCallTime,e=this._interval;e<=i&&this._canRunImmediate?(this._lastCallTime=t,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(e-i,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._callback=null,this._timerCallFunc=null}};

// workers/domElementHandler.js
"use strict";{class a{constructor(e){this._elem=e,this._hadFirstUpdate=!1,this._isVisibleFlag=!0,this._wantHtmlIndex=-1,this._actualHtmlIndex=-1,this._htmlZIndex=-1}SetVisibleFlag(e){this._isVisibleFlag=!!e}GetVisibleFlag(){return this._isVisibleFlag}HadFirstUpdate(){return this._hadFirstUpdate}SetHadFirstUpdate(){this._hadFirstUpdate=!0}GetWantHTMLIndex(){return this._wantHtmlIndex}SetWantHTMLIndex(e){this._wantHtmlIndex=e}GetActualHTMLIndex(){return this._actualHtmlIndex}SetActualHTMLIndex(e){this._actualHtmlIndex=e}SetHTMLZIndex(e){this._htmlZIndex=e}GetHTMLZIndex(){return this._htmlZIndex}GetElement(){return this._elem}}window.DOMElementHandler=class extends self.DOMHandler{constructor(e,t){super(e,t),this._elementMap=new Map,this._autoAttach=!0,this.AddRuntimeMessageHandlers([["create",e=>this._OnCreate(e)],["destroy",e=>this._OnDestroy(e)],["set-visible",e=>this._OnSetVisible(e)],["update-position",e=>this._OnUpdatePosition(e)],["update-state",e=>this._OnUpdateState(e)],["focus",e=>this._OnSetFocus(e)],["set-css-style",e=>this._OnSetCssStyle(e)],["set-attribute",e=>this._OnSetAttribute(e)],["remove-attribute",e=>this._OnRemoveAttribute(e)]]),this.AddDOMElementMessageHandler("get-element",e=>e)}SetAutoAttach(e){this._autoAttach=!!e}AddDOMElementMessageHandler(e,s){this.AddRuntimeMessageHandler(e,e=>{const t=e["elementId"],n=this.GetElementById(t);return s(n,e)})}AddDOMElementMessageHandlers(e){for(const[t,n]of e)this.AddDOMElementMessageHandler(t,n)}_OnCreate(e){const t=e["elementId"],n=this.CreateElement(t,e),s=new a(n),i=(this._elementMap.set(t,s),n.style.boxSizing="border-box",n.style.display="none",s.SetVisibleFlag(e["isVisible"]),this._GetFocusElement(n)),l=(i.addEventListener("focus",e=>this._OnFocus(t)),i.addEventListener("blur",e=>this._OnBlur(t)),e["htmlIndex"]);if(s.SetWantHTMLIndex(l),s.SetHTMLZIndex(e["htmlZIndex"]),this._autoAttach){const d=this.GetRuntimeInterface().GetAvailableHTMLIndex(l),r=(s.SetActualHTMLIndex(d),this.GetRuntimeInterface().GetHTMLWrapElement(d));r.appendChild(n)}}CreateElement(e,t){throw new Error("required override")}DestroyElement(e){}_OnDestroy(e){const t=e["elementId"],n=this.GetElementById(t);this.DestroyElement(n),this._autoAttach&&n.parentElement.removeChild(n),this._elementMap.delete(t)}PostToRuntimeElement(e,t,n){(n=n||{})["elementId"]=t,this.PostToRuntime(e,n)}_PostToRuntimeElementMaybeSync(e,t,n){(n=n||{})["elementId"]=t,this._PostToRuntimeMaybeSync(e,n)}_OnSetVisible(e){if(this._autoAttach){const t=this._elementMap.get(e["elementId"]),n=t.GetElement();t.HadFirstUpdate()?n.style.display=e["isVisible"]?"":"none":t.SetVisibleFlag(e["isVisible"])}}_OnUpdatePosition(e){if(this._autoAttach){const t=this._elementMap.get(e["elementId"]),n=t.GetElement(),s=this.GetRuntimeInterface(),i=(n.style.left=e["left"]+"px",n.style.top=e["top"]+"px",n.style.width=e["width"]+"px",n.style.height=e["height"]+"px",e["fontSize"]),l=(null!==i&&(n.style.fontSize=i+"em"),e["htmlIndex"]),a=(t.SetWantHTMLIndex(l),s.GetAvailableHTMLIndex(l));if(a!==t.GetActualHTMLIndex()){n.remove();const r=s.GetHTMLWrapElement(a);r.appendChild(n),t.SetActualHTMLIndex(a),s._UpdateHTMLElementsZOrder()}const d=e["htmlZIndex"];d!==t.GetHTMLZIndex()&&(t.SetHTMLZIndex(d),s._UpdateHTMLElementsZOrder()),t.HadFirstUpdate()||(t.SetHadFirstUpdate(),t.GetVisibleFlag()&&(n.style.display=""))}}_OnHTMLLayersChanged(){if(this._autoAttach)for(const e of this._elementMap.values()){const t=this.GetRuntimeInterface().GetAvailableHTMLIndex(e.GetWantHTMLIndex()),n=e.GetActualHTMLIndex();if(-1!==t&&-1!==n&&t!==n){const s=e.GetElement(),i=(s.remove(),this.GetRuntimeInterface().GetHTMLWrapElement(t));i.appendChild(s),e.SetActualHTMLIndex(t)}}}_GetAllElementStatesForZOrderUpdate(){return this._autoAttach?[...this._elementMap.values()]:null}_OnUpdateState(e){const t=this.GetElementById(e["elementId"]);this.UpdateState(t,e)}UpdateState(e,t){throw new Error("required override")}_GetFocusElement(e){return e}_OnFocus(e){this.PostToRuntimeElement("elem-focused",e)}_OnBlur(e){this.PostToRuntimeElement("elem-blurred",e)}_OnSetFocus(e){const t=this._GetFocusElement(this.GetElementById(e["elementId"]));e["focus"]?t.focus():t.blur()}_OnSetCssStyle(e){const t=this.GetElementById(e["elementId"]),n=e["prop"],s=e["val"];n.startsWith("--")?t.style.setProperty(n,s):t.style[n]=s}_OnSetAttribute(e){const t=this.GetElementById(e["elementId"]);t.setAttribute(e["name"],e["val"])}_OnRemoveAttribute(e){const t=this.GetElementById(e["elementId"]);t.removeAttribute(e["name"])}GetElementById(e){const t=this._elementMap.get(e);if(t)return t.GetElement();throw new Error("no element with id "+e)}}}

// workers/domSide.js
"use strict";{const a=/(iphone|ipod|ipad|macos|macintosh|mac os x)/i.test(navigator.userAgent),b=/android/i.test(navigator.userAgent),c=/safari/i.test(navigator.userAgent)&&!/(chrome|chromium|edg\/|OPR\/|nwjs)/i.test(navigator.userAgent);let d=0;function AddScript(s){const r=document.createElement("script");return r.async=!1,r.type="module",s.isStringSrc?new Promise(e=>{const t="c3_resolve_"+d;++d,self[t]=e,r.textContent=s.str+`

self["${t}"]();`,document.head.appendChild(r)}):new Promise((e,t)=>{r.onload=e,r.onerror=t,r.src=s,document.head.appendChild(r)})}async function CheckSupportsWorkerMode(){if(!navigator["userActivation"]||"undefined"==typeof OffscreenCanvas)return!1;try{let e=!1;const t=new Blob([`
	self.addEventListener("message", () =>
	{
		try {
			const offscreenCanvas = new OffscreenCanvas(32, 32);
			const gl = offscreenCanvas.getContext("webgl");
			self.postMessage(!!gl);
		}
		catch (err)
		{
			console.warn("Feature detection worker error:", err);
			self.postMessage(false);
		}
	});`],{"type":"text/javascript"}),s=new Worker(URL.createObjectURL(t),{get type(){e=!0}}),r=await new Promise(t=>{s.addEventListener("message",e=>{s.terminate(),t(e.data)}),s.postMessage("")});return e&&r}catch(e){return console.warn("Error feature detecting worker mode: ",e),!1}}let e=new Audio;const f={"audio/webm; codecs=opus":!!e.canPlayType("audio/webm; codecs=opus"),"audio/ogg; codecs=opus":!!e.canPlayType("audio/ogg; codecs=opus"),"audio/webm; codecs=vorbis":!!e.canPlayType("audio/webm; codecs=vorbis"),"audio/ogg; codecs=vorbis":!!e.canPlayType("audio/ogg; codecs=vorbis"),"audio/mp4":!!e.canPlayType("audio/mp4"),"audio/mpeg":!!e.canPlayType("audio/mpeg")};async function BlobToString(e){const t=await BlobToArrayBuffer(e),s=new TextDecoder("utf-8");return s.decode(t)}function BlobToArrayBuffer(r){return new Promise((t,s)=>{const e=new FileReader;e.onload=e=>t(e.target.result),e.onerror=e=>s(e),e.readAsArrayBuffer(r)})}e=null;const g=[];let r=0;const i=8,j=(window["RealFile"]=window["File"],[]),k=new Map,l=new Map;let h=0;const n=[],o=(self.runOnStartup=function(e){if("function"!=typeof e)throw new Error("runOnStartup called without a function");n.push(e)},new Set(["cordova","playable-ad-single-file","playable-ad-zip","instant-games"]));function IsWebViewExportType(e){return o.has(e)}let t=!1;window.RuntimeInterface=class Q{constructor(e){if(this._useWorker=e.useWorker,this._messageChannelPort=null,this._runtimeBaseUrl="",this._scriptFolder=e.scriptFolder,this._worker=null,this._localRuntime=null,this._domHandlers=[],this._runtimeDomHandler=null,this._isFirstSizeUpdate=!0,this._canvasLayers=[],this._pendingRemoveElements=[],this._pendingUpdateHTMLZOrder=!1,this._updateHTMLZOrderRAFCallback=()=>this._DoUpdateHTMLElementsZOrder(),this._isExportingToVideo=!1,this._exportToVideoDuration=0,this._jobScheduler=null,this._rafId=-1,this._rafFunc=()=>this._OnRAFCallback(),this._rafCallbacks=new Set,this._wrapperInitResolve=null,this._wrapperComponentIds=[],this._exportType=e.exportType,this._isFileProtocol="file"===location.protocol.substr(0,4),this._directoryHandles=[],"playable-ad-single-file"!==this._exportType&&"playable-ad-zip"!==this._exportType&&"instant-games"!==this._exportType||(this._useWorker=!1),c&&(this._useWorker=!1),"cordova"===this._exportType&&this._useWorker&&b){const t=/Chrome\/(\d+)/i.exec(navigator.userAgent);t&&90<=parseInt(t[1],10)||(this._useWorker=!1)}this.IsAnyWebView2Wrapper()?self["chrome"]["webview"].addEventListener("message",e=>this._OnWrapperMessage(e.data,e["additionalObjects"])):"macos-wkwebview"===this._exportType?self["C3WrapperOnMessage"]=e=>this._OnWrapperMessage(e):"linux-cef"===this._exportType&&self["c3_linux_cef_set_message_callback"](e=>this._OnWrapperMessage(JSON.parse(e))),this._localFileBlobs=null,this._localFileStrings=null,"html5"!==this._exportType||window.isSecureContext||console.warn("[Construct] Warning: the browser indicates this is not a secure context. Some features may be unavailable. Use secure (HTTPS) hosting to ensure all features are available."),this.AddRuntimeComponentMessageHandler("canvas","update-size",e=>this._OnUpdateCanvasSize(e)),this.AddRuntimeComponentMessageHandler("canvas","set-html-layer-count",e=>this["_OnSetHTMLLayerCount"](e)),this.AddRuntimeComponentMessageHandler("canvas","cleanup-html-layers",()=>this._OnCleanUpHTMLLayers()),this.AddRuntimeComponentMessageHandler("canvas","update-html-layer-dom-state",e=>this._UpdateHTMLLayerDOMProperties(e["layersDomState"])),this.AddRuntimeComponentMessageHandler("runtime","cordova-fetch-local-file",e=>this._OnCordovaFetchLocalFile(e)),this.AddRuntimeComponentMessageHandler("runtime","create-job-worker",e=>this._OnCreateJobWorker(e)),this.AddRuntimeComponentMessageHandler("runtime","send-wrapper-extension-message",e=>this._OnSendWrapperExtensionMessage(e)),"cordova"===this._exportType?document.addEventListener("deviceready",()=>this._Init(e)):this._Init(e),this._skipAndroidVirtualKeyboardDetection=0}Release(){this._CancelAnimationFrame(),this._messageChannelPort&&(this._messageChannelPort.onmessage=null,this._messageChannelPort=null),this._worker&&(this._worker.terminate(),this._worker=null),this._localRuntime&&(this._localRuntime.Release(),this._localRuntime=null);for(const{canvas:e,htmlWrap:t}of this._canvasLayers)e.remove(),t.remove();this._canvasLayers.length=0}GetMainCanvas(){return this._canvasLayers[0].canvas}GetAvailableHTMLIndex(e){return Math.min(e,this._canvasLayers.length-1)}GetHTMLWrapElement(e){if(e<0||e>=this._canvasLayers.length)throw new RangeError("invalid canvas layer");return this._canvasLayers[e].htmlWrap}["_GetHTMLWrapElement"](e){return this.GetHTMLWrapElement(e)}GetRuntimeBaseURL(){return this._runtimeBaseUrl}UsesWorker(){return this._useWorker}GetExportType(){return this._exportType}IsFileProtocol(){return this._isFileProtocol}GetScriptFolder(){return this._scriptFolder}IsiOSCordova(){return a&&"cordova"===this._exportType}IsiOSWebView(){const e=navigator.userAgent;return a&&IsWebViewExportType(this._exportType)||navigator["standalone"]||/crios\/|fxios\/|edgios\//i.test(e)}IsAndroid(){return b}IsAndroidWebView(){return b&&IsWebViewExportType(this._exportType)}IsWindowsWebView2(){return"windows-webview2"===this._exportType||!!("preview"===this._exportType&&window["chrome"]&&window["chrome"]["webview"]&&window["chrome"]["webview"]["postMessage"])}IsAnyWebView2Wrapper(){return this.IsWindowsWebView2()||"xbox-uwp-webview2"===this._exportType}SkipNextAndroidVirtualKeyboardDetection(){this.IsAndroidWebView()&&this._skipAndroidVirtualKeyboardDetection++}CanDoAndroidVirtualKeyboardDetection(){return this._CanDoAndroidVirtualKeyboardDetection().next().value}*_CanDoAndroidVirtualKeyboardDetection(){if(!this.IsAndroidWebView())return!0;yield 0===this._skipAndroidVirtualKeyboardDetection,0<this._skipAndroidVirtualKeyboardDetection&&this._skipAndroidVirtualKeyboardDetection--}async _Init(e){if(this._useWorker){const s=await CheckSupportsWorkerMode();s||(this._useWorker=!1)}if("macos-wkwebview"===this._exportType)this._SendWrapperMessage({"type":"ready"});else if(this.IsAnyWebView2Wrapper()||"linux-cef"===this._exportType){this._SetupDesktopWrapperPolyfills();const r=await this._InitWrapper();this._wrapperComponentIds=r["registeredComponentIds"]}if("playable-ad-single-file"===this._exportType&&(this._localFileBlobs=self["c3_base64files"],this._localFileStrings={},await this._ConvertDataUrisToBlobs()),"nwjs"===this._exportType&&self["nw"]){const i=self["nw"]["Window"]["get"]();if(i["on"]("close",()=>self["nw"]["App"]["quit"]()),self["nw"]["App"]["manifest"]["c3-steam-mode"]){let e=0;this._AddRAFCallback(()=>{e++,document.documentElement.style.opacity=e%2==0?"1":"0.999"})}}if(e.runtimeBaseUrl)this._runtimeBaseUrl=e.runtimeBaseUrl;else{const n=location.origin,a=(this._runtimeBaseUrl=("null"===n?"file:///":n)+location.pathname,this._runtimeBaseUrl.lastIndexOf("/"));-1!==a&&(this._runtimeBaseUrl=this._runtimeBaseUrl.substr(0,a+1))}const t=new MessageChannel;if(this._messageChannelPort=t.port1,this._messageChannelPort.onmessage=e=>this["_OnMessageFromRuntime"](e.data),window["c3_addPortMessageHandler"]&&window["c3_addPortMessageHandler"](e=>this._OnMessageFromDebugger(e)),this._jobScheduler=new self.JobSchedulerDOM(this),await this._jobScheduler.Init(),"object"==typeof window["StatusBar"]&&window["StatusBar"]["hide"](),"object"==typeof window["AndroidFullScreen"])try{await new Promise((e,t)=>{window["AndroidFullScreen"]["immersiveMode"](e,t)})}catch(e){console.error("Failed to enter Android immersive mode: ",e)}this._useWorker?await this._InitWorker(e,t.port2):await this._InitDOM(e,t.port2)}_GetCommonRuntimeOptions(e){return{"runtimeBaseUrl":this._runtimeBaseUrl,"previewUrl":location.href,"windowInnerWidth":this._GetWindowInnerWidth(),"windowInnerHeight":this._GetWindowInnerHeight(),"cssDisplayMode":this.GetCssDisplayMode(),"devicePixelRatio":window.devicePixelRatio,"isFullscreen":Q.IsDocumentFullscreen(),"swClientId":window["cr_swClientId"]||"","exportType":e.exportType,"isNWjs":"undefined"!=typeof nw,"fileMap":globalThis.c3_swFileMap??new Map(Object.entries(this._localFileBlobs??{})),"scriptFolder":this._scriptFolder,"isDebug":new URLSearchParams(self.location.search).has("debug"),"ife":!!self.ife,"jobScheduler":this._jobScheduler.GetPortData(),"supportedAudioFormats":f,"isFileProtocol":this._isFileProtocol,"isiOSCordova":this.IsiOSCordova(),"isiOSWebView":this.IsiOSWebView(),"isWindowsWebView2":this.IsWindowsWebView2(),"isAnyWebView2Wrapper":this.IsAnyWebView2Wrapper(),"wrapperComponentIds":this._wrapperComponentIds,"isFBInstantAvailable":void 0!==self["FBInstant"]}}async _InitWorker(e,t){const i=e.workerMainUrl,s=("preview"===this._exportType?(this._worker=new Worker("previewworker.js",{type:"module",name:"Runtime"}),await new Promise((t,s)=>{const r=e=>{this._worker.removeEventListener("message",r),(e.data&&"ok"===e.data["type"]?t:s)()};this._worker.addEventListener("message",r),this._worker.postMessage({"type":"construct-worker-init","import":new URL(i,this._runtimeBaseUrl).toString()})})):this._worker=await this.CreateWorker(i,{type:"module",name:"Runtime"}),document.createElement("canvas")),r=(s.style.display="none",s["transferControlToOffscreen"]()),n=(document.body.appendChild(s),document.createElement("div"));n.className="c3htmlwrap",n.setAttribute("interactive",""),document.body.appendChild(n),this._canvasLayers.push({canvas:s,htmlWrap:n,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}}),window["c3canvas"]=s,self["C3_InsertHTMLPlaceholders"]&&self["C3_InsertHTMLPlaceholders"](),this._worker.postMessage(Object.assign(this._GetCommonRuntimeOptions(e),{"type":"init-runtime","isInWorker":!0,"messagePort":t,"canvas":r,"runtimeScriptList":e.runtimeScriptList,"projectMainScriptPath":e.projectMainScriptPath,"scriptsInEventsPath":e.scriptsInEventsPath}),[t,r,...this._jobScheduler.GetPortTransferables()]),this._domHandlers=j.map(e=>new e(this)),this._FindRuntimeDOMHandler(),this._runtimeDomHandler._AddDefaultCanvasEventHandlers(s),this._runtimeDomHandler._AddDefaultHTMLWrapEventHandlers(n),this._runtimeDomHandler._EnableWindowResizeEvent(),self["c3_callFunction"]=(e,t)=>this._runtimeDomHandler._InvokeFunctionFromJS(e,t),"preview"===this._exportType&&(self["goToLastErrorScript"]=()=>this.PostToRuntimeComponent("runtime","go-to-last-error-script"))}async _InitDOM(e,t){const s=document.createElement("canvas"),r=(s.style.display="none",document.body.appendChild(s),document.createElement("div")),i=(r.className="c3htmlwrap",r.setAttribute("interactive",""),document.body.appendChild(r),this._canvasLayers.push({canvas:s,htmlWrap:r,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}}),window["c3canvas"]=s,self["C3_InsertHTMLPlaceholders"]&&self["C3_InsertHTMLPlaceholders"](),this._domHandlers=j.map(e=>new e(this)),this._FindRuntimeDOMHandler(),this._runtimeDomHandler._AddDefaultCanvasEventHandlers(s),this._runtimeDomHandler._AddDefaultHTMLWrapEventHandlers(r),await Promise.all(e.runtimeScriptList.map(e=>this._MaybeGetPlatformSpecificScriptURL(e)))),a=(await Promise.all(i.map(e=>AddScript(e))),e.projectMainScriptPath),o=e.scriptsInEventsPath;if(a)try{if(await AddScript(a),"preview"===this._exportType&&!globalThis.C3_ProjectMainScriptOK)throw new Error("main script did not run to completion")}catch(e){this._RemoveLoadingMessage(),console.error("Error loading project main script: ",e),alert(`Failed to load the project main script (${a}). Check all your JavaScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the script. Press F12 and check the console for error details.`)}if(o)try{if(await AddScript(o),"preview"===this._exportType&&!globalThis.C3.ScriptsInEvents)throw new Error("scripts in events did not run to completion")}catch(e){this._RemoveLoadingMessage(),console.error("Error loading scripts in events: ",e),alert("Failed to load scripts in events. Check all your JavaScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the 'Imports for events' script. Press F12 and check the console for error details.")}const l=Object.assign(this._GetCommonRuntimeOptions(e),{"isInWorker":!1,"messagePort":t,"canvas":s,"runOnStartupFunctions":n});this._runtimeDomHandler._EnableWindowResizeEvent(),this._OnBeforeCreateRuntime(),this._localRuntime=self["C3_CreateRuntime"](l),await self["C3_InitRuntime"](this._localRuntime,l)}async CreateWorker(e,t){if(e.startsWith("blob:"))return new Worker(e,t);if("cordova"===this._exportType&&this._isFileProtocol){const i=await this.CordovaFetchLocalFileAsArrayBuffer(e),n=new Blob([i],{type:"application/javascript"});return new Worker(URL.createObjectURL(n),t)}if("playable-ad-single-file"===this._exportType){const a=this._localFileBlobs[e];if(a)return new Worker(URL.createObjectURL(a),t);throw new Error("missing script: "+e)}const s=new URL(e,location.href),r=location.origin!==s.origin;if(r){const o=await fetch(s);if(!o.ok)throw new Error("failed to fetch worker script");const l=await o.blob();return new Worker(URL.createObjectURL(l),t)}return new Worker(s,t)}_GetWindowInnerWidth(){return Math.max(window.innerWidth,1)}_GetWindowInnerHeight(){return Math.max(window.innerHeight,1)}GetCssDisplayMode(){if(this.IsAnyWebView2Wrapper())return"standalone";const e=this.GetExportType(),t=new Set(["cordova","nwjs","macos-wkwebview","linux-cef"]);return t.has(e)?"standalone":window.matchMedia("(display-mode: fullscreen)").matches?"fullscreen":window.matchMedia("(display-mode: standalone)").matches?"standalone":window.matchMedia("(display-mode: minimal-ui)").matches?"minimal-ui":navigator["standalone"]?"standalone":"browser"}_OnBeforeCreateRuntime(){this._RemoveLoadingMessage()}_RemoveLoadingMessage(){const e=window["cr_previewLoadingElem"];e&&(e.parentElement.removeChild(e),window["cr_previewLoadingElem"]=null)}async _OnCreateJobWorker(e){const t=await this._jobScheduler._CreateJobWorker();return{"outputPort":t,"transferables":[t]}}_OnUpdateCanvasSize(e){if(!this.IsExportingToVideo()){const t=e["styleWidth"]+"px",s=e["styleHeight"]+"px",r=e["marginLeft"]+"px",i=e["marginTop"]+"px";for(const{canvas:n,htmlWrap:a}of this._canvasLayers)n.style.width=t,n.style.height=s,n.style.marginLeft=r,n.style.marginTop=i,a.style.width=t,a.style.height=s,a.style.marginLeft=r,a.style.marginTop=i,this._isFirstSizeUpdate&&(n.style.display="",a.style.display="");document.documentElement.style.setProperty("--construct-scale",e["displayScale"]),this._isFirstSizeUpdate=!1}}["_OnSetHTMLLayerCount"](e){const s=e["count"],t=e["layersDomState"],r=e["immediate"],i=e["styleWidth"]+"px",n=e["styleHeight"]+"px",a=e["marginLeft"]+"px",o=e["marginTop"]+"px",l=[],c=[];if(s<this._canvasLayers.length)for(;this._canvasLayers.length>s;){const{canvas:d,htmlWrap:h}=this._canvasLayers.pop();h.remove(),this._useWorker&&!r?this._pendingRemoveElements.push(d):d.remove()}else if(s>this._canvasLayers.length)for(let e=0,t=s-this._canvasLayers.length;e<t;++e){const p=document.createElement("canvas");if(p.classList.add("c3overlay"),this._useWorker){const u=p["transferControlToOffscreen"]();l.push(u),c.push(u)}else l.push(p);document.body.appendChild(p);const m=document.createElement("div");m.classList.add("c3htmlwrap","c3overlay"),m.setAttribute("interactive",""),document.body.appendChild(m),p.style.width=i,p.style.height=n,p.style.marginLeft=a,p.style.marginTop=o,m.style.width=i,m.style.height=n,m.style.marginLeft=a,m.style.marginTop=o,this._runtimeDomHandler._AddDefaultCanvasEventHandlers(p),this._runtimeDomHandler._AddDefaultHTMLWrapEventHandlers(m),this._canvasLayers.push({canvas:p,htmlWrap:m,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}})}this._UpdateHTMLLayerDOMProperties(t);for(const _ of this._domHandlers)_ instanceof window.DOMElementHandler&&_._OnHTMLLayersChanged();return this._UpdateHTMLElementsZOrder(),{"addedCanvases":l,"transferables":c}}_UpdateHTMLLayerDOMProperties(s){for(let e=0,t=Math.min(this._canvasLayers.length,s.length);e<t;++e){const{htmlWrap:r,lastHtmlLayerDomState:i}=this._canvasLayers[e],n=s[e],a=n["isVisible"],o=n["opacity"],l=n["isInteractive"];a!==i.isVisible&&(r.style.display=a?"":"none",i.isVisible=a),o!==i.opacity&&(r.style.opacity=1===o?"":String(o),i.opacity=o),l!==i.isInteractive&&(r.style.pointerEvents=l?"":"none",l?r.setAttribute("interactive",""):r.removeAttribute("interactive"),i.isInteractive=l)}}_OnCleanUpHTMLLayers(){for(const e of this._pendingRemoveElements)e.remove();this._pendingRemoveElements.length=0}_UpdateHTMLElementsZOrder(){this._pendingUpdateHTMLZOrder||(this._pendingUpdateHTMLZOrder=!0,this._AddRAFCallback(this._updateHTMLZOrderRAFCallback))}_DoUpdateHTMLElementsZOrder(){this._RemoveRAFCallback(this._updateHTMLZOrderRAFCallback),this._pendingUpdateHTMLZOrder=!1;let e=[];for(const n of this._domHandlers)if(n instanceof window.DOMElementHandler){const a=n._GetAllElementStatesForZOrderUpdate();a&&e.push(...a)}e.sort((e,t)=>{const s=e.GetActualHTMLIndex(),r=t.GetActualHTMLIndex();if(s!==r)return s-r;const i=e.GetHTMLZIndex(),n=t.GetHTMLZIndex();return i-n});let t=0,s=0,r=0,i=e.length;for(;r<i;++r){const o=e[r];o.GetActualHTMLIndex()!==t&&(this._DoUpdateHTMLElementsZOrderOnHTMLLayer(t,e.slice(s,r)),t=o.GetActualHTMLIndex(),s=r)}s<r&&this._DoUpdateHTMLElementsZOrderOnHTMLLayer(t,e.slice(s,r))}_DoUpdateHTMLElementsZOrderOnHTMLLayer(e,t){if(!(t.length<=1||e>=this._canvasLayers.length)){const r=t.map(e=>e.GetElement()),s=new Set(r),i=this.GetHTMLWrapElement(e),n=Array.from(i.children).filter(e=>s.has(e));for(let e=0,t=0,s=r.length;e<s;++e){const a=r[e],o=n[t];a===o?++t:i.insertBefore(a,o)}}}_GetLocalRuntime(){if(this._useWorker)throw new Error("not available in worker mode");return this._localRuntime}PostToRuntimeComponent(e,t,s,r,i){this._messageChannelPort.postMessage({"type":"event","component":e,"handler":t,"dispatchOpts":r||null,"data":s,"responseId":null},i)}PostToRuntimeComponentAsync(e,t,s,r,i){const n=h++,a=new Promise((e,t)=>{l.set(n,{resolve:e,reject:t})});return this._messageChannelPort.postMessage({"type":"event","component":e,"handler":t,"dispatchOpts":r||null,"data":s,"responseId":n},i),a}["_OnMessageFromRuntime"](e){const t=e["type"];if("event"===t)return this._OnEventFromRuntime(e);if("result"===t)this._OnResultFromRuntime(e);else if("runtime-ready"===t)this._OnRuntimeReady();else if("alert-error"===t)this._RemoveLoadingMessage(),alert(e["message"]);else{if("creating-runtime"!==t)throw new Error(`unknown message '${t}'`);this._OnBeforeCreateRuntime()}}_OnEventFromRuntime(e){const t=e["component"],s=e["handler"],r=e["data"],i=e["responseId"],n=k.get(t);if(n){const a=n.get(s);if(a){let e=null;try{e=a(r)}catch(e){return console.error(`Exception in '${t}' handler '${s}':`,e),void(null!==i&&this._PostResultToRuntime(i,!1,""+e))}if(null===i)return e;e&&e.then?e.then(e=>this._PostResultToRuntime(i,!0,e)).catch(e=>{console.error(`Rejection from '${t}' handler '${s}':`,e),this._PostResultToRuntime(i,!1,""+e)}):this._PostResultToRuntime(i,!0,e)}else console.warn(`[DOM] No handler '${s}' for component '${t}'`)}else console.warn(`[DOM] No event handlers for component '${t}'`)}_PostResultToRuntime(e,t,s){let r;s&&s["transferables"]&&(r=s["transferables"]),this._messageChannelPort.postMessage({"type":"result","responseId":e,"isOk":t,"result":s},r)}_OnResultFromRuntime(e){const t=e["responseId"],s=e["isOk"],r=e["result"],i=l.get(t);s?i.resolve(r):i.reject(r),l.delete(t)}AddRuntimeComponentMessageHandler(e,t,s){let r=k.get(e);if(r||(r=new Map,k.set(e,r)),r.has(t))throw new Error(`[DOM] Component '${e}' already has handler '${t}'`);r.set(t,s)}static AddDOMHandlerClass(e){if(j.includes(e))throw new Error("DOM handler already added");j.push(e)}_FindRuntimeDOMHandler(){for(const e of this._domHandlers)if("runtime"===e.GetComponentID())return void(this._runtimeDomHandler=e);throw new Error("cannot find runtime DOM handler")}_OnMessageFromDebugger(e){this.PostToRuntimeComponent("debugger","message",e)}_OnRuntimeReady(){for(const e of this._domHandlers)e.Attach()}static IsDocumentFullscreen(){return!!(document["fullscreenElement"]||document["webkitFullscreenElement"]||document["mozFullScreenElement"]||t)}static _SetWrapperIsFullscreenFlag(e){t=!!e}async GetRemotePreviewStatusInfo(){return this.PostToRuntimeComponentAsync("runtime","get-remote-preview-status-info")}_AddRAFCallback(e){this._rafCallbacks.add(e),this._RequestAnimationFrame()}_RemoveRAFCallback(e){this._rafCallbacks.delete(e),0===this._rafCallbacks.size&&this._CancelAnimationFrame()}_RequestAnimationFrame(){-1===this._rafId&&0<this._rafCallbacks.size&&(this._rafId=requestAnimationFrame(this._rafFunc))}_CancelAnimationFrame(){-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1)}_OnRAFCallback(){this._rafId=-1;for(const e of this._rafCallbacks)e();this._RequestAnimationFrame()}TryPlayMedia(e){this._runtimeDomHandler.TryPlayMedia(e)}RemovePendingPlay(e){this._runtimeDomHandler.RemovePendingPlay(e)}_PlayPendingMedia(){this._runtimeDomHandler._PlayPendingMedia()}SetSilent(e){this._runtimeDomHandler.SetSilent(e)}IsAudioFormatSupported(e){return!!f[e]}async _WasmDecodeWebMOpus(e){const t=await this.PostToRuntimeComponentAsync("runtime","opus-decode",{"arrayBuffer":e},null,[e]);return new Float32Array(t)}SetIsExportingToVideo(e){this._isExportingToVideo=!0,this._exportToVideoDuration=e}IsExportingToVideo(){return this._isExportingToVideo}GetExportToVideoDuration(){return this._exportToVideoDuration}IsAbsoluteURL(e){return/^(?:[a-z\-]+:)?\/\//.test(e)||"data:"===e.substr(0,5)||"blob:"===e.substr(0,5)}IsRelativeURL(e){return!this.IsAbsoluteURL(e)}async _MaybeGetPlatformSpecificScriptURL(t){if("cordova"===this._exportType&&(t.startsWith("file:")||this._isFileProtocol&&this.IsRelativeURL(t))){let e=t;e.startsWith(this._runtimeBaseUrl)&&(e=e.substr(this._runtimeBaseUrl.length));const s=await this.CordovaFetchLocalFileAsArrayBuffer(e),r=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(r)}if("playable-ad-single-file"!==this._exportType)return t;if(this._localFileStrings.hasOwnProperty(t))return{isStringSrc:!0,str:this._localFileStrings[t]};if(this._localFileBlobs.hasOwnProperty(t))return URL.createObjectURL(this._localFileBlobs[t]);throw new Error("missing script: "+t)}async _OnCordovaFetchLocalFile(e){const t=e["filename"];switch(e["as"]){case"text":return this.CordovaFetchLocalFileAsText(t);case"buffer":return this.CordovaFetchLocalFileAsArrayBuffer(t);default:throw new Error("unsupported type")}}CordovaFetchLocalFile(e){const r=window["cordova"]["file"]["applicationDirectory"]+"www/"+e;return new Promise((t,s)=>{window["resolveLocalFileSystemURL"](r,e=>{e["file"](t,s)},s)})}async CordovaFetchLocalFileAsText(e){const t=await this.CordovaFetchLocalFile(e);return BlobToString(t)}_CordovaMaybeStartNextArrayBufferRead(){if(g.length&&!(r>=i)){r++;const e=g.shift();this._CordovaDoFetchLocalFileAsAsArrayBuffer(e.filename,e.successCallback,e.errorCallback)}}CordovaFetchLocalFileAsArrayBuffer(e){return new Promise((t,s)=>{g.push({filename:e,successCallback:e=>{r--,this._CordovaMaybeStartNextArrayBufferRead(),t(e)},errorCallback:e=>{r--,this._CordovaMaybeStartNextArrayBufferRead(),s(e)}}),this._CordovaMaybeStartNextArrayBufferRead()})}async _CordovaDoFetchLocalFileAsAsArrayBuffer(e,t,s){try{const r=await this.CordovaFetchLocalFile(e),i=await BlobToArrayBuffer(r);t(i)}catch(e){s(e)}}["_PlayableAdFetchBlob"](e){if(this._localFileBlobs.hasOwnProperty(e))return this._localFileBlobs[e];throw new Error("missing file: "+e)}_GetPermissionAPI(){const e=window["cordova"]&&window["cordova"]["plugins"]&&window["cordova"]["plugins"]["permissions"];if("object"!=typeof e)throw new Error("Permission API is not loaded");return e}_MapPermissionID(e,t){const s=e[t];if("string"!=typeof s)throw new Error("Invalid permission name");return s}_HasPermission(s){const r=this._GetPermissionAPI();return new Promise((t,e)=>r["checkPermission"](this._MapPermissionID(r,s),e=>t(!!e["hasPermission"]),e))}_RequestPermission(s){const r=this._GetPermissionAPI();return new Promise((t,e)=>r["requestPermission"](this._MapPermissionID(r,s),e=>t(!!e["hasPermission"]),e))}async RequestPermissions(e){if("cordova"===this.GetExportType()&&!this.IsiOSCordova())for(const t of e){const s=await this._HasPermission(t);if(!s){const r=await this._RequestPermission(t);if(!1===r)return!1}}return!0}async RequirePermissions(...e){if(!1===await this.RequestPermissions(e))throw new Error("Permission not granted")}_OnWrapperMessage(e,t){if("entered-fullscreen"===e)Q._SetWrapperIsFullscreenFlag(!0),this._runtimeDomHandler._OnFullscreenChange();else if("exited-fullscreen"===e)Q._SetWrapperIsFullscreenFlag(!1),this._runtimeDomHandler._OnFullscreenChange();else if("object"==typeof e){const s=e["type"];"directory-handles"===s?this._directoryHandles=t:"wrapper-init-response"===s?(this._wrapperInitResolve(e),this._wrapperInitResolve=null):"extension-message"===s?this.PostToRuntimeComponent("runtime","wrapper-extension-message",e):console.warn("Unknown wrapper message: ",e)}else console.warn("Unknown wrapper message: ",e)}_OnSendWrapperExtensionMessage(e){this._SendWrapperMessage({"type":"extension-message","componentId":e["componentId"],"messageId":e["messageId"],"params":e["params"]||[],"asyncId":e["asyncId"]})}_SendWrapperMessage(e){this.IsAnyWebView2Wrapper()?window["chrome"]["webview"]["postMessage"](JSON.stringify(e)):"macos-wkwebview"===this._exportType?window["webkit"]["messageHandlers"]["C3Wrapper"]["postMessage"](JSON.stringify(e)):"linux-cef"===this._exportType&&window["c3_linux_cef_sendmessage"](JSON.stringify(e))}_SetupDesktopWrapperPolyfills(){window.moveTo=(e,t)=>{this._SendWrapperMessage({"type":"set-window-position","windowX":Math.ceil(e),"windowY":Math.ceil(t)})},window.resizeTo=(e,t)=>{this._SendWrapperMessage({"type":"set-window-size","windowWidth":Math.ceil(e),"windowHeight":Math.ceil(t)})}}_InitWrapper(){return new Promise(e=>{this._wrapperInitResolve=e,this._SendWrapperMessage({"type":"wrapper-init"})})}_GetDirectoryHandles(){return this._directoryHandles}async _ConvertDataUrisToBlobs(){const e=[];for(const[t,s]of Object.entries(this._localFileBlobs))e.push(this._ConvertDataUriToBlobs(t,s));await Promise.all(e)}async _ConvertDataUriToBlobs(t,s){if("object"==typeof s)this._localFileBlobs[t]=new Blob([s["str"]],{"type":s["type"]}),this._localFileStrings[t]=s["str"];else{let e=await this._FetchDataUri(s);e=e||this._DataURIToBinaryBlobSync(s),this._localFileBlobs[t]=e}}async _FetchDataUri(e){try{const t=await fetch(e);return await t.blob()}catch(e){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.",e),null}}_DataURIToBinaryBlobSync(e){const t=this._ParseDataURI(e);return this._BinaryStringToBlob(t.data,t.mime_type)}_ParseDataURI(e){const t=e.indexOf(",");if(t<0)throw new URIError("expected comma in data: uri");const s=e.substring(5,t),r=e.substring(t+1),i=s.split(";"),n=i[0]||"",a=i[1],o=i[2];let l;return{mime_type:n,data:l=("base64"===a||"base64"===o?atob:decodeURIComponent)(r)}}_BinaryStringToBlob(e,t){let s=e.length,r=s>>2,i=new Uint8Array(s),n=new Uint32Array(i.buffer,0,r),a,o;for(a=0,o=0;a<r;++a)n[a]=e.charCodeAt(o++)|e.charCodeAt(o++)<<8|e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<24;let l=3&s;for(;l--;)i[o]=e.charCodeAt(o),++o;return new Blob([i],{"type":t})}}}

// workers/runtimeDomEvents.js
"use strict";{const a=self.RuntimeInterface;function IsCompatibilityMouseEvent(e){return e["sourceCapabilities"]&&e["sourceCapabilities"]["firesTouchEvents"]||e["originalEvent"]&&e["originalEvent"]["sourceCapabilities"]&&e["originalEvent"]["sourceCapabilities"]["firesTouchEvents"]}const b=new Map([["OSLeft","MetaLeft"],["OSRight","MetaRight"]]),c={"dispatchRuntimeEvent":!0,"dispatchUserScriptEvent":!0},d={"dispatchUserScriptEvent":!0},e={"dispatchRuntimeEvent":!0};function AddStyleSheet(i){return new Promise((e,t)=>{const n=document.createElement("link");n.onload=()=>e(n),n.onerror=e=>t(e),n.rel="stylesheet",n.href=i,document.head.appendChild(n)})}function FetchImage(i){return new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=i})}async function BlobToImage(e){const t=URL.createObjectURL(e);try{return await FetchImage(t)}finally{URL.revokeObjectURL(t)}}function BlobToString(i){return new Promise((t,n)=>{let e=new FileReader;e.onload=e=>t(e.target.result),e.onerror=e=>n(e),e.readAsText(i)})}function IsInContentEditable(e){do{if(e.parentNode&&e.hasAttribute("contenteditable"))return!0}while(e=e.parentNode);return!1}const f=new Set(["input","textarea","datalist","select"]);function IsKeyboardInputElement(e){return f.has(e.tagName.toLowerCase())||IsInContentEditable(e)}const g=new Set(["canvas","body","html"]);function PreventDefaultOnCanvasOrDoc(e){if(e.target.tagName){const t=e.target.tagName.toLowerCase();g.has(t)&&e.preventDefault()}}function PreventDefaultOnHTMLWrap(e){e.target.tagName&&e.target.classList.contains("c3htmlwrap")&&e.preventDefault()}function BlockWheelZoom(e){(e.metaKey||e.ctrlKey)&&e.preventDefault()}self["C3_GetSvgImageSize"]=async function(e){const t=await BlobToImage(e);if(0<t.width&&0<t.height)return[t.width,t.height];{t.style.position="absolute",t.style.left="0px",t.style.top="0px",t.style.visibility="hidden",document.body.appendChild(t);const n=t.getBoundingClientRect();return document.body.removeChild(t),[n.width,n.height]}};let t=!(self["C3_RasterSvgImageBlob"]=async function(e,t,n,i,o){const s=await BlobToImage(e),a=document.createElement("canvas"),r=(a.width=i,a.height=o,a.getContext("2d"));return r.drawImage(s,0,0,t,n),a});function ParentHasFocus(){try{return window.parent&&window.parent.document.hasFocus()}catch(e){return!1}}document.addEventListener("pause",()=>t=!0),document.addEventListener("resume",()=>t=!1);const i="runtime",j=class extends self.DOMHandler{constructor(e){super(e,i),this._enableWindowResizeEvent=!1,this._simulatedResizeTimerId=-1,this._targetOrientation="any",this._attachedDeviceOrientationEvent=!1,this._attachedDeviceMotionEvent=!1,this._pageVisibilityIsHidden=!1,this._screenReaderTextWrap=document.createElement("div"),this._screenReaderTextWrap.className="c3-screen-reader-text",this._screenReaderTextWrap.setAttribute("aria-live","polite"),document.body.appendChild(this._screenReaderTextWrap),this._debugHighlightElem=null,this._isExportToVideo=!1,this._exportVideoProgressMessage="",this._exportVideoUpdateTimerId=-1,this._enableAndroidVKDetection=!1,this._lastWindowWidth=e._GetWindowInnerWidth(),this._lastWindowHeight=e._GetWindowInnerHeight(),this._virtualKeyboardHeight=0,this._vkTranslateYOffset=0,e.AddRuntimeComponentMessageHandler("runtime","invoke-download",e=>this._OnInvokeDownload(e)),e.AddRuntimeComponentMessageHandler("runtime","load-webfonts",e=>this._OnLoadWebFonts(e)),e.AddRuntimeComponentMessageHandler("runtime","raster-svg-image",e=>this._OnRasterSvgImage(e)),e.AddRuntimeComponentMessageHandler("runtime","get-svg-image-size",e=>this._OnGetSvgImageSize(e)),e.AddRuntimeComponentMessageHandler("runtime","set-target-orientation",e=>this._OnSetTargetOrientation(e)),e.AddRuntimeComponentMessageHandler("runtime","register-sw",()=>this._OnRegisterSW()),e.AddRuntimeComponentMessageHandler("runtime","post-to-debugger",e=>this._OnPostToDebugger(e)),e.AddRuntimeComponentMessageHandler("runtime","go-to-script",e=>this._OnPostToDebugger(e)),e.AddRuntimeComponentMessageHandler("runtime","before-start-ticking",()=>this._OnBeforeStartTicking()),e.AddRuntimeComponentMessageHandler("runtime","debug-highlight",e=>this._OnDebugHighlight(e)),e.AddRuntimeComponentMessageHandler("runtime","enable-device-orientation",()=>this._AttachDeviceOrientationEvent()),e.AddRuntimeComponentMessageHandler("runtime","enable-device-motion",()=>this._AttachDeviceMotionEvent()),e.AddRuntimeComponentMessageHandler("runtime","add-stylesheet",e=>this._OnAddStylesheet(e)),e.AddRuntimeComponentMessageHandler("runtime","script-create-worker",e=>this._OnScriptCreateWorker(e)),e.AddRuntimeComponentMessageHandler("runtime","alert",e=>this._OnAlert(e)),e.AddRuntimeComponentMessageHandler("runtime","screen-reader-text",e=>this._OnScreenReaderTextEvent(e)),e.AddRuntimeComponentMessageHandler("runtime","hide-cordova-splash",()=>this._OnHideCordovaSplash()),e.AddRuntimeComponentMessageHandler("runtime","set-exporting-to-video",e=>this._SetExportingToVideo(e)),e.AddRuntimeComponentMessageHandler("runtime","export-to-video-progress",e=>this._OnExportVideoProgress(e)),e.AddRuntimeComponentMessageHandler("runtime","exported-to-video",e=>this._OnExportedToVideo(e)),e.AddRuntimeComponentMessageHandler("runtime","exported-to-image-sequence",e=>this._OnExportedToImageSequence(e));const o=new Set(["input","textarea","datalist"]);if(window.addEventListener("contextmenu",e=>{const t=e.target,n=t.tagName.toLowerCase();o.has(n)||IsInContentEditable(t)||e.preventDefault()}),window.addEventListener("selectstart",PreventDefaultOnCanvasOrDoc),window.addEventListener("gesturehold",PreventDefaultOnCanvasOrDoc),window.addEventListener("touchstart",PreventDefaultOnCanvasOrDoc,{"passive":!1}),window.addEventListener("pointerdown",PreventDefaultOnCanvasOrDoc,{"passive":!1}),this._mousePointerLastButtons=0,window.addEventListener("mousedown",e=>{1===e.button&&e.preventDefault()}),window.addEventListener("mousewheel",BlockWheelZoom,{"passive":!1}),window.addEventListener("wheel",BlockWheelZoom,{"passive":!1}),window.addEventListener("resize",()=>this._OnWindowResize()),window.addEventListener("fullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("webkitfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("mozfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("fullscreenerror",e=>this._OnFullscreenError(e)),window.addEventListener("webkitfullscreenerror",e=>this._OnFullscreenError(e)),window.addEventListener("mozfullscreenerror",e=>this._OnFullscreenError(e)),e.IsiOSWebView()){let t=1/0;window["visualViewport"].addEventListener("resize",()=>{const e=window["visualViewport"].height;e>t&&(document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0),t=e}),document.documentElement.setAttribute("ioswebview","")}this._mediaPendingPlay=new Set,this._mediaRemovedPendingPlay=new WeakSet,this._isSilent=!1}_AddDefaultCanvasEventHandlers(e){e.addEventListener("selectstart",PreventDefaultOnCanvasOrDoc),e.addEventListener("gesturehold",PreventDefaultOnCanvasOrDoc),e.addEventListener("pointerdown",PreventDefaultOnCanvasOrDoc)}_AddDefaultHTMLWrapEventHandlers(e){e.addEventListener("selectstart",PreventDefaultOnHTMLWrap),e.addEventListener("gesturehold",PreventDefaultOnHTMLWrap),e.addEventListener("touchstart",PreventDefaultOnHTMLWrap)}_OnBeforeStartTicking(){return self.setTimeout(()=>{this._enableAndroidVKDetection=!0},1e3),"cordova"===this._iRuntime.GetExportType()?(document.addEventListener("pause",()=>this._OnVisibilityChange(!0)),document.addEventListener("resume",()=>this._OnVisibilityChange(!1))):document.addEventListener("visibilitychange",()=>this._OnVisibilityChange("hidden"===document.visibilityState)),this._pageVisibilityIsHidden=!("hidden"!==document.visibilityState&&!t),{"isSuspended":this._pageVisibilityIsHidden}}Attach(){window.addEventListener("focus",()=>this._PostRuntimeEvent("window-focus")),window.addEventListener("blur",()=>{this._PostRuntimeEvent("window-blur",{"parentHasFocus":ParentHasFocus()}),this._mousePointerLastButtons=0}),window.addEventListener("focusin",e=>{IsKeyboardInputElement(e.target)&&this._PostRuntimeEvent("keyboard-blur")}),window.addEventListener("keydown",e=>this._OnKeyEvent("keydown",e)),window.addEventListener("keyup",e=>this._OnKeyEvent("keyup",e)),window.addEventListener("mousedown",e=>this._OnMouseEvent("mousedown",e,d)),window.addEventListener("mousemove",e=>this._OnMouseEvent("mousemove",e,d)),window.addEventListener("mouseup",e=>this._OnMouseEvent("mouseup",e,d)),window.addEventListener("dblclick",e=>this._OnMouseEvent("dblclick",e,c)),window.addEventListener("wheel",e=>this._OnMouseWheelEvent("wheel",e,c)),window.addEventListener("pointerdown",e=>{this._HandlePointerDownFocus(e),this._OnPointerEvent("pointerdown",e)}),this._iRuntime.UsesWorker()&&void 0!==window["onpointerrawupdate"]&&self===self.top?window.addEventListener("pointerrawupdate",e=>this._OnPointerRawUpdate(e)):window.addEventListener("pointermove",e=>this._OnPointerEvent("pointermove",e)),window.addEventListener("pointerup",e=>this._OnPointerEvent("pointerup",e)),window.addEventListener("pointercancel",e=>this._OnPointerEvent("pointercancel",e));const e=()=>this._PlayPendingMedia();window.addEventListener("pointerup",e,!0),window.addEventListener("touchend",e,!0),window.addEventListener("click",e,!0),window.addEventListener("keydown",e,!0),window.addEventListener("gamepadconnected",e,!0),this._iRuntime.IsAndroid()&&!this._iRuntime.IsAndroidWebView()&&navigator["virtualKeyboard"]&&(navigator["virtualKeyboard"]["overlaysContent"]=!0,navigator["virtualKeyboard"].addEventListener("geometrychange",()=>{this._OnAndroidVirtualKeyboardChange(this._GetWindowInnerHeight(),navigator["virtualKeyboard"]["boundingRect"]["height"])})),this._iRuntime.IsiOSWebView()&&(document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0)}_OnAndroidVirtualKeyboardChange(t,n){if(document.body.style.position="",document.body.style.overflow="",document.body.style.transform="",(this._vkTranslateYOffset=0)<n){const i=document.activeElement;if(i){const o=i.getBoundingClientRect(),s=(o.top+o.bottom)/2,a=(t-n)/2;let e=s-a;0<(e=(e=e>n?n:e)<0?0:e)&&(document.body.style.position="absolute",document.body.style.overflow="visible",document.body.style.transform=`translateY(${-e}px)`,this._vkTranslateYOffset=e)}}}_PostRuntimeEvent(t,n){this.PostToRuntime(t,n||null,e)}_GetWindowInnerWidth(){return this._iRuntime._GetWindowInnerWidth()}_GetWindowInnerHeight(){return this._iRuntime._GetWindowInnerHeight()}_EnableWindowResizeEvent(){this._enableWindowResizeEvent=!0,this._lastWindowWidth=this._iRuntime._GetWindowInnerWidth(),this._lastWindowHeight=this._iRuntime._GetWindowInnerHeight()}_OnWindowResize(){if(!this._isExportToVideo&&this._enableWindowResizeEvent){const e=this._GetWindowInnerWidth(),t=this._GetWindowInnerHeight();if(this._iRuntime.IsAndroidWebView()){if(this._enableAndroidVKDetection){const n=this._iRuntime.CanDoAndroidVirtualKeyboardDetection();if(n&&this._lastWindowWidth===e&&t<this._lastWindowHeight)return this._virtualKeyboardHeight=this._lastWindowHeight-t,void this._OnAndroidVirtualKeyboardChange(this._lastWindowHeight,this._virtualKeyboardHeight);0<this._virtualKeyboardHeight&&(this._virtualKeyboardHeight=0,this._OnAndroidVirtualKeyboardChange(t,this._virtualKeyboardHeight))}this._lastWindowWidth=e,this._lastWindowHeight=t}this.PostToRuntime("window-resize",{"innerWidth":e,"innerHeight":t,"devicePixelRatio":window.devicePixelRatio,"isFullscreen":a.IsDocumentFullscreen(),"cssDisplayMode":this._iRuntime.GetCssDisplayMode()}),this._iRuntime.IsiOSWebView()&&(-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._OnSimulatedResize(e,t,0))}}_ScheduleSimulatedResize(e,t,n){-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._simulatedResizeTimerId=setTimeout(()=>this._OnSimulatedResize(e,t,n),48)}_OnSimulatedResize(e,t,n){const i=this._GetWindowInnerWidth(),o=this._GetWindowInnerHeight();this._simulatedResizeTimerId=-1,i!=e||o!=t?this.PostToRuntime("window-resize",{"innerWidth":i,"innerHeight":o,"devicePixelRatio":window.devicePixelRatio,"isFullscreen":a.IsDocumentFullscreen(),"cssDisplayMode":this._iRuntime.GetCssDisplayMode()}):n<10&&this._ScheduleSimulatedResize(i,o,n+1)}_OnSetTargetOrientation(e){this._targetOrientation=e["targetOrientation"]}_TrySetTargetOrientation(){const t=this._targetOrientation;if(screen["orientation"]&&screen["orientation"]["lock"])screen["orientation"]["lock"](t).catch(e=>console.warn("[Construct] Failed to lock orientation: ",e));else try{let e=!1;screen["lockOrientation"]?e=screen["lockOrientation"](t):screen["webkitLockOrientation"]?e=screen["webkitLockOrientation"](t):screen["mozLockOrientation"]?e=screen["mozLockOrientation"](t):screen["msLockOrientation"]&&(e=screen["msLockOrientation"](t)),e||console.warn("[Construct] Failed to lock orientation")}catch(e){console.warn("[Construct] Failed to lock orientation: ",e)}}_OnFullscreenChange(){if(!this._isExportToVideo){const e=a.IsDocumentFullscreen();e&&"any"!==this._targetOrientation&&this._TrySetTargetOrientation(),this.PostToRuntime("fullscreenchange",{"isFullscreen":e,"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}}_OnFullscreenError(e){console.warn("[Construct] Fullscreen request failed: ",e),this.PostToRuntime("fullscreenerror",{"isFullscreen":a.IsDocumentFullscreen(),"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnVisibilityChange(e){if(this._pageVisibilityIsHidden!==e&&((this._pageVisibilityIsHidden=e)?this._iRuntime._CancelAnimationFrame():this._iRuntime._RequestAnimationFrame(),this.PostToRuntime("visibilitychange",{"hidden":e}),!e)&&this._iRuntime.IsiOSWebView()){const t=()=>{document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0};setTimeout(t,50),setTimeout(t,100),setTimeout(t,250),setTimeout(t,500)}}_OnKeyEvent(e,t){if(void 0!==t.key&&("Backspace"===t.key&&PreventDefaultOnCanvasOrDoc(t),"nwjs"===this._iRuntime.GetExportType()&&"u"===t.key&&(t.ctrlKey||t.metaKey)&&t.preventDefault(),!this._isExportToVideo)){const n=b.get(t.code)||t.code;this._PostToRuntimeMaybeSync(e,{"code":n,"key":t.key,"which":t.which,"repeat":t.repeat,"altKey":t.altKey,"ctrlKey":t.ctrlKey,"metaKey":t.metaKey,"shiftKey":t.shiftKey,"timeStamp":t.timeStamp},c)}}_OnMouseWheelEvent(e,t,n){this._isExportToVideo||this.PostToRuntime(e,{"clientX":t.clientX,"clientY":t.clientY+this._vkTranslateYOffset,"pageX":t.pageX,"pageY":t.pageY+this._vkTranslateYOffset,"deltaX":t.deltaX,"deltaY":t.deltaY,"deltaZ":t.deltaZ,"deltaMode":t.deltaMode,"timeStamp":t.timeStamp},n)}_OnMouseEvent(e,t,n){this._isExportToVideo||IsCompatibilityMouseEvent(t)||this._PostToRuntimeMaybeSync(e,{"button":t.button,"buttons":t.buttons,"clientX":t.clientX,"clientY":t.clientY+this._vkTranslateYOffset,"pageX":t.pageX,"pageY":t.pageY+this._vkTranslateYOffset,"movementX":t.movementX||0,"movementY":t.movementY||0,"timeStamp":t.timeStamp},n)}_OnPointerEvent(t,n){if(!this._isExportToVideo){let e=0;"mouse"===n.pointerType&&(e=this._mousePointerLastButtons),this._PostToRuntimeMaybeSync(t,{"pointerId":n.pointerId,"pointerType":n.pointerType,"button":n.button,"buttons":n.buttons,"lastButtons":e,"clientX":n.clientX,"clientY":n.clientY+this._vkTranslateYOffset,"pageX":n.pageX,"pageY":n.pageY+this._vkTranslateYOffset,"movementX":n.movementX||0,"movementY":n.movementY||0,"width":n.width||0,"height":n.height||0,"pressure":n.pressure||0,"tangentialPressure":n["tangentialPressure"]||0,"tiltX":n.tiltX||0,"tiltY":n.tiltY||0,"twist":n["twist"]||0,"timeStamp":n.timeStamp},c),"mouse"===n.pointerType&&(this._mousePointerLastButtons=n.buttons)}}_OnPointerRawUpdate(e){this._OnPointerEvent("pointermove",e)}_OnTouchEvent(n,i){if(!this._isExportToVideo)for(let e=0,t=i.changedTouches.length;e<t;++e){const o=i.changedTouches[e];this._PostToRuntimeMaybeSync(n,{"pointerId":o.identifier,"pointerType":"touch","button":0,"buttons":0,"lastButtons":0,"clientX":o.clientX,"clientY":o.clientY+this._vkTranslateYOffset,"pageX":o.pageX,"pageY":o.pageY+this._vkTranslateYOffset,"movementX":i.movementX||0,"movementY":i.movementY||0,"width":2*(o["radiusX"]||o["webkitRadiusX"]||0),"height":2*(o["radiusY"]||o["webkitRadiusY"]||0),"pressure":o["force"]||o["webkitForce"]||0,"tangentialPressure":0,"tiltX":0,"tiltY":0,"twist":o["rotationAngle"]||0,"timeStamp":i.timeStamp},c)}}_HandlePointerDownFocus(e){window!==window.top&&window.focus(),this._IsElementCanvasOrDocument(e.target)&&document.activeElement&&!this._IsElementCanvasOrDocument(document.activeElement)&&document.activeElement.blur()}_IsElementCanvasOrDocument(e){return!e||e===document||e===window||e===document.body||"canvas"===e.tagName.toLowerCase()}_AttachDeviceOrientationEvent(){this._attachedDeviceOrientationEvent||(this._attachedDeviceOrientationEvent=!0,window.addEventListener("deviceorientation",e=>this._OnDeviceOrientation(e)),window.addEventListener("deviceorientationabsolute",e=>this._OnDeviceOrientationAbsolute(e)))}_AttachDeviceMotionEvent(){this._attachedDeviceMotionEvent||(this._attachedDeviceMotionEvent=!0,window.addEventListener("devicemotion",e=>this._OnDeviceMotion(e)))}_OnDeviceOrientation(e){this._isExportToVideo||this.PostToRuntime("deviceorientation",{"absolute":!!e["absolute"],"alpha":e["alpha"]||0,"beta":e["beta"]||0,"gamma":e["gamma"]||0,"timeStamp":e.timeStamp,"webkitCompassHeading":e["webkitCompassHeading"],"webkitCompassAccuracy":e["webkitCompassAccuracy"]},c)}_OnDeviceOrientationAbsolute(e){this._isExportToVideo||this.PostToRuntime("deviceorientationabsolute",{"absolute":!!e["absolute"],"alpha":e["alpha"]||0,"beta":e["beta"]||0,"gamma":e["gamma"]||0,"timeStamp":e.timeStamp},c)}_OnDeviceMotion(i){if(!this._isExportToVideo){let e=null;const o=i["acceleration"];o&&(e={"x":o["x"]||0,"y":o["y"]||0,"z":o["z"]||0});let t=null;const s=i["accelerationIncludingGravity"];s&&(t={"x":s["x"]||0,"y":s["y"]||0,"z":s["z"]||0});let n=null;const a=i["rotationRate"];a&&(n={"alpha":a["alpha"]||0,"beta":a["beta"]||0,"gamma":a["gamma"]||0}),this.PostToRuntime("devicemotion",{"acceleration":e,"accelerationIncludingGravity":t,"rotationRate":n,"interval":i["interval"],"timeStamp":i.timeStamp},c)}}_OnInvokeDownload(e){const t=e["url"],n=e["filename"],i=document.createElement("a"),o=document.body;i.textContent=n,i.href=t,i.download=n,o.appendChild(i),i.click(),o.removeChild(i)}async _OnLoadWebFonts(e){const t=e["webfonts"];await Promise.all(t.map(async e=>{const t=new FontFace(e.name,`url('${e.url}')`);document.fonts.add(t),await t.load()}))}async _OnRasterSvgImage(e){const t=e["blob"],n=e["imageWidth"],i=e["imageHeight"],o=e["surfaceWidth"],s=e["surfaceHeight"],a=e["imageBitmapOpts"],r=await self["C3_RasterSvgImageBlob"](t,n,i,o,s);let d;return{"imageBitmap":d=a?await createImageBitmap(r,a):await createImageBitmap(r),"transferables":[d]}}async _OnGetSvgImageSize(e){return self["C3_GetSvgImageSize"](e["blob"])}async _OnAddStylesheet(e){await AddStyleSheet(e["url"])}_PlayPendingMedia(){const e=[...this._mediaPendingPlay];if(this._mediaPendingPlay.clear(),!this._isSilent)for(const t of e){const n=t.play();n&&n.catch(e=>{this._mediaRemovedPendingPlay.has(t)||this._mediaPendingPlay.add(t)})}}TryPlayMedia(t){if("function"!=typeof t.play)throw new Error("missing play function");this._mediaRemovedPendingPlay.delete(t);let e;try{e=t.play()}catch(e){return void this._mediaPendingPlay.add(t)}e&&e.catch(e=>{this._mediaRemovedPendingPlay.has(t)||this._mediaPendingPlay.add(t)})}RemovePendingPlay(e){this._mediaPendingPlay.delete(e),this._mediaRemovedPendingPlay.add(e)}SetSilent(e){this._isSilent=!!e}_OnHideCordovaSplash(){navigator["splashscreen"]&&navigator["splashscreen"]["hide"]&&navigator["splashscreen"]["hide"]()}_OnDebugHighlight(e){const t=e["show"];if(t){this._debugHighlightElem||(this._debugHighlightElem=document.createElement("div"),this._debugHighlightElem.id="inspectOutline",document.body.appendChild(this._debugHighlightElem));const n=this._debugHighlightElem;n.style.display="",n.style.left=e["left"]-1+"px",n.style.top=e["top"]-1+"px",n.style.width=e["width"]+2+"px",n.style.height=e["height"]+2+"px",n.textContent=e["name"]}else this._debugHighlightElem&&(this._debugHighlightElem.style.display="none")}_OnRegisterSW(){window["C3_RegisterSW"]&&window["C3_RegisterSW"]()}_OnPostToDebugger(e){window["c3_postToMessagePort"]&&(e["from"]="runtime",window["c3_postToMessagePort"](e))}_InvokeFunctionFromJS(e,t){return this.PostToRuntimeAsync("js-invoke-function",{"name":e,"params":t})}_OnScriptCreateWorker(e){const t=e["url"],n=e["opts"],i=e["port2"],o=new Worker(t,n);o.postMessage({"type":"construct-worker-init","port2":i},[i])}_OnAlert(e){alert(e["message"])}_OnScreenReaderTextEvent(e){const t=e["type"];if("create"===t){const n=document.createElement("p");n.id="c3-sr-"+e["id"],n.textContent=e["text"],this._screenReaderTextWrap.appendChild(n)}else if("update"===t){const i=document.getElementById("c3-sr-"+e["id"]);i?i.textContent=e["text"]:console.warn("[Construct] Missing screen reader text with id "+e["id"])}else if("release"===t){const o=document.getElementById("c3-sr-"+e["id"]);o?o.remove():console.warn("[Construct] Missing screen reader text with id "+e["id"])}else console.warn(`[Construct] Unknown screen reader text update '${t}'`)}_SetExportingToVideo(e){this._isExportToVideo=!0;const t=document.createElement("h1");t.id="exportToVideoMessage",t.textContent=e["message"],document.body.prepend(t),document.body.classList.add("exportingToVideo"),this.GetRuntimeInterface().GetMainCanvas().style.display="",this._iRuntime.SetIsExportingToVideo(e["duration"])}_OnExportVideoProgress(e){this._exportVideoProgressMessage=e["message"],-1===this._exportVideoUpdateTimerId&&(this._exportVideoUpdateTimerId=setTimeout(()=>this._DoUpdateExportVideoProgressMessage(),250))}_DoUpdateExportVideoProgressMessage(){this._exportVideoUpdateTimerId=-1;const e=document.getElementById("exportToVideoMessage");e&&(e.textContent=this._exportVideoProgressMessage)}_OnExportedToVideo(e){window.c3_postToMessagePort({"type":"exported-video","arrayBuffer":e["arrayBuffer"],"contentType":e["contentType"],"time":e["time"]})}_OnExportedToImageSequence(e){window.c3_postToMessagePort({"type":"exported-image-sequence","blobArr":e["blobArr"],"time":e["time"],"gif":e["gif"]})}};a.AddDOMHandlerClass(j)}

// workers/jobSchedulerDom.js
"use strict";{const a="dispatchworker.js",b="jobworker.js";self.JobSchedulerDOM=class{constructor(t){this._runtimeInterface=t,this._maxNumWorkers=Math.min(navigator.hardwareConcurrency||2,16),this._dispatchWorker=null,this._jobWorkers=[],this._inputPort=null,this._outputPort=null}async Init(){if(this._hasInitialised)throw new Error("already initialised");this._hasInitialised=!0;const t=this._runtimeInterface.GetScriptFolder()+a,r=(this._dispatchWorker=await this._runtimeInterface.CreateWorker(t,{name:"DispatchWorker"}),new MessageChannel);this._inputPort=r.port1,this._dispatchWorker.postMessage({"type":"_init","in-port":r.port2},[r.port2]),this._outputPort=await this._CreateJobWorker()}async _CreateJobWorker(){const t=this._jobWorkers.length,r=this._runtimeInterface.GetScriptFolder()+b,e=await this._runtimeInterface.CreateWorker(r,{name:"JobWorker"+t}),o=new MessageChannel,s=new MessageChannel;return this._dispatchWorker.postMessage({"type":"_addJobWorker","port":o.port1},[o.port1]),e.postMessage({"type":"init","number":t,"dispatch-port":o.port2,"output-port":s.port2},[o.port2,s.port2]),this._jobWorkers.push(e),s.port1}GetPortData(){return{"inputPort":this._inputPort,"outputPort":this._outputPort,"maxNumWorkers":this._maxNumWorkers}}GetPortTransferables(){return[this._inputPort,this._outputPort]}}}

// scripts/plugins/Touch/dom/domSide.js
"use strict";{const a="touch",b=class extends self.DOMHandler{constructor(e){super(e,a),this.AddRuntimeMessageHandler("request-permission",e=>this._OnRequestPermission(e))}async _OnRequestPermission(e){const t=e["type"];let s=!0;0===t?s=await this._RequestOrientationPermission():1===t&&(s=await this._RequestMotionPermission()),this.PostToRuntime("permission-result",{"type":t,"result":s})}async _RequestOrientationPermission(){if(!self["DeviceOrientationEvent"]||!self["DeviceOrientationEvent"]["requestPermission"])return!0;try{const e=await self["DeviceOrientationEvent"]["requestPermission"]();return"granted"===e}catch(e){return console.warn("[Touch] Failed to request orientation permission: ",e),!1}}async _RequestMotionPermission(){if(!self["DeviceMotionEvent"]||!self["DeviceMotionEvent"]["requestPermission"])return!0;try{const e=await self["DeviceMotionEvent"]["requestPermission"]();return"granted"===e}catch(e){return console.warn("[Touch] Failed to request motion permission: ",e),!1}}};self.RuntimeInterface.AddDOMHandlerClass(b)}

// scripts/plugins/Mouse/dom/domSide.js
"use strict";{const a="mouse",b=class extends self.DOMHandler{constructor(e){super(e,a),this.AddRuntimeMessageHandlers([["cursor",e=>this._OnChangeCursorStyle(e)],["request-pointer-lock",e=>this._OnRequestPointerLock(e)],["release-pointer-lock",()=>this._OnReleasePointerLock()]]),document.addEventListener("pointerlockchange",e=>this._OnPointerLockChange()),document.addEventListener("pointerlockerror",e=>this._OnPointerLockError())}_OnChangeCursorStyle(e){document.documentElement.style.cursor=e}_OnRequestPointerLock(e){this._iRuntime.GetMainCanvas().requestPointerLock(e)}_OnReleasePointerLock(){document.exitPointerLock()}_OnPointerLockChange(){this.PostToRuntime("pointer-lock-change",{"has-pointer-lock":!!document.pointerLockElement})}_OnPointerLockError(){this.PostToRuntime("pointer-lock-error",{"has-pointer-lock":!!document.pointerLockElement})}};self.RuntimeInterface.AddDOMHandlerClass(b)}

// scripts/plugins/Browser/dom/domSide.js
"use strict";{let t=null,n=null;function elemsForSelector(e,t){if(e){if(t)return Array.from(document.querySelectorAll(e));{const n=document.querySelector(e);return n?[n]:[]}}return[document.documentElement]}function noop(){}window.addEventListener("beforeinstallprompt",e=>(e.preventDefault(),t=e,n&&n._OnBeforeInstallPrompt(),!1));const c="browser",d=class extends self.DOMHandler{constructor(e){super(e,c),this._exportType="",this.AddRuntimeMessageHandlers([["get-initial-state",e=>this._OnGetInitialState(e)],["ready-for-sw-messages",()=>this._OnReadyForSWMessages()],["alert",e=>this._OnAlert(e)],["close",()=>this._OnClose()],["set-focus",e=>this._OnSetFocus(e)],["vibrate",e=>this._OnVibrate(e)],["lock-orientation",e=>this._OnLockOrientation(e)],["unlock-orientation",()=>this._OnUnlockOrientation()],["navigate",e=>this._OnNavigate(e)],["request-fullscreen",e=>this._OnRequestFullscreen(e)],["exit-fullscreen",()=>this._OnExitFullscreen()],["set-hash",e=>this._OnSetHash(e)],["set-document-css-style",e=>this._OnSetDocumentCSSStyle(e)],["get-document-css-style",e=>this._OnGetDocumentCSSStyle(e)],["set-window-size",e=>this._OnSetWindowSize(e)],["set-window-position",e=>this._OnSetWindowPosition(e)],["request-install",()=>this._OnRequestInstall()],["set-warn-on-close",e=>this._OnSetWarnOnClose(e)]]),window.addEventListener("online",()=>this._OnOnlineStateChanged(!0)),window.addEventListener("offline",()=>this._OnOnlineStateChanged(!1)),window.addEventListener("hashchange",()=>this._OnHashChange()),this._beforeunload_handler=e=>e.preventDefault(),document.addEventListener("backbutton",()=>this._OnCordovaBackButton())}Attach(){t?this._OnBeforeInstallPrompt():n=this,window.addEventListener("appinstalled",()=>this._OnAppInstalled())}_OnGetInitialState(e){return this._exportType=e["exportType"],{"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,"isConstructArcade":void 0!==window["is_scirra_arcade"]}}_OnReadyForSWMessages(){window["C3_RegisterSW"]&&window["OfflineClientInfo"]&&window["OfflineClientInfo"]["SetMessageCallback"](e=>this.PostToRuntime("sw-message",e["data"]))}_OnBeforeInstallPrompt(){this.PostToRuntime("install-available")}async _OnRequestInstall(){if(!t)return{"result":"unavailable"};try{t["prompt"]();const e=await t["userChoice"];return{"result":e["outcome"]}}catch(e){return console.error("[Construct] Requesting install failed: ",e),{"result":"failed"}}}_OnAppInstalled(){this.PostToRuntime("app-installed")}_OnOnlineStateChanged(e){this.PostToRuntime("online-state",{"isOnline":e})}_OnCordovaBackButton(){this.PostToRuntime("backbutton")}GetNWjsWindow(){return"nwjs"===this._exportType?nw["Window"]["get"]():null}_OnAlert(e){alert(e["message"])}_OnClose(){navigator["app"]&&navigator["app"]["exitApp"]?navigator["app"]["exitApp"]():navigator["device"]&&navigator["device"]["exitApp"]?navigator["device"]["exitApp"]():self["nw"]?self["nw"]["App"]["quit"]():window.close()}_OnSetFocus(e){const t=e["isFocus"];if("nwjs"===this._exportType){const n=this.GetNWjsWindow();t?n["focus"]():n["blur"]()}else t?window.focus():window.blur()}_OnVibrate(e){navigator["vibrate"]&&navigator["vibrate"](e["pattern"])}_OnLockOrientation(e){const t=e["orientation"];if(screen["orientation"]&&screen["orientation"]["lock"])screen["orientation"]["lock"](t).catch(e=>console.warn("[Construct] Failed to lock orientation: ",e));else try{let e=!1;screen["lockOrientation"]?e=screen["lockOrientation"](t):screen["webkitLockOrientation"]?e=screen["webkitLockOrientation"](t):screen["mozLockOrientation"]?e=screen["mozLockOrientation"](t):screen["msLockOrientation"]&&(e=screen["msLockOrientation"](t)),e||console.warn("[Construct] Failed to lock orientation")}catch(e){console.warn("[Construct] Failed to lock orientation: ",e)}}_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(e){}}_OnNavigate(e){const t=e["type"];if("back"===t)navigator["app"]&&navigator["app"]["backHistory"]?navigator["app"]["backHistory"]():window.history.back();else if("forward"===t)window.history.forward();else if("reload"===t)location.reload();else if("url"===t){const n=e["url"],o=e["target"],i=e["exportType"];self["cordova"]&&self["cordova"]["InAppBrowser"]?self["cordova"]["InAppBrowser"]["open"](n,"_system"):"preview"===i||"linux-cef"===i||this._iRuntime.IsAnyWebView2Wrapper()?window.open(n,"_blank"):this._isConstructArcade||(2===o?window.top.location=n:1===o?window.parent.location=n:window.location=n)}else if("new-window"===t){const s=e["url"],r=e["tag"];self["cordova"]&&self["cordova"]["InAppBrowser"]?self["cordova"]["InAppBrowser"]["open"](s,"_system"):window.open(s,r)}}_OnRequestFullscreen(t){if(this._iRuntime.IsAnyWebView2Wrapper()||"macos-wkwebview"===this._exportType||"linux-cef"===this._exportType)self.RuntimeInterface._SetWrapperIsFullscreenFlag(!0),this._iRuntime._SendWrapperMessage({"type":"set-fullscreen","fullscreen":!0});else{const n={"navigationUI":"auto"},o=t["navUI"],i=(1===o?n["navigationUI"]="hide":2===o&&(n["navigationUI"]="show"),document.documentElement);let e;i["requestFullscreen"]?e=i["requestFullscreen"](n):i["mozRequestFullScreen"]?e=i["mozRequestFullScreen"](n):i["msRequestFullscreen"]?e=i["msRequestFullscreen"](n):i["webkitRequestFullScreen"]&&(e=void 0!==Element["ALLOW_KEYBOARD_INPUT"]?i["webkitRequestFullScreen"](Element["ALLOW_KEYBOARD_INPUT"]):i["webkitRequestFullScreen"]()),e instanceof Promise&&e.catch(noop)}}_OnExitFullscreen(){if(this._iRuntime.IsAnyWebView2Wrapper()||"macos-wkwebview"===this._exportType||"linux-cef"===this._exportType)self.RuntimeInterface._SetWrapperIsFullscreenFlag(!1),this._iRuntime._SendWrapperMessage({"type":"set-fullscreen","fullscreen":!1});else{let e;document["exitFullscreen"]?e=document["exitFullscreen"]():document["mozCancelFullScreen"]?e=document["mozCancelFullScreen"]():document["msExitFullscreen"]?e=document["msExitFullscreen"]():document["webkitCancelFullScreen"]&&(e=document["webkitCancelFullScreen"]()),e instanceof Promise&&e.catch(noop)}}_OnSetHash(e){location.hash=e["hash"]}_OnHashChange(){this.PostToRuntime("hashchange",{"location":location.toString()})}_OnSetDocumentCSSStyle(e){const t=e["prop"],n=e["value"],o=e["selector"],i=e["is-all"];try{const s=elemsForSelector(o,i);for(const e of s)t.startsWith("--")?e.style.setProperty(t,n):e.style[t]=n}catch(e){console.warn("[Browser] Failed to set style: ",e)}}_OnGetDocumentCSSStyle(e){const t=e["prop"],n=e["selector"];try{const o=document.querySelector(n);if(o){const i=window.getComputedStyle(o);return{"isOk":!0,"result":i.getPropertyValue(t)}}return{"isOk":!1}}catch(e){return console.warn("[Browser] Failed to get style: ",e),{"isOk":!1}}}_OnSetWindowSize(e){window.resizeTo(e["windowWidth"],e["windowHeight"])}_OnSetWindowPosition(e){window.moveTo(e["windowX"],e["windowY"])}_OnSetWarnOnClose(e){const t=e["enabled"];t?window.addEventListener("beforeunload",this._beforeunload_handler):window.removeEventListener("beforeunload",this._beforeunload_handler)}};self.RuntimeInterface.AddDOMHandlerClass(d)}

// scripts/plugins/LocalStorage/dom/domSide.js
"use strict";{const a="localstorage",b=class extends self.DOMHandler{constructor(t){super(t,a),this.AddRuntimeMessageHandlers([["init",()=>this._Init()],["request-persistent",()=>this._OnRequestPersistent()]])}async _Init(){let s=!1;try{s=await navigator["storage"]["persisted"]()}catch(t){s=!1,console.warn("[Construct] Error checking storage persisted state: ",t)}return{"isPersistent":s}}async _OnRequestPersistent(){try{const t=await navigator["storage"]["persist"]();return{"isOk":!0,"isPersistent":t}}catch(t){return console.error("[Construct] Error requesting persistent storage: ",t),{"isOk":!1}}}};self.RuntimeInterface.AddDOMHandlerClass(b)}

// scripts/plugins/Audio/dom/domSide.js
"use strict";{const a=180/Math.PI,b="audio";self.AudioDOMHandler=class extends self.DOMHandler{constructor(t){super(t,b),this._audioContext=null,this._destinationNode=null,this._hasUnblocked=!1,this._hasAttachedUnblockEvents=!1,this._unblockFunc=()=>this._UnblockAudioContext(),this._audioBuffers=[],this._audioInstances=[],this._lastAudioInstance=null,this._lastPlayedTags=[],this._loadedAudioUrls=new Set,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._lastListenerPos=[0,0,0],this._lastListenerOrientation=[0,0,-1,0,1,0],this._playMusicAsSound=!1,this._hasAnySoftwareDecodedMusic=!1,this._supportsWebMOpus=this._iRuntime.IsAudioFormatSupported("audio/webm; codecs=opus"),this._effects=new Map,this._analysers=new Set,this._isPendingPostFxState=!1,this._hasStartedOfflineRender=!1,this._microphoneTag="",this._microphoneSource=null,self["C3Audio_OnMicrophoneStream"]=(t,e)=>this._OnMicrophoneStream(t,e),this._destMediaStreamNode=null,self["C3Audio_GetOutputStream"]=()=>this._OnGetOutputStream(),(self["C3Audio_DOMInterface"]=this).AddRuntimeMessageHandlers([["create-audio-context",t=>this._CreateAudioContext(t)],["play",t=>this._Play(t)],["stop",t=>this._Stop(t)],["stop-all",()=>this._StopAll()],["set-paused",t=>this._SetPaused(t)],["set-volume",t=>this._SetVolume(t)],["fade-volume",t=>this._FadeVolume(t)],["set-master-volume",t=>this._SetMasterVolume(t)],["set-muted",t=>this._SetMuted(t)],["set-silent",t=>this._SetSilent(t)],["set-looping",t=>this._SetLooping(t)],["set-playback-rate",t=>this._SetPlaybackRate(t)],["set-stereo-pan",t=>this._SetStereoPan(t)],["seek",t=>this._Seek(t)],["preload",t=>this._Preload(t)],["unload",t=>this._Unload(t)],["unload-all",()=>this._UnloadAll()],["set-suspended",t=>this._SetSuspended(t)],["add-effect",t=>this._AddEffect(t)],["set-effect-param",t=>this._SetEffectParam(t)],["remove-effects",t=>this._RemoveEffects(t)],["tick",t=>this._OnTick(t)],["load-state",t=>this._OnLoadState(t)],["offline-render-audio",t=>this._OnOfflineRenderAudio(t)],["offline-render-finish",()=>this._OnOfflineRenderFinish()]])}async _CreateAudioContext(t){if(t["usePlayMusicAsSoundWorkaround"]&&(this._playMusicAsSound=!0),this._timeScaleMode=t["timeScaleMode"],this._panningModel=["equalpower","HRTF","soundfield"][t["panningModel"]],this._distanceModel=["linear","inverse","exponential"][t["distanceModel"]],this._refDistance=t["refDistance"],this._maxDistance=t["maxDistance"],this._rolloffFactor=t["rolloffFactor"],this._iRuntime.IsExportingToVideo()){this._playMusicAsSound=!0;this._audioContext=new OfflineAudioContext({"numberOfChannels":2,"sampleRate":48e3,"length":Math.ceil(48e3*this._iRuntime.GetExportToVideoDuration())})}else{const s={"latencyHint":t["latencyHint"]};if(this.SupportsWebMOpus()||(s["sampleRate"]=48e3),"undefined"!=typeof AudioContext)this._audioContext=new AudioContext(s);else{if("undefined"==typeof webkitAudioContext)throw new Error("Web Audio API not supported");this._audioContext=new webkitAudioContext(s)}this._AttachUnblockEvents(),this._audioContext.onstatechange=()=>{"running"!==this._audioContext.state&&this._AttachUnblockEvents(),this.PostToRuntime("audiocontext-state",{"audioContextState":this._audioContext.state})}}this._destinationNode=this._audioContext["createGain"](),this._destinationNode["connect"](this._audioContext["destination"]);const e=t["listenerPos"];this._lastListenerPos[0]=e[0],this._lastListenerPos[1]=e[1],this._lastListenerPos[2]=e[2],this._audioContext["listener"]["setPosition"](e[0],e[1],e[2]),this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation),self["C3_GetAudioContextCurrentTime"]=()=>this.GetAudioCurrentTime();try{await Promise.all(t["preloadList"].map(t=>this._GetAudioBuffer(t["originalUrl"],t["url"],t["type"],!1)))}catch(t){console.error("[Construct] Preloading sounds failed: ",t)}return{"sampleRate":this._audioContext["sampleRate"],"audioContextState":this._audioContext.state,"outputLatency":this._audioContext["outputLatency"]||0}}_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){const t=this._audioContext,e=("suspended"===t["state"]&&t["resume"]&&t["resume"](),t["createBuffer"](1,220,22050)),s=t["createBufferSource"]();s["buffer"]=e,s["connect"](t["destination"]),s["start"](0),"running"===t["state"]&&this._DetachUnblockEvents()}}_MatchTagLists(e,t){for(const s of t){let t=!1;for(const i of e)if(self.AudioDOMHandler.EqualsNoCase(i,s)){t=!0;break}if(!t)return!1}return!0}GetAudioContext(){return this._audioContext}GetAudioCurrentTime(){return this._audioContext["currentTime"]}GetDestinationNode(){return this._destinationNode}["GetAudioContextExtern"](){return this.GetAudioContext()}["GetDestinationNodeExtern"](){return this.GetDestinationNode()}GetDestinationForTag(t){const e=this._effects.get(t.toLowerCase());return e?e[0].GetInputNode():this.GetDestinationNode()}AddEffectForTag(t,e){t=t.toLowerCase();let s=this._effects.get(t);s||(s=[],this._effects.set(t,s)),e._SetIndex(s.length),e._SetTag(t),s.push(e),this._ReconnectEffects(t)}_ReconnectEffects(t){t=t.toLowerCase();let e=this.GetDestinationNode();const s=this._effects.get(t);if(s&&s.length){e=s[0].GetInputNode();for(let t=0,e=s.length;t<e;++t){const i=s[t];t+1===e?i.ConnectTo(this.GetDestinationNode()):i.ConnectTo(s[t+1].GetInputNode())}}for(const n of this.audioInstancesByEffectTag(t))n.Reconnect(e);this._microphoneSource&&this._microphoneTag===t&&(this._microphoneSource["disconnect"](),this._microphoneSource["connect"](e))}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(s,t){return t?this._iRuntime._WasmDecodeWebMOpus(s).then(t=>{const e=this._audioContext["createBuffer"](1,t.length,48e3),s=e["getChannelData"](0);return s.set(t),e}):new Promise((t,e)=>{this._audioContext["decodeAudioData"](s,t,e)})}TryPlayMedia(t){this._iRuntime.TryPlayMedia(t)}RemovePendingPlay(t){this._iRuntime.RemovePendingPlay(t)}ReleaseInstancesForBuffer(s){let i=0;for(let t=0,e=this._audioInstances.length;t<e;++t){const n=this._audioInstances[t];(this._audioInstances[i]=n).GetBuffer()===s?n.Release():++i}this._audioInstances.length=i}ReleaseAllMusicBuffers(){let s=0;for(let t=0,e=this._audioBuffers.length;t<e;++t){const i=this._audioBuffers[t];(this._audioBuffers[s]=i).IsMusic()?i.Release():++s}this._audioBuffers.length=s}*audioInstancesMatchingTags(t){if(0<t.length)for(const e of this._audioInstances)this._MatchTagLists(e.GetTags(),t)&&(yield e);else this._lastAudioInstance&&!this._lastAudioInstance.HasEnded()&&(yield this._lastAudioInstance)}*audioInstancesByEffectTag(t){if(t)for(const e of this._audioInstances)self.AudioDOMHandler.EqualsNoCase(e.GetEffectTag(),t)&&(yield e);else this._lastAudioInstance&&!this._lastAudioInstance.HasEnded()&&(yield this._lastAudioInstance)}async _GetAudioBuffer(t,e,s,i,n){for(const a of this._audioBuffers)if(a.GetUrl()===e)return await a.Load(),a;if(n)return null;i&&(this._playMusicAsSound||this._hasAnySoftwareDecodedMusic)&&this.ReleaseAllMusicBuffers();const o=self.C3AudioBuffer.Create(this,t,e,s,i);return this._audioBuffers.push(o),await o.Load(),this._loadedAudioUrls.has(t)||(this.PostToRuntime("buffer-metadata",{"originalUrl":t,"duration":o.GetDuration()}),this._loadedAudioUrls.add(t)),o}async _GetAudioInstance(t,e,s,i,n){for(const r of this._audioInstances)if(r.GetUrl()===e&&(r.CanBeRecycled()||n))return r.SetTags(i),r;const o=await this._GetAudioBuffer(t,e,s,n),a=o.CreateInstance(i);return this._audioInstances.push(a),a}_AddPendingTags(t){const s=t.join(" ");let i=this._pendingTags.get(s);if(!i){let e=null;const n=new Promise(t=>e=t);i={pendingCount:0,promise:n,resolve:e},this._pendingTags.set(s,i)}i.pendingCount++}_RemovePendingTags(t){const e=t.join(" "),s=this._pendingTags.get(e);if(!s)throw new Error("expected pending tag");s.pendingCount--,0===s.pendingCount&&(s.resolve(),this._pendingTags.delete(e))}TagsReady(t){const e=(0===t.length?this._lastPlayedTags:t).join(" "),s=this._pendingTags.get(e);return s?s.promise:Promise.resolve()}_MaybeStartTicking(){if(0<this._analysers.size)this._StartTicking();else for(const t of this._audioInstances)if(t.IsActive())return void this._StartTicking()}Tick(){for(const s of this._analysers)s.Tick();const t=this.GetAudioCurrentTime();for(const i of this._audioInstances)i.Tick(t);const e=this._audioInstances.filter(t=>t.IsActive()).map(t=>t.GetState());this.PostToRuntime("state",{"tickCount":this._lastTickCount,"outputLatency":this._audioContext["outputLatency"]||0,"audioInstances":e,"analysers":[...this._analysers].map(t=>t.GetData())}),0===e.length&&0===this._analysers.size&&this._StopTicking()}PostTrigger(t,e,s){this.PostToRuntime("trigger",{"type":t,"tags":e,"aiid":s})}async _Play(t){const e=t["originalUrl"],s=t["url"],i=t["type"],n=t["isMusic"],o=t["tags"],a=t["isLooping"],r=t["vol"],d=t["pos"],u=t["panning"],l=t["stereoPan"];let h=t["off"];if(0<h&&!t["trueClock"])if(this._audioContext["getOutputTimestamp"]){const c=this._audioContext["getOutputTimestamp"]();h=h-c["performanceTime"]/1e3+c["contextTime"]}else h=h-performance.now()/1e3+this._audioContext["currentTime"];this._lastPlayedTags=o.slice(0),this._AddPendingTags(o);try{this._lastAudioInstance=await this._GetAudioInstance(e,s,i,o,n),u?(this._lastAudioInstance.SetPannerEnabled(!0),this._lastAudioInstance.SetPan(u["x"],u["y"],u["z"],u["angle"],u["innerAngle"],u["outerAngle"],u["outerGain"]),u.hasOwnProperty("uid")&&this._lastAudioInstance.SetUID(u["uid"])):"number"==typeof l&&0!==l?(this._lastAudioInstance.SetStereoPannerEnabled(!0),this._lastAudioInstance.SetStereoPan(l)):(this._lastAudioInstance.SetPannerEnabled(!1),this._lastAudioInstance.SetStereoPannerEnabled(!1)),this._lastAudioInstance.Play(a,r,d,h)}catch(t){return void console.error("[Construct] Audio: error starting playback: ",t)}finally{this._RemovePendingTags(o)}this._StartTicking()}_Stop(t){const e=t["tags"];for(const s of this.audioInstancesMatchingTags(e))s.Stop()}_StopAll(){for(const t of this._audioInstances)t.Stop()}_SetPaused(t){const e=t["tags"],s=t["paused"];for(const i of this.audioInstancesMatchingTags(e))s?i.Pause():i.Resume();this._MaybeStartTicking()}_SetVolume(t){const e=t["tags"],s=t["vol"];for(const i of this.audioInstancesMatchingTags(e))i.SetVolume(s)}_SetStereoPan(t){const e=t["tags"],s=t["p"];for(const i of this.audioInstancesMatchingTags(e))i.SetStereoPannerEnabled(!0),i.SetStereoPan(s)}async _FadeVolume(t){const e=t["tags"],s=t["vol"],i=t["duration"],n=t["stopOnEnd"];await this.TagsReady(e);for(const o of this.audioInstancesMatchingTags(e))o.FadeVolume(s,i,n);this._MaybeStartTicking()}_SetMasterVolume(t){this._masterVolume=t["vol"],this._destinationNode["gain"]["value"]=this._masterVolume}_SetMuted(t){const e=t["tags"],s=t["isMuted"];for(const i of this.audioInstancesMatchingTags(e))i.SetMuted(s)}_SetSilent(t){this._isSilent=t["isSilent"],this._iRuntime.SetSilent(this._isSilent);for(const e of this._audioInstances)e._UpdateMuted()}_SetLooping(t){const e=t["tags"],s=t["isLooping"];for(const i of this.audioInstancesMatchingTags(e))i.SetLooping(s)}async _SetPlaybackRate(t){const e=t["tags"],s=t["rate"];await this.TagsReady(e);for(const i of this.audioInstancesMatchingTags(e))i.SetPlaybackRate(s)}async _Seek(t){const e=t["tags"],s=t["pos"];await this.TagsReady(e);for(const i of this.audioInstancesMatchingTags(e))i.Seek(s)}async _Preload(t){const e=t["originalUrl"],s=t["url"],i=t["type"],n=t["isMusic"];try{await this._GetAudioInstance(e,s,i,"",n)}catch(t){console.error("[Construct] Audio: error preloading: ",t)}}async _Unload(t){const e=t["url"],s=t["type"],i=t["isMusic"],n=await this._GetAudioBuffer("",e,s,i,!0);if(n){n.Release();const o=this._audioBuffers.indexOf(n);-1!==o&&this._audioBuffers.splice(o,1)}}_UnloadAll(){for(const t of this._audioBuffers)t.Release();this._audioBuffers.length=0}_SetSuspended(t){const e=t["isSuspended"];!e&&this._audioContext["resume"]&&this._audioContext["resume"]();for(const s of this._audioInstances)s.SetSuspended(e);e&&this._audioContext["suspend"]&&this._audioContext["suspend"]()}_OnTick(t){if(this._timeScale=t["timeScale"],this._gameTime=t["gameTime"],this._lastTickCount=t["tickCount"],0!==this._timeScaleMode)for(const i of this._audioInstances)i._UpdatePlaybackRate();const e=t["listenerPos"],s=(!e||this._lastListenerPos[0]===e[0]&&this._lastListenerPos[1]===e[1]&&this._lastListenerPos[2]===e[2]||(this._lastListenerPos[0]=e[0],this._lastListenerPos[1]=e[1],this._lastListenerPos[2]=e[2],this._audioContext["listener"]["setPosition"](e[0],e[1],e[2])),t["listenerOrientation"]);if(s&&(this._lastListenerOrientation[0]!==s[0]||this._lastListenerOrientation[1]!==s[1]||this._lastListenerOrientation[2]!==s[2]||this._lastListenerOrientation[3]!==s[3]||this._lastListenerOrientation[4]!==s[4]||this._lastListenerOrientation[5]!==s[5])){for(let t=0;t<6;++t)this._lastListenerOrientation[t]=s[t];this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation)}for(const n of t["instPans"]){const o=n["uid"];for(const a of this._audioInstances)a.GetUID()===o&&a.SetPanXYZA(n["x"],n["y"],n["z"],n["angle"])}}async _AddEffect(t){const e=t["type"],s=t.hasOwnProperty("tags")?t["tags"]:[t["tag"]],i=t["params"];let n,o;if("convolution"===e)try{o=await this._GetAudioBuffer(t["bufferOriginalUrl"],t["bufferUrl"],t["bufferType"],!1)}catch(t){return void console.log("[Construct] Audio: error loading convolution: ",t)}for(const a of s){if("filter"===e)n=new self.C3AudioFilterFX(this,...i);else if("delay"===e)n=new self.C3AudioDelayFX(this,...i);else if("convolution"===e)(n=new self.C3AudioConvolveFX(this,o.GetAudioBuffer(),...i))._SetBufferInfo(t["bufferOriginalUrl"],t["bufferUrl"],t["bufferType"]);else if("flanger"===e)n=new self.C3AudioFlangerFX(this,...i);else if("phaser"===e)n=new self.C3AudioPhaserFX(this,...i);else if("gain"===e)n=new self.C3AudioGainFX(this,...i);else if("stereopan"===e)n=new self.C3AudioStereoPanFX(this,...i);else if("tremolo"===e)n=new self.C3AudioTremoloFX(this,...i);else if("ringmod"===e)n=new self.C3AudioRingModFX(this,...i);else if("distortion"===e)n=new self.C3AudioDistortionFX(this,...i);else if("compressor"===e)n=new self.C3AudioCompressorFX(this,...i);else{if("analyser"!==e)throw new Error("invalid effect type");n=new self.C3AudioAnalyserFX(this,...i)}this.AddEffectForTag(a,n)}this._PostUpdatedFxState()}_SetEffectParam(t){const e=t["tags"],s=t["index"],i=t["param"],n=t["value"],o=t["ramp"],a=t["time"];for(const r of e){const d=this._effects.get(r.toLowerCase());!d||s<0||s>=d.length||d[s].SetParam(i,n,o,a)}this._PostUpdatedFxState()}_RemoveEffects(t){const e=t["tags"];for(const s of e){const i=s.toLowerCase(),n=this._effects.get(i);if(!n||!n.length)return;for(const o of n)o.Release();this._effects.delete(i),this._ReconnectEffects(i)}}_AddAnalyser(t){this._analysers.add(t),this._MaybeStartTicking()}_RemoveAnalyser(t){this._analysers.delete(t)}_PostUpdatedFxState(){this._isPendingPostFxState||(this._isPendingPostFxState=!0,Promise.resolve().then(()=>this._DoPostUpdatedFxState()))}_DoPostUpdatedFxState(){const t={};for(const[e,s]of this._effects)t[e]=s.map(t=>t.GetState());this.PostToRuntime("fxstate",{"fxstate":t}),this._isPendingPostFxState=!1}async _OnLoadState(t){const e=t["saveLoadMode"];if(3!==e){const o=[];for(const a of this._audioInstances)a.IsMusic()&&1===e||!a.IsMusic()&&2===e?o.push(a):a.Release();this._audioInstances=o}for(const r of this._effects.values())for(const d of r)d.Release();this._effects.clear(),this._timeScale=t["timeScale"],this._gameTime=t["gameTime"];const s=t["listenerPos"],i=(this._lastListenerPos[0]=s[0],this._lastListenerPos[1]=s[1],this._lastListenerPos[2]=s[2],this._audioContext["listener"]["setPosition"](s[0],s[1],s[2]),t["listenerOrientation"]);if(Array.isArray(i)){for(let t=0;t<6;++t)this._lastListenerOrientation[t]=i[t];this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation)}this._isSilent=t["isSilent"],this._iRuntime.SetSilent(this._isSilent),this._masterVolume=t["masterVolume"],this._destinationNode["gain"]["value"]=this._masterVolume;const n=[];for(const u of Object.values(t["effects"]))n.push(Promise.all(u.map(t=>this._AddEffect(t))));await Promise.all(n),await Promise.all(t["playing"].map(t=>this._LoadAudioInstance(t,e))),this._MaybeStartTicking()}async _LoadAudioInstance(e,t){if(3!==t){const s=e["bufferOriginalUrl"],i=e["bufferUrl"],n=e["bufferType"],o=e["isMusic"],a=e["tags"],r=e["isLooping"],d=e["volume"],u=e["playbackTime"];if((!o||1!==t)&&(o||2!==t)){let t=null;try{t=await this._GetAudioInstance(s,i,n,a,o)}catch(t){return void console.error("[Construct] Audio: error loading audio state: ",t)}t.LoadPanState(e["pan"]),t.LoadStereoPanState(e["stereoPan"]),t.Play(r,d,u,0),e["isPlaying"]||t.Pause(),t._LoadAdditionalState(e)}}}_OnMicrophoneStream(t,e){this._microphoneSource&&this._microphoneSource["disconnect"](),this._microphoneTag=e.toLowerCase(),this._microphoneSource=this._audioContext["createMediaStreamSource"](t),this._microphoneSource["connect"](this.GetDestinationForTag(this._microphoneTag))}_OnGetOutputStream(){return this._destMediaStreamNode||(this._destMediaStreamNode=this._audioContext["createMediaStreamDestination"](),this._destinationNode["connect"](this._destMediaStreamNode)),this._destMediaStreamNode["stream"]}async _OnOfflineRenderAudio(t){try{const e=t["time"],s=this._audioContext["suspend"](e);this._hasStartedOfflineRender?this._audioContext["resume"]():(this._audioContext["startRendering"]().then(t=>this._OnOfflineRenderCompleted(t)).catch(t=>this._OnOfflineRenderError(t)),this._hasStartedOfflineRender=!0),await s}catch(t){this._OnOfflineRenderError(t)}}_OnOfflineRenderFinish(){this._audioContext["resume"]()}_OnOfflineRenderCompleted(s){const i=[];for(let t=0,e=s["numberOfChannels"];t<e;++t){const n=s["getChannelData"](t);i.push(n.buffer)}this._iRuntime.PostToRuntimeComponent("runtime","offline-audio-render-completed",{"duration":s["duration"],"length":s["length"],"numberOfChannels":s["numberOfChannels"],"sampleRate":s["sampleRate"],"channelData":i},null,i)}_OnOfflineRenderError(t){console.error("[Audio] Offline rendering error: ",t)}static EqualsNoCase(t,e){return t===e||t.normalize().toLowerCase()===e.normalize().toLowerCase()}static ToDegrees(t){return t*a}static DbToLinearNoCap(t){return Math.pow(10,t/20)}static DbToLinear(t){return Math.max(Math.min(self.AudioDOMHandler.DbToLinearNoCap(t),1),0)}static LinearToDbNoCap(t){return Math.log(t)/Math.log(10)*20}static LinearToDb(t){return self.AudioDOMHandler.LinearToDbNoCap(Math.max(Math.min(t,1),0))}static e4(t,e){return 1-Math.exp(-e*t)}},self.RuntimeInterface.AddDOMHandlerClass(self.AudioDOMHandler)}

// scripts/plugins/Audio/dom/audioBuffer.js
"use strict";self.C3AudioBuffer=class{constructor(t,e,i,s,o){this._audioDomHandler=t,this._originalUrl=e,this._url=i,this._type=s,this._isMusic=o,this._api="",this._loadState="not-loaded",this._loadPromise=null}Release(){this._loadState="not-loaded",this._audioDomHandler=null,this._loadPromise=null}static Create(t,e,i,s,o){const a="audio/webm; codecs=opus"===s&&!t.SupportsWebMOpus();return o&&a&&t._SetHasAnySoftwareDecodedMusic(),!o||t.IsPlayMusicAsSound()||a?new self.C3WebAudioBuffer(t,e,i,s,o,a):new self.C3Html5AudioBuffer(t,e,i,s,o)}CreateInstance(t){return new("html5"===this._api?self.C3Html5AudioInstance:self.C3WebAudioInstance)(this._audioDomHandler,this,t)}_Load(){}Load(){return this._loadPromise||(this._loadPromise=this._Load()),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(){}};

// scripts/plugins/Audio/dom/html5AudioBuffer.js
"use strict";self.C3Html5AudioBuffer=class extends self.C3AudioBuffer{constructor(e,t,o,i,d){super(e,t,o,i,d),this._api="html5",this._audioElem=new Audio,this._audioElem.crossOrigin="anonymous",this._audioElem.autoplay=!1,this._audioElem.preload="auto",this._loadResolve=null,this._loadReject=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._loadResolve=null,this._loadReject=null),!this._mediaSourceNode&&this._audioElem&&(this._mediaSourceNode=this.GetAudioContext()["createMediaElementSource"](this._audioElem),this._mediaSourceNode["connect"](this._outNode))}),this.onended=null,this._audioElem.addEventListener("ended",()=>{this.onended&&this.onended()}),this._audioElem.addEventListener("error",e=>this._OnError(e))}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.onended=null,this._audioElem=null,super.Release()}_Load(){return this._loadState="loading",new Promise((e,t)=>{this._loadResolve=e,this._loadReject=t,this._audioElem.src=this._url})}_OnError(e){console.error(`[Construct] Audio '${this._url}' error: `,e),this._loadReject&&(this._loadState="failed",this._loadReject(e),this._loadResolve=null,this._loadReject=null)}IsLoaded(){const e=4<=this._audioElem["readyState"];return e&&(this._reachedCanPlayThrough=!0),e||this._reachedCanPlayThrough}IsLoadedAndDecoded(){return this.IsLoaded()}GetAudioElement(){return this._audioElem}GetOutputNode(){return this._outNode}GetDuration(){return this._audioElem["duration"]}};

// scripts/plugins/Audio/dom/webAudioBuffer.js
"use strict";self.C3WebAudioBuffer=class extends self.C3AudioBuffer{constructor(a,t,e,i,o,s){super(a,t,e,i,o),this._api="webaudio",this._audioData=null,this._audioBuffer=null,this._needsSoftwareDecode=!!s}Release(){this._audioDomHandler.ReleaseInstancesForBuffer(this),this._audioData=null,this._audioBuffer=null,super.Release()}async _Fetch(){if(this._audioData)return this._audioData;const a=this._audioDomHandler.GetRuntimeInterface();if("cordova"===a.GetExportType()&&a.IsRelativeURL(this._url)&&a.IsFileProtocol())this._audioData=await a.CordovaFetchLocalFileAsArrayBuffer(this._url);else if("playable-ad-single-file"===a.GetExportType()&&a.IsRelativeURL(this._url)){const t=a["_PlayableAdFetchBlob"](this._url);this._audioData=await t.arrayBuffer()}else{const e=await fetch(this._url);if(!e.ok)throw new Error(`error fetching audio data: ${e.status} `+e.statusText);this._audioData=await e.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(a){this._loadState="failed",console.error(`[Construct] Failed to load audio '${this._url}': `,a)}}IsLoaded(){return!(!this._audioData&&!this._audioBuffer)}IsLoadedAndDecoded(){return!!this._audioBuffer}GetAudioBuffer(){return this._audioBuffer}GetDuration(){return this._audioBuffer?this._audioBuffer["duration"]:0}};

// scripts/plugins/Audio/dom/audioInstance.js
"use strict";{let s=0;self.C3AudioInstance=class{constructor(e,t,n){this._audioDomHandler=e,this._buffer=t,this._tags=n,this._aiId=s++,this._gainNode=this.GetAudioContext()["createGain"](),this._gainNode["connect"](this.GetDestinationNode()),this._pannerNode=null,this._isPannerEnabled=!1,this._pannerPosition=[0,0,0],this._pannerOrientation=[0,0,0],this._pannerConeParams=[0,0,0],this._stereoPannerNode=null,this._isStereoPannerEnabled=!1,this._stereoPan=0,this._isStopped=!0,this._isPaused=!1,this._resumeMe=!1,this._isLooping=!1,this._volume=1,this._isMuted=!1,this._playbackRate=1;const i=this._audioDomHandler.GetTimeScaleMode();this._isTimescaled=1===i&&!this.IsMusic()||2===i,this._instUid=-1,this._fadeEndTime=-1,this._stopOnFadeEnd=!1}Release(){this._audioDomHandler=null,this._buffer=null,this._pannerNode&&(this._pannerNode["disconnect"](),this._pannerNode=null),this._stereoPannerNode&&(this._stereoPannerNode["disconnect"](),this._stereoPannerNode=null),this._gainNode["disconnect"](),this._gainNode=null}GetAudioContext(){return this._audioDomHandler.GetAudioContext()}SetTags(e){this._tags=e}GetTags(){return this._tags}GetEffectTag(){return 0<this._tags.length?this._tags[0]:""}GetDestinationNode(){return this._audioDomHandler.GetDestinationForTag(this.GetEffectTag())}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()}GetAiId(){return this._aiId}HasEnded(){}CanBeRecycled(){}IsPlaying(){return!this._isStopped&&!this._isPaused&&!this.HasEnded()}IsActive(){return!this._isStopped&&!this.HasEnded()}GetPlaybackTime(){}GetDuration(e){let t=this._buffer.GetDuration();return e&&(t/=this._playbackRate||.001),t}Play(e,t,n,i){}Stop(){}Pause(){}IsPaused(){return this._isPaused}Resume(){}SetVolume(e){this._volume=e,this._gainNode["gain"]["cancelScheduledValues"](0),this._fadeEndTime=-1,this._gainNode["gain"]["value"]=this.GetOutputVolume()}FadeVolume(e,t,n){if(!this.IsMuted()){const i=this._gainNode["gain"],s=(i["cancelScheduledValues"](0),this._audioDomHandler.GetAudioCurrentTime()),a=s+t;i["setValueAtTime"](i["value"],s),i["linearRampToValueAtTime"](e,a),this._volume=e,this._fadeEndTime=a,this._stopOnFadeEnd=n}}_UpdateVolume(){this.SetVolume(this._volume)}Tick(e){-1!==this._fadeEndTime&&e>=this._fadeEndTime&&(this._fadeEndTime=-1,this._stopOnFadeEnd&&this.Stop(),this._audioDomHandler.PostTrigger("fade-ended",this._tags,this._aiId))}GetOutputVolume(){const e=this._volume;return isFinite(e)?e:0}SetMuted(e){this._isMuted!==(e=!!e)&&(this._isMuted=e,this._UpdateMuted())}IsMuted(){return this._isMuted}IsSilent(){return this._audioDomHandler.IsSilent()}_UpdateMuted(){}SetLooping(e){}IsLooping(){return this._isLooping}SetPlaybackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this._UpdatePlaybackRate())}_UpdatePlaybackRate(){}GetPlaybackRate(){return this._playbackRate}Seek(e){}SetSuspended(e){}SetPannerEnabled(e){this._isPannerEnabled!==(e=!!e)&&(this._isPannerEnabled=e,(this._isPannerEnabled?(this.SetStereoPannerEnabled(!1),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):(this._pannerNode["disconnect"](),this._gainNode["disconnect"](),this._gainNode))["connect"](this.GetDestinationNode()))}SetPan(e,t,n,i,s,a,o){if(this._isPannerEnabled){this.SetPanXYZA(e,t,n,i);const r=self.AudioDOMHandler.ToDegrees;this._pannerConeParams[0]!==r(s)&&(this._pannerConeParams[0]=r(s),this._pannerNode["coneInnerAngle"]=r(s)),this._pannerConeParams[1]!==r(a)&&(this._pannerConeParams[1]=r(a),this._pannerNode["coneOuterAngle"]=r(a)),this._pannerConeParams[2]!==o&&(this._pannerConeParams[2]=o,this._pannerNode["coneOuterGain"]=o)}}SetPanXYZA(e,t,n,i){if(this._isPannerEnabled){const s=this._pannerPosition,a=this._pannerOrientation,o=Math.cos(i),r=Math.sin(i);s[0]===e&&s[1]===t&&s[2]===n||(s[0]=e,s[1]=t,s[2]=n,this._pannerNode["setPosition"](...s)),a[0]===o&&a[1]===r&&0===a[2]||(a[0]=o,a[1]=r,a[2]=0,this._pannerNode["setOrientation"](...a))}}SetStereoPannerEnabled(e){this._isStereoPannerEnabled!==(e=!!e)&&(this._isStereoPannerEnabled=e,(this._isStereoPannerEnabled?(this.SetPannerEnabled(!1),this._stereoPannerNode=this.GetAudioContext()["createStereoPanner"](),this._gainNode["disconnect"](),this._gainNode["connect"](this._stereoPannerNode),this._stereoPannerNode):(this._stereoPannerNode["disconnect"](),this._stereoPannerNode=null,this._gainNode["disconnect"](),this._gainNode))["connect"](this.GetDestinationNode()))}SetStereoPan(e){this._isStereoPannerEnabled&&this._stereoPan!==e&&(this._stereoPannerNode["pan"]["value"]=e,this._stereoPan=e)}SetUID(e){this._instUid=e}GetUID(){return this._instUid}GetResumePosition(){}Reconnect(e){const t=this._stereoPannerNode||this._pannerNode||this._gainNode;t["disconnect"](),t["connect"](e)}GetState(){return{"aiid":this.GetAiId(),"tags":this._tags,"duration":this.GetDuration(),"volume":-1===this._fadeEndTime?this._volume:this._gainNode["gain"]["value"],"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(),"stereoPan":this.GetStereoPanState()}}_LoadAdditionalState(e){this.SetPlaybackRate(e["playbackRate"]),this.SetMuted(e["isMuted"])}GetPanState(){if(!this._pannerNode)return null;const e=this._pannerNode;return{"pos":this._pannerPosition,"orient":this._pannerOrientation,"cia":e["coneInnerAngle"],"coa":e["coneOuterAngle"],"cog":e["coneOuterGain"],"uid":this._instUid}}LoadPanState(e){if(e){this.SetPannerEnabled(!0);const t=this._pannerNode,n=e["pos"],i=(this._pannerPosition[0]=n[0],this._pannerPosition[1]=n[1],this._pannerPosition[2]=n[2],e["orient"]);this._pannerOrientation[0]=i[0],this._pannerOrientation[1]=i[1],this._pannerOrientation[2]=i[2],t["setPosition"](...this._pannerPosition),t["setOrientation"](...this._pannerOrientation),this._pannerConeParams[0]=e["cia"],this._pannerConeParams[1]=e["coa"],this._pannerConeParams[2]=e["cog"],t["coneInnerAngle"]=e["cia"],t["coneOuterAngle"]=e["coa"],t["coneOuterGain"]=e["cog"],this._instUid=e["uid"]}else this.SetPannerEnabled(!1)}GetStereoPanState(){return this._stereoPannerNode?this._stereoPan:null}LoadStereoPanState(e){"number"!=typeof e?this.SetStereoPannerEnabled(!1):(this.SetStereoPannerEnabled(!0),this.SetStereoPan(e))}}}

// scripts/plugins/Audio/dom/html5AudioInstance.js
"use strict";self.C3Html5AudioInstance=class extends self.C3AudioInstance{constructor(e,t,i){super(e,t,i),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._tags,this._aiId)}HasEnded(){return this.GetAudioElement()["ended"]}CanBeRecycled(){return!!this._isStopped||this.HasEnded()}GetPlaybackTime(){let e=this.GetAudioElement()["currentTime"];return e=this._isLooping?e:Math.min(e,this.GetDuration())}Play(e,t,i,s){const d=this.GetAudioElement();if(1!==d.playbackRate&&(d.playbackRate=1),d.loop!==e&&(d.loop=e),this.SetVolume(t),this._isMuted=!1,d.muted&&(d.muted=!1),d.currentTime!==i)try{d.currentTime=i}catch(e){console.warn(`[Construct] Exception seeking audio '${this._buffer.GetUrl()}' to position '${i}': `,e)}this._audioDomHandler.TryPlayMedia(d),this._isStopped=!1,this._isPaused=!1,this._isLooping=e,this._playbackRate=1}Stop(){const e=this.GetAudioElement();e.paused||e.pause(),this._audioDomHandler.RemovePendingPlay(e),this._isStopped=!0,this._isPaused=!1,this._instUid=-1}Pause(){if(!(this._isPaused||this._isStopped||this.HasEnded())){const e=this.GetAudioElement();e.paused||e.pause(),this._audioDomHandler.RemovePendingPlay(e),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(e){this._isLooping!==(e=!!e)&&(this._isLooping=e,this.GetAudioElement().loop=e)}_UpdatePlaybackRate(){let t=this._playbackRate;this._isTimescaled&&(t*=this._audioDomHandler.GetTimeScale());try{this.GetAudioElement()["playbackRate"]=t}catch(e){console.warn(`[Construct] Unable to set playback rate '${t}':`,e)}}Seek(t){if(!this._isStopped&&!this.HasEnded())try{this.GetAudioElement()["currentTime"]=t}catch(e){console.warn(`[Construct] Error seeking audio to '${t}': `,e)}}GetResumePosition(){return this.GetPlaybackTime()}SetSuspended(e){e?this.IsPlaying()?(this.GetAudioElement()["pause"](),this._resumeMe=!0):this._resumeMe=!1:this._resumeMe&&(this._audioDomHandler.TryPlayMedia(this.GetAudioElement()),this._resumeMe=!1)}};

// scripts/plugins/Audio/dom/webAudioInstance.js
"use strict";self.C3WebAudioInstance=class extends self.C3AudioInstance{constructor(e,t,s){super(e,t,s),this._bufferSource=null,this._onended_handler=e=>this._OnEnded(e),this._hasPlaybackEnded=!0,this._activeSource=null,this._playStartTime=0,this._playFromSeekPos=0,this._resumePosition=0,this._muteVol=1}Release(){this.Stop(),this._ReleaseBufferSource(),this._onended_handler=null,super.Release()}_ReleaseBufferSource(){this._bufferSource&&(this._bufferSource["onended"]=null,this._bufferSource["disconnect"](),this._bufferSource["buffer"]=null),this._bufferSource=null,this._activeSource=null}_OnEnded(e){this._isPaused||this._resumeMe||e.target===this._activeSource&&(this._hasPlaybackEnded=!0,this._isStopped=!0,this._instUid=-1,this._ReleaseBufferSource(),this._audioDomHandler.PostTrigger("ended",this._tags,this._aiId))}HasEnded(){return!(!this._isStopped&&this._bufferSource&&this._bufferSource["loop"]||this._isPaused)&&this._hasPlaybackEnded}CanBeRecycled(){return!(this._bufferSource&&!this._isStopped)||this.HasEnded()}GetPlaybackTime(){let e=0;return e=this._isPaused?this._resumePosition:this._playFromSeekPos+(this.GetCurrentTime()-this._playStartTime)*this._playbackRate,e=this._isLooping?e:Math.min(e,this.GetDuration())}Play(e,t,s,i){this._isMuted=!1,this._muteVol=1,this.SetVolume(t),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"]=e,this._bufferSource["start"](i,s),this._hasPlaybackEnded=!1,this._isStopped=!1,this._isPaused=!1,this._isLooping=e,this._playbackRate=1,this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=s}Stop(){if(this._bufferSource)try{this._bufferSource["stop"](0)}catch(e){}this._isStopped=!0,this._isPaused=!1,this._instUid=-1}Pause(){this._isPaused||this._isStopped||this.HasEnded()||(this._resumePosition=this.GetPlaybackTime(),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._bufferSource["start"](0,this._resumePosition),this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=this._resumePosition,this._isPaused=!1)}GetOutputVolume(){return super.GetOutputVolume()*this._muteVol}_UpdateMuted(){this._muteVol=this._isMuted||this.IsSilent()?0:1,this._UpdateVolume()}SetLooping(e){this._isLooping!==(e=!!e)&&(this._isLooping=e,this._bufferSource)&&(this._bufferSource["loop"]=e)}_UpdatePlaybackRate(){let e=this._playbackRate;this._isTimescaled&&(e*=this._audioDomHandler.GetTimeScale()),this._bufferSource&&(this._bufferSource["playbackRate"]["value"]=e)}Seek(e){this._isStopped||this.HasEnded()||(this._isPaused?this._resumePosition=e:(this.Pause(),this._resumePosition=e,this.Resume()))}GetResumePosition(){return this._resumePosition}SetSuspended(e){e?this.IsPlaying()?(this._resumeMe=!0,this._resumePosition=this.GetPlaybackTime(),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._bufferSource["start"](0,this._resumePosition),this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=this._resumePosition,this._resumeMe=!1)}_LoadAdditionalState(e){super._LoadAdditionalState(e),this._resumePosition=e["resumePosition"]}};

// scripts/plugins/Audio/dom/effects.js
"use strict";{class a{constructor(e){this._audioDomHandler=e,this._audioContext=e.GetAudioContext(),this._index=-1,this._tag="",this._type="",this._params=null}Release(){this._audioContext=null}_SetIndex(e){this._index=e}GetIndex(){return this._index}_SetTag(e){this._tag=e}GetTag(){return this._tag}CreateGain(){return this._audioContext["createGain"]()}GetInputNode(){}ConnectTo(e){}SetAudioParam(e,t,i,s){if(e["cancelScheduledValues"](0),0===s)e["value"]=t;else{const o=this._audioContext["currentTime"];switch(s+=o,i){case 0:e["setValueAtTime"](t,s);break;case 1:e["setValueAtTime"](e["value"],o),e["linearRampToValueAtTime"](t,s);break;case 2:e["setValueAtTime"](e["value"],o),e["exponentialRampToValueAtTime"](t,s)}}}GetState(){return{"type":this._type,"tag":this._tag,"params":this._params}}}self.C3AudioFilterFX=class extends a{constructor(e,t,i,s,o,a,n){super(e),this._type="filter",this._params=[t,i,s,o,a,n],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=n,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-n,this._filterNode=this._audioContext["createBiquadFilter"](),this._filterNode["type"]=t,this._filterNode["frequency"]["value"]=i,this._filterNode["detune"]["value"]=s,this._filterNode["Q"]["value"]=o,this._filterNode["gain"]["vlaue"]=a,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(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[5]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 1:this._params[1]=t,this.SetAudioParam(this._filterNode["frequency"],t,i,s);break;case 2:this._params[2]=t,this.SetAudioParam(this._filterNode["detune"],t,i,s);break;case 3:this._params[3]=t,this.SetAudioParam(this._filterNode["Q"],t,i,s);break;case 4:this._params[4]=t,this.SetAudioParam(this._filterNode["gain"],t,i,s)}}},self.C3AudioDelayFX=class extends a{constructor(e,t,i,s){super(e),this._type="delay",this._params=[t,i,s],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=s,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-s,this._mainNode=this.CreateGain(),this._delayNode=this._audioContext["createDelay"](t),this._delayNode["delayTime"]["value"]=t,this._delayGainNode=this.CreateGain(),this._delayGainNode["gain"]["value"]=i,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(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){const o=self.AudioDOMHandler.DbToLinear;switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[2]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 4:this._params[1]=o(t),this.SetAudioParam(this._delayGainNode["gain"],o(t),i,s);break;case 5:this._params[0]=t,this.SetAudioParam(this._delayNode["delayTime"],t,i,s)}}},self.C3AudioConvolveFX=class extends a{constructor(e,t,i,s){super(e),this._type="convolution",this._params=[i,s],this._bufferOriginalUrl="",this._bufferUrl="",this._bufferType="",this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=s,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-s,this._convolveNode=this._audioContext["createConvolver"](),this._convolveNode["normalize"]=i,this._convolveNode["buffer"]=t,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(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){0===e&&(t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s))}_SetBufferInfo(e,t,i){this._bufferOriginalUrl=e,this._bufferUrl=t,this._bufferType=i}GetState(){const e=super.GetState();return e["bufferOriginalUrl"]=this._bufferOriginalUrl,e["bufferUrl"]="",e["bufferType"]=this._bufferType,e}},self.C3AudioFlangerFX=class extends a{constructor(e,t,i,s,o,a){super(e),this._type="flanger",this._params=[t,i,s,o,a],this._inputNode=this.CreateGain(),this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-a/2,this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=a/2,this._feedbackNode=this.CreateGain(),this._feedbackNode["gain"]["value"]=o,this._delayNode=this._audioContext["createDelay"](t+i),this._delayNode["delayTime"]["value"]=t,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=s,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=i,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(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[4]=t,this.SetAudioParam(this._wetNode["gain"],t/2,i,s),this.SetAudioParam(this._dryNode["gain"],1-t/2,i,s);break;case 6:this._params[1]=t/1e3,this.SetAudioParam(this._oscGainNode["gain"],t/1e3,i,s);break;case 7:this._params[2]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s);break;case 8:this._params[3]=t/100,this.SetAudioParam(this._feedbackNode["gain"],t/100,i,s)}}},self.C3AudioPhaserFX=class extends a{constructor(e,t,i,s,o,a,n){super(e),this._type="phaser",this._params=[t,i,s,o,a,n],this._inputNode=this.CreateGain(),this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-n/2,this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=n/2,this._filterNode=this._audioContext["createBiquadFilter"](),this._filterNode["type"]="allpass",this._filterNode["frequency"]["value"]=t,this._filterNode["detune"]["value"]=i,this._filterNode["Q"]["value"]=s,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=a,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=o,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(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[5]=t,this.SetAudioParam(this._wetNode["gain"],t/2,i,s),this.SetAudioParam(this._dryNode["gain"],1-t/2,i,s);break;case 1:this._params[0]=t,this.SetAudioParam(this._filterNode["frequency"],t,i,s);break;case 2:this._params[1]=t,this.SetAudioParam(this._filterNode["detune"],t,i,s);break;case 3:this._params[2]=t,this.SetAudioParam(this._filterNode["Q"],t,i,s);break;case 6:this._params[3]=t,this.SetAudioParam(this._oscGainNode["gain"],t,i,s);break;case 7:this._params[4]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioGainFX=class extends a{constructor(e,t){super(e),this._type="gain",this._params=[t],this._node=this.CreateGain(),this._node["gain"]["value"]=t}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){const o=self.AudioDOMHandler.DbToLinear;4===e&&(this._params[0]=o(t),this.SetAudioParam(this._node["gain"],o(t),i,s))}},self.C3AudioStereoPanFX=class extends a{constructor(e,t){super(e),this._type="stereopan",this._params=[t],this._node=this._audioContext["createStereoPanner"](),this._node["pan"]["value"]=t}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){t=Math.min(Math.max(t/100,-1),1),9===e&&(this._params[0]=t,this.SetAudioParam(this._node["pan"],t,i,s))}},self.C3AudioTremoloFX=class extends a{constructor(e,t,i){super(e),this._type="tremolo",this._params=[t,i],this._node=this.CreateGain(),this._node["gain"]["value"]=1-i/2,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=t,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=i/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(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._node["gain"],1-t/2,i,s),this.SetAudioParam(this._oscGainNode["gain"],t/2,i,s);break;case 7:this._params[0]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioRingModFX=class extends a{constructor(e,t,i){super(e),this._type="ringmod",this._params=[t,i],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=i,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-i,this._ringNode=this.CreateGain(),this._ringNode["gain"]["value"]=0,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=t,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(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 7:this._params[0]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioDistortionFX=class extends a{constructor(e,t,i,s,o,a){super(e),this._type="distortion",this._params=[t,i,s,o,a],this._inputNode=this.CreateGain(),this._preGain=this.CreateGain(),this._postGain=this.CreateGain(),this._SetDrive(s,o),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=a,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-a,this._waveShaper=this._audioContext["createWaveShaper"](),this._curve=new Float32Array(65536),this._GenerateColortouchCurve(t,i),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(e,t){this._preGain["gain"]["value"]=e=e<.01?.01:e,this._postGain["gain"]["value"]=Math.pow(1/e,.6)*t}_GenerateColortouchCurve(i,s){const o=32768;for(let t=0;t<o;++t){let e=t/o;e=this._Shape(e,i,s),this._curve[o+t]=e,this._curve[o-t-1]=-e}}_Shape(e,t,i){const s=1.05*i*t,o=s-t,a=e<0?-1:1,n=e<0?-e:e;let d=n<t?n:t+o*self.AudioDOMHandler.e4(n-t,1/o);return d*=a}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){0===e&&(t=Math.max(Math.min(t/100,1),0),this._params[4]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s))}},self.C3AudioCompressorFX=class extends a{constructor(e,t,i,s,o,a){super(e),this._type="compressor",this._params=[t,i,s,o,a],this._node=this._audioContext["createDynamicsCompressor"](),this._node["threshold"]["value"]=t,this._node["knee"]["value"]=i,this._node["ratio"]["value"]=s,this._node["attack"]["value"]=o,this._node["release"]["value"]=a}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){}},self.C3AudioAnalyserFX=class extends a{constructor(e,t,i){super(e),this._type="analyser",this._params=[t,i],this._node=this._audioContext["createAnalyser"](),this._node["fftSize"]=t,this._node["smoothingTimeConstant"]=i,this._freqBins=new Float32Array(this._node["frequencyBinCount"]),this._signal=new Uint8Array(t),this._peak=0,this._rms=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 e=this._node["fftSize"];let i=this._peak=0;for(let t=0;t<e;++t){let e=(this._signal[t]-128)/128;e<0&&(e=-e),this._peak<e&&(this._peak=e),i+=e*e}const t=self.AudioDOMHandler.LinearToDb;this._peak=t(this._peak),this._rms=t(Math.sqrt(i/e))}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){}GetData(){return{"tag":this.GetTag(),"index":this.GetIndex(),"peak":this._peak,"rms":this._rms,"binCount":this._node["frequencyBinCount"],"freqBins":this._freqBins}}}}

// start-export.js
"use strict";if(window["C3_Is_Supported"]){const a=false;window["c3_runtimeInterface"]=new self.RuntimeInterface({useWorker:a,workerMainUrl:"workermain.js",runtimeScriptList:["scripts/c3main.js"],scriptFolder:"scripts/",exportType:"html5"})}
