@needle-tools/engine 3.10.3-beta → 3.10.4-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/needle-engine.js +1 -1
- package/dist/needle-engine.light.js +1 -1
- package/dist/needle-engine.light.min.js +1 -1
- package/dist/needle-engine.light.umd.cjs +1 -1
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine-components/ui/Canvas.js +3 -1
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/package.json +1 -1
- package/src/engine-components/ui/Canvas.ts +3 -1
|
@@ -5018,7 +5018,7 @@ void main() {
|
|
|
5018
5018
|
justify-content: center;
|
|
5019
5019
|
align-items: flex-start;
|
|
5020
5020
|
gap: 10px;
|
|
5021
|
-
`,this.context.appendHTMLElement(e);const i=YR;YR&&console.log("ARSupported?",Ll,"VRSupported?",xl),(i||this.createARButton&&this.enableAR&&Ll)&&(t=Oi.createARButton(this),this._arButton=t,e.appendChild(t)),(i||this.createVRButton&&this.enableVR&&xl)&&(A=Oi.createVRButton(this),this._vrButton=A,e.appendChild(A)),setTimeout(()=>{Oi.resetButtonStyles(A),Oi.resetButtonStyles(t)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(t){var A;if(!t)return;const e=this.context.renderer.xr.getSession();if(e){const i=t.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!i)return;this._currentHeadPose=i;const g=i?.transform;g&&this._transformOrientation.set(g.orientation.x,g.orientation.y,g.orientation.z,g.orientation.w),Oi._isInXr===!1&&e&&this.onEnterXR(e,t);for(const I of this.controllers)I.onUpdate(e);this._isInAR&&((A=this.webAR)==null||A.onUpdate(e,t))}Oi.events.dispatchEvent({type:"xrUpdate",frame:t,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let t=0;t<2;t++)mi.Create(this,t,this.gameObject,RE.PhysicalDevice);Oi.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(ue(this.context.mainCamera)),this._originalCameraRotation.copy(Ti(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){const t=tA.findObjectOfType(Ey,this.context);t?(this.rig=t.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new co,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(t,A){var e,i;console.log("[XR] session begin",t,A),Oi._isInXr=!0,this.ensureRig();const g=this.context.renderer.xr.getReferenceSpace();if(g&&this.rig){const s=A.getViewerPose(g),C=s?.transform.orientation;if(C){const a=new xA(C.x,C.y,C.z,C.w),n=new og().setFromQuaternion(a);this.rig.rotateY(n.y)}}const I=this.context.renderer.xr;if(this.context.mainCamera){const s=I.getCamera();YR&&console.log("WebXRCamera",s);const C=(e=this.context.mainCameraComponent)==null?void 0:e.cullingMask;if(s&&C!==void 0){for(const a of s.cameras)a.layers.mask=C;s.layers.mask=C}else if(s){for(const a of s.cameras)a.layers.enableAll();s.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const o=this._requestedAR?Si.AR:Si.VR;switch(Ws.Global.Set(o),o){case Si.AR:this.context.xrSessionMode=gl.ImmersiveAR,this._isInAR=!0,(i=this.webAR)==null||i.onBegin(t);break;case Si.VR:this.context.xrSessionMode=gl.ImmersiveVR,this._isInVR=!0,this.onEnterVR(t);break}t.addEventListener("end",()=>{console.log("[XR] session end"),Oi._isInXr=!1,this.onExitXR(t)}),this.onEnterXR_HandleMirrorWindow(t),Oi.events.dispatchEvent({type:"xrStarted",session:t})}onExitXR(t){var A,e,i,g;const I=this._isInAR;t&&(this._isInAR?(A=this.webAR)==null||A.onEnd(t):(e=this.context.mainCameraComponent)==null||e.applyClearFlagsIfIsActiveCamera()),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&((i=this._originalCameraParent)==null||i.add(this.context.mainCamera),ai(this.context.mainCamera,this._originalCameraPosition),uI(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),I&&((g=this._originalXRRigParent)==null||g.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Ws.Global.Set(Si.Browser|Si.ThirdPerson),Oi.events.dispatchEvent({type:"xrStopped",session:t})}onEnterVR(t){}destroyControllers(){var t;for(let A=this.controllers.length-1;A>=0;A-=1)(t=this.controllers[A])==null||t.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(t){oA("mirror")&&setTimeout(()=>{if(!Oi.IsInWebXR)return;const A=new URL(window.location.href);Yh(A.searchParams,xw,1),Yh(A.searchParams,"isMirror",1);const e=A.toString();this.xrMirrorWindow=window.open(e,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Oi.IsInWebXR&&t.end()})})},1e3)}},r(NE,"_isInXr",!1),r(NE,"events",new qi),r(NE,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),r(NE,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),NE);let Se=Oi;FE([y()],Se.prototype,"enableVR",2),FE([y()],Se.prototype,"enableAR",2),FE([y(Kg)],Se.prototype,"defaultAvatar",2),FE([y()],Se.prototype,"handModelPath",2),FE([y()],Se.prototype,"createVRButton",2),FE([y()],Se.prototype,"createARButton",2);const Tl=class{constructor(t){r(this,"_webxr"),r(this,"reticle",null),r(this,"reticleParent",null),r(this,"hitTestSource",null),r(this,"reticleActive",!0),r(this,"previousBackground",null),r(this,"previousEnvironment",null),r(this,"sessionRoot",null),r(this,"_previousParent",null),r(this,"arDomOverlay",null),r(this,"arOverlayElement",null),r(this,"noHitTestAvailable",!1),r(this,"didPlaceARSessionRoot",!1),this._webxr=t}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const t=this.arDomOverlay;return t.getAROverlayContainer?this.arOverlayElement=t.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(t){this.reticleActive=t}async onBegin(t){var A,e,i,g;const I=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const o=(A=navigator.userAgent)!=null&&A.includes("OculusBrowser")?RE.PhysicalDevice:RE.Touch,s=o===RE.Touch?4:2;for(let a=0;a<s;a++)mi.Create(this.webxr,a,this.webxr.gameObject,o);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=tA.findObjectOfType(js,I)),!this.sessionRoot){const a=this.webxr.gameObject;this.sessionRoot=tA.addNewComponent(a,js),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=I.scene.background,this.previousEnvironment=I.scene.environment,I.scene.background=null,t.requestReferenceSpace("viewer").then(a=>{var n,B;(B=(n=t.requestHitTestSource)==null?void 0:n.call(t,{space:a}))==null||B.then(Q=>{this.hitTestSource=Q}).catch(Q=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",Q)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new fA(new cp(.07,.09,32).rotateX(-Math.PI/2),new Et),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new vA,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,Tl.tempWebXRObject||(Tl.tempWebXRObject=new vA),this.context.scene.add(Tl.tempWebXRObject),tA.addComponent(Tl.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(e=this.sessionRoot)==null||e.onBegin(t)):console.warn("No WebARSessionRoot found in scene");const C=this.context.domElement;(i=C?.onEnterAR)==null||i.call(C,t,this.arOverlayElement),(g=this.context.mainCameraComponent)==null||g.applyClearFlagsIfIsActiveCamera()}onEnd(t){var A,e;this._previousParent&&(tA.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const i=this.webxr.context;i.scene.background=this.previousBackground,i.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,t);const g=this.context.domElement;(A=g.onExitAR)==null||A.call(g,t),(e=this.context.mainCameraComponent)==null||e.applyClearFlagsIfIsActiveCamera()}onUpdate(t,A){var e,i;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const I=this.webxr.Rig,o=fgA.clone();(e=this.sessionRoot)==null||e.placeAt(I,o)}return}if(!this.hitTestSource)return;const g=A.getHitTestResults(this.hitTestSource);if(g.length){const I=g[0],o=this.webxr.context.renderer.xr.getReferenceSpace();if(o){const s=I.getPose(o);if(this.sessionRoot){const C=this.sessionRoot.onUpdate(this.webxr.Rig,t,s);this.didPlaceARSessionRoot=C}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&s)){const C=s.transform.matrix;this.reticle.matrix.fromArray(C),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(i=this.sessionRoot)==null||i.onUpdate(this.webxr.Rig,t,null),this.reticle&&(this.reticle.visible=!1)}};let Yl=Tl;r(Yl,"tempWebXRObject");const fgA=new JA().identity().makeTranslation(0,0,0);class Ja{constructor(A,e){r(this,"used",!1),r(this,"inputSource"),r(this,"object"),r(this,"pointerId"),r(this,"isDown"),r(this,"isUp"),r(this,"isPressed"),r(this,"isClicked"),r(this,"input"),r(this,"event"),this.event=e,this.input=A}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var A;(A=this.event)==null||A.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var A;(A=this.event)==null||A.stopImmediatePropagation()}clone(){const A=new Ja(this.input,this.event);return Object.assign(A,this),A}}class KE extends UA{awake(){ZI.createIfNoneExists(this.context)}onEnable(){var A;(A=ZI.get(this.context))==null||A.register(this)}onDisable(){var A;(A=ZI.get(this.context))==null||A.unregister(this)}performRaycast(A=null){return null}}class aa extends KE{constructor(){super(...arguments),r(this,"targets",null),r(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(A=null){return this.targets?(A??(A=new es),A.targets=this.targets,A.results=this.raycastHits,this.context.physics.raycast(A)):null}}class HR extends aa{}const Hl=oA("debugeventsystem");var OR=(t=>(t.BeforeHandleInput="BeforeHandleInput",t.AfterHandleInput="AfterHandleInput",t))(OR||{});const na=class extends UA{constructor(){super(),r(this,"raycaster",[]),r(this,"_selectStartFn"),r(this,"_selectEndFn"),r(this,"_selectUpdateFn"),r(this,"_handleEventFn"),r(this,"lastPointerEvent",null),r(this,"objectsHoveredThisFrame",[]),r(this,"objectsHoveredLastFrame",[]),r(this,"raisedPointerDownEvents",[]),r(this,"raisedPointerDownObjects",[]),r(this,"_didMove",!1),r(this,"_tempComponentsArray",[]),r(this,"_sortedHits",[]),r(this,"_sortingBuffer",[]),r(this,"_noDepthTestingResults",[]),r(this,"handleEventsArray",[]),r(this,"out",{}),r(this,"currentActiveMeshUIComponents",[]),na.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,na.systems.length<=0&&na.systems.push(...tA.findObjectsOfType(na,t)));for(const e of na.systems)if(e.context===t)return;const A=new vA;tA.addNewComponent(A,na),t.scene.add(A)}static get systems(){const t=be.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const A=this._eventSystemMap.get(t);return A&&A.length>0?A[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,A){ra.update(t,A)}static markUIDirty(t){ra.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){na.systems.splice(na.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!tA.findObjectOfType(KE,this.context)){const t=tA.addNewComponent(this.context.scene,aa);this.raycaster.push(t),$t()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(t){var A;t&&this.raycaster&&!this.raycaster.includes(t)&&((A=this.raycaster)==null||A.push(t))}unregister(t){var A,e;const i=(A=this.raycaster)==null?void 0:A.indexOf(t);i!==void 0&&i!==-1&&((e=this.raycaster)==null||e.splice(i,1))}onEnable(){const t=new Map;this._selectStartFn??(this._selectStartFn=(e,i)=>{if(!i.grab)return;ra.resetLastSelected();const g=new Ja(this.context.input);g.inputSource=e,g.pointerId=0,g.isDown=e.selectionDown,g.isUp=e.selectionUp,g.isPressed=e.selectionPressed,g.isClicked=!1,t.set(e,i.grab),i.grab&&!this.handleEvents(i.grab,g)&&(i.grab=null)}),this._selectEndFn??(this._selectEndFn=(e,i)=>{var g;if(!i.grab)return;const I=new Ja(this.context.input);I.inputSource=e,I.pointerId=0,I.isDown=e.selectionDown,I.isUp=e.selectionUp,I.isPressed=e.selectionPressed,I.isClicked=e.selectionClick,this.handleEvents(i.grab,I);const o=t.get(e);if(t.set(e,null),o)for(let s=0;s<this.raisedPointerDownEvents.length;s++){const C=this.raisedPointerDownEvents[s];this.raisedPointerDownObjects[s]===o&&C&&((g=C.onPointerUp)==null||g.call(C,I),this.raisedPointerDownEvents.splice(s,1),this.raisedPointerDownObjects.splice(s,1),s--)}});const A=new es;this._selectUpdateFn??(this._selectUpdateFn=e=>{A.ray=e.getRay();const i=this.performRaycast(A);if(!i)return;const g=new Ja(this.context.input);g.inputSource=e,this.handleIntersections(i,g)}),mi.addEventListener(sa.SelectStart,this._selectStartFn),mi.addEventListener(sa.SelectEnd,this._selectEndFn),mi.addEventListener(sa.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){mi.removeEventListener(sa.SelectStart,this._selectStartFn),mi.removeEventListener(sa.SelectEnd,this._selectEndFn),mi.removeEventListener(sa.Update,this._selectUpdateFn),this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._handleEventFn),1)}onHandleEvents(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),Se.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const I=this.context.input.getPointerPositionRC(0);if(I&&I.x===0&&I.y===0)return;this._didMove=!0}let t=0;for(const I of this.context.input.foreachPointerId()){const o=this.context.input.getPointerDown(I),s=this.context.input.getPointerUp(I);if(o||s){t=I;break}}const A=this.context.input.getPointerEvent(t),e=new Ja(this.context.input,A);e.inputSource=this.context.input,e.pointerId=t,e.isClicked=this.context.input.getPointerClicked(t),e.isDown=this.context.input.getPointerDown(t),e.isUp=this.context.input.getPointerUp(t),e.isPressed=this.context.input.getPointerPressed(t),Hl&&e.isClicked&&console.log("CLICK",t);const i=this.performRaycast(null);if(!i)return;this.lastPointerEvent=e;const g={sender:this,args:e,hasActiveUI:this.currentActiveMeshUIComponents.length>0};Hl&&e.isClicked&&pi("EventSystem: "+e.pointerId+" - "+this.context.time.frame+" - Up:"+e.isUp+", Down:"+e.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:g})),this.handleIntersections(i,e),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:g}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const A of this.raisedPointerDownEvents)A.onPointerUp&&A.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const A of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(A)<0){this._tempComponentsArray.length=0;const e=tA.getComponentsInParent(A,UA,this._tempComponentsArray);this.lastPointerEvent.object=A;for(let i=0;i<e.length;i++){const g=e[i];if(!g.gameObject||g.destroyed)continue;const I=g;I.onPointerExit&&I.onPointerExit(this.lastPointerEvent)}}const t=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=t}performRaycast(t){if(!this.raycaster)return null;this._sortedHits.length=0;for(const A of this.raycaster){if(!A.activeAndEnabled)continue;const e=A.performRaycast(t);e&&e.length>0&&this._sortedHits.push(...e)}return this._sortedHits.sort((A,e)=>A.distance-e.distance),this._sortedHits}handleIntersections(t,A){if(!t||t.length<=0)return!1;t=this.sortCandidates(t);for(const e of t){const{object:i}=e;if(this.handleEvents(i,A))return!0}return!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let A=0;A<t.length;A++){const e=t[A],i=e.object;if(i.material&&i.material.depthTest===!1){this._noDepthTestingResults.push(e);continue}this._sortingBuffer.push(e)}for(const A of this._sortingBuffer)this._noDepthTestingResults.push(A);return this._noDepthTestingResults}handleEvents(t,A){if(!this.testIsVisible(t))return A.isClicked&&Hl&&console.log("not allowed",t),!1;const e=t;A.object=t,this.lastPointerEvent=A;const i=t.parent;let g=!1;const I=A.isClicked??!1;let o=null;if(i&&i.isUI){const s=(A.isPressed||A.isClicked)??!1;if(i[$s]){const C=i[$s].gameObject;if(C){if(!ME.isInteractable(C,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,s),t=C,g=!0}}if(!g&&this.handleMeshUiObjectWithoutShadowDom(i,s))return!0}if(I&&Hl&&console.log(this.context.time.frame,t),this.objectsHoveredThisFrame.push(t),o===null||o.interactable){const s=this.objectsHoveredLastFrame.indexOf(t)>=0;this.handleEventsArray.length=0;const C=tA.getComponentsInParent(t,UA,this.handleEventsArray);for(let a=0;a<C.length;a++){if(A.used)return!0;if(C[a].destroyed)continue;const n=C[a];if(n.interactable!==!1){if(n.onPointerEnter&&(s||n.onPointerEnter(A)),n.onPointerMove&&n.onPointerMove(A),A.isDown&&n.onPointerDown&&!this.raisedPointerDownEvents.includes(n)&&(n.onPointerDown(A),this.raisedPointerDownEvents.push(n),this.raisedPointerDownObjects.push(e)),A.isUp&&n.onPointerUp){const B=this.raisedPointerDownEvents.indexOf(n);B!==-1&&this.raisedPointerDownEvents.splice(B,1),n.onPointerUp(A)}A.isClicked&&n.onPointerClick&&n.onPointerClick(A)}}}return!0}handleMeshUiObjectWithoutShadowDom(t,A){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,A)}handleMeshUIIntersection(t,A){const e=ra.updateState(t,A);return e&&this.currentActiveMeshUIComponents.push(e),e!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&ra.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const A=this.currentActiveMeshUIComponents[t];ra.resetState(A)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?tA.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let ZI=na;r(ZI,"_eventSystemMap",new Map),r(ZI,"didSearchEventSystem",!1);class ra{static markDirty(){this.needsUpdate=!0}static update(A,e){const i=e.time.frameCount;for(const g of this.lastUpdateFrame)if(g.context===e){if(i===g.frame)return;g.frame=i;let I=this.needsUpdate||i<1;g.nextUpdate===e.time.frameCount&&(I=!0),I&&(Hl&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:i,nextUpdate:i}],A.update()}static updateState(A,e){let i=null;if(A&&(i=this.findBlockInParent(A),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}r(ra,"lastSelected",null),r(ra,"lastUpdateFrame",[]),r(ra,"needsUpdate",!1);const cy=Symbol("cameraController");function mgA(t){return t[cy]}function U2(t,A,e){e?t[cy]=A:t[cy]===A&&(t[cy]=null)}var kgA=Object.defineProperty,GgA=Object.getOwnPropertyDescriptor,MgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?GgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&kgA(A,e,g),g};const ly=oA("freecam"),_R=oA("debugcamerafit"),RgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let PR;class Ba extends UA{constructor(){super(...arguments),r(this,"autoRotate",!1),r(this,"autoRotateSpeed",1),r(this,"enableKeys",!0),r(this,"enableDamping",!0),r(this,"dampingFactor",.1),r(this,"enableZoom",!0),r(this,"minZoom",0),r(this,"maxZoom",1/0),r(this,"enablePan",!0),r(this,"lookAtConstraint",null),r(this,"lookAtConstraint01",1),r(this,"middleClickToFocus",!0),r(this,"doubleClickToFocus",!0),r(this,"useSlerp",!0),r(this,"debugLog",!1),r(this,"targetLerpSpeed",5),r(this,"_lookTargetPosition"),r(this,"_controls",null),r(this,"_cameraObject",null),r(this,"_lerpToTargetPosition",!1),r(this,"_lerpCameraToTarget",!1),r(this,"_cameraTargetPosition",null),r(this,"_inputs",0),r(this,"_enableTime",0),r(this,"_startedListeningToKeyEvents",!1),r(this,"_eventSystem"),r(this,"_afterHandleInputFn"),r(this,"_camera",null),r(this,"_syncedTransform"),r(this,"targetElement",null),r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),r(this,"_shouldDisable",!1),r(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(A){var e;(e=this.controls)==null||e.addEventListener("start",A)}awake(){this._lookTargetPosition=new S,this._startedListeningToKeyEvents=!1}start(){if(this._controls){const A=tA.getComponent(this.gameObject,Tt);if(A&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const e=ue(A.cam).length(),i=new S(0,0,-e).applyMatrix4(A.cam.matrixWorld);this.setTarget(i,!0)}}this.startCoroutine(this.startRaycastDelayed()),this._eventSystem=ZI.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(OR.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var A,e;(A=this._controls)==null||A.dispose(),(e=this._eventSystem)==null||e.removeEventListener(OR.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const A=tA.getComponent(this.gameObject,Tt);this._camera=A;const e=A?.cam;if(e&&U2(e,this,!0),!this._controls){console.assert(e!=null,"Missing camera",this),e&&(this._cameraObject=e);const i=this.targetElement??this.context.domElement,g=e?.quaternion.clone();this._controls=new M$(e,i),e?.quaternion.copy(g),PR===void 0&&(PR={...this._controls.keys})}this._controls&&(ly&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Ha()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),e?.type==="PerspectiveCamera"?ly||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):ly||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=tA.getComponent(this.gameObject,Kn)??void 0}onDisable(){var A;(A=this._camera)!=null&&A.cam&&U2(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(A){A.detail.args.pointerId===0&&(A.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!A.detail.args.isPressed||A.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,!this.setFromTargetPosition()){const A=new es;A.screenPoint=new Z(0,0),A.lineThreshold=.1;const e=this.context.physics.raycast(A);e.length>0&&this.setTarget(e[0].point,!0)}}onBeforeRender(){var A,e,i;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.autoRotate=!1,this._controls.autoRotate=!1,this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let g=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(g||(g=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),g?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const I=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const o=(A=this._cameraObject)==null?void 0:A.position;bv(o,this._cameraTargetPosition,I)}else(e=this._cameraObject)==null||e.position.lerp(this._cameraTargetPosition,I);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,I),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!ly&&(i=this.lookAtConstraint)!=null&&i.locked&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls&&(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.enableDamping=this.enableDamping,this._controls.keys=this.enableKeys?PR:RgA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this.context.isInXR||this._controls.update())}setCameraTarget(A,e=!1){var i;A?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=A.clone(),e&&this._cameraTargetPosition&&((i=this.controllerObject)==null||i.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(A=0,e=1){var i;if(!this._controls)return!1;const g=(i=this.lookAtConstraint)==null?void 0:i.sources;if(g&&g.length>0){const I=g[A];if(I)return I.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,e),!0}return!1}setTarget(A=null,e=!1){this._controls&&(A!==null&&this._lookTargetPosition.copy(A),e?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(A,e){this._controls&&this._controls.target.lerp(A,e)}distanceToTarget(A){return this._controls?this._controls.target.distanceTo(A):-1}setTargetFromRaycast(){var A,e;if(!this.controls)return;const i=this.context.physics.raycast();for(const g of i)if(g.distance>0&&tA.isActiveInHierarchy(g.object)){if(this._lookTargetPosition.copy(g.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const I=ue(this.context.mainCamera);this._cameraTargetPosition=I.clone().sub(this.controls.target).add(this._lookTargetPosition),(e=(A=this._cameraObject)==null?void 0:A.parent)==null||e.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(A,e=1.1){const i=this._cameraObject,g=this._controls;if(A!=null&&A.length||(A=this.context.scene.children),A.length<=0||!i||!g)return;const I=new S,o=new S,s=new vi;s.makeEmpty();for(const l of A)l instanceof Mk||l instanceof Gk||s.expandByObject(l,!0);if(i.updateMatrixWorld(),i.updateProjectionMatrix(),s.getCenter(o),s.applyMatrix4(i.matrixWorldInverse),s.getSize(I),s.setFromCenterAndSize(o,I),I.length()<=1e-10){_R&&console.warn("Camera fit size is zero",s,[...A]);return}const C=i.fov,a=2*Math.atan(Math.tan(C*Math.PI/360/2)*i.aspect)/Math.PI*360,n=I.y/(2*Math.atan(Math.PI*C/360)),B=I.x/(2*Math.atan(Math.PI*a/360)),Q=e*Math.max(n,B)+I.z/2;_R&&console.log("Fit camera to objects",n,B,"distance",Q);const E=ue(i),h=g.target.clone().sub(E).normalize().multiplyScalar(Q);if(g.maxDistance=Q*10,g.minDistance=Q*.01,g.target.copy(o),i.near=Q/100,i.far=Q*100,i.updateMatrixWorld(),i.updateProjectionMatrix(),ai(i,g.target.clone().sub(h)),_R){const l=new Mk(s);this.context.scene.add(l),Pv(l,cD(i)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",d=>{d.code==="KeyF"&&this.fitCamera(A)}))}g.update()}}MgA([y(Dl)],Ba.prototype,"lookAtConstraint",2);var UgA=Object.defineProperty,FgA=Object.getOwnPropertyDescriptor,Ko=(t,A,e,i)=>{for(var g=i>1?void 0:i?FgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&UgA(A,e,g),g},F2=(t=>(t[t.Skybox=1]="Skybox",t[t.SolidColor=2]="SolidColor",t[t.Uninitialized=4]="Uninitialized",t))(F2||{});const Ol=oA("debugcam"),N2=oA("debugscreenpointtoray");var dy;const _l=(dy=class extends UA{constructor(){super(...arguments),r(this,"_nearClipPlane",.1),r(this,"_farClipPlane",1e3),r(this,"orthographic",!1),r(this,"orthographicSize",5),r(this,"ARBackgroundAlpha",0),r(this,"_cullingMask",4294967295),r(this,"_backgroundBlurriness"),r(this,"_backgroundIntensity"),r(this,"_targetTexture",null),r(this,"_backgroundColor"),r(this,"_fov"),r(this,"_cam",null),r(this,"_clearFlags",2),r(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof ze?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof ze?this._cam.fov:this._fov}set fieldOfView(t){const A=this.fieldOfView!=t;if(this._fov=t,A&&this._cam&&this._cam instanceof ze){if(this._fov===void 0){console.error("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(t){const A=this._nearClipPlane!=t;this._nearClipPlane=t,this._cam&&A&&(this._cam.near=t,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(t){const A=this._farClipPlane!=t;this._farClipPlane=t,this._cam&&A&&(this._cam.far=t,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(t){t!==this._clearFlags&&(this._clearFlags=t,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(t){this._cullingMask=t,this._cam&&(this._cam.layers.mask=t)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(t){t!==this._backgroundBlurriness&&(t===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(t,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(t){t!==this._backgroundIntensity&&(t===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(t,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(t){if(t){if(this._backgroundColor)this._backgroundColor.copy(t);else{if(!t.clone)return;this._backgroundColor=t.clone()}t.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(t){this._targetTexture=t}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(t,A,e){let i=this.cam;const g=_l._origin;g.set(t,A,-1),this.context.input.convertScreenspaceToRaycastSpace(g),N2&&console.log("screenPointToRay",t.toFixed(2),A.toFixed(2),"now:",g.x.toFixed(2),g.y.toFixed(2),"isInXR:"+this.context.isInXR),g.z=-1,g.unproject(i);const I=_l._direction.set(g.x,g.y,g.z),o=ue(i);return I.sub(o),I.normalize(),e?(e.set(o,I),e):new qs(o.clone(),I.clone())}awake(){N2&&window.addEventListener("pointerdown",t=>{const A=t.clientX,e=t.clientY;console.log("touch",A.toFixed(2),e.toFixed(2));const i=this.screenPointToRay(A,e),g="#"+Math.floor(Math.random()*16777215).toString(16);zC.DrawRay(i.origin,i.direction,g,10)})}onEnable(){Ol&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),KgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const t=this.context.renderer;t&&this._targetTexture.render(this.context.scene,this._cam,t)}}buildCamera(){if(this._cam)return;const t=this.gameObject.isCamera;let A=null;if(t?(A=this.gameObject,A?.layers.enableAll(),A instanceof ze&&(this._fov=A.fov)):A=this.gameObject.children[0],A&&A.isCamera)A instanceof ze&&(this._fov&&(A.fov=this._fov),A.near=this._nearClipPlane,A.far=this._farClipPlane,A.updateProjectionMatrix());else if(!this.orthographic)A=new ze(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(A.fov=this.fieldOfView),this.gameObject.add(A);else{const e=this.orthographicSize*100;A=new Fr(window.innerWidth/-e,window.innerWidth/e,window.innerHeight/e,window.innerHeight/-e,this._nearClipPlane,this._farClipPlane),this.gameObject.add(A)}this._cam=A,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){Ol&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,Ol&&pi("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(_l.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let t=this._backgroundColor.alpha;_l.backgroundShouldBeTransparent(this.context)&&(t=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,t)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new NgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(t){var A,e,i,g;const I=(A=t.renderer.xr)==null?void 0:A.getSession();if(!I)return!1;const o=I.environmentBlendMode;Ol&&pi("Environment blend mode: "+o+" on "+navigator.userAgent);const s=o==="additive"||o==="alpha-blend";return t.xrSessionMode===gl.ImmersiveAR&&o==="opaque"&&((e=navigator.userAgent)!=null&&e.includes("OculusBrowser")||(i=navigator.userAgent)!=null&&i.includes("Mozilla")&&(g=navigator.userAgent)!=null&&g.includes("Mobile WebXRViewer/v2"))?!0:s}},r(dy,"_origin",new S),r(dy,"_direction",new S),dy);let Tt=_l;Ko([y()],Tt.prototype,"fieldOfView",1),Ko([y()],Tt.prototype,"nearClipPlane",1),Ko([y()],Tt.prototype,"farClipPlane",1),Ko([y()],Tt.prototype,"clearFlags",1),Ko([y()],Tt.prototype,"orthographic",2),Ko([y()],Tt.prototype,"orthographicSize",2),Ko([y()],Tt.prototype,"ARBackgroundAlpha",2),Ko([y()],Tt.prototype,"cullingMask",1),Ko([y()],Tt.prototype,"backgroundBlurriness",1),Ko([y()],Tt.prototype,"backgroundIntensity",1),Ko([y(yt)],Tt.prototype,"backgroundColor",1),Ko([y(QE)],Tt.prototype,"targetTexture",1);class NgA{constructor(A){r(this,"_camera"),r(this,"_skybox"),this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Ol&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=Ie,this._skybox.mapping=no,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function KgA(t){oA("freecam")&&t.context.mainCameraComponent===t&&tA.getOrAddComponent(t.gameObject,Ba)}class JE extends UA{constructor(){super(...arguments),r(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new wk),this._listener}awake(){yi.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const A=this.listener;if(A==null||A.parent)return;const e=tA.getComponentInParent(this.gameObject,Tt);e?e.cam.add(A):this.gameObject.add(A)})}}var JgA=Object.defineProperty,qgA=Object.getOwnPropertyDescriptor,py=(t,A,e,i)=>{for(var g=i>1?void 0:i?qgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&JgA(A,e,g),g};const vgA=oA("debugsignals");class Pl{constructor(){r(this,"guid")}}py([y()],Pl.prototype,"guid",2);class qE{constructor(){r(this,"signal"),r(this,"reaction")}}py([y(Pl)],qE.prototype,"signal",2),py([y(SI)],qE.prototype,"reaction",2);var jR;const Qa=(jR=class extends UA{constructor(){super(...arguments),r(this,"events")}static invoke(t){if(Qa.receivers[t]){const A=Qa.receivers[t];if(!A)return;for(const e of A)e.invoke(t)}}awake(){vgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const t of this.events)Qa.receivers[t.signal.guid]||(Qa.receivers[t.signal.guid]=[]),Qa.receivers[t.signal.guid].push(this)}onDisable(){if(this.events){for(const t of this.events)if(Qa.receivers[t.signal.guid]){const A=Qa.receivers[t.signal.guid].indexOf(this);A>=0&&Qa.receivers[t.signal.guid].splice(A,1)}}}invoke(t){if(!this.events||!Array.isArray(this.events))return;let A=typeof t=="object"?t.guid:t;for(const e of this.events)if(e.signal.guid===A)try{if(e.reaction){if(!e.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",e,this);continue}}else{console.warn("Missing reaction for signal",e,this);continue}e.reaction.invoke()}catch(i){console.error(i)}}},r(jR,"receivers",{}),jR);let vE=Qa;py([y(qE)],vE.prototype,"events",2);var XI=(t=>(t.Activation="ActivationTrack",t.Animation="AnimationTrack",t.Audio="AudioTrack",t.Control="ControlTrack",t.Marker="MarkerTrack",t.Signal="SignalTrack",t))(XI||{}),eC=(t=>(t[t.None=0]="None",t[t.Hold=1]="Hold",t[t.Loop=2]="Loop",t[t.PingPong=3]="PingPong",t[t.Continue=4]="Continue",t))(eC||{}),WR=(t=>(t.Signal="SignalEmitter",t))(WR||{});const jl=oA("debugtimeline"),VR=class extends UA{constructor(){super(...arguments),r(this,"playableAsset"),r(this,"playOnAwake"),r(this,"extrapolationMode",1),r(this,"waitForAudio",!0),r(this,"_visibilityChangeEvt"),r(this,"_clonedPlayableAsset",!1),r(this,"_speed",1),r(this,"_guidsMap"),r(this,"_isPlaying",!1),r(this,"_internalUpdateRoutine"),r(this,"_isPaused",!1),r(this,"_time",0),r(this,"_duration",0),r(this,"_weight",1),r(this,"_animationTracks",[]),r(this,"_audioTracks",[]),r(this,"_signalTracks",[]),r(this,"_controlTracks",[]),r(this,"_customTracks",[]),r(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks])}static registerCreateTrack(t,A){this.createTrackFunctions[t]=A}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(jl||Yg())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,A,e;jl&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(A=this.playableAsset)==null?void 0:A.tracks,Array.isArray((e=this.playableAsset)==null?void 0:e.tracks),this)}onEnable(){var t,A;for(const e of this._audioTracks)(t=e.onEnable)==null||t.call(e);for(const e of this._customTracks)(A=e.onEnable)==null||A.call(e);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,A;this.stop();for(const e of this._audioTracks)(t=e.onDisable)==null||t.call(e);for(const e of this._customTracks)(A=e.onDisable)==null||A.call(e);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const A of this._allTracks)for(const e of A)(t=e.onDestroy)==null||t.call(e)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const A=[];for(const e of this._audioTracks){const i=e.loadAudio(this._time,1,0);i&&A.push(i)}if(A.length>0&&(await Promise.all(A),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!yi.userInteractionRegistered&&this.waitForAudio;)await Hh(200)}this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate())}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks()))}stop(){for(const e of this._audioTracks)e.stop();const t=this._isPaused==!0,A=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!A&&this.invokePauseChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null}evaluate(){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}this.internalEvaluate(t)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const A of t)yield A}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onPauseChanged)==null||t.call(A)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(t){for(const A of this.playableAsset.tracks)if(!A.muted)switch(A.type){case XI.Activation:for(let e=0;e<A.outputs.length;e++){const i=A.outputs[e];if(typeof i=="object"){let g=!1;for(const o of A.clips)o.start<=t&&t<=o.end&&(g=!0);const I=i;I.visible!==void 0&&(I.visible=g)}}break}for(const A of this._animationTracks)A.evaluate(t);for(const A of this._audioTracks)A.evaluate(t);for(const A of this._signalTracks)A.evaluate(t);for(const A of this._controlTracks)A.evaluate(t);for(const A of this._customTracks)A.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Gp(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const A of this.playableAsset.tracks){for(let e=A.outputs.length-1;e>=0;e--){let i=A.outputs[e];if(typeof i=="string"){this._guidsMap&&this._guidsMap[i]&&(i=this._guidsMap[i]);const g=tA.findByGuid(i,t);g===null||typeof g!="object"?(A.outputs.splice(e,1),console.warn("Failed to resolve binding",i,A.name,A.type)):(jl&&console.log("Resolved binding",i,"to",g),A.outputs[e]=g)}else if(i===null){if(A.outputs.splice(e,1),VR.createTrackFunctions[A.type])continue;A.type!==XI.Audio&&A.type!==XI.Control&&A.type!==XI.Marker&&A.type!==XI.Signal&&console.warn("Missing binding",i,A.name,A.type,this.name,this.playableAsset.name)}}if(A.type===XI.Control)for(let e=0;e<A.clips.length;e++){const i=A.clips[e];let g=i.asset.sourceObject;if(typeof g=="string"){this._guidsMap&&this._guidsMap[g]&&(g=this._guidsMap[g]);const I=tA.findByGuid(g,t);I===null||typeof I!="object"?console.warn("Failed to resolve sourceObject binding",g,A.name,i):(jl&&console.log("Resolved binding",g,"to",I),i.asset.sourceObject=I)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){for(const A of t.clips)A.end>this._duration&&(this._duration=A.end);for(const A of t.markers)A.time>this._duration&&(this._duration=A.time+.001)}}}setupAndCreateTrackHandlers(){var t,A;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const e=tA.findObjectOfType(JE,this.context);for(const i of this.playableAsset.tracks){const g=i.type,I=VR.createTrackFunctions[g];if(I!=null){const o=I(this,i);if(typeof o.evaluate=="function"){o.director=this,o.track=i,this._customTracks.push(o);continue}}if(i.type===XI.Animation){if(i.clips.length<=0){jl&&console.warn("Animation track has no clips",i);continue}for(let o=i.outputs.length-1;o>=0;o--){let s=i.outputs[o];if(s instanceof vA){const a=tA.getOrAddComponent(s,tI);a&&(s=a)}const C=(t=s?.gameObject)==null?void 0:t.animations;if(C){const a=new uy;a.trackOffset=i.trackOffset,a.director=this,a.track=i;for(let n=0;n<i.clips.length;n++){const B=i.clips[n],Q=B.asset;if(!Q){console.error("MISSING anim model?","clip#"+n,B,i,this.playableAsset,this.name);continue}const E=Q.clip;let h=E;if((typeof h=="string"||typeof h=="number")&&(h=C.find(d=>d.name===E)),!h){console.warn("Could not find animationClip for model",B,i.name,this.name,(A=this.playableAsset)==null?void 0:A.name);continue}a.mixer||(a.mixer=new tD(s.gameObject)),a.clips.push(h),a.mixer.uncacheAction(h),a.createHooks(B.asset,h);const l=a.mixer.clipAction(h);a.actions.push(l),a.models.push(B)}this._animationTracks.push(a)}}}else if(i.type===XI.Audio){if(i.clips.length<=0)continue;const o=new zl;if(o.director=this,o.track=i,this._audioTracks.push(o),!e)continue;o.listener=e.listener;for(let s=0;s<i.clips.length;s++){const C=i.clips[s];o.addModel(C)}}else if(i.type===XI.Marker){const o=new Zl;o.director=this,o.track=i;for(const s of i.markers)switch(s.type){case WR.Signal:o.models.push(s),o.didTrigger.push(!1);break}if(o!==null&&o.models.length>0){const s=tA.getComponent(this.gameObject,vE);s&&(o.receivers.push(s),this._signalTracks.push(o))}}else if(i.type===XI.Signal){const o=new Zl;o.director=this,o.track=i;for(const s of i.markers)o.models.push(s),o.didTrigger.push(!1);for(const s of i.outputs)o.receivers.push(s);this._signalTracks.push(o)}else if(i.type===XI.Control){const o=new Dy;o.director=this,o.track=i;for(const s of i.clips)o.models.push(s);o.resolveSourceObjects(this.context),this._controlTracks.push(o)}}}setAudioTracksAllowPlaying(t){for(const A of this._audioTracks)A.onAllowAudioChanged(t)}};let nB=VR;r(nB,"createTrackFunctions",{});const rB=oA("debugtimeline");class Wl{constructor(){r(this,"director"),r(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,i,g=!0){if(e<0||e>=i.length)return 0;const I=i[e];if(g||A>=I.start&&A<=I.end){let o=1,s=!1;if(I.easeInDuration>0){const C=Math.min((A-I.start)/I.easeInDuration,1);o*=C}if(I.easeOutDuration>0&&!s){const C=Math.min((I.end-A)/I.easeOutDuration,1);o*=C}return o}return 0}}class bgA{constructor(A){r(this,"clip"),r(this,"rootPositionOffset"),r(this,"rootQuaternionOffset"),r(this,"rootStartPosition"),r(this,"rootEndPosition"),r(this,"rootStartQuaternion"),r(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const i=A.getRoot(),g=i.name+".position",I=i.name+".quaternion";rB&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new S().fromArray(o.values,0),this.rootEndPosition=new S().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),rB&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new xA().fromArray(o.values,0),this.rootEndQuaternion=new xA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),rB)){const s=new og().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class uy extends Wl{constructor(){super(...arguments),r(this,"models",[]),r(this,"trackOffset"),r(this,"target"),r(this,"mixer"),r(this,"clips",[]),r(this,"actions",[]),r(this,"_actionOffsets",[]),r(this,"_didBind",!1),r(this,"_animator",null),r(this,"_animatorWasEnabled",!1),r(this,"_useclipOffsets",!0),r(this,"_totalOffsetPosition",new S),r(this,"_totalOffsetRotation",new xA),r(this,"_totalOffsetPosition2",new S),r(this,"_totalOffsetRotation2",new xA),r(this,"_summedPos",new S),r(this,"_tempPos",new S),r(this,"_summedRot",new xA),r(this,"_tempRot",new xA),r(this,"_clipRotQuat",new xA)}onPauseChanged(){this._animator&&this._animatorWasEnabled!==void 0&&(this._animator.enabled=this.director.isPlaying===!1?this._animatorWasEnabled:!1)}createHooks(A,e){var i,g;if(((i=e.tracks)==null?void 0:i.length)<=0){console.warn("No tracks in AnimationClip",e);return}const I=e.tracks[0].name.split("."),o=I[I.length-2],s=o+".position",C=o+".quaternion";let a=!1,n=!1;for(const B of e.tracks)B.name.endsWith(s)?(a=!0,this.createPositionInterpolant(e,A,B)):B.name.endsWith(C)&&(n=!0,this.createRotationInterpolant(e,A,B));if(!a||!n){const B=(g=this.mixer)==null?void 0:g.getRoot(),Q=e.tracks[0],E=Q.name.lastIndexOf("."),h=Q.name.substring(0,E),l=h.substring(h.lastIndexOf(".")+1),d=B.getObjectByName(l);if(d)if(a){if(!n){const c=e.tracks[0].name.substring(0,E)+".quaternion";rB&&console.warn("Create quaternion track",l,d);const u=d.quaternion,p=new vs(c,[0,e.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);e.tracks.push(p),this.createRotationInterpolant(e,A,p)}}else{const c=h+".position";rB&&console.warn("Create position track",l,d);const u=d.position,p=new on(c,[0,e.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);e.tracks.push(p),this.createPositionInterpolant(e,A,p)}}}bind(){if(!this._didBind){this._didBind=!0,rB&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const A of this.actions){const e=new bgA(A);this._actionOffsets.push(e)}this.target&&(this._animator=tA.getComponent(this.target,tI)??null,this._animator?(this._animatorWasEnabled=this._animator.enabled,this._animator.enabled=!1):this._animatorWasEnabled=!1);for(const A of this.models){const e=A.asset,i=e.position,g=e.rotation;i&&i.x!==void 0&&(i.isVector3||(e.position=new S(i.x,i.y,i.z)),g.isQuaternion||(e.rotation=new xA(g.x,g.y,g.z,g.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const A=this.trackOffset.position;A&&(A.isVector3||(this.trackOffset.position=new S(A.x,A.y,A.z)));const e=this.trackOffset.rotation;e&&(e.isQuaternion||(this.trackOffset.rotation=new xA(e.x,e.y,e.z,e.w)))}}evaluate(A){if(this.track.muted||!this.mixer)return;this.bind(),this._animator&&this.director.isPlaying&&this.director.weight>0&&(this._animator.enabled=!1),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let e=0,i=0,g=!1,I=!1;for(let o=0;o<this.clips.length;o++){const s=this.models[o],C=this.actions[o],a=s.asset;C.weight=0;const n=A>=s.start&&A<=s.end,B=s.preExtrapolationMode,Q=s.postExtrapolationMode,E=o<this.clips.length-1?this.models[o+1]:null;let h=n,l=!1;if(!h&&!g&&s.end<A&&Q!==eC.None?(!E||E.start>A)&&(h=!0,g=!0):o==0&&!h&&!I&&s.start>A&&B!==eC.None&&(!E||E.start<A)&&(h=!0,l=!0,I=!0),h){let d=1;d*=this.evaluateWeight(A,o,this.models,h),d*=this.director.weight;let c=n;if(l)switch(B){case eC.Hold:break;case eC.Loop:A+=s.start,c=!0;break;default:A+=s.start,c=!0;break}let u=this.getClipTime(A,s),p=0;const D=a.duration;if(l&&B===eC.Hold&&(u=0),c){if(a.loop)for(p+=Math.floor(u/(D+1e-6));u>D;)u-=D}else if(!n&&g)switch(Q){case eC.Hold:u=this.getClipTime(s.end,s);break;case eC.Loop:u%=D;break;case eC.PingPong:const m=Math.floor(u/D)%2!==0;u%=D,m&&(u=D-u);break}s.reversed===!0?C.time=C.getClip().duration-u:C.time=u,C.timeScale=0;const w=d;if(C.weight=w,C.clampWhenFinished=!0,C.isRunning()||C.play(),this._useclipOffsets){const m=e==0?this._totalOffsetPosition:this._totalOffsetPosition2,M=e==0?this._totalOffsetRotation:this._totalOffsetRotation2;e<1&&(i=1-d),e+=1;const F=this._summedPos.set(0,0,0),k=this._tempPos.set(0,0,0),f=this._summedRot.identity(),b=this._tempRot.identity(),O=a.rotation;O&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(O,d));const L=this._actionOffsets[o];if(L.hasOffsets)for(let T=0;T<p;T++)L.rootPositionOffset?k.copy(L.rootPositionOffset):k.set(0,0,0),k.applyQuaternion(f),this._clipRotQuat&&k.applyQuaternion(this._clipRotQuat),L.rootQuaternionOffset&&(b.copy(L.rootQuaternionOffset),f.multiply(b)),F.add(k);this._clipRotQuat&&M.multiply(this._clipRotQuat),M.multiply(f),a.position&&F.add(a.position),m.add(F)}}}this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,i),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,i)),this.mixer.update(A)}createRotationInterpolant(A,e,i){var g;const I=i.createInterpolant.bind(i),o=new xA;this.ensureTrackOffsets();const s=(g=this.trackOffset)==null?void 0:g.rotation;i.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=n=>{const B=a(n);return o.set(B[0],B[1],B[2],B[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),B[0]=o.x,B[1]=o.y,B[2]=o.z,B[3]=o.w,B},C}}createPositionInterpolant(A,e,i){var g,I;const o=i.createInterpolant.bind(i),s=new S;this.ensureTrackOffsets();const C=(g=this.trackOffset)==null?void 0:g.rotation,a=(I=this.trackOffset)==null?void 0:I.position;let n;i.createInterpolant=()=>{const B=o(),Q=B.evaluate.bind(B);return B.evaluate=E=>{var h,l;const d=Q(E);return s.set(d[0],d[1],d[2]),e.removeStartOffset&&(n===void 0?(n=null,n=(l=(h=this._actionOffsets.find(c=>c.clip===A))==null?void 0:h.rootStartPosition)==null?void 0:l.clone()):n!=null&&n.isVector3&&s.sub(n)),s.applyQuaternion(this._totalOffsetRotation),s.add(this._totalOffsetPosition),C&&s.applyQuaternion(C),a&&(s.x-=a.x,s.y+=a.y,s.z+=a.z),d[0]=s.x,d[1]=s.y,d[2]=s.z,d},B}}}const LgA=oA("mutetimeline"),Vl=class extends Wl{constructor(){super(...arguments),r(this,"models",[]),r(this,"listener"),r(this,"audio",[]),r(this,"audioContextTimeOffset",[]),r(this,"lastTime",0),r(this,"_audioLoader",null)}getAudioFilePath(t){const A=this.director.sourceId;return Ya(A,t)}onAllowAudioChanged(t){for(let A=0;A<this.models.length;A++){const e=this.models[A];this.audio[A].setVolume(t?e.asset.volume:0)}}addModel(t){const A=new eD(this.listener);this.audio.push(A),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&t?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}evaluate(t){if(LgA||this.track.muted||this.director.speed<0)return;const A=this.director.context.application.muted,e=A?.1:0;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=this.audio[i];if((!I||!I.buffer)&&this.isInTimeRange(g,t-1,t+1)&&this.handleAudioLoading(g,I),yi.userInteractionRegistered!==!1&&!(I===null||!I.buffer))if(I.playbackRate=this.director.context.time.timeScale,I.loop=g.asset.loop,t>=g.start&&t<=g.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(I.isPlaying&&I.stop(),this.lastTime===t)continue}else if(!I.isPlaying)I.offset=g.clipIn+(t-g.start)*g.timeScale,I.play(e);else{const s=g.clipIn+(t-g.start)*g.timeScale,C=I.context.currentTime-I._startedAt+I.offset;Math.abs(s-C)>.3&&(I.offset=s,I.stop(),I.play(e))}let o=g.asset.volume;if(A&&(o=0),g.easeInDuration>0){const s=Math.min((t-g.start)/g.easeInDuration,1);o*=s}if(g.easeOutDuration>0){const s=Math.min((g.end-t)/g.easeOutDuration,1);o*=s}I.setVolume(o*this.director.weight)}else I.isPlaying&&I.stop()}this.lastTime=t}loadAudio(t,A=0,e=0){let i=null;const g=t-e,I=t+A;for(const o of this.models)if(this.isInTimeRange(o,g,I)){const s=this.audio[this.models.indexOf(o)],C=this.handleAudioLoading(o,s);C!==null&&(i===null&&(i=[]),i.push(C))}return i!==null?Promise.all(i):null}isInTimeRange(t,A,e){return A<=t.start&&e>=t.end||A>=t.start&&A<=t.end||e>=t.start&&e<=t.end}static dispose(){Vl._audioBuffers.clear()}handleAudioLoading(t,A){this._audioLoader||(this._audioLoader=new $u);const e=this.getAudioFilePath(t.asset.clip);if(Vl._audioBuffers.get(e)){const g=Vl._audioBuffers.get(e);return g.then(I=>{I&&A.setBuffer(I)}),g}rB&&console.warn("LOAD audio track",e,this.director.sourceId);const i=new Promise((g,I)=>{this._audioLoader.load(e,o=>{A.setBuffer(o),g(o)},void 0,o=>{console.error("Error loading audio",o),g(null)})});return Vl._audioBuffers.set(e,i),i}};let zl=Vl;r(zl,"_audioBuffers",new Map);class Zl extends Wl{constructor(){super(...arguments),r(this,"models",[]),r(this,"didTrigger",[]),r(this,"receivers",[])}evaluate(A){var e;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=this.didTrigger[g],s=I.time-A;let C=!1;if(I.retroActive)C=s<=1e-6;else{const a=Math.abs(s);a>=1e-5&&a<i&&(C=!0)}if(C){if(!o)if(this.didTrigger[g]=!0,((e=this.receivers)==null?void 0:e.length)<=0)vE.invoke(I.asset);else for(const a of this.receivers)a&&a.invoke(I.asset)}else I.emitOnce||(this.didTrigger[g]=!1)}}}class Dy extends Wl{constructor(){super(...arguments),r(this,"models",[]),r(this,"timelines",[]),r(this,"_previousActiveModel",null)}resolveSourceObjects(A){for(let e=this.models.length-1;e>=0;e--){const i=this.models[e].asset;if(!i.sourceObject||typeof i.sourceObject!="object"){console.log("no source object, removing model",e,i),this.models.splice(e,1);continue}else{const g=tA.getComponent(i.sourceObject,nB);this.timelines.push(g),g&&i.updateDirector&&(g.playOnAwake=!1)}}}evaluate(A){var e;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=g.asset;if(A>=g.start&&A<=g.end){this._previousActiveModel=g;const o=this.getClipTime(A,g);if(I.controlActivation){const s=I.sourceObject;s.visible=!0}if(I.updateDirector){const s=this.timelines[i];s&&(s.isPlaying&&s.pause(),s.time=o,s.evaluate())}}else{const o=(e=this._previousActiveModel)==null?void 0:e.asset;if(I.controlActivation){const s=I.sourceObject;o?.sourceObject!==s&&(s.visible=!1)}}}}}var xgA=Object.defineProperty,TgA=Object.getOwnPropertyDescriptor,K2=(t,A,e,i)=>{for(var g=i>1?void 0:i?TgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&xgA(A,e,g),g};class ke{constructor(A){r(this,"_active",!0),r(this,"_value"),r(this,"_valueRaw"),r(this,"_defaultValue"),r(this,"valueProcessor"),r(this,"onValueChanged"),this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const i=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged&&this.onValueChanged(A,i,this)}testIfValueChanged(A){return this._valueRaw!==A}}K2([y()],ke.prototype,"overrideState",1),K2([y()],ke.prototype,"value",1);var YgA=Object.defineProperty,HgA=Object.getOwnPropertyDescriptor,OgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?HgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&YgA(A,e,g),g};const _gA=oA("debugpost");class vg extends ln{constructor(A=void 0){if(super(),r(this,"active",!0),r(this,"_result"),r(this,"_didCreateVolumeParameters",!1),A){this.ensureVolumeParameters();for(const e of Object.keys(A)){const i=A[e],g=this[e];g instanceof ke&&(g.value=i)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var A;return this.ensureVolumeParameters(),this._result||(this._result=(A=this.onCreateEffect)==null?void 0:A.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){_gA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(A=>A.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const A=Object.keys(this);for(const e of A){const i=this[e];i instanceof ke&&i.__init()}}onAfterDeserialize(A,e){if(typeof A=="object"){const i=this.$serializedTypes;if(i){for(const g of Object.keys(i))if(i[g]===ke){const I=A[g];if(I!==void 0){const o=this[g];o.value=I}}}}}onEditorModification(A){const e=A.propertyName;if(this[e]instanceof ke){const i=A.value;return this[e].value=i,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const A=this.$serializedTypes;if(A)for(const e of Object.keys(A))A[e]===ke&&(this[e]||(this[e]=new ke))}}OgA([y()],vg.prototype,"active",2);var PgA=Object.defineProperty,jgA=Object.getOwnPropertyDescriptor,WgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?jgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&PgA(A,e,g),g};const VgA=oA("debugpost"),zR={};function Jo(t,A){zR[t]=A}function zgA(t){return t.__type in zR?zR[t.__type]:(VgA&&t.__type&&console.warn("Unknown postprocessing type",t.__type,t),vg)}class Xl{constructor(){r(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}WgA([rE([t=>zgA(t),vg])],Xl.prototype,"components",2);var ZgA=Object.defineProperty,XgA=Object.getOwnPropertyDescriptor,$gA=(t,A,e,i)=>{for(var g=i>1?void 0:i?XgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ZgA(A,e,g),g};class $l extends vg{constructor(){super(...arguments),r(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const A=new n9({preset:$Q.HIGH,edgeDetectionMode:SG.DEPTH});return this.preset.onValueChanged=e=>{A.applyPreset(e)},A}}$gA([y(ke)],$l.prototype,"preset",2),Jo("Antialiasing",$l);class wy{constructor(){r(this,"files",[])}get extensionName(){return"Audio"}onExportObject(A,e,i){const g=tA.getComponents(A,yi);if(g.length)for(const I of g){if(!I.clip||!I.playOnAwake)continue;const o=I.clip.split("/").pop();this.files.includes(I.clip)||this.files.push(I.clip),e.addEventListener("serialize",(s,C)=>{s.appendLine(),s.beginBlock(`def SpatialAudio "${e.name}"`),s.appendLine(`uniform asset filePath = @audio/${o}@`),s.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),s.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),s.appendLine(`uniform float gain = ${I.volume}`),s.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const i=e.split("/").pop(),g=await(await(await fetch(e)).blob()).arrayBuffer(),I=new Uint8Array(g);A.files["audio/"+i]=I}}}var AIA=Object.defineProperty,eIA=Object.getOwnPropertyDescriptor,J2=(t,A,e,i)=>{for(var g=i>1?void 0:i?eIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&AIA(A,e,g),g};const tIA=oA("debugmouth");class Ad extends UA{constructor(){super(...arguments),r(this,"idle",[]),r(this,"talking",[]),r(this,"marker",null),r(this,"voip",null),r(this,"lastMouthChangeTime",0),r(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=tA.findObjectOfType(Ka,this.context),this.marker||(this.marker=tA.getComponentInParent(this.gameObject,qg))},3e3)}update(){var A;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((A=this.marker)==null?void 0:A.connectionId)??null;if(!e){tIA&&(e=null);return}const i=this.voip.getFrequency(e)??0;this.updateLips(i)}updateLips(A){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&A>30){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,e)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,e)}}}setMouthShapeActive(A,e){if(A){A!=this.idle?this.idle.map(i=>i.visible=!1):this.talking.map(i=>i.visible=!1);for(let i=0;i<A.length;i++){const g=A[i];g&&(g.visible=i===e)}}}}J2([y(vA)],Ad.prototype,"idle",2),J2([y(vA)],Ad.prototype,"talking",2);class ZR extends UA{constructor(){super(...arguments),r(this,"voip",null),r(this,"marker",null),r(this,"_startPosition",null)}awake(){this.voip=tA.findObjectOfType(Ka,this.context),this.marker=tA.getComponentInParent(this.gameObject,qg)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const A=this.marker.connectionId,e=this.voip.getFrequency(A);if(e==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());let i=e/100;this.gameObject.position.y=this._startPosition.y+i*.07}}var iIA=Object.defineProperty,gIA=Object.getOwnPropertyDescriptor,yy=(t,A,e,i)=>{for(var g=i>1?void 0:i?gIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&iIA(A,e,g),g};class BB extends UA{constructor(){super(...arguments),r(this,"eyes",[]),r(this,"lastBlinkTime",0),r(this,"blinkLength",0),r(this,"eyesOpen",!0),r(this,"state",null)}awake(){this.state=tA.getComponentInParent(this.gameObject,iI)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const A of this.eyes)A&&(A.visible=this.eyesOpen)}}}yy([y(vA)],BB.prototype,"eyes",2),yy([y()],BB.prototype,"lastBlinkTime",2),yy([y()],BB.prototype,"blinkLength",2),yy([y()],BB.prototype,"eyesOpen",2);var IIA=Object.defineProperty,oIA=Object.getOwnPropertyDescriptor,XR=(t,A,e,i)=>{for(var g=i>1?void 0:i?oIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&IIA(A,e,g),g},$R;const q2=($R=class extends UA{constructor(){super(...arguments),r(this,"head",null),r(this,"eyes",null),r(this,"target",null),r(this,"brain",null),r(this,"vec",new S),r(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=tA.getComponentInParent(this.gameObject,Sl)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=tA.addNewComponent(this.gameObject,Sl)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const t=this.target;if(t&&this.head){const A=this.eyes;if(A){const e=ue(t);this.currentTargetPoint.lerp(e,this.context.time.deltaTime/.1);const i=ue(this.head),g=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(g.length()<.1)return;const I=q2.forward;if(I.set(0,0,1),I.applyQuaternion(Ti(this.head)),I.dot(g)>.45)for(let o=0;o<A.length;o++)A[o].lookAt(this.currentTargetPoint)}}}},r($R,"forward",new S(0,0,1)),$R);let bE=q2;XR([y(vA)],bE.prototype,"head",2),XR([y(vA)],bE.prototype,"eyes",2),XR([y(vA)],bE.prototype,"target",2);var sIA=Object.defineProperty,CIA=Object.getOwnPropertyDescriptor,AU=(t,A,e,i)=>{for(var g=i>1?void 0:i?CIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&sIA(A,e,g),g};class LE extends UA{constructor(){super(...arguments),r(this,"length",1),r(this,"depthTest",!0),r(this,"isGizmo",!0),r(this,"_axes",null)}onEnable(){if(this.isGizmo&&!Mc)return;this._axes||(this._axes=new YQ(this.length)),this.gameObject.add(this._axes);const A=this._axes.material;A&&A.depthTest!==void 0&&(A.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}AU([y()],LE.prototype,"length",2),AU([y()],LE.prototype,"depthTest",2),AU([y()],LE.prototype,"isGizmo",2);class eU extends UA{constructor(){super(...arguments),r(this,"from"),r(this,"to"),r(this,"hint"),r(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;let A=ue(this.to).clone(),e=ue(this.from).clone(),i=A.distanceTo(e),g=A.clone();g.sub(e);let I=e.clone();I.add(A),I.multiplyScalar(.5);let o=ue(this.hint).clone();o.sub(I);let s=new S;s.crossVectors(o,g),s.crossVectors(g,s),s.normalize();let C=i*.5,a=Math.max(this.desiredDistance,C),n=Math.sqrt(a*a-C*C),B=s.clone();B.multiplyScalar(n),B.add(I),ai(this.gameObject,B);let Q=I.clone();Q.sub(s),this.gameObject.lookAt(Q)}}class Sy{constructor(){r(this,"behaviours",[]),r(this,"behaviourComponents",[]),r(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(i=>{tA.foreachComponent(i,g=>{var I;const o=g;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const s=(I=o.beforeCreateDocument)==null?void 0:I.call(o,this,A);s instanceof Promise&&e.push(s)}},!1)}),Promise.all(e)}onExportObject(A,e,i){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.call(I,this,e,i)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var i;if((i=this.behaviours)!=null&&i.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){console.log("onAfterSerialize",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)console.log("behaviour",e),typeof e.afterSerialize=="function"&&(console.log("beh has afterSerialize",e),e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A))}}var aIA=Object.defineProperty,nIA=Object.getOwnPropertyDescriptor,tU=(t,A,e,i)=>{for(var g=i>1?void 0:i?nIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&aIA(A,e,g),g};class QB extends vg{constructor(){super(...arguments),r(this,"threshold"),r(this,"intensity"),r(this,"scatter"),r(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>1*Math.PI*(1-A)):(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>100*(1-A))}onCreateEffect(){let A;if(this.selectiveBloom){const e=A=new kx(this.context.scene,this.context.mainCamera,{blendFunction:qe.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});e.inverted=!0}else A=new RG;return this.intensity.onValueChanged=e=>{A.intensity=e},this.threshold.onValueChanged=e=>{A.luminanceMaterial.threshold=e},this.scatter.onValueChanged=e=>{A.luminancePass.enabled=!0,A.luminanceMaterial.smoothing=e},A}}tU([y(ke)],QB.prototype,"threshold",2),tU([y(ke)],QB.prototype,"intensity",2),tU([y(ke)],QB.prototype,"scatter",2),Jo("Bloom",QB);var rIA=Object.defineProperty,BIA=Object.getOwnPropertyDescriptor,hs=(t,A,e,i)=>{for(var g=i>1?void 0:i?BIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&rIA(A,e,g),g};class tC extends UA{constructor(){super(...arguments),r(this,"attachedRigidbody",null),r(this,"isTrigger",!1),r(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Wt))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Wt))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Wt))}onDisable(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}}hs([y(Wt)],tC.prototype,"attachedRigidbody",2),hs([y()],tC.prototype,"isTrigger",2),hs([y()],tC.prototype,"sharedMaterial",2);class ed extends tC{constructor(){super(...arguments),r(this,"radius",.5),r(this,"center",new S(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addSphereCollider(this,this.center,this.radius)}}hs([y()],ed.prototype,"radius",2),hs([y(S)],ed.prototype,"center",2);class td extends tC{constructor(){super(...arguments),r(this,"size",new S(1,1,1)),r(this,"center",new S(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addBoxCollider(this,this.center,this.size)}}hs([y(S)],td.prototype,"size",2),hs([y(S)],td.prototype,"center",2);class id extends tC{constructor(){super(...arguments),r(this,"sharedMesh"),r(this,"convex",!1)}onEnable(){var A,e,i,g,I;if(super.onEnable(),(A=this.sharedMesh)!=null&&A.isMesh||this.gameObject instanceof fA&&(this.sharedMesh=this.gameObject),(e=this.sharedMesh)!=null&&e.isMesh)(i=this.context.physics.engine)==null||i.addMeshCollider(this,this.sharedMesh,this.convex,Cg(this.gameObject));else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${(g=this.sharedMesh)==null?void 0:g.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const s in o.children){const C=o.children[s];C.isMesh&&((I=this.context.physics.engine)==null||I.addMeshCollider(this,C,this.convex,Cg(this.gameObject)))}}}}}hs([y()],id.prototype,"convex",2);class vn extends tC{constructor(){super(...arguments),r(this,"center",new S(0,0,0)),r(this,"radius",.5),r(this,"height",2)}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addCapsuleCollider(this,this.center,this.height,this.radius)}}hs([y(S)],vn.prototype,"center",2),hs([y()],vn.prototype,"radius",2),hs([y()],vn.prototype,"height",2);function iU(t){return t[$s]||(t.parent?iU(t.parent):null)}function fy(t,A){if(!t)return;const e=t.material;if(e?.isMaterial===!0){const i=t.parent;i&&i.isText,e.side=A.doubleSided??!0?Ut:kg,e.shadowSide=A.doubleSided?Ut:kg,t.castShadow=A.castShadows?A.castShadows:!1,t.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const i of t.children)fy(i,A)}function xE(t,A,e){t[A]===void 0&&console.warn("Field",A,"is undefined on",t);const i=Proxy.revocable(t[A],{set(o,s,C,a){const n=o[s],B=Reflect.set(o,s,C,a);return e(C,n),B}}),g=i.revoke,I=t[A];return i.revoke=()=>{t[A]=I,g()},t[A]=i.proxy,i}const v2=Symbol("Scheduled action");function QIA(t,A,e=WI.OnBeforeRender){let i=t[v2];i||(i=t[v2]={});const g=A.name;i[e]||(i[e]={});const I=i[e];if(I[g])return;function*o(){A?.call(t),I[g]=null}const s=t.startCoroutine(o(),e);I[g]=s}var EIA=Object.defineProperty,hIA=Object.getOwnPropertyDescriptor,EB=(t,A,e,i)=>{for(var g=i>1?void 0:i?hIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&EIA(A,e,g),g};const gU=oA("debugui"),IU=oA("debuguilayout");class oU{constructor(){r(this,"width"),r(this,"height")}}class sU{constructor(){r(this,"x"),r(this,"y"),r(this,"width"),r(this,"height")}}const cs=new S,gd=new JA,my=new xA,b2=class extends ms{constructor(){super(...arguments),r(this,"_anchoredPosition"),r(this,"sizeDelta",new Z(100,100)),r(this,"pivot",new Z(.5,.5)),r(this,"anchorMin",new Z(0,0)),r(this,"anchorMax",new Z(1,1)),r(this,"offsetMin",new Z(0,0)),r(this,"offsetMax",new Z(0,0)),r(this,"lastMatrix"),r(this,"rectBlock"),r(this,"_transformNeedsUpdate",!1),r(this,"_initialPosition"),r(this,"_parentRectTransform"),r(this,"_lastUpdateFrame",-1),r(this,"_lastAnchoring"),r(this,"_createdBlocks",[]),r(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new Z),this._anchoredPosition}set anchoredPosition(t){this._anchoredPosition=t}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const t=this._parentRectTransform.width,A=this.anchorMax.x-this.anchorMin.x;let e=t*A;return e+=this.sizeDelta.x,e}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const t=this._parentRectTransform.height,A=this.anchorMax.y-this.anchorMin.y;let e=t*A;return e+=this.sizeDelta.y,e}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new Z),this.lastMatrix=new JA,this.rectBlock=new vA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,xE(this,"_anchoredPosition",()=>{this.markDirty()}),xE(this,"sizeDelta",()=>{this.markDirty()}),xE(this,"pivot",()=>{this.markDirty()}),xE(this,"anchorMin",()=>{this.markDirty()}),xE(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var t;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(t=this.Canvas)==null||t.registerTransform(this)}onDisable(){var t;super.onDisable(),this.removeShadowComponent(),(t=this.Canvas)==null||t.unregisterTransform(this)}onParentRectTransformChanged(t){this._transformNeedsUpdate||this.onApplyTransform(IU?`${t.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(IU&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(t){var A;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=tA.getComponentInParent(this.gameObject.parent,b2):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,IU&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+t),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,cs.set(0,0,0),this.applyPivot(cs),e.matrix.setPosition(cs.x,cs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(my.copy(this.gameObject.quaternion),my.x*=-1,my.z*=-1,gd.makeRotationFromQuaternion(my),e.matrix.premultiply(gd)),cs.set(0,0,0),this.applyAnchoring(cs),(A=this.Canvas)!=null&&A.screenspace?cs.z+=.1:cs.z+=.01,gd.identity(),gd.setPosition(cs.x,cs.y,cs.z),e.matrix.premultiply(gd),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const g of dG(this.gameObject,ms,i,1)){if(g===this||!g.activeAndEnabled)continue;const I=g;I.onParentRectTransformChanged&&I.onParentRectTransformChanged(this)}}applyAnchoring(t){this._lastAnchoring||(this._lastAnchoring=new Z);const A=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=A.x,this.gameObject.position.y+=A.y,this._lastAnchoring.copy(this._anchoredPosition),t.x+=this._initialPosition.x-this.gameObject.position.x,t.y+=this._initialPosition.y-this.gameObject.position.y,t.z+=this._initialPosition.z-this.gameObject.position.z;const e=this._parentRectTransform;if(e){let i=0;const g=1-this.anchorMax.y-this.anchorMin.y;i-=e.height*.5*g,t.y+=i;let I=0;const o=1-this.anchorMax.x-this.anchorMin.x;I-=e.width*.5*o,t.x+=I}}applyPivot(t){if(this.pivot&&!this.isRoot()){const A=this.pivot.x-.5;t.x-=A*this.sizeDelta.x*this.gameObject.scale.x;const e=this.pivot.y-.5;t.y-=e*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const t={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(t),t}ensureValidSize(t,A=1e-4){return t.width<=0&&(t.width=A),t.height<=0&&(t.height=1e-4),t}createNewBlock(t){t={...this.getBasicOptions(),...t},gU&&console.log(this.name,t);const A=new qR(t);return this._createdBlocks.push(A),A}createNewText(t){gU&&console.log(t),t={...this.getBasicOptions(),...t},gU&&console.log(this.name,t);const A=new m2(t);return this._createdTextBlocks.push(A),A}};let hg=b2;EB([y(Z)],hg.prototype,"anchoredPosition",1),EB([y(Z)],hg.prototype,"sizeDelta",2),EB([y(Z)],hg.prototype,"pivot",2),EB([y(Z)],hg.prototype,"anchorMin",2),EB([y(Z)],hg.prototype,"anchorMax",2),EB([y(Z)],hg.prototype,"offsetMin",2),EB([y(Z)],hg.prototype,"offsetMax",2);class cIA extends f2{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const i in e)for(const g in e[i])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].push(i);for(const i of A._components)A._simpleState__statesProperties[i.id]&&(A._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const i=[];for(const g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],i.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)i.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const i in A)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=A[i]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var lIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,L2=(t,A,e,i)=>{for(var g=i>1?void 0:i?dIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lIA(A,e,g),g};class TE extends UA{constructor(){super(...arguments),r(this,"effectColor"),r(this,"effectDistance")}}L2([y(yt)],TE.prototype,"effectColor",2),L2([y(Z)],TE.prototype,"effectDistance",2);var pIA=Object.defineProperty,uIA=Object.getOwnPropertyDescriptor,x2=(t,A,e,i)=>{for(var g=i>1?void 0:i?uIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&pIA(A,e,g),g};const ky={backgroundColor:new wA(1,1,1),backgroundOpacity:1,borderColor:new wA(1,1,1),borderOpacity:1};var CU;const Gy=(CU=class extends ms{constructor(){super(...arguments),r(this,"_alphaFactor",1),r(this,"raycastTarget",!0),r(this,"uiObject",null),r(this,"_color",null),r(this,"_rect",null),r(this,"_stateManager",null),r(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new yt(1,1,1,1)),this._color}set color(t){(!this._color||this._color.r!==t.r||this._color.g!==t.g||this._color.b!==t.b||this._color.alpha!==t.alpha)&&(this._color||(this._color=new yt(1,1,1,1)),this._color.copy(t))}setAlphaFactor(t){this._alphaFactor=t,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(ky.backgroundColor=this._color,ky.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(ky,this._alphaFactor),this.uiObject.set(ky),this.markDirty())}get m_Color(){return this._color}get rectTransform(){return this._rect||(this._rect=tA.getComponent(this.gameObject,hg)),this._rect}onParentRectTransformChanged(){var t;(t=this.uiObject)==null||t.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(t){this.makePanel(),this.uiObject&&(this.uiObject.setState(t),this==null||this.markDirty())}setupState(t){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new cIA(this.uiObject)),this.uiObject.setupState(t.state,t.attributes))}setOptions(t){this.makePanel(),this.uiObject&&this.uiObject.set(t)}awake(){super.awake(),this.makePanel(),xE(this,"_color",()=>QIA(this,this.onColorChanged))}onEnable(){var t;super.onEnable(),this.uiObject&&((t=this.rectTransform.shadowComponent)==null||t.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;let t=.015;const A={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:t};this.onBeforeCreate(A),this.applyEffects(A),this.onCreate(A),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(t){}onCreate(t){this.uiObject=this.rectTransform.createNewBlock(t),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(t,A=1){var e;const i=(e=this.gameObject)==null?void 0:e.getComponent(TE);i&&(i.effectDistance&&(t.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(t.borderColor=i.effectColor,t.borderOpacity=i.effectColor.alpha*A))}async setTexture(t){if(this.setOptions({backgroundOpacity:0}),t){if(t.colorSpace===Ie)if(Gy.textureCache.has(t))t=Gy.textureCache.get(t);else{const A=t.clone();A.colorSpace=zi,Gy.textureCache.set(t,A),t=A}this.setOptions({backgroundImage:t,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},r(CU,"textureCache",new Map),CU);let hB=Gy;x2([y(yt)],hB.prototype,"color",1),x2([y()],hB.prototype,"raycastTarget",2);class Id extends hB{constructor(){super(...arguments),r(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var DIA=Object.defineProperty,wIA=Object.getOwnPropertyDescriptor,My=(t,A,e,i)=>{for(var g=i>1?void 0:i?wIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&DIA(A,e,g),g};let aU=class{constructor(){r(this,"texture",null),r(this,"rect")}};My([y(_e)],aU.prototype,"texture",2);let YE=class extends Id{constructor(){super(...arguments),r(this,"_sprite"),r(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new aU),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,A,e,i,g,I,o,s;switch((A=(t=this.sprite)==null?void 0:t.texture)==null?void 0:A.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((g=(i=(e=this.sprite)==null?void 0:e.texture)==null?void 0:i.image)==null?void 0:g.width)===32&&((s=(o=(I=this.sprite)==null?void 0:I.texture)==null?void 0:o.image)==null?void 0:s.height)===32}onBeforeCreate(t){var A,e;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((e=(A=this.sprite)==null?void 0:A.texture)==null?void 0:e.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};My([y(aU)],YE.prototype,"sprite",1),My([y()],YE.prototype,"pixelsPerUnitMultiplier",2);class Ry extends Id{constructor(){super(...arguments),r(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(A){this._mainTexture!==A&&(this._mainTexture=A,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}My([y(_e)],Ry.prototype,"mainTexture",1);var yIA=Object.defineProperty,SIA=Object.getOwnPropertyDescriptor,$I=(t,A,e,i)=>{for(var g=i>1?void 0:i?SIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&yIA(A,e,g),g};const HE=oA("debugbutton");class cB{constructor(){r(this,"colorMultiplier"),r(this,"disabledColor"),r(this,"fadeDuration"),r(this,"highlightedColor"),r(this,"normalColor"),r(this,"pressedColor"),r(this,"selectedColor")}}$I([y()],cB.prototype,"colorMultiplier",2),$I([y(yt)],cB.prototype,"disabledColor",2),$I([y()],cB.prototype,"fadeDuration",2),$I([y(yt)],cB.prototype,"highlightedColor",2),$I([y(yt)],cB.prototype,"normalColor",2),$I([y(yt)],cB.prototype,"pressedColor",2),$I([y(yt)],cB.prototype,"selectedColor",2);class Ea extends UA{constructor(){super(...arguments),r(this,"onClick"),r(this,"_isHovered",!1),r(this,"colors"),r(this,"transition"),r(this,"animationTriggers"),r(this,"animator"),r(this,"_interactable",!0),r(this,"_requestedAnimatorTrigger"),r(this,"_isInit",!1),r(this,"_image")}onPointerEnter(A){var e,i;HE&&console.log("Button Enter",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var A,e;HE&&console.log("Button Exit",(A=this.animationTriggers)==null?void 0:A.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((e=this._image)==null||e.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(A){var e,i;HE&&console.log("Button Down",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("pressed")))}onPointerUp(A){var e,i;HE&&console.warn("Button Up",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState(this._isHovered?"hovered":"normal")))}onPointerClick(A){var e;this.interactable&&A.pointerId===0&&(HE&&(console.warn("Button Click",this.onClick),pi("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(e=this.onClick)==null||e.invoke())}set interactable(A){this._interactable=A,this._image&&(this._image.setInteractable(A),A?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(A){this.interactable=A}awake(){super.awake(),HE&&console.log(this),this._isInit=!1,this.init()}start(){var A;(A=this._image)==null||A.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(A){var e;this._requestedAnimatorTrigger=A,yield,yield,this._requestedAnimatorTrigger==A&&((e=this.animator)==null||e.SetTrigger(A))}init(){this._isInit||(this._isInit=!0,this._image=tA.getComponent(this.gameObject,YE),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(A){var e,i,g,I,o;A.setInteractable(this.interactable);const s=this.getFinalColor(A.color,(e=this.colors)==null?void 0:e.normalColor),C={state:"normal",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};A.setupState(C);const a=this.getFinalColor(A.color,(i=this.colors)==null?void 0:i.highlightedColor),n={state:"hovered",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};A.setupState(n);const B=this.getFinalColor(A.color,(g=this.colors)==null?void 0:g.pressedColor),Q={state:"pressed",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};A.setupState(Q);const E=this.getFinalColor(A.color,(I=this.colors)==null?void 0:I.selectedColor),h={state:"selected",attributes:{backgroundColor:E,backgroundOpacity:E.alpha}};A.setupState(h);const l=this.getFinalColor(A.color,(o=this.colors)==null?void 0:o.disabledColor),d={state:"disabled",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};A.setupState(d)}getFinalColor(A,e){return e?A.clone().multiply(e):A.clone()}}$I([y(SI)],Ea.prototype,"onClick",2),$I([y()],Ea.prototype,"colors",2),$I([y()],Ea.prototype,"transition",2),$I([y()],Ea.prototype,"animationTriggers",2),$I([y(tI)],Ea.prototype,"animator",2),$I([y()],Ea.prototype,"interactable",1);var fIA=Object.defineProperty,mIA=Object.getOwnPropertyDescriptor,ki=(t,A,e,i)=>{for(var g=i>1?void 0:i?mIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&fIA(A,e,g),g};const T2=oA("debuguilayout");class bn{constructor(){r(this,"left",0),r(this,"right",0),r(this,"top",0),r(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}ki([y()],bn.prototype,"left",2),ki([y()],bn.prototype,"right",2),ki([y()],bn.prototype,"top",2),ki([y()],bn.prototype,"bottom",2);class Ao extends UA{constructor(){super(...arguments),r(this,"_rectTransform",null),r(this,"_needsUpdate",!1),r(this,"childAlignment",0),r(this,"reverseArrangement",!1),r(this,"spacing",0),r(this,"padding"),r(this,"minWidth",0),r(this,"minHeight",0),r(this,"flexibleHeight",0),r(this,"flexibleWidth",0),r(this,"preferredHeight",0),r(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(A){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(T2&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){T2&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(hg);const A=this.gameObject.getComponentInParent(cg);A&&A.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const A=this.gameObject.getComponentInParent(cg);A&&A.unregisterLayoutGroup(this)}set m_Spacing(A){A!==this.spacing&&(this._needsUpdate=!0,this.spacing=A)}get m_Spacing(){return this.spacing}}ki([y()],Ao.prototype,"childAlignment",2),ki([y()],Ao.prototype,"reverseArrangement",2),ki([y()],Ao.prototype,"spacing",2),ki([y(bn)],Ao.prototype,"padding",2),ki([y()],Ao.prototype,"minWidth",2),ki([y()],Ao.prototype,"minHeight",2),ki([y()],Ao.prototype,"flexibleHeight",2),ki([y()],Ao.prototype,"flexibleWidth",2),ki([y()],Ao.prototype,"preferredHeight",2),ki([y()],Ao.prototype,"preferredWidth",2);class Ln extends Ao{constructor(){super(...arguments),r(this,"childControlHeight",!0),r(this,"childControlWidth",!0),r(this,"childForceExpandHeight",!1),r(this,"childForceExpandWidth",!1),r(this,"childScaleHeight",!1),r(this,"childScaleWidth",!1)}onCalculateLayout(A){var e;const i=this.primaryAxis,g=A.width;let I=g;const o=A.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const C=i==="x",a=C?"y":"x",n=C?this.childControlWidth:this.childControlHeight,B=C?this.childControlHeight:this.childControlWidth,Q=C?this.childForceExpandWidth:this.childForceExpandHeight,E=C?this.childForceExpandHeight:this.childForceExpandWidth,h=C?s:I,l=C?g:o,d=.5*(C?this.childAlignment%3:Math.floor(this.childAlignment/3));let c=0;C?c+=this.padding.left:c+=this.padding.top;let u=0,p=0;for(let F=0;F<this.gameObject.children.length;F++){const k=this.gameObject.children[F],f=tA.getComponent(k,hg);f!=null&&f.activeAndEnabled&&(p+=1,C?u+=f.width:u+=f.height)}let D=0;const w=this.spacing*(p-1);if(Q||n){let F=0;C?F=I-=w:F=s-=w,p>0&&(D=F/p)}let m=0;m+=this.padding.left,m-=this.padding.right,d!==0&&(c=l-u,c*=d,c-=w*d,C?(c-=this.padding.right*d,c+=this.padding.left*(1-d),c<this.padding.left&&(c=this.padding.left)):(c-=this.padding.bottom*d,c+=this.padding.top*(1-d),c<this.padding.top&&(c=this.padding.top)));let M=1;for(let F=0;F<this.gameObject.children.length;F++){const k=this.gameObject.children[F],f=tA.getComponent(k,hg);if(f!=null&&f.activeAndEnabled){(e=f.pivot)==null||e.set(.5,.5),f.anchorMin.set(0,1),f.anchorMax.set(0,1);const b=g*.5+m*.5;f.anchoredPosition.x!==b&&(f.anchoredPosition.x=b);const O=o*-.5;f.anchoredPosition.y!==O&&(f.anchoredPosition.y=O),E&&B&&f.sizeDelta[a]!==h&&(f.sizeDelta[a]=h),Q&&n&&f.sizeDelta[i]!==D&&(f.sizeDelta[i]=D);const L=C?f.width:f.height;let T=L*.5;if(c+=T,Q){let iA=D*M-D*.5;iA>c&&(c=iA-D*.5+L+this.padding.left,c-=T)}let W=c;i==="y"&&(W=-W),f.anchoredPosition[i]!==W&&(f.anchoredPosition[i]=W),c+=T,c+=this.spacing,M+=1}}}}ki([y()],Ln.prototype,"childControlHeight",2),ki([y()],Ln.prototype,"childControlWidth",2),ki([y()],Ln.prototype,"childForceExpandHeight",2),ki([y()],Ln.prototype,"childForceExpandWidth",2),ki([y()],Ln.prototype,"childScaleHeight",2),ki([y()],Ln.prototype,"childScaleWidth",2);class nU extends Ln{get primaryAxis(){return"y"}}class rU extends Ln{get primaryAxis(){return"x"}}class BU extends Ao{onCalculateLayout(){}}var kIA=Object.defineProperty,GIA=Object.getOwnPropertyDescriptor,iC=(t,A,e,i)=>{for(var g=i>1?void 0:i?GIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&kIA(A,e,g),g},Y2=(t=>(t[t.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",t[t.ScreenSpaceCamera=1]="ScreenSpaceCamera",t[t.WorldSpace=2]="WorldSpace",t[t.Undefined=-1]="Undefined",t))(Y2||{});const QU=oA("debuguilayout"),H2=class extends Jl{constructor(){super(...arguments),r(this,"_renderOnTop"),r(this,"_depthWrite",!1),r(this,"_doubleSided",!0),r(this,"_castShadows",!1),r(this,"_receiveShadows",!1),r(this,"_renderMode",-1),r(this,"_rootCanvas"),r(this,"_scaleFactor",1),r(this,"worldCamera"),r(this,"planeDistance",-1),r(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),r(this,"previousParent",null),r(this,"_lastMatrixWorld",null),r(this,"_rectTransforms",[]),r(this,"_layoutGroups",new Map),r(this,"onBeforeRenderRoutine",()=>{var t,A,e,i;if(this.context.isInVR){(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(A=this.shadowComponent)==null||A.updateWorldMatrix(!0,!0),ZI.ensureUpdateMeshUI(bR,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(i=this.shadowComponent)==null||i.updateWorldMatrix(!0,!0),ZI.ensureUpdateMeshUI(bR,this.context))}),r(this,"onAfterRenderRoutine",()=>{var t,A;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const g=this.context.mainCamera;g?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const e=this.context.renderer.autoClear,i=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),ZI.ensureUpdateMeshUI(bR,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=e,this.context.renderer.autoClearColor=i,this.previousParent.add(this.gameObject)}(A=this._lastMatrixWorld)==null||A.copy(this.gameObject.matrixWorld)}}),r(this,"_updateRenderSettingsRoutine"),r(this,"_activeRenderMode",-1),r(this,"_lastWidth",-1),r(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(t){t!==this._renderOnTop&&(this._renderOnTop=t,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(t){this._depthWrite!==t&&(this._depthWrite=t,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(t){this._doubleSided!==t&&(this._doubleSided=t,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(t){this._castShadows!==t&&(this._castShadows=t,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(t){this._receiveShadows!==t&&(this._receiveShadows=t,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode!==t&&(this._renderMode=t,this.onRenderSettingsChanged())}set rootCanvas(t){this._rootCanvas instanceof H2||(this._rootCanvas=t)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(t){this._scaleFactor=t}awake(){var t;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,QU&&console.log("Canvas.Awake()",((t=this.previousParent)==null?void 0:t.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new JA,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);t!==-1&&this.context.pre_render_callbacks.splice(t,1);const A=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);A!==-1&&this.context.post_render_callbacks.splice(A,1)}registerTransform(t){this._rectTransforms.push(t)}unregisterTransform(t){const A=this._rectTransforms.indexOf(t);A!==-1&&this._rectTransforms.splice(A,1)}registerLayoutGroup(t){const A=t.gameObject;this._layoutGroups.set(A,t)}unregisterLayoutGroup(t){const A=t.gameObject;this._layoutGroups.delete(A)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new JA);const t=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);QU&&t&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);let A=!1;for(const e of this._rectTransforms){t&&e.markDirty();let i=this._layoutGroups.get(e.gameObject);e.isDirty&&!i&&(i=e.gameObject.getComponentInParent(Ao)),(e.isDirty||i!=null&&i.isDirty)&&(QU&&!A&&console.log("CANVAS UPDATE ### "+e.name+" ##################################### "+this.context.time.frame),i?.updateLayout(),e.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),WI.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),fy(this.shadowComponent,this);for(const t of tA.getComponentsInChildren(this.gameObject,ms))fy(t.shadowComponent,this)}}onUpdateRenderMode(t=!1){if(!t&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let A=this.context.mainCameraComponent,e=10;switch(A&&A.nearClipPlane>0&&A.farClipPlane>0&&(e=te.lerp(A.nearClipPlane,A.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(A=this.worldCamera),this.planeDistance>0&&(e=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!A)return;const i=e+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-i,this.gameObject.quaternion.identity();const g=this.gameObject.getComponent(hg);let I=!1;g.sizeDelta.x!==this.context.domWidth&&(I=!0),g.sizeDelta.y!==this.context.domHeight&&(I=!0);const o=A.fieldOfView*Math.PI/180,s=2*Math.tan(o/2)*Math.abs(i);this.gameObject.scale.x=s/this.context.domHeight,this.gameObject.scale.y=s/this.context.domHeight,this.gameObject.scale.z=.01,I&&(g.sizeDelta.x=this.context.domWidth,g.sizeDelta.y=this.context.domHeight,g?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let cg=H2;iC([y()],cg.prototype,"renderOnTop",1),iC([y()],cg.prototype,"depthWrite",1),iC([y()],cg.prototype,"doubleSided",1),iC([y()],cg.prototype,"castShadows",1),iC([y()],cg.prototype,"receiveShadows",1),iC([y()],cg.prototype,"renderMode",1),iC([y(cg)],cg.prototype,"rootCanvas",1),iC([y()],cg.prototype,"scaleFactor",1),iC([y(Tt)],cg.prototype,"worldCamera",2),iC([y()],cg.prototype,"planeDistance",2);var MIA=Object.defineProperty,RIA=Object.getOwnPropertyDescriptor,EU=(t,A,e,i)=>{for(var g=i>1?void 0:i?RIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&MIA(A,e,g),g};class xn extends UA{constructor(){super(...arguments),r(this,"_alpha",1),r(this,"interactable",!0),r(this,"blocksRaycasts",!0),r(this,"_isDirty",!1),r(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(A){A!==this._alpha&&(this._alpha=A,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),WI.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const A of tA.getComponentsInChildren(this.gameObject,ms,this._buffer)){const e=A;e.setAlphaFactor&&e.setAlphaFactor(this._alpha)}}}EU([y()],xn.prototype,"alpha",1),EU([y()],xn.prototype,"interactable",2),EU([y()],xn.prototype,"blocksRaycasts",2);var UIA=Object.defineProperty,FIA=Object.getOwnPropertyDescriptor,Nt=(t,A,e,i)=>{for(var g=i>1?void 0:i?FIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&UIA(A,e,g),g};class lB extends UA{constructor(){super(...arguments),r(this,"object"),r(this,"target"),r(this,"duration",1),r(this,"relativeMotion",!1),r(this,"coroutine",null),r(this,"targetPos",new S),r(this,"targetRot",new xA),r(this,"targetScale",new S)}*moveToTarget(){if(!this.target||!this.object)return;const A=ue(this.object).clone(),e=ue(this.target).clone(),i=Ti(this.object).clone(),g=Ti(this.target).clone(),I=Cg(this.object).clone(),o=Cg(this.target).clone(),s=A.distanceTo(e),C=i.angleTo(g),a=I.distanceTo(o);if(s<.01&&C<.01&&a<.01){ai(this.object,e),uI(this.object,g),Hk(this.object,o),this.coroutine=null;return}let n=0,B=0;for(;n<1;)n+=this.context.time.deltaTime/this.duration,n>1&&(n=1),B=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,this.targetPos.lerpVectors(A,e,B),this.targetRot.slerpQuaternions(i,g,B),this.targetScale.lerpVectors(I,o,B),ai(this.object,this.targetPos),uI(this.object,this.targetRot),Hk(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const A=this.object.position.clone(),e=this.object.quaternion.clone(),i=this.object.scale.clone(),g=this.target.position.clone(),I=this.target.quaternion.clone(),o=this.target.scale.clone();g.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(g),this.targetRot.copy(this.object.quaternion).multiply(I),this.targetScale.copy(this.object.scale).multiply(o);let s=0,C=0;for(;s<1;)s+=this.context.time.deltaTime/this.duration,s>1&&(s=1),C=s<.5?4*s*s*s:1-Math.pow(-2*s+2,3)/2,this.object.position.lerpVectors(A,this.targetPos,C),this.object.quaternion.slerpQuaternions(e,this.targetRot,C),this.object.scale.lerpVectors(i,this.targetScale,C),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(A){var e;if(this.target&&this.object&&this.gameObject){const i=new eI("Move to "+((e=this.target)==null?void 0:e.name),fI.tapTrigger(this.gameObject),Bt.transformAction(this.object,this.target,this.duration,this.relativeMotion?JM.Relative:JM.Absolute));A.addBehavior(i)}}}Nt([y(vA)],lB.prototype,"object",2),Nt([y(vA)],lB.prototype,"target",2),Nt([y()],lB.prototype,"duration",2),Nt([y()],lB.prototype,"relativeMotion",2);var hU;const dB=(hU=class extends UA{constructor(){super(...arguments),r(this,"materialToSwitch"),r(this,"variantMaterial"),r(this,"fadeDuration",0),r(this,"_objectsWithThisMaterial",[]),r(this,"selfModel"),r(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const t=tA.findObjectsOfType(bt);for(const A of t)A.sharedMaterial===this.materialToSwitch&&this._objectsWithThisMaterial.push(A)}}onPointerClick(){if(this.variantMaterial)for(const t of this._objectsWithThisMaterial)t.sharedMaterial=this.variantMaterial}async beforeCreateDocument(t,A){this.targetModels=[],dB._materialTriggersPerId={},this.materialToSwitch&&await Cs.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Cs.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(t,A,e){this._objectsWithThisMaterial.find(i=>i.gameObject.uuid===A.uuid)&&this.targetModels.push(A),this.gameObject.uuid===A.uuid&&(this.selfModel=A,this.materialToSwitch&&(dB._materialTriggersPerId[this.materialToSwitch.uuid]||(dB._materialTriggersPerId[this.materialToSwitch.uuid]=[]),dB._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(t,A){if(!this.materialToSwitch)return;const e=dB._materialTriggersPerId[this.materialToSwitch.uuid];if(e){const i={};for(const I of e){const o=I.createVariants();o&&o.length>0&&(i[I.selfModel.uuid]=o)}const g=[];for(const I of e){for(const o in i)o!==I.selfModel.uuid&&g.push(i[o]);I.createAndAttachBehaviors(t,i[I.selfModel.uuid],g)}}delete dB._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(t,A,e){const i=[],g=[],I=Math.max(0,this.fadeDuration);for(const o of this.targetModels){const s=Bt.fadeAction(o,I,!1);g.push(s)}for(const o of e)g.push(Bt.fadeAction(o,I,!1));for(const o of A)i.push(Bt.fadeAction(o,I,!1)),g.push(Bt.fadeAction(o,I,!0));t.addBehavior(new eI("Select "+this.selfModel.name,fI.tapTrigger(this.selfModel),Bt.parallel(...g))),t.addBehavior(new eI("Start hidden "+this.selfModel.name,fI.sceneStartTrigger(),Bt.parallel(...i)))}createVariants(){if(!this.variantMaterial)return null;const t=[];for(const A of this.targetModels){const e=A.clone();e.name+=" variant_"+this.variantMaterial.name,e.name=e.name.replace(/\s/g,"_"),e.material=this.variantMaterial,e.geometry=A.geometry,e.matrix=A.matrix,(!A.parent||!A.parent.isEmpty())&&mo.createEmptyParent(A),A.parent&&A.parent.add(e),t.push(e)}return t}},r(hU,"_materialTriggersPerId",{}),hU);let OE=dB;Nt([y(Ue)],OE.prototype,"materialToSwitch",2),Nt([y(Ue)],OE.prototype,"variantMaterial",2),Nt([y()],OE.prototype,"fadeDuration",2);class _E extends UA{constructor(){super(...arguments),r(this,"target"),r(this,"toggleOnClick",!1),r(this,"targetState",!0),r(this,"hideSelf",!0),r(this,"selfModel"),r(this,"otherModel"),r(this,"toggleModel"),r(this,"stateBeforeCreatingDocument",!1)}onPointerClick(){!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(A,e,i){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(A,e){if(this.target){if(this.otherModel=e.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let i=this.hideSelf;this.targetState,this.toggleOnClick&&(i=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&lY.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const g=[];if(i&&g.push(Bt.fadeAction(this.selfModel,0,!1)),this.toggleModel&&g.push(Bt.fadeAction(this.toggleModel,0,!0)),g.push(Bt.fadeAction(this.otherModel,0,this.targetState)),A.addBehavior(new eI("Toggle_"+this.selfModel.name+"_hideSelf",fI.tapTrigger(this.selfModel),Bt.sequence(...g))),this.toggleOnClick&&this.toggleModel){const I=[];I.push(Bt.fadeAction(this.toggleModel,0,!1)),I.push(Bt.fadeAction(this.selfModel,0,!0)),I.push(Bt.fadeAction(this.otherModel,0,!this.targetState)),A.addBehavior(new eI("Toggle_"+this.selfModel.name+"_toggleSelf",fI.tapTrigger(this.toggleModel),Bt.sequence(...I))),A.addBehavior(new eI("HideOnStart_"+this.gameObject.name,fI.sceneStartTrigger(),Bt.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Nt([y(vA)],_E.prototype,"target",2),Nt([y()],_E.prototype,"targetState",2),Nt([y()],_E.prototype,"hideSelf",2);class cU extends UA{start(){this.gameObject.visible=!1}createBehaviours(A,e,i){e.uuid===this.gameObject.uuid&&A.addBehavior(new eI("HideOnStart_"+this.gameObject.name,fI.sceneStartTrigger(),Bt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class PE extends UA{constructor(){super(...arguments),r(this,"target"),r(this,"duration",.5),r(this,"motionType",KM.bounce)}beforeCreateDocument(){}createBehaviours(A,e,i){if(this.target&&e.uuid===this.gameObject.uuid){const g=new eI("emphasize "+this.name,fI.tapTrigger(this.gameObject),Bt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));A.addBehavior(g)}}afterCreateDocument(A,e){}}Nt([y()],PE.prototype,"target",2),Nt([y()],PE.prototype,"duration",2),Nt([y()],PE.prototype,"motionType",2);class jE extends UA{constructor(){super(...arguments),r(this,"target"),r(this,"clip",""),r(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const A=this.gameObject.addNewComponent(yi);A&&(A.spatialBlend=1,A.volume=1,A.loop=!1,this.target=A)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(A,e,i){if(!(!this.target&&!this.clip)&&e.uuid===this.gameObject.uuid){const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g)return;const I=this.target?this.target.gameObject:this.gameObject,o=g.split("/").pop(),s=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?vM.NonSpatial:vM.Spatial,a=new eI("playAudio "+this.name,fI.tapTrigger(this.gameObject),Bt.playAudioAction(I,"audio/"+o,RY.Play,s,C));A.addBehavior(a)}}async afterSerialize(A,e){if(!this.target&&!this.clip)return;const i=this.clip?this.clip:this.target?this.target.clip:void 0;if(!i)return;const g=i.split("/").pop(),I=await(await(await fetch(this.clip)).blob()).arrayBuffer(),o=new Uint8Array(I);e.files["audio/"+g]=o}}Nt([y(yi)],jE.prototype,"target",2),Nt([y(URL)],jE.prototype,"clip",2),Nt([y()],jE.prototype,"toggleOnClick",2);var lU;const WE=(lU=class extends UA{constructor(){super(...arguments),r(this,"target"),r(this,"animator"),r(this,"stateName"),r(this,"stateNameAfterPlaying"),r(this,"loopAfterPlaying",!1),r(this,"selfModel"),r(this,"stateAnimationModel"),r(this,"stateAnimation"),r(this,"stateAfterPlayingAnimationModel"),r(this,"stateAfterPlayingAnimation")}onPointerClick(){var t;this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(t,A,e){A.uuid===this.gameObject.uuid&&(this.selfModel=A)}onAfterHierarchy(){WE.animationActions=[]}afterCreateDocument(t,A){!this.stateAnimation||!this.stateAnimationModel||A.document.traverse(e=>{var i,g;if(e.uuid===((i=this.target)==null?void 0:i.uuid)&&this.stateAnimation){const I=[];let o=WE.animationActions.find(C=>C.affectedObjects==e&&C.start==this.stateAnimation.start&&C.duration==this.stateAnimation.duration);if(o||(o=Bt.startAnimationAction(e,this.stateAnimation.start,this.stateAnimation.duration),WE.animationActions.push(o)),I.push(o),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let C=WE.animationActions.find(n=>n.affectedObjects==e&&n.start==this.stateAfterPlayingAnimation.start&&n.duration==this.stateAfterPlayingAnimation.duration);C||(C=Bt.startAnimationAction(e,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),WE.animationActions.push(C));const a=Bt.sequence(C);this.loopAfterPlaying&&a.makeLooping(),I.push(a)}const s=new eI("tap "+this.name+" for "+this.stateName+" on "+((g=this.target)==null?void 0:g.name),fI.tapTrigger(this.selfModel),Bt.sequence(...I));t.addBehavior(s)}})}createAnimation(t,A,e){var i,g,I,o;if(this.target&&this.animator){const s=(g=(i=this.animator)==null?void 0:i.runtimeAnimatorController)==null?void 0:g.findState(this.stateName);this.stateAnimationModel=A,this.stateAnimation=t.registerAnimation(this.target,s?.motion.clip);const C=(o=(I=this.animator)==null?void 0:I.runtimeAnimatorController)==null?void 0:o.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=A,this.stateAfterPlayingAnimation=t.registerAnimation(this.target,C?.motion.clip)}}},r(lU,"animationActions",[]),lU);let Tn=WE;Nt([y(vA)],Tn.prototype,"target",2),Nt([y(tI)],Tn.prototype,"animator",2),Nt([y()],Tn.prototype,"stateName",2),Nt([y()],Tn.prototype,"stateNameAfterPlaying",2),Nt([y()],Tn.prototype,"loopAfterPlaying",2);class VE extends UA{constructor(){super(...arguments),r(this,"target")}getType(){}getDuration(){}}Nt([y(vA)],VE.prototype,"target",2);class od extends UA{constructor(){super(...arguments),r(this,"target")}}Nt([y(VE)],od.prototype,"target",2);class sd extends VE{constructor(){super(...arguments),r(this,"type",1),r(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Nt([y()],sd.prototype,"type",2),Nt([y()],sd.prototype,"duration",2);class dU extends od{}var NIA=Object.defineProperty,KIA=Object.getOwnPropertyDescriptor,ha=(t,A,e,i)=>{for(var g=i>1?void 0:i?KIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&NIA(A,e,g),g};class pB extends UA{constructor(){super(...arguments),r(this,"center",new S(0,0,0)),r(this,"radius",.5),r(this,"height",2),r(this,"_rigidbody",null),r(this,"_activeGroundCollisions",new Set)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Wt),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Wt)),this.rigidbody)}onEnable(){let A=this.rigidbody,e=this.gameObject.getComponent(vn);e||(e=this.gameObject.addNewComponent(vn)),e.center.copy(this.center),e.radius=this.radius,e.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,A.lockRotationX=!0,A.lockRotationY=!0,A.lockRotationZ=!0}move(A){this.gameObject.position.add(A)}onCollisionEnter(A){for(const e of A.contacts)if(e.normal.y>.1){this._activeGroundCollisions.add(A);break}}onCollisionExit(A){this._activeGroundCollisions.delete(A)}get isGrounded(){return this._activeGroundCollisions.size>0}}ha([y(S)],pB.prototype,"center",2),ha([y()],pB.prototype,"radius",2),ha([y()],pB.prototype,"height",2);class ca extends UA{constructor(){super(...arguments),r(this,"controller"),r(this,"movementSpeed",2),r(this,"rotationSpeed",2),r(this,"jumpForce",1),r(this,"doubleJumpForce",2),r(this,"animator"),r(this,"lookForward",!0),r(this,"_currentSpeed",new S(0,0,0)),r(this,"_currentAngularSpeed",new S(0,0,0)),r(this,"_temp",new S(0,0,0)),r(this,"_jumpCount",0),r(this,"_currentRotation"),r(this,"_raycastOptions",new es)}awake(){this._currentRotation=new xA}update(){var A,e,i,g,I,o,s,C,a,n,B;(A=this.controller)!=null&&A.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((e=this.animator)==null||e.setBool("doubleJump",!1)));const Q=this.context.input.isKeyPressed("w"),E=this.context.input.isKeyPressed("s"),h=this.context.input.isKeyPressed("a"),l=this.context.input.isKeyPressed("d"),d=this.context.input.isKeyDown(" "),c=(Q?1:0)+(E?-1:0);this._currentSpeed.z+=c*this.movementSpeed*this.context.time.deltaTime,(i=this.animator)==null||i.setBool("running",c!=0),(I=this.animator)==null||I.setBool("jumping",((g=this.controller)==null?void 0:g.isGrounded)===!0&&d),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp);const u=(h?1:0)+(l?-1:0);if(this._currentAngularSpeed.y+=te.toRadians(u*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const p=this.context.mainCameraComponent.forward;p.y=0,p.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),p),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&d&&this.jumpForce>0){let p=(o=this.controller)==null?void 0:o.isGrounded;if(this.doubleJumpForce>0&&!((s=this.controller)!=null&&s.isGrounded)&&this._jumpCount===1&&(p=!0,(C=this.animator)==null||C.setBool("doubleJump",!0)),p){this._jumpCount+=1;const D=this.controller.rigidbody,w=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;D.applyImpulse(new S(0,1,0).multiplyScalar(w))}}if(this.controller){const p=(a=this.controller)==null?void 0:a.rigidbody.getVelocity().y;if(p<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new qs),this._raycastOptions.ray.origin.copy(ue(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const D=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const w=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(D),(w.length&&w[0].distance>2||p<-10)&&((n=this.animator)==null||n.setBool("falling",!0))}else(B=this.animator)==null||B.setBool("falling",!1)}}}ha([y(pB)],ca.prototype,"controller",2),ha([y()],ca.prototype,"movementSpeed",2),ha([y()],ca.prototype,"rotationSpeed",2),ha([y()],ca.prototype,"jumpForce",2),ha([y()],ca.prototype,"doubleJumpForce",2),ha([y(tI)],ca.prototype,"animator",2);var JIA=Object.defineProperty,qIA=Object.getOwnPropertyDescriptor,vIA=(t,A,e,i)=>{for(var g=i>1?void 0:i?qIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&JIA(A,e,g),g};class Cd extends vg{constructor(){super(...arguments),r(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const A=new yx;return A.offset=new Z(0,0),A.radialModulation=!0,A.modulationOffset=.15,this.intensity.valueProcessor=e=>e*.02,this.intensity.onValueChanged=e=>{A.offset.x=-e,A.offset.y=e},A}}vIA([y(ke)],Cd.prototype,"intensity",2),Jo("ChromaticAberration",Cd);var bIA=Object.defineProperty,LIA=Object.getOwnPropertyDescriptor,Uy=(t,A,e,i)=>{for(var g=i>1?void 0:i?LIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&bIA(A,e,g),g};class Yn extends vg{constructor(){super(...arguments),r(this,"postExposure"),r(this,"contrast"),r(this,"hueShift"),r(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=A=>(A=Math.pow(2,A),A),this.postExposure.defaultValue=0,this.contrast.valueProcessor=A=>{let e=1;return A>0?e=200:A<0&&(e=100),A/e},this.contrast.defaultValue=0,this.hueShift.valueProcessor=A=>Math.PI*A/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=A=>A<0?A/100:A/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Hg&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Wh);const A=new wx;this.postExposure.onValueChanged=i=>{this.context.renderer.toneMapping===Hg&&(this.context.renderer.toneMapping=Wh),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=i)},this.contrast.onValueChanged=i=>{A.contrast=i};const e=new fx;return this.hueShift.onValueChanged=i=>e.hue=i,this.saturation.onValueChanged=i=>e.saturation=i,[e,A]}}Uy([y(ke)],Yn.prototype,"postExposure",2),Uy([y(ke)],Yn.prototype,"contrast",2),Uy([y(ke)],Yn.prototype,"hueShift",2),Uy([y(ke)],Yn.prototype,"saturation",2),Jo("ColorAdjustments",Yn);const xIA=(Math.sqrt(5)-1)/4,lg=(5-Math.sqrt(5))/20,Fy=t=>Math.floor(t)|0,Ny=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function TIA(t=Math.random){const A=YIA(t),e=new Float64Array(A).map(o=>Ny[o%32*4]),i=new Float64Array(A).map(o=>Ny[o%32*4+1]),g=new Float64Array(A).map(o=>Ny[o%32*4+2]),I=new Float64Array(A).map(o=>Ny[o%32*4+3]);return function(o,s,C,a){let n,B,Q,E,h;const l=(o+s+C+a)*xIA,d=Fy(o+l),c=Fy(s+l),u=Fy(C+l),p=Fy(a+l),D=(d+c+u+p)*lg,w=d-D,m=c-D,M=u-D,F=p-D,k=o-w,f=s-m,b=C-M,O=a-F;let L=0,T=0,W=0,iA=0;k>f?L++:T++,k>b?L++:W++,k>O?L++:iA++,f>b?T++:W++,f>O?T++:iA++,b>O?W++:iA++;const AA=L>=3?1:0,eA=T>=3?1:0,EA=W>=3?1:0,rA=iA>=3?1:0,V=L>=2?1:0,sA=T>=2?1:0,mA=W>=2?1:0,RA=iA>=2?1:0,bA=L>=1?1:0,YA=T>=1?1:0,ee=W>=1?1:0,XA=iA>=1?1:0,VA=k-AA+lg,we=f-eA+lg,lA=b-EA+lg,_=O-rA+lg,LA=k-V+2*lg,yA=f-sA+2*lg,uA=b-mA+2*lg,HA=O-RA+2*lg,pA=k-bA+3*lg,ZA=f-YA+3*lg,ge=b-ee+3*lg,re=O-XA+3*lg,Ve=k-1+4*lg,It=f-1+4*lg,v=b-1+4*lg,J=O-1+4*lg,QA=d&255,NA=c&255,KA=u&255,Y=p&255;let DA=.6-k*k-f*f-b*b-O*O;if(DA<0)n=0;else{const SA=QA+A[NA+A[KA+A[Y]]];DA*=DA,n=DA*DA*(e[SA]*k+i[SA]*f+g[SA]*b+I[SA]*O)}let GA=.6-VA*VA-we*we-lA*lA-_*_;if(GA<0)B=0;else{const SA=QA+AA+A[NA+eA+A[KA+EA+A[Y+rA]]];GA*=GA,B=GA*GA*(e[SA]*VA+i[SA]*we+g[SA]*lA+I[SA]*_)}let hA=.6-LA*LA-yA*yA-uA*uA-HA*HA;if(hA<0)Q=0;else{const SA=QA+V+A[NA+sA+A[KA+mA+A[Y+RA]]];hA*=hA,Q=hA*hA*(e[SA]*LA+i[SA]*yA+g[SA]*uA+I[SA]*HA)}let jA=.6-pA*pA-ZA*ZA-ge*ge-re*re;if(jA<0)E=0;else{const SA=QA+bA+A[NA+YA+A[KA+ee+A[Y+XA]]];jA*=jA,E=jA*jA*(e[SA]*pA+i[SA]*ZA+g[SA]*ge+I[SA]*re)}let zA=.6-Ve*Ve-It*It-v*v-J*J;if(zA<0)h=0;else{const SA=QA+1+A[NA+1+A[KA+1+A[Y+1]]];zA*=zA,h=zA*zA*(e[SA]*Ve+i[SA]*It+g[SA]*v+I[SA]*J)}return 27*(n+B+Q+E+h)}}function YIA(t){const A=new Uint8Array(512);for(let e=0;e<512/2;e++)A[e]=e;for(let e=0;e<512/2-1;e++){const i=e+~~(t()*(256-e)),g=A[e];A[e]=A[i],A[i]=g}for(let e=256;e<512;e++)A[e]=A[e-256];return A}var HIA=Object.defineProperty,OIA=Object.getOwnPropertyDescriptor,$=(t,A,e,i)=>{for(var g=i>1?void 0:i?OIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&HIA(A,e,g),g};const Ky=oA("debugparticles");var la=(t=>(t[t.Billboard=0]="Billboard",t[t.Stretch=1]="Stretch",t[t.HorizontalBillboard=2]="HorizontalBillboard",t[t.VerticalBillboard=3]="VerticalBillboard",t[t.Mesh=4]="Mesh",t))(la||{});class Hn{constructor(){r(this,"alphaKeys"),r(this,"colorKeys")}get duration(){return 1}evaluate(A,e){let i,g=0,I=null,o=0;for(let s=0;s<this.alphaKeys.length;s++){const C=this.alphaKeys[s];(C.time<A||!i)&&(i=C,g=s)}for(let s=0;s<this.colorKeys.length;s++){const C=this.colorKeys[s];(C.time<A||!I)&&(I=C,o=s)}if(I)if(o+1<this.colorKeys.length){const s=this.colorKeys[o+1],C=te.remap(A,I.time,s.time,0,1);e.r=te.lerp(I.color.r,s.color.r,C),e.g=te.lerp(I.color.g,s.color.g,C),e.b=te.lerp(I.color.b,s.color.b,C)}else e.r=I.color.r,e.g=I.color.g,e.b=I.color.b;if(i)if(g+1<this.alphaKeys.length){const s=this.alphaKeys[g+1],C=te.remap(A,i.time,s.time,0,1);e.alpha=te.lerp(i.alpha,s.alpha,C)}else e.alpha=i.alpha;return e}}$([y()],Hn.prototype,"alphaKeys",2),$([y()],Hn.prototype,"colorKeys",2);var Jy=(t=>(t[t.Local=0]="Local",t[t.World=1]="World",t[t.Custom=2]="Custom",t))(Jy||{}),O2=(t=>(t[t.Sphere=0]="Sphere",t[t.SphereShell=1]="SphereShell",t[t.Hemisphere=2]="Hemisphere",t[t.HemisphereShell=3]="HemisphereShell",t[t.Cone=4]="Cone",t[t.Box=5]="Box",t[t.Mesh=6]="Mesh",t[t.ConeShell=7]="ConeShell",t[t.ConeVolume=8]="ConeVolume",t[t.ConeVolumeShell=9]="ConeVolumeShell",t[t.Circle=10]="Circle",t[t.CircleEdge=11]="CircleEdge",t[t.SingleSidedEdge=12]="SingleSidedEdge",t[t.MeshRenderer=13]="MeshRenderer",t[t.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",t[t.BoxShell=15]="BoxShell",t[t.BoxEdge=16]="BoxEdge",t[t.Donut=17]="Donut",t[t.Rectangle=18]="Rectangle",t[t.Sprite=19]="Sprite",t[t.SpriteRenderer=20]="SpriteRenderer",t))(O2||{});class ae{constructor(){r(this,"mode"),r(this,"constant"),r(this,"constantMin"),r(this,"constantMax"),r(this,"curve"),r(this,"curveMin"),r(this,"curveMax"),r(this,"curveMultiplier")}evaluate(A,e){const i=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return A=te.clamp01(A),this.curve.evaluate(A)*this.curveMultiplier;case 2:const g=A*this.curveMin.duration,I=A*this.curveMax.duration;return te.lerp(this.curveMin.evaluate(g),this.curveMax.evaluate(I),i%1)*this.curveMultiplier;case 3:return te.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(A)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(A){if(!A)return 0;let e=Number.MIN_VALUE;for(let i=0;i<A.keys.length;i++){const g=A.keys[i];g.value>e&&(e=g.value)}return e}}$([y()],ae.prototype,"mode",2),$([y()],ae.prototype,"constant",2),$([y()],ae.prototype,"constantMin",2),$([y()],ae.prototype,"constantMax",2),$([y(IB)],ae.prototype,"curve",2),$([y(IB)],ae.prototype,"curveMin",2),$([y(IB)],ae.prototype,"curveMax",2),$([y()],ae.prototype,"curveMultiplier",2);var qy;const ls=(qy=class{constructor(){r(this,"mode"),r(this,"color"),r(this,"colorMin"),r(this,"colorMax"),r(this,"gradient"),r(this,"gradientMin"),r(this,"gradientMax")}evaluate(t,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(t,ls._temp),ls._temp;case 2:return ls._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(t,ls._temp),this.gradientMax.evaluate(t,ls._temp2),ls._temp.lerp(ls._temp2,e)}return ls._temp.set(16711935),ls._temp.alpha=1,ls._temp}},r(qy,"_temp",new yt(0,0,0,1)),r(qy,"_temp2",new yt(0,0,0,1)),qy);let MI=ls;$([y(yt)],MI.prototype,"color",2),$([y(yt)],MI.prototype,"colorMin",2),$([y(yt)],MI.prototype,"colorMax",2),$([y(Hn)],MI.prototype,"gradient",2),$([y(Hn)],MI.prototype,"gradientMin",2),$([y(Hn)],MI.prototype,"gradientMax",2);class dg{constructor(){r(this,"cullingMode"),r(this,"duration"),r(this,"emitterVelocityMode"),r(this,"flipRotation"),r(this,"gravityModifier"),r(this,"gravityModifierMultiplier"),r(this,"loop"),r(this,"maxParticles"),r(this,"playOnAwake"),r(this,"prewarm"),r(this,"ringBufferLoopRange"),r(this,"ringBufferMode"),r(this,"scalingMode"),r(this,"simulationSpace"),r(this,"simulationSpeed"),r(this,"startColor"),r(this,"startDelay"),r(this,"startDelayMultiplier"),r(this,"startLifetime"),r(this,"startLifetimeMultiplier"),r(this,"startRotation"),r(this,"startRotationMultiplier"),r(this,"startRotation3D"),r(this,"startRotationX"),r(this,"startRotationXMultiplier"),r(this,"startRotationY"),r(this,"startRotationYMultiplier"),r(this,"startRotationZ"),r(this,"startRotationZMultiplier"),r(this,"startSize"),r(this,"startSize3D"),r(this,"startSizeMultiplier"),r(this,"startSizeX"),r(this,"startSizeXMultiplier"),r(this,"startSizeY"),r(this,"startSizeYMultiplier"),r(this,"startSizeZ"),r(this,"startSizeZMultiplier"),r(this,"startSpeed"),r(this,"startSpeedMultiplier"),r(this,"stopAction"),r(this,"useUnscaledTime")}}$([y(ae)],dg.prototype,"gravityModifier",2),$([y(MI)],dg.prototype,"startColor",2),$([y(ae)],dg.prototype,"startDelay",2),$([y(ae)],dg.prototype,"startLifetime",2),$([y(ae)],dg.prototype,"startRotation",2),$([y(ae)],dg.prototype,"startRotationX",2),$([y(ae)],dg.prototype,"startRotationY",2),$([y(ae)],dg.prototype,"startRotationZ",2),$([y(ae)],dg.prototype,"startSize",2),$([y(ae)],dg.prototype,"startSizeX",2),$([y(ae)],dg.prototype,"startSizeY",2),$([y(ae)],dg.prototype,"startSizeZ",2),$([y(ae)],dg.prototype,"startSpeed",2);class ad{constructor(){r(this,"cycleCount"),r(this,"maxCount"),r(this,"minCount"),r(this,"probability"),r(this,"repeatInterval"),r(this,"time"),r(this,"count"),r(this,"_performed",0)}reset(){this._performed=0}run(A){if(A<=this.time)return 0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(A>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=te.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:const g=Math.random();e=te.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class gC{constructor(){r(this,"enabled"),r(this,"bursts"),r(this,"rateOverTime"),r(this,"rateOverTimeMultiplier"),r(this,"rateOverDistance"),r(this,"rateOverDistanceMultiplier"),r(this,"system")}get burstCount(){var A;return((A=this.bursts)==null?void 0:A.length)??0}reset(){var A;(A=this.bursts)==null||A.forEach(e=>e.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){const i=this.bursts[e];this.system.main.loop&&i.time>=this.system.time&&i.reset(),A+=Math.round(i.run(this.system.time))}return A}}$([y()],gC.prototype,"enabled",2),$([y()],gC.prototype,"bursts",2),$([y(ae)],gC.prototype,"rateOverTime",2),$([y()],gC.prototype,"rateOverTimeMultiplier",2),$([y(ae)],gC.prototype,"rateOverDistance",2),$([y()],gC.prototype,"rateOverDistanceMultiplier",2);class nd{constructor(){r(this,"enabled"),r(this,"color")}}$([y(MI)],nd.prototype,"color",2);class On{constructor(){r(this,"enabled"),r(this,"separateAxes"),r(this,"size"),r(this,"sizeMultiplier"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier"),r(this,"_time",0),r(this,"_temp",new S)}evaluate(A,e,i){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,i)*this.xMultiplier,e.y=this.y.evaluate(A,i)*this.yMultiplier,e.z=this.z.evaluate(A,i)*this.zMultiplier;else{const g=this.size.evaluate(A,i)*this.sizeMultiplier;e.x=g}return e}}$([y(ae)],On.prototype,"size",2),$([y(ae)],On.prototype,"x",2),$([y(ae)],On.prototype,"y",2),$([y(ae)],On.prototype,"z",2);var vy;const rd=(vy=class{constructor(){r(this,"shapeType",5),r(this,"enabled",!0),r(this,"alignToDirection",!1),r(this,"angle",0),r(this,"arc",360),r(this,"arcSpread"),r(this,"arcSpeedMultiplier"),r(this,"arcMode"),r(this,"boxThickness"),r(this,"position"),r(this,"rotation"),r(this,"_rotation",new og),r(this,"scale"),r(this,"radius"),r(this,"radiusThickness"),r(this,"sphericalDirectionAmount"),r(this,"randomDirectionAmount"),r(this,"randomPositionAmount"),r(this,"system"),r(this,"_space"),r(this,"_worldSpaceMatrix",new JA),r(this,"_worldSpaceMatrixInverse",new JA),r(this,"_vector",new S(0,0,0)),r(this,"_temp",new S(0,0,0)),r(this,"_dir",new S),r(this,"_loopTime",0),r(this,"_loopDirection",1),Ky&&console.log(this)}get type(){return O2[this.shapeType]}initialize(t){this.getPosition(),t.position.copy(this._vector)}toJSON(){return this}clone(){return new rd}update(t,A,e,i){this.system=t,this._space=e,e===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(t){const A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=te.toRadians(this.rotation.x),this._rotation.y=te.toRadians(this.rotation.y),this._rotation.z=te.toRadians(this.rotation.z),this._rotation.order="ZYX",t.applyEuler(this._rotation)),A}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const t=this._temp.copy(this.position),A=this._space===1;A&&t.applyQuaternion(this.system.worldQuaternion);let e=this.radius;if(A&&(e*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Ky&&zC.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(t);break;case 4:this.randomConePoint(this.position,this.angle,e,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),A&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Ky&&zC.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(t){var A;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const e=t.x,i=t.y,g=t.z;this._dir.set(e,i,g),(A=this.system)!=null&&A.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),Ky&&(zC.DrawSphere(t,.01,8925952,.5,!0),zC.DrawDirection(t,this._dir,8925952,.5,!0)),this._dir}randomizePosition(t,A){if(A<=0)return;const e=rd._tempVec;e.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),e.x*=A*this.scale.x,e.y*=A*this.scale.y,e.z*=A*this.scale.z,t.add(e)}randomizeDirection(t,A){if(A===0)return;const e=rd._randomQuat,i=rd._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(i,A*Math.random()*Math.PI),t.applyQuaternion(e)}spherizeDirection(t,A){if(A===0)return;const e=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),g=Math.sin(i)*Math.cos(e),I=Math.sin(i)*Math.sin(e),o=Math.cos(i),s=new S(g,I,o);t.lerp(s,A)}randomSpherePoint(t,A,e,i,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(i/360),C=Math.acos(2*o-1),a=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,n=t.x+this.scale.x*(-a*Math.sin(C)*Math.cos(s)),B=t.y+this.scale.y*(a*Math.sin(C)*Math.sin(s)),Q=t.z+this.scale.z*(a*Math.cos(C));g.x=n,g.y=B,g.z=Q}randomCirclePoint(t,A,e,i,g){const I=Math.random(),o=2*Math.PI*I*(i/360),s=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,C=t.x+this.scale.x*s*Math.cos(o),a=t.y+this.scale.y*s*Math.sin(o),n=t.z;g.x=C,g.y=a,g.z=n}randomConePoint(t,A,e,i,g,I,o){let s=0,C=0;switch(I){case 0:s=Math.random(),C=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,C=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let a=2*Math.PI*s*(g/360);switch(I){case 2:case 1:a+=Math.PI+.5,a+=this._loopTime*Math.PI*2,a%=te.toRadians(g);break}const n=Math.acos(2*C-1),B=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*e,Q=t.x+-B*Math.sin(n)*Math.cos(a),E=t.y+B*Math.sin(n)*Math.sin(a),h=t.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=h*this.scale.z}},r(vy,"_randomQuat",new xA),r(vy,"_tempVec",new S),vy);let Bi=rd;$([y()],Bi.prototype,"shapeType",2),$([y()],Bi.prototype,"enabled",2),$([y()],Bi.prototype,"alignToDirection",2),$([y()],Bi.prototype,"angle",2),$([y()],Bi.prototype,"arc",2),$([y()],Bi.prototype,"arcSpread",2),$([y()],Bi.prototype,"arcSpeedMultiplier",2),$([y()],Bi.prototype,"arcMode",2),$([y(S)],Bi.prototype,"boxThickness",2),$([y(S)],Bi.prototype,"position",2),$([y(S)],Bi.prototype,"rotation",2),$([y(S)],Bi.prototype,"scale",2),$([y()],Bi.prototype,"radius",2),$([y()],Bi.prototype,"radiusThickness",2),$([y()],Bi.prototype,"sphericalDirectionAmount",2),$([y()],Bi.prototype,"randomDirectionAmount",2),$([y()],Bi.prototype,"randomPositionAmount",2);class dt{constructor(){r(this,"damping"),r(this,"enabled"),r(this,"frequency"),r(this,"octaveCount"),r(this,"octaveMultiplier"),r(this,"octaveScale"),r(this,"positionAmount"),r(this,"quality"),r(this,"remap"),r(this,"remapEnabled"),r(this,"remapMultiplier"),r(this,"remapX"),r(this,"remapXMultiplier"),r(this,"remapY"),r(this,"remapYMultiplier"),r(this,"remapZ"),r(this,"remapZMultiplier"),r(this,"scrollSpeedMultiplier"),r(this,"separateAxes"),r(this,"strengthMultiplier"),r(this,"strengthX"),r(this,"strengthXMultiplier"),r(this,"strengthY"),r(this,"strengthYMultiplier"),r(this,"strengthZ"),r(this,"strengthZMultiplier"),r(this,"_noise"),r(this,"_time",0),r(this,"_temp",new S)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,i,g,I,o){if(!this.enabled)return;this._noise||(this._noise=TIA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),C=this._noise(s.x,s.y,s.z,this._time),a=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),n=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(C,a,n).normalize();const B=I/o;let Q=this.positionAmount.evaluate(B);this.separateAxes?(this._temp.x*=Q*this.strengthXMultiplier,this._temp.y*=Q*this.strengthYMultiplier,this._temp.z*=Q*this.strengthZMultiplier):(this.strengthX&&(Q*=this.strengthX.evaluate(B)*1.5),this._temp.multiplyScalar(Q)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}$([y()],dt.prototype,"damping",2),$([y()],dt.prototype,"enabled",2),$([y()],dt.prototype,"frequency",2),$([y()],dt.prototype,"octaveCount",2),$([y()],dt.prototype,"octaveMultiplier",2),$([y()],dt.prototype,"octaveScale",2),$([y(ae)],dt.prototype,"positionAmount",2),$([y()],dt.prototype,"quality",2),$([y(ae)],dt.prototype,"remap",2),$([y()],dt.prototype,"remapEnabled",2),$([y()],dt.prototype,"remapMultiplier",2),$([y(ae)],dt.prototype,"remapX",2),$([y()],dt.prototype,"remapXMultiplier",2),$([y(ae)],dt.prototype,"remapY",2),$([y()],dt.prototype,"remapYMultiplier",2),$([y(ae)],dt.prototype,"remapZ",2),$([y()],dt.prototype,"remapZMultiplier",2),$([y()],dt.prototype,"scrollSpeedMultiplier",2),$([y()],dt.prototype,"separateAxes",2),$([y()],dt.prototype,"strengthMultiplier",2),$([y(ae)],dt.prototype,"strengthX",2),$([y()],dt.prototype,"strengthXMultiplier",2),$([y(ae)],dt.prototype,"strengthY",2),$([y()],dt.prototype,"strengthYMultiplier",2),$([y(ae)],dt.prototype,"strengthZ",2),$([y()],dt.prototype,"strengthZMultiplier",2);class Yt{constructor(){r(this,"enabled"),r(this,"attachRibbonToTransform",!1),r(this,"colorOverLifetime"),r(this,"colorOverTrail"),r(this,"dieWithParticles",!0),r(this,"inheritParticleColor",!0),r(this,"lifetime"),r(this,"lifetimeMultiplier"),r(this,"minVertexDistance",.2),r(this,"mode",0),r(this,"ratio",1),r(this,"ribbonCount",1),r(this,"shadowBias",0),r(this,"sizeAffectsLifetime",!1),r(this,"sizeAffectsWidth",!1),r(this,"splitSubEmitterRibbons",!1),r(this,"textureMode",0),r(this,"widthOverTrail"),r(this,"widthOverTrailMultiplier"),r(this,"worldSpace",!1)}getWidth(A,e,i,g){let I=this.widthOverTrail.evaluate(i,g);return A*=I,A}getColor(A,e,i){const g=this.colorOverTrail.evaluate(i),I=this.colorOverLifetime.evaluate(e);A.x*=g.r*I.r,A.y*=g.g*I.g,A.z*=g.b*I.b,A.w*=g.alpha*I.alpha}}$([y()],Yt.prototype,"enabled",2),$([y()],Yt.prototype,"attachRibbonToTransform",2),$([y(MI)],Yt.prototype,"colorOverLifetime",2),$([y(MI)],Yt.prototype,"colorOverTrail",2),$([y()],Yt.prototype,"dieWithParticles",2),$([y()],Yt.prototype,"inheritParticleColor",2),$([y(ae)],Yt.prototype,"lifetime",2),$([y()],Yt.prototype,"lifetimeMultiplier",2),$([y()],Yt.prototype,"minVertexDistance",2),$([y()],Yt.prototype,"mode",2),$([y()],Yt.prototype,"ratio",2),$([y()],Yt.prototype,"ribbonCount",2),$([y()],Yt.prototype,"shadowBias",2),$([y()],Yt.prototype,"sizeAffectsLifetime",2),$([y()],Yt.prototype,"sizeAffectsWidth",2),$([y()],Yt.prototype,"splitSubEmitterRibbons",2),$([y()],Yt.prototype,"textureMode",2),$([y(ae)],Yt.prototype,"widthOverTrail",2),$([y()],Yt.prototype,"widthOverTrailMultiplier",2),$([y()],Yt.prototype,"worldSpace",2);class Vt{constructor(){r(this,"enabled"),r(this,"space",0),r(this,"orbitalX"),r(this,"orbitalY"),r(this,"orbitalZ"),r(this,"orbitalXMultiplier"),r(this,"orbitalYMultiplier"),r(this,"orbitalZMultiplier"),r(this,"orbitalOffsetX"),r(this,"orbitalOffsetY"),r(this,"orbitalOffsetZ"),r(this,"speedModifier"),r(this,"speedModifierMultiplier"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier"),r(this,"_system"),r(this,"_temp",new S),r(this,"_temp2",new S),r(this,"_temp3",new S),r(this,"_hasOrbital",!1),r(this,"_index",0),r(this,"_orbitalMatrix",new JA)}update(A){this._system=A}init(A){this._index==0&&(A.debug=!0),this._index+=1,A.orbitx=this.orbitalX.evaluate(Math.random()),A.orbity=this.orbitalY.evaluate(Math.random()),A.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=A.orbitx!=0||A.orbity!=0||A.orbitz!=0}apply(A,e,i,g,I,o,s){var C;if(!this.enabled)return;const a=o/s,n=this.speedModifier.evaluate(a)*this.speedModifierMultiplier,B=this.x.evaluate(a),Q=this.y.evaluate(a),E=this.z.evaluate(a);if(this._temp.set(-B,Q,E),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((C=this._system)==null?void 0:C.worldPos)){const h=this._temp2.set(i.x,i.y,i.z),l=this.orbitalXMultiplier,d=this.orbitalYMultiplier,c=this.orbitalZMultiplier,u=n*Math.PI*2*10,p=Math.cos(u*l),D=Math.sin(u*l),w=Math.cos(u*d),m=Math.sin(u*d),M=Math.cos(u*c),F=Math.sin(u*c),k=h.x*(w*M)+h.y*(w*F)+h.z*-m,f=h.x*(D*m*M-p*F)+h.y*(D*m*F+p*M)+h.z*(D*w),b=h.x*(p*m*M+D*F)+h.y*(p*m*F-D*M)+h.z*(p*w),O=this._temp3.set(h.x-k,h.y-f,h.z-b);O.normalize(),O.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=O.x,g.y+=O.y,g.z+=O.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=n,g.y*=n,g.z*=n}}$([y()],Vt.prototype,"enabled",2),$([y()],Vt.prototype,"space",2),$([y(ae)],Vt.prototype,"orbitalX",2),$([y(ae)],Vt.prototype,"orbitalY",2),$([y(ae)],Vt.prototype,"orbitalZ",2),$([y()],Vt.prototype,"orbitalXMultiplier",2),$([y()],Vt.prototype,"orbitalYMultiplier",2),$([y()],Vt.prototype,"orbitalZMultiplier",2),$([y()],Vt.prototype,"orbitalOffsetX",2),$([y()],Vt.prototype,"orbitalOffsetY",2),$([y()],Vt.prototype,"orbitalOffsetZ",2),$([y(ae)],Vt.prototype,"speedModifier",2),$([y()],Vt.prototype,"speedModifierMultiplier",2),$([y(ae)],Vt.prototype,"x",2),$([y()],Vt.prototype,"xMultiplier",2),$([y(ae)],Vt.prototype,"y",2),$([y()],Vt.prototype,"yMultiplier",2),$([y(ae)],Vt.prototype,"z",2),$([y()],Vt.prototype,"zMultiplier",2);class pg{constructor(){r(this,"animation"),r(this,"enabled"),r(this,"cycleCount"),r(this,"frameOverTime"),r(this,"frameOverTimeMultiplier"),r(this,"numTilesX"),r(this,"numTilesY"),r(this,"startFrame"),r(this,"startFrameMultiplier"),r(this,"rowMode"),r(this,"rowIndex"),r(this,"spriteCount"),r(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){const e=this.numTilesX*this.numTilesY;A=A*this.cycleCount;let i=this.frameOverTime.evaluate(A%1);return i*=this.frameOverTimeMultiplier,i*=e,i=i%e,i=Math.floor(i),i}}$([y()],pg.prototype,"animation",2),$([y()],pg.prototype,"enabled",2),$([y()],pg.prototype,"cycleCount",2),$([y(ae)],pg.prototype,"frameOverTime",2),$([y()],pg.prototype,"frameOverTimeMultiplier",2),$([y()],pg.prototype,"numTilesX",2),$([y()],pg.prototype,"numTilesY",2),$([y(ae)],pg.prototype,"startFrame",2),$([y()],pg.prototype,"startFrameMultiplier",2),$([y()],pg.prototype,"rowMode",2),$([y()],pg.prototype,"rowIndex",2),$([y()],pg.prototype,"spriteCount",2),$([y()],pg.prototype,"timeMode",2);class qo{constructor(){r(this,"enabled"),r(this,"separateAxes"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}$([y()],qo.prototype,"enabled",2),$([y()],qo.prototype,"separateAxes",2),$([y(ae)],qo.prototype,"x",2),$([y()],qo.prototype,"xMultiplier",2),$([y(ae)],qo.prototype,"y",2),$([y()],qo.prototype,"yMultiplier",2),$([y(ae)],qo.prototype,"z",2),$([y()],qo.prototype,"zMultiplier",2);class eo{constructor(){r(this,"enabled"),r(this,"range"),r(this,"separateAxes"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const i=te.lerp(this.range.x,this.range.y,e);return this.z.evaluate(i)*-1}return 0}}$([y()],eo.prototype,"enabled",2),$([y()],eo.prototype,"range",2),$([y()],eo.prototype,"separateAxes",2),$([y(ae)],eo.prototype,"x",2),$([y()],eo.prototype,"xMultiplier",2),$([y(ae)],eo.prototype,"y",2),$([y()],eo.prototype,"yMultiplier",2),$([y(ae)],eo.prototype,"z",2),$([y()],eo.prototype,"zMultiplier",2);class Gi{constructor(){r(this,"enabled"),r(this,"dampen"),r(this,"drag"),r(this,"dragMultiplier"),r(this,"limit"),r(this,"limitMultiplier"),r(this,"separateAxes"),r(this,"limitX"),r(this,"limitXMultiplier"),r(this,"limitY"),r(this,"limitYMultiplier"),r(this,"limitZ"),r(this,"limitZMultiplier"),r(this,"multiplyDragByParticleSize",!1),r(this,"multiplyDragByParticleVelocity",!1),r(this,"space"),r(this,"_temp",new S),r(this,"_temp2",new S)}apply(A,e,i,g,I,o,s){if(this.enabled){const C=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>C){this._temp.copy(e).normalize().multiplyScalar(C);let a=this.dampen*.5;e.x=te.lerp(e.x,this._temp.x,a),e.y=te.lerp(e.y,this._temp.y,a),e.z=te.lerp(e.z,this._temp.z,a),i.x=te.lerp(i.x,this._temp.x,a),i.y=te.lerp(i.y,this._temp.y,a),i.z=te.lerp(i.z,this._temp.z,a)}}}}$([y()],Gi.prototype,"enabled",2),$([y()],Gi.prototype,"dampen",2),$([y(ae)],Gi.prototype,"drag",2),$([y()],Gi.prototype,"dragMultiplier",2),$([y(ae)],Gi.prototype,"limit",2),$([y()],Gi.prototype,"limitMultiplier",2),$([y()],Gi.prototype,"separateAxes",2),$([y(ae)],Gi.prototype,"limitX",2),$([y()],Gi.prototype,"limitXMultiplier",2),$([y(ae)],Gi.prototype,"limitY",2),$([y()],Gi.prototype,"limitYMultiplier",2),$([y(ae)],Gi.prototype,"limitZ",2),$([y()],Gi.prototype,"limitZMultiplier",2),$([y()],Gi.prototype,"multiplyDragByParticleSize",2),$([y()],Gi.prototype,"multiplyDragByParticleVelocity",2),$([y()],Gi.prototype,"space",2);class _n{constructor(){r(this,"enabled"),r(this,"curve"),r(this,"curveMultiplier"),r(this,"mode"),r(this,"system"),r(this,"_lastWorldPosition"),r(this,"_velocity",new S),r(this,"_temp",new S)}update(A){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(A){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),A.add(this._temp)}}applyCurrent(A,e,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const g=this.curve.evaluate(e,i);this._temp.copy(this._velocity).multiplyScalar(g),A.add(this._temp)}}}$([y()],_n.prototype,"enabled",2),$([y(ae)],_n.prototype,"curve",2),$([y()],_n.prototype,"curveMultiplier",2),$([y()],_n.prototype,"mode",2);class oI{constructor(){r(this,"enabled"),r(this,"range"),r(this,"separateAxes"),r(this,"size"),r(this,"sizeMultiplier"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier")}evaluate(A,e,i,g){const I=A.length(),o=te.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,i);return g*s}}$([y()],oI.prototype,"enabled",2),$([y(Z)],oI.prototype,"range",2),$([y()],oI.prototype,"separateAxes",2),$([y(ae)],oI.prototype,"size",2),$([y()],oI.prototype,"sizeMultiplier",2),$([y(ae)],oI.prototype,"x",2),$([y()],oI.prototype,"xMultiplier",2),$([y(ae)],oI.prototype,"y",2),$([y()],oI.prototype,"yMultiplier",2),$([y(ae)],oI.prototype,"z",2),$([y()],oI.prototype,"zMultiplier",2);class uB{constructor(){r(this,"enabled"),r(this,"range"),r(this,"color")}evaluate(A,e,i){const g=A.length(),I=te.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}$([y()],uB.prototype,"enabled",2),$([y(Z)],uB.prototype,"range",2),$([y(MI)],uB.prototype,"color",2);function _IA(t){const A=t.domElement.querySelector("link[rel='ar']");if(A)return A;const e=document.createElement("div");e.classList.add("menu"),e.classList.add("quicklook-menu"),e.style.display="none",e.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",e.appendChild(i);const g=document.createElement("a");g.id="needle-usdz-link",g.style.display="none",g.rel="ar",g.href="",e.appendChild(g);const I=document.createElement("img");return I.id="button",g.appendChild(I),t.domElement.appendChild(e),g}function PIA(){var t=new Date;const A=t.getMonth()+1,e=t.getDate(),i=t.getHours(),g=t.getMinutes(),I=t.getSeconds(),o=(A<10?"0":"")+A,s=(e<10?"0":"")+e,C=(i<10?"0":"")+i,a=(g<10?"0":"")+g,n=(I<10?"0":"")+I;return t.getFullYear()+o+s+"-"+C+a+n}const by=oA("debugusdz");function jIA(t,A){const e=[],i=tA.getComponentsInChildren(t,tI);let g=!1;by&&console.log(i);for(const I of i){if(!I||!I.runtimeAnimatorController)continue;by&&console.log(I);const o=[];for(const s of I.runtimeAnimatorController.enumerateActions()){by&&console.log(s);const C=s.getClip();if(!g&&C.tracks.length>0){g=!0;const a=C.tracks[0],n=a.name.substring(0,a.name.lastIndexOf(".")),B=new PI(n+".position",[0,.01],[0,0,0,0,0,0]),Q=new PI(n+".quaternion",[0,.01],[0,0,0,1,0,0,0,1]);o.push(new jg("rest",.01,[B,Q]))}o.includes(C)||o.push(C)}e.push({root:I.gameObject,clips:o})}by&&console.log(e);for(const I of e)for(const o of I.clips)A.registerAnimation(I.root,o)}var WIA=Object.defineProperty,VIA=Object.getOwnPropertyDescriptor,da=(t,A,e,i)=>{for(var g=i>1?void 0:i?VIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&WIA(A,e,g),g};const DB=oA("debugtext");var _i=(t=>(t[t.UpperLeft=0]="UpperLeft",t[t.UpperCenter=1]="UpperCenter",t[t.UpperRight=2]="UpperRight",t[t.MiddleLeft=3]="MiddleLeft",t[t.MiddleCenter=4]="MiddleCenter",t[t.MiddleRight=5]="MiddleRight",t[t.LowerLeft=6]="LowerLeft",t[t.LowerCenter=7]="LowerCenter",t[t.LowerRight=8]="LowerRight",t))(_i||{}),_2=(t=>(t[t.Normal=0]="Normal",t[t.Bold=1]="Bold",t[t.Italic=2]="Italic",t[t.BoldAndItalic=3]="BoldAndItalic",t))(_2||{});class sI extends hB{constructor(){super(...arguments),r(this,"alignment",0),r(this,"verticalOverflow",0),r(this,"horizontalOverflow",0),r(this,"lineSpacing",1),r(this,"supportRichText",!1),r(this,"font"),r(this,"fontStyle",0),r(this,"_text",""),r(this,"_fontSize",12),r(this,"_textMeshUi",null),r(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(A){var e;super.setAlphaFactor(A),(e=this.uiObject)==null||e.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(A){A!==this._text&&(this._text=A,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(A){this.text=A}get fontSize(){return this._fontSize}set fontSize(A){var e;this._fontSize=A,(e=this.uiObject)==null||e.set({fontSize:A})}onColorChanged(){var A;(A=this.uiObject)==null||A.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var A;this.uiObject&&((A=this.Canvas)!=null&&A.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var A;const e=(A=this.uiObject)==null?void 0:A._overflow;e&&(e._needsUpdate=!0,this.markDirty())}onCreate(A){DB&&console.log(this),this.horizontalOverflow==1&&(A.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,A.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,A.lineHeight=this.lineSpacing,delete A.backgroundOpacity,delete A.backgroundColor,DB&&(A.backgroundColor=16750848,A.backgroundOpacity=.5);const e=this.rectTransform;A={...A,...this.getTextOpts()},this.getAlignment(A),DB&&(A.backgroundColor=Math.random()*16777215,A.backgroundOpacity=.1),this.uiObject=e.createNewText(A),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let A=this.fontSize;const e={color:this.color,fontOpacity:this.color.alpha,fontSize:A,fontKerning:"normal"};return this.setFont(e,this.fontStyle),e}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(A){switch(A.flexDirection="column",this.alignment){case 0:case 3:case 6:A.textAlign="left";break;case 1:case 4:case 7:A.textAlign="center";break;case 2:case 5:case 8:A.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:A.alignItems="start";break;case 3:case 4:case 5:A.alignItems="center";break;case 6:case 7:case 8:A.alignItems="end";break}return A}feedText(A,e){var i,g,I;if(DB&&console.log("feedText",this.uiObject,A,e),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!e||A.length===0)this.uiObject.textContent=A;else{let o=this.getNextTag(A);if(o){if(o.startIndex>0){for(let a=this.uiObject.children.length-1;a>=0;a--){const n=this.uiObject.children[a];n.isUI&&(this.uiObject.remove(n),n.clear())}const C=new ry({textContent:A.substring(0,o.startIndex),color:"inherit"});this.uiObject.add(C)}}else{this.uiObject.textContent="",this.setOptions({textContent:A});return}const s=[];for(;o;){const C=this.getNextTag(A,o.endIndex),a={fontFamily:(i=this.uiObject)==null?void 0:i.get("fontFamily"),color:"inherit",textContent:""};if(C){a.textContent=this.getText(A,o,C),this.handleTag(o,a,s);const n=new ry(a);(g=this.uiObject)==null||g.add(n)}else{a.textContent=A.substring(o.endIndex),this.handleTag(o,a,s);const n=new ry(a);(I=this.uiObject)==null||I.add(n)}o=C}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const A=[],e=this.canvas,i={renderOnTop:e.renderOnTop,depthWrite:e.depthWrite,doubleSided:e.doubleSided};for(;;){let g=!1;if(this._textMeshUi)for(let I=0;I<this._textMeshUi.length;I++){if(A[I]===!0)continue;g=!0;const o=this._textMeshUi[I];o.textContent&&(fy(o,i),A[I]=!0)}if(!g)break;yield}}handleTag(A,e,i){if(!A.isEndTag){if(A.type.includes("color")){const g=new pU(A,{color:e.color});if(i.push(g),A.type.length>6){const I=parseInt("0x"+A.type.substring(7));e.color=I}else e.color=new wA(1,1,1)}else if(A.type=="b"){this.setFont(e,1);const g=new pU(A,{fontWeight:700});i.push(g)}else if(A.type=="i"){this.setFont(e,2);const g=new pU(A,{fontStyle:"italic"});i.push(g)}}}getText(A,e,i){return A.substring(e.endIndex,i.startIndex)}getNextTag(A,e=0){const i=A.indexOf("<",e),g=A.indexOf(">",i);if(i>=0&&g>=0){const I=A.substring(i+1,g);return{type:I,startIndex:i,endIndex:g+1,isEndTag:I.startsWith("/")}}return null}setFont(A,e){if(!this.font)return;let i=this.font,g=this.getFamilyNameWithCorrectSuffix(i,e);DB&&console.log("Selected font family:"+g);let I=vR.getFontFamily(g);switch(I||(I=vR.addFontFamily(g)),A.fontFamily=I,e){default:case 0:A.fontWeight=400,A.fontStyle="normal";break;case 1:A.fontWeight=700,A.fontStyle="normal";break;case 2:A.fontWeight=400,A.fontStyle="italic";break;case 3:A.fontStyle="italic",A.fontWeight=400}let o=I.getVariant(A.fontWeight,A.fontStyle);if(!o){let s=g;s!=null&&s.endsWith("-msdf.json")||(s+="-msdf.json");let C=g;C!=null&&C.endsWith(".png")||(C+=".png"),o=I.addVariant(A.fontWeight,A.fontStyle,s,C),o?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(A,e){var i;const g=A.lastIndexOf("-");if(g<0)return A;const I=(i=A.substring(g+1))==null?void 0:i.toLowerCase();if(zIA.includes(I))return DB&&console.warn("Unsupported font style: "+I),A;const o=A.lastIndexOf("/");let s=A;o>=0&&(s=s.substring(o+1));let C=s[0]===s[0].toUpperCase();const a=A.substring(0,g);switch(DB&&console.log("Select font: ",A,_2[e],s,C,a),e){case 0:return C?a+"-Regular":a+"-regular";case 1:return C?a+"-Bold":a+"-bold";case 2:return C?a+"-Italic":a+"-italic";case 3:return C?a+"-BoldItalic":a+"-bolditalic";default:return A}}}da([y()],sI.prototype,"alignment",2),da([y()],sI.prototype,"verticalOverflow",2),da([y()],sI.prototype,"horizontalOverflow",2),da([y()],sI.prototype,"lineSpacing",2),da([y()],sI.prototype,"supportRichText",2),da([y(URL)],sI.prototype,"font",2),da([y()],sI.prototype,"fontStyle",2),da([y()],sI.prototype,"text",1),da([y()],sI.prototype,"fontSize",1);class pU{constructor(A,e){r(this,"tag"),r(this,"previousValues"),this.tag=A,this.previousValues=e}}const zIA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Pn{constructor(A){r(this,"id"),r(this,"content",""),r(this,"font",[]),r(this,"pointSize",144),r(this,"width"),r(this,"height"),r(this,"depth"),r(this,"wrapMode"),r(this,"horizontalAlignment"),r(this,"verticalAlignment"),r(this,"material"),this.id=A}static getId(){return this.global_id++}setDepth(A){return this.depth=A,this}setPointSize(A){return this.pointSize=A,this}setHorizontalAlignment(A){return this.horizontalAlignment=A,this}setVerticalAlignment(A){return this.verticalAlignment=A,this}writeTo(A,e){var i;e.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&e.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(i=this.font)==null||i.push("sans-serif"));const g=this.font.map(I=>`"${I}"`).join(", ");e.appendLine(`string[] font = [ ${g} ]`),e.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&e.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&e.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&e.appendLine(`double depth = ${this.depth}`),this.wrapMode&&e.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&e.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&e.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&e.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),e.closeBlock()}}r(Pn,"global_id",0);class Ly{static singleLine(A,e,i){const g=new Pn("text_"+Pn.getId());return g.content=A,e&&(g.pointSize=e),i&&(g.depth=i),g}static multiLine(A,e,i,g,I,o){const s=new Pn("text_"+Pn.getId());return s.content=A,s.width=e,s.height=i,s.horizontalAlignment=g,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const ZIA=new JA().makeRotationY(Math.PI),XIA=new JA().makeScale(-1,1,-1);class Bd{get extensionName(){return"text"}onExportObject(A,e,i){}exportText(A,e,i){const g=tA.getComponent(A,sI);if(!g)return;const I=tA.getComponent(A,hg);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=ZIA.clone(),I&&e.matrix.premultiply(XIA);const C=new wA().copySRGBToLinear(g.color);e.material=new Xo({color:C,emissive:C}),e.addEventListener("serialize",(a,n)=>{let B=g.text;B=B.replace(/\n/g,"\\n");const Q=Ly.multiLine(B,o,s,"center","bottom","flowing");this.setTextAlignment(Q,g.alignment),this.setOverflow(Q,g),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(g.fontSize),Q.depth=.001,Q.writeTo(void 0,a)})}convertToTextSize(A){return 1/.0502*144*A}setOverflow(A,e){e.horizontalOverflow?A.wrapMode="singleLine":A.wrapMode="flowing"}setTextAlignment(A,e){switch(e){case _i.LowerLeft:case _i.MiddleLeft:case _i.UpperLeft:A.horizontalAlignment="left";break;case _i.LowerCenter:case _i.MiddleCenter:case _i.UpperCenter:A.horizontalAlignment="center";break;case _i.LowerRight:case _i.MiddleRight:case _i.UpperRight:A.horizontalAlignment="right";break}switch(e){case _i.LowerLeft:case _i.LowerCenter:case _i.LowerRight:A.verticalAlignment="bottom";break;case _i.MiddleLeft:case _i.MiddleCenter:case _i.MiddleRight:A.verticalAlignment="middle";break;case _i.UpperLeft:case _i.UpperCenter:case _i.UpperRight:A.verticalAlignment="top";break}}}class xy{get extensionName(){return"tmui"}onExportObject(A,e,i){const g=tA.getComponent(A,cg);if(g&&g.activeAndEnabled&&g.renderMode===Y2.WorldSpace){const I=new Bd,o=tA.getComponent(A,hg),s=tA.getComponent(A,xn);if(o){o.width,o.height;const C=mo.createEmpty(),a=o.shadowComponent;if(e.add(C),a){const n=a.matrix;C.matrix.copy(n);const B=new Map,Q=new Map;B.set(a,C),Q.set(a,s?s.alpha:1),a.traverse(E=>{if(E===a)return;const h=mo.createEmpty();h.matrix.copy(E.matrix);const l=E.parent,d=l&&typeof l.textContent=="string"&&l.textContent.length;let c=Q.get(l)||1;const u=tA.getComponent(E,xn);if(u&&(c*=u.alpha),E instanceof fA&&d){const D=E[$s].gameObject;I.exportText(D,h,i)}if(E instanceof fA&&!d){const D=E.geometry.clone();D.scale(1,1,-1),this.flipWindingOrder(D),h.geometry=D;const w=new wA,m=E.material.opacity;w.copy(E.material.color),h.material=new Et({color:w,opacity:m*c,map:E.material.map,transparent:!0})}B.set(E,h),Q.set(E,c);const p=B.get(l);if(!p){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}p.add(h)})}}}}flipWindingOrder(A){const e=A.index.array;for(let i=0,g=e.length/3;i<g;i++){let I=e[i*3];e[i*3]=e[i*3+2],e[i*3+2]=I}A.index.needsUpdate=!0}}var $IA=Object.defineProperty,AoA=Object.getOwnPropertyDescriptor,to=(t,A,e,i)=>{for(var g=i>1?void 0:i?AoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&$IA(A,e,g),g};const Ag=oA("debugusdz");class jn{constructor(){r(this,"callToAction"),r(this,"checkoutTitle"),r(this,"checkoutSubtitle"),r(this,"callToActionURL")}}to([y()],jn.prototype,"callToAction",2),to([y()],jn.prototype,"checkoutTitle",2),to([y()],jn.prototype,"checkoutSubtitle",2),to([y()],jn.prototype,"callToActionURL",2);class io extends UA{constructor(){super(...arguments),r(this,"objectToExport"),r(this,"autoExportAnimations",!1),r(this,"exportFileName"),r(this,"customUsdzFile"),r(this,"customBranding"),r(this,"anchoringType","plane"),r(this,"planeAnchoringAlignment","horizontal"),r(this,"interactive",!0),r(this,"extensions",[]),r(this,"allowCreateQuicklookButton",!0),r(this,"link"),r(this,"webxr"),r(this,"onClickedOpenInARElement",A=>{A.preventDefault(),this.exportAsync()}),r(this,"lastCallback"),r(this,"_quicklookButton"),r(this,"_quicklookButtonContainer",null)}start(){var A,e,i;Ag&&(console.log(this),console.log("Debug USDZ, press 't' to export"),window.addEventListener("keydown",g=>{switch(g.key){case"t":this.exportAsync();break}}),Ha()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((e=(A=this.objectToExport)==null?void 0:A.children)!=null&&e.length)&&!((i=this.objectToExport)!=null&&i.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Sy),this.extensions.push(new wy),this.extensions.push(new Bd),this.extensions.push(new xy))}onEnable(){var A;const e=Oh(),i=wC();(Ag||e&&i)&&((Ag||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=_IA(this.context),this.link.addEventListener("message",this.lastCallback)),Ag&&pi("USDZ Exporter enabled: "+this.name),(A=document.getElementById("open-in-ar"))==null||A.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var A,e;(A=this.link)==null||A.removeEventListener("message",this.lastCallback);const i=Oh(),g=wC();(Ag||i&&g)&&this.removeQuicklookButton(),Ag&&pi("USDZ Exporter disabled: "+this.name),(e=document.getElementById("open-in-ar"))==null||e.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var A;let e=this.exportFileName??((A=this.objectToExport)==null?void 0:A.name)??this.name;if(tE()||(e+="-MadeWithNeedle"),e+="-"+PIA(),this.customUsdzFile){Ag&&console.log("Exporting custom usdz",this.customUsdzFile);const l=this.buildQuicklookOverlay();Ag&&console.log(l);const d=l.callToAction?encodeURIComponent(l.callToAction):"",c=l.checkoutTitle?encodeURIComponent(l.checkoutTitle):"",u=l.checkoutSubtitle?encodeURIComponent(l.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${d}&checkoutTitle=${c}&checkoutSubtitle=${u}&callToActionURL=${l.callToActionURL}`,Ag&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click();return}if(!this.objectToExport)return;const i=tA.getComponentsInChildren(this.objectToExport,bt),g=new Array;for(const l of i)for(const d of l.sharedMaterials)if(d){const c=l.loadProgressiveTextures(d);c instanceof Promise&&g.push(c)}Ag&&pi("Load textures: "+g.length),await Promise.all(g),Ag&&pi("Load textures: done"),this.applyWebARSessionRoot();const I=new X7,o=[...this.extensions],s=new qw;o.push(s),this.autoExportAnimations&&jIA(this.objectToExport,s);const C={self:this,exporter:I,extensions:o,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:C})),I.debug=Ag,this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal");const a=await I.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:o,quickLookCompatible:!0}),n=new Blob([a],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:C}));const B=this.buildQuicklookOverlay();Ag&&console.log(B);const Q=B.callToAction?encodeURIComponent(B.callToAction):"",E=B.checkoutTitle?encodeURIComponent(B.checkoutTitle):"",h=B.checkoutSubtitle?encodeURIComponent(B.checkoutSubtitle):"";this.link.href=URL.createObjectURL(n)+`#callToAction=${Q}&checkoutTitle=${E}&checkoutSubtitle=${h}&callToActionURL=${B.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}quicklookCallback(A){if(A?.data=="_apple_ar_quicklook_button_tapped"){Ag&&Do("Quicklook closed via call to action button");var e=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(e),!e.defaultPrevented){const i=new URLSearchParams(this.link.href);if(i){const g=i.get("callToActionURL");Ag&&pi("Quicklook url: "+g),g&&(tE()?globalThis.open(g,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",g))}}}}buildQuicklookOverlay(){var A,e,i,g,I,o;const s={};return this.customBranding&&Object.assign(s,this.customBranding),tE()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),s.callToAction="Close",s.checkoutTitle="\u{1F335} Made with Needle",s.checkoutSubtitle="_"),(((A=s.callToAction)==null?void 0:A.length)||((e=s.checkoutTitle)==null?void 0:e.length)||((i=s.checkoutSubtitle)==null?void 0:i.length))&&((g=s.callToAction)!=null&&g.length||(s.callToAction="\0"),(I=s.checkoutTitle)!=null&&I.length||(s.checkoutTitle="\0"),(o=s.checkoutSubtitle)!=null&&o.length||(s.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:s})),s}async createQuicklookButton(){var A,e;if(!this.webxr)if(await Hh(1),this.webxr=tA.findObjectOfType(Se)??void 0,this.webxr)if(this.webxr.VRButton&&((A=this.webxr.VRButton.parentElement)==null||A.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const i=(e=this.webxr.ARButton.parentElement)==null?void 0:e.querySelector("a");i&&(i.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",g=>{g.preventDefault(),this.exportAsync()}),this.webxr.ARButton.classList.add("quicklook-ar-button"),this._quicklookButtonContainer=this.webxr.ARButton.parentElement,this.dispatchEvent(new CustomEvent("created-button",{detail:this.webxr.ARButton}))}else{this.webxr.createARButton=!1,this.webxr.createVRButton=!1;let i=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");i||(i=document.createElement("div"),i.classList.add("webxr-buttons"));const g=document.createElement("button");g.innerText="Open in Quicklook",g.addEventListener("click",()=>{this.exportAsync()}),g.classList.add("webxr-ar-button"),g.classList.add("webxr-button"),g.classList.add("quicklook-ar-button"),this._quicklookButton=g,i.appendChild(g),this._quicklookButtonContainer=i,this.dispatchEvent(new CustomEvent("created-button",{detail:g}))}else console.warn("Could not find WebXR component: will not create Quicklook button",be.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var A;(A=this._quicklookButton)==null||A.remove()}applyWebARSessionRoot(){if(Ag&&console.log("applyWebARSessionRoot"),!this.objectToExport)return;let A=tA.getComponentInParent(this.objectToExport,js);const e=A!=null;if(A||(A=tA.getComponentInChildren(this.objectToExport,js)),!A){Ag&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const i=e?this.objectToExport:A.gameObject,g=1/A.arScale;Ag&&console.log("Scale",g,i),i.matrix.makeScale(g,g,g),A.invertForward&&i.matrix.multiply(new JA().makeRotationY(Math.PI))}}to([y(vA)],io.prototype,"objectToExport",2),to([y()],io.prototype,"autoExportAnimations",2),to([y()],io.prototype,"exportFileName",2),to([y(URL)],io.prototype,"customUsdzFile",2),to([y(jn)],io.prototype,"customBranding",2),to([y()],io.prototype,"anchoringType",2),to([y()],io.prototype,"planeAnchoringAlignment",2),to([y()],io.prototype,"interactive",2),to([y()],io.prototype,"allowCreateQuicklookButton",2);const P2=oA("debugdeletable");class Ty extends Ps{}class uU extends UA{constructor(){super(...arguments),r(this,"deleteBoxes",[])}awake(){this.deleteBoxes=tA.findObjectsOfType(Ty,this.context)}update(){for(const A of this.deleteBoxes){const e=this.gameObject;if(A.isInBox(e)===!0){const i=tA.getComponentInParent(this.gameObject,wE);i?P2&&console.warn("Can not delete object with usage marker",this.guid,i):(P2&&console.log("DESTROY",this.gameObject),OD(this.gameObject,this.context.connection))}}}}var eoA=Object.defineProperty,toA=Object.getOwnPropertyDescriptor,wB=(t,A,e,i)=>{for(var g=i>1?void 0:i?toA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&eoA(A,e,g),g};class ds extends vg{constructor(){super(...arguments),r(this,"mode"),r(this,"focusDistance"),r(this,"focalLength"),r(this,"aperture"),r(this,"gaussianMaxRadius"),r(this,"resolutionScale"),r(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=e=>{const i=e/300,g=2;return te.lerp(g,.01,i)};const A=20;this.aperture.valueProcessor=e=>{const i=1-e/32;return te.lerp(1,A,i)}}onCreateEffect(){if(this.mode===0)return;const A=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let i=1;Ha()&&(i=.6),this.resolutionScale=new ke(i*A)}const e=new Sx(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=i=>{e.circleOfConfusionMaterial.worldFocusDistance=i},this.focalLength.onValueChanged=i=>e.circleOfConfusionMaterial.worldFocusRange=i,this.aperture.onValueChanged=i=>e.bokehScale=i,this.resolutionScale&&(this.resolutionScale.onValueChanged=i=>e.resolution.scale=i),[e]}unapply(){}}wB([y()],ds.prototype,"mode",2),wB([y(ke)],ds.prototype,"focusDistance",2),wB([y(ke)],ds.prototype,"focalLength",2),wB([y(ke)],ds.prototype,"aperture",2),wB([y(ke)],ds.prototype,"gaussianMaxRadius",2),wB([y(ke)],ds.prototype,"resolutionScale",2),wB([y(ke)],ds.prototype,"bokehScale",2),Jo("DepthOfField",ds);var ioA=Object.defineProperty,goA=Object.getOwnPropertyDescriptor,IoA=(t,A,e,i)=>{for(var g=i>1?void 0:i?goA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ioA(A,e,g),g};class Yy extends UA{constructor(){super(...arguments),r(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||tA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:ooA()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}IoA([y()],Yy.prototype,"visibleOn",2);let Hy;function ooA(){if(Hy===!0||Hy===!1)return Hy;let t=!1;return function(A){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(A)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(A.substr(0,4)))&&(t=!0)}(navigator.userAgent||navigator.vendor||window.opera),Hy=t,t}class DU{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var soA=Object.defineProperty,CoA=Object.getOwnPropertyDescriptor,j2=(t,A,e,i)=>{for(var g=i>1?void 0:i?CoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&soA(A,e,g),g},W2=(t=>(t.SelectStart="selectstart",t.SelectEnd="selectend",t))(W2||{}),Oy;const Wn=(Oy=class extends DE{constructor(){super(),r(this,"showGizmo",!0),r(this,"useViewAngle",!0),r(this,"transformSelf",!0),r(this,"orbit",null),r(this,"selectStartEventListener",[]),r(this,"selectEndEventListener",[]),r(this,"_dragHelper",null),r(this,"_draggingRigidbodies",[]),r(this,"_waitingForDragStart",null),r(this,"_isDragging",!1),r(this,"_marker",null),r(this,"_dragDelta"),r(this,"_didDrag",!1),r(this,"_activePointerId"),this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new Z}static get HasAnySelected(){return this._active>0}addDragEventListener(t,A){switch(t){case"selectstart":this.selectStartEventListener.push(A);break;case"selectend":this.selectEndEventListener.push(A);break}}start(){this.orbit=tA.findObjectOfType(Ba,this.context),this.gameObject.getComponentInParent(aa)||this.gameObject.addNewComponent(aa)}allowEdit(t=null){return this.context.connection.allowEditing}onPointerEnter(t){if(!this.allowEdit(this.gameObject)||Se.IsInWebXR)return;const A=tA.getComponentInParent(t.object,Wn);!A||A!==this||(Wn.lastHovered=t.object,this.context.domElement.style.cursor="pointer")}onPointerExit(t){this.allowEdit(this.gameObject)&&(Se.IsInWebXR||Wn.lastHovered===t.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(t){this.allowEdit(this.gameObject)&&(Se.IsInWebXR||(Wn._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=t.clone(),t.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(t){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(Wn._active>0&&(Wn._active-=1),!Se.IsInWebXR&&(this.onDragEnd(t),t.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var t;if(!Se.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const e=this.context.input.getPointerPositionDelta(0);if(e&&this._dragDelta.add(e),this._dragDelta.length()>2)this._didDrag=!0;else return}const A=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(A)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((t=this._dragHelper)==null?void 0:t.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(t){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new z2(this.context.mainCamera);else return;if(!t||!t.object)return;const A=tA.getComponentInParent(t.object,Wn);if(!A||A!==this)return;let e=t.object;this.transformSelf&&(e=this.gameObject);const i={selected:e,attached:e};for(const s of this.selectStartEventListener)s(this,i);if(this._activePointerId=t.pointerId,!i.attached)return;i.attached,e=i.attached,this._isDragging=!0,this._dragHelper.setSelected(e,this.context),this.orbit&&(this.orbit.enabled=!1);const g=tA.getComponentInChildren(e,Kn);g&&(g.fastMode=!0,g?.requestOwnership()),this._marker=tA.addNewComponent(e,wE),this._draggingRigidbodies.length=0;const I=tA.getComponentsInChildren(e,Wt);I&&this._draggingRigidbodies.push(...I);const o=kp();tA.invokeOnChildren(this._dragHelper.selected,o("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const t of this._draggingRigidbodies)t.wakeUp(),t.resetVelocities()}}onDragEnd(t){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const i of this._draggingRigidbodies)i.setVelocity(i.smoothedVelocity);this._draggingRigidbodies.length=0;const A=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),t!=null&&t.object){const i=tA.getComponentInChildren(t.object,Kn);i&&(i.fastMode=!1)}this._marker&&this._marker.destroy();for(const i of this.selectEndEventListener)i(this);const e=kp();tA.invokeOnChildren(A,e("onDragEnd"))}},r(Oy,"_active",0),r(Oy,"lastHovered"),Oy);let zE=Wn;j2([y()],zE.prototype,"showGizmo",2),j2([y()],zE.prototype,"useViewAngle",2);const V2=class{constructor(t){r(this,"showGizmo",!0),r(this,"useViewAngle",!0),r(this,"_selected",null),r(this,"_context",null),r(this,"_camera"),r(this,"_cameraPlane",new ho),r(this,"_hasGroundPlane",!1),r(this,"_groundPlane",new ho),r(this,"_groundOffset",new S),r(this,"_groundOffsetFactor",0),r(this,"_groundDistance",0),r(this,"_groundPlanePoint",new S),r(this,"_raycaster",new TQ),r(this,"_cameraPlaneOffset",new S),r(this,"_intersection",new S),r(this,"_worldPosition",new S),r(this,"_inverseMatrix",new JA),r(this,"_rbs",[]),r(this,"_groundLine"),r(this,"_groundMarker"),r(this,"_groundOffsetVector",new S(0,1,0)),r(this,"_requireUpdateGroundPlane",!0),r(this,"_didDragOnGroundPlaneLastFrame",!1),this._camera=t;const A=new si(V2.geometry),e=A.material;e.color=new wA(.4,.4,.4),A.layers.set(2),A.name="line",A.scale.y=1,this._groundLine=A;const i=new Yo(.5,22,22),g=new Et({color:e.color}),I=new fA(i,g);I.visible=!1,I.layers.set(2),this._groundMarker=I}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(t,A){if(this._selected&&A)for(const e of this._rbs)e.wakeUp(),e.setVelocity(0,0,0);if(this._selected&&gI.Remove(A,this._selected),this._selected=t,this._context=A,this._rbs.length=0,t?(A.scene.add(this._groundLine),A.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!A){console.error("DragHelper: no context");return}gI.Add(A,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(t){var A,e,i,g,I;if(!this._context)return;const o="Space",s="KeyD",C=((A=this._context)==null?void 0:A.input.isKeyPressed(o))||((e=this._context)==null?void 0:e.input.isKeyPressed(s)),a=this._context.input.getTouchesPressedCount()>=2||C;if(a){const B=this._context.input.getPointerPositionDelta(0);B&&(this._groundOffsetVector.set(0,1,0),(i=this._selected)==null||i.rotateOnWorldAxis(this._groundOffsetVector,B.x*this._context.time.deltaTime))}const n=this._context.input.getPointerPositionRC(0);if(n&&(this._raycaster.setFromCamera(n,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const B=ue(this._camera).clone().sub(ue(this._selected)).normalize(),Q=Math.abs(B.dot(this._groundOffsetVector)),E=((g=this._context)==null?void 0:g.input.isKeyPressed(o))||((I=this._context)==null?void 0:I.input.isKeyPressed(s));let h=!this.useViewAngle||Q>.2;(a||E||this._context.input.getPointerPressedCount()>1)&&(h=!1);const l=this._didDragOnGroundPlaneLastFrame!==h;if(this._didDragOnGroundPlaneLastFrame=h,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!h||l)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const d=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=d,h){this._groundOffsetVector.set(0,1,0);const c=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(c,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);l&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(t,A,e){if(this._selected){if(e){const i=ue(this._selected);i.y=t.y,t=i}if(ai(this._selected,t),ai(this._groundLine,t),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=A!==null&&this.showGizmo,A){const i=ue(this._camera).distanceTo(A)*.01;this._groundMarker.scale.set(i,i,i),ai(this._groundMarker,A)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const t=this._context.input.getPointerPositionRC(0);t&&(this._raycaster.setFromCamera(t,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;const t=ue(this._selected),A=new qs(new S(0,.1,0).add(t),new S(0,-1,0)),e=new es;e.ignore=[this._selected];const i=this._context.physics.raycastFromRay(A,e);for(let g=0;g<i.length;g++){const I=i[g];if(!I.face||this.contains(this._selected,I.object))continue;const o=new S(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(o,I.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(A.direction.multiplyScalar(-1),A.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(t),this._groundOffset.copy(this._intersection).sub(t)}onDidUpdate(){qI.markDirty(this._selected);for(const t of this._rbs)t.wakeUp(),t.resetForcesAndTorques(),t.setAngularVelocity(0,0,0)}contains(t,A){if(t===A)return!0;if(t.children){for(const e of t.children)if(this.contains(e,A))return!0}return!1}};let z2=V2;r(z2,"geometry",new pe().setFromPoints([new S(0,0,0),new S(0,-1,0)]));function wU(t,A,e){console.warn("Adding components on object has been temporarily disabled")}var Z2=(t=>(t.File_Spawned="file-spawned",t))(Z2||{});class X2{constructor(A,e,i,g,I,o,s,C){r(this,"guid"),r(this,"file_name"),r(this,"file_hash"),r(this,"file_size"),r(this,"position"),r(this,"seed"),r(this,"sender"),r(this,"serverUrl"),r(this,"parentGuid"),r(this,"boundsSize"),this.seed=e,this.guid=i,this.file_name=g,this.file_hash=I,this.file_size=o,this.position=s,this.sender=A,this.serverUrl=C}}async function $2(t,A,e){const i=t.name;return i.endsWith(".gltf")||i.endsWith(".glb")?new Promise((g,I)=>{const o=new FileReader;o.readAsArrayBuffer(t),o.onloadend=async s=>{const C=o.result,a=_D(),n=new EI(a),B=await gs().parseSync(A,C,t.name,n);if(B&&B.scene){const Q=B.scene;if(!Q.guid){const E=new EI(a);Q.guid=E.generateUUID()}e&&aoA(A.connection,t,a,Q,e),wU(),g(B)}}}):(console.warn("Unsupported file type: "+i,t),null)}async function AO(t,A){return new Promise(async(e,i)=>{const g=_D(),I=new EI(g),o=t.toString(),s=await gs().loadSync(A,o,o,I);s&&s.scene?(s.scene,wU(),e(s)):console.warn("Unsupported file type: "+t.toString())})}Rt.registerCallback(mg.ContextCreated,t=>{eO(t.context)});function eO(t){t.connection.beginListen("file-spawned",async A=>{if(A.sender!==t.connection.connectionId){console.log("received file event",A),noA(A,t);let e=null;try{e=await JG(A.file_name,A.file_hash,A.file_size,A.serverUrl)}finally{roA(A)}if(e){const i=new EI(A.seed),g=await gs().parseSync(t,e,A.file_name,i);if(g&&g.scene){const I=g.scene;if(wU(),A.parentGuid){const o=Zc(A.parentGuid,t.scene);o&&"add"in o&&o.add(I)}I.parent||t.scene.add(I),A.position!==null&&I.position.copy(A.position)}}else console.error("download didnt return file")}})}async function aoA(t,A,e,i,g){if(!t.connectionId){console.error("Can not upload file - no connection id");return}if(!i.guid){console.error("Can not upload file - no guid",i,i.guid);return}const I=await Yx(A,g);if(!I)return;if(!I.filename){console.error("Can not send upload event - no filename",A.name);return}if(!I.hash){console.error("Can not send upload event - no hash",A.name);return}const o=new X2(t.connectionId,e,i.guid,I.filename,I.hash,A.size,i.position,I.url??g);i.parent&&(o.parentGuid=i.parent.guid),t.send("file-spawned",o)}const yU={};function noA(t,A){const e=new Dt,i=new fA(e,new Et({color:65280})),g=new CD(i,5592405);if(yU[t.guid]=g,A.scene.add(g),t.parentGuid){const I=Zc(t.parentGuid,A.scene);I&&I.add(g)}t.position&&g.position.copy(t.position)}function roA(t,A){const e=t.guid,i=yU[e];i&&(delete yU[e],i.removeFromParent())}var BoA=Object.defineProperty,QoA=Object.getOwnPropertyDescriptor,SU=(t,A,e,i)=>{for(var g=i>1?void 0:i?QoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&BoA(A,e,g),g};const EoA=oA("debugnet"),fU=class extends UA{constructor(){super(...arguments),r(this,"url",null),r(this,"urlParameterName",null),r(this,"localhost",null)}awake(){EoA&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let t=this.url?fU.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const e=oA(this.urlParameterName);e&&typeof e=="string"&&(t=e)}if(!t)return null;const A=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(t);return A!=null&&A.groups?A?.groups.socket_prefix?t:"wss://"+A?.groups.url:null}static GetUrl(t,A){let e=t;const i=fU.IsLocalNetwork()&&A;return i&&(e=A),t!=null&&t.startsWith("/")&&(e=(i?e:window.location.origin)+t),e}static IsLocalNetwork(t=window.location.hostname){return Yg(t)}};let yB=fU;SU([y()],yB.prototype,"url",2),SU([y()],yB.prototype,"urlParameterName",2),SU([y()],yB.prototype,"localhost",2);var hoA=Object.defineProperty,coA=Object.getOwnPropertyDescriptor,tO=(t,A,e,i)=>{for(var g=i>1?void 0:i?coA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&hoA(A,e,g),g};const ZE=oA("debugdroplistener");class Qd extends UA{constructor(){super(...arguments),r(this,"filesBackendUrl"),r(this,"localhost"),r(this,"onDrag",A=>{A.preventDefault()}),r(this,"onDrop",async A=>{if(ZE&&console.log(A),!A.dataTransfer)return;A.preventDefault();const e=A.dataTransfer.items;if(e)for(const i in e){const g=e[i];if(g.kind==="file"){const I=g.getAsFile();if(!I)continue;await this.addFiles(I)}else g.kind==="string"&&g.type=="text/plain"&&g.getAsString(async I=>{ZE&&console.log("dropped url",I);try{const o=new URL(I);if(!o)return;const s=await AO(o,this.context);s&&this.addObject(A,s)}catch{console.log("dropped string is not a valid URL!",I)}})}})}onEnable(){this.filesBackendUrl=yB.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,ZE&&console.log(this,this.filesBackendUrl),this.context.domElement.addEventListener("dragover",this.onDrag),this.context.domElement.addEventListener("drop",this.onDrop)}onDisable(){this.context.domElement.removeEventListener("dragover",this.onDrag),this.context.domElement.removeEventListener("drop",this.onDrop)}async addFiles(...A){if(ZE&&console.log("Add files",A),!!Array.isArray(A)&&A.length)for(const e of A){if(!e)continue;ZE&&console.log("Register file "+e.name+" to",this.filesBackendUrl,e);const i=await $2(e,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:e})),i&&this.addObject(void 0,i)}}async addObject(A,e){ZE&&console.log("Dropped",e);const i=e.scene;if(A!==void 0){const g=new es;g.setMask(16777215),g.screenPointFromOffset(A.offsetX,A.offsetY);const I=this.context.physics.raycast(g);if(I&&I.length>0)for(const o of I){i.position.copy(o.point);break}}this.gameObject.add(i),this.dispatchEvent(new CustomEvent("object-added",{detail:e}))}}tO([y()],Qd.prototype,"filesBackendUrl",2),tO([y()],Qd.prototype,"localhost",2);var loA=Object.defineProperty,doA=Object.getOwnPropertyDescriptor,_y=(t,A,e,i)=>{for(var g=i>1?void 0:i?doA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&loA(A,e,g),g};class SB extends DE{constructor(){super(...arguments),r(this,"parent",null),r(this,"object",null),r(this,"limitCount",10),r(this,"limitInterval",60),r(this,"_currentCount",0),r(this,"_startPosition",null),r(this,"_startQuaternion",null)}awake(){var A,e;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((A=this.object.position)==null?void 0:A.clone())??new S(0,0,0),this._startQuaternion=((e=this.object.quaternion)==null?void 0:e.clone())??new xA(0,0,0,1)}const i=tA.getComponentInParent(this.gameObject,zE);i?i.addDragEventListener(W2.SelectStart,(g,I)=>{if(this._currentCount>=this.limitCount){I.attached=null;return}const o=this.handleDuplication(I.selected);o&&(console.assert(o!==I.selected,"Duplicated object is original"),I.attached=o)}):console.warn("Could no find drag controls in parent",this.name),mi.addEventListener(sa.SelectStart,(g,I)=>{if(this._currentCount>=this.limitCount){I.grab=null;return}const o=this.handleDuplication(I.selected);o&&(I.grab=o)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(A){var e;if(this._currentCount>=this.limitCount||!this.object)return null;if(A===this.gameObject||this.handleMultiObject(A)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const i=new Ys;this.parent||(this.parent=this.gameObject.parent),this.parent&&(i.parent=this.parent.guid??((e=this.parent.userData)==null?void 0:e.guid),i.keepWorldPosition=!0),i.position=this.worldPosition,i.rotation=this.worldQuaternion,i.context=this.context,this._currentCount+=1;const g=tA.instantiateSynced(this.object,i);return console.assert(g!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),g}return null}handleMultiObject(A){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,A):!1}isInChildren(A,e){if(!A)return!1;if(A===e)return!0;if(A.children){for(let i of A.children)if(this.isInChildren(i,e))return!0}return!1}}_y([y(vA)],SB.prototype,"parent",2),_y([y(vA)],SB.prototype,"object",2),_y([y()],SB.prototype,"limitCount",2),_y([y()],SB.prototype,"limitInterval",2);var XE=(t=>(t[t.PointerEnter=0]="PointerEnter",t[t.PointerExit=1]="PointerExit",t[t.PointerDown=2]="PointerDown",t[t.PointerUp=3]="PointerUp",t[t.PointerClick=4]="PointerClick",t[t.Drag=5]="Drag",t[t.Drop=6]="Drop",t[t.Scroll=7]="Scroll",t[t.UpdateSelected=8]="UpdateSelected",t[t.Select=9]="Select",t[t.Deselect=10]="Deselect",t[t.Move=11]="Move",t[t.InitializePotentialDrag=12]="InitializePotentialDrag",t[t.BeginDrag=13]="BeginDrag",t[t.EndDrag=14]="EndDrag",t[t.Submit=15]="Submit",t[t.Cancel=16]="Cancel",t))(XE||{}),poA=Object.defineProperty,uoA=Object.getOwnPropertyDescriptor,mU=(t,A,e,i)=>{for(var g=i>1?void 0:i?uoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&poA(A,e,g),g};class kU{constructor(){r(this,"eventID"),r(this,"callback")}}mU([y()],kU.prototype,"eventID",2),mU([y(SI)],kU.prototype,"callback",2);class Py extends UA{constructor(){super(...arguments),r(this,"triggers")}invoke(A){if(this.triggers)for(const e of this.triggers)e.eventID===A&&e.callback.invoke()}onPointerClick(A){this.invoke(XE.PointerClick)}onPointerEnter(A){this.invoke(XE.PointerEnter)}onPointerExit(A){this.invoke(XE.PointerExit)}onPointerDown(A){this.invoke(XE.PointerDown)}onPointerUp(A){this.invoke(XE.PointerUp)}}mU([y(kU)],Py.prototype,"triggers",2);var DoA=Object.defineProperty,woA=Object.getOwnPropertyDescriptor,GU=(t,A,e,i)=>{for(var g=i>1?void 0:i?woA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&DoA(A,e,g),g};class MU extends UA{constructor(){super(...arguments),r(this,"connectedBody"),r(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(Wt)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}GU([y(Wt)],MU.prototype,"connectedBody",2);class RU extends MU{createJoint(A,e){var i;(i=this.context.physics.engine)==null||i.addFixedJoint(A,e)}}class Ed extends MU{constructor(){super(...arguments),r(this,"anchor"),r(this,"axis")}createJoint(A,e){var i;this.axis&&this.anchor&&((i=this.context.physics.engine)==null||i.addHingeJoint(A,e,this.anchor,this.axis))}}GU([y(S)],Ed.prototype,"anchor",2),GU([y(S)],Ed.prototype,"axis",2);const yoA={type:"change"};let SoA=class extends qi{constructor(t,A){super(),this.object=t,this.domElement=A,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const e=this,i=1e-6,g=new xA,I=new S;this.tmpQuaternion=new xA,this.status=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new S(0,0,0),this.rotationVector=new S(0,0,0),this.keydown=function(Q){if(!(Q.altKey||this.enabled===!1)){switch(Q.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this.moveState.forward=1;break;case"KeyS":this.moveState.back=1;break;case"KeyA":this.moveState.left=1;break;case"KeyD":this.moveState.right=1;break;case"KeyR":this.moveState.up=1;break;case"KeyF":this.moveState.down=1;break;case"ArrowUp":this.moveState.pitchUp=1;break;case"ArrowDown":this.moveState.pitchDown=1;break;case"ArrowLeft":this.moveState.yawLeft=1;break;case"ArrowRight":this.moveState.yawRight=1;break;case"KeyQ":this.moveState.rollLeft=1;break;case"KeyE":this.moveState.rollRight=1;break}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(Q){if(this.enabled!==!1){switch(Q.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this.moveState.forward=0;break;case"KeyS":this.moveState.back=0;break;case"KeyA":this.moveState.left=0;break;case"KeyD":this.moveState.right=0;break;case"KeyR":this.moveState.up=0;break;case"KeyF":this.moveState.down=0;break;case"ArrowUp":this.moveState.pitchUp=0;break;case"ArrowDown":this.moveState.pitchDown=0;break;case"ArrowLeft":this.moveState.yawLeft=0;break;case"ArrowRight":this.moveState.yawRight=0;break;case"KeyQ":this.moveState.rollLeft=0;break;case"KeyE":this.moveState.rollRight=0;break}this.updateMovementVector(),this.updateRotationVector()}},this.pointerdown=function(Q){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(Q.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(Q){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const E=this.getContainerDimensions(),h=E.size[0]/2,l=E.size[1]/2;this.moveState.yawLeft=-(Q.pageX-E.offset[0]-h)/h,this.moveState.pitchDown=(Q.pageY-E.offset[1]-l)/l,this.updateRotationVector()}},this.pointerup=function(Q){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(Q.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(Q){this.enabled!==!1&&Q.preventDefault()},this.update=function(Q){if(this.enabled===!1)return;const E=Q*e.movementSpeed,h=Q*e.rollSpeed;e.object.translateX(e.moveVector.x*E),e.object.translateY(e.moveVector.y*E),e.object.translateZ(e.moveVector.z*E),e.tmpQuaternion.set(e.rotationVector.x*h,e.rotationVector.y*h,e.rotationVector.z*h,1).normalize(),e.object.quaternion.multiply(e.tmpQuaternion),(I.distanceToSquared(e.object.position)>i||8*(1-g.dot(e.object.quaternion))>i)&&(e.dispatchEvent(yoA),g.copy(e.object.quaternion),I.copy(e.object.position))},this.updateMovementVector=function(){const Q=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-Q+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",o),this.domElement.removeEventListener("pointerdown",C),this.domElement.removeEventListener("pointermove",s),this.domElement.removeEventListener("pointerup",a),window.removeEventListener("keydown",n),window.removeEventListener("keyup",B)};const o=this.contextMenu.bind(this),s=this.pointermove.bind(this),C=this.pointerdown.bind(this),a=this.pointerup.bind(this),n=this.keydown.bind(this),B=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",o),this.domElement.addEventListener("pointerdown",C),this.domElement.addEventListener("pointermove",s),this.domElement.addEventListener("pointerup",a),window.addEventListener("keydown",n),window.addEventListener("keyup",B),this.updateMovementVector(),this.updateRotationVector()}};class UU extends UA{constructor(){super(...arguments),r(this,"_controls",null)}onEnable(){var A;const e=(A=tA.getComponent(this.gameObject,Tt))==null?void 0:A.cam;this._controls=new SoA(e,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var A;(A=this._controls)==null||A.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var foA=Object.defineProperty,moA=Object.getOwnPropertyDescriptor,FU=(t,A,e,i)=>{for(var g=i>1?void 0:i?moA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&foA(A,e,g),g};class $E extends UA{constructor(){super(...arguments),r(this,"_fog")}get fog(){return this._fog||(this._fog=new xm(0,0,50)),this._fog}get mode(){return 1}set near(A){this.fog.near=A}get near(){return this.fog.near}set far(A){this.fog.far=A}get far(){return this.fog.far}set color(A){this.fog.color.copy(A)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}FU([y()],$E.prototype,"near",1),FU([y()],$E.prototype,"far",1),FU([y(wA)],$E.prototype,"color",1);let jy,NU,Ah,Wy;function KU(t,A=1/0,e=null){NU||(NU=new HI(2,2,1,1)),Ah||(Ah=new Je({uniforms:{blitTexture:new FA(t)},vertexShader:`
|
|
5021
|
+
`,this.context.appendHTMLElement(e);const i=YR;YR&&console.log("ARSupported?",Ll,"VRSupported?",xl),(i||this.createARButton&&this.enableAR&&Ll)&&(t=Oi.createARButton(this),this._arButton=t,e.appendChild(t)),(i||this.createVRButton&&this.enableVR&&xl)&&(A=Oi.createVRButton(this),this._vrButton=A,e.appendChild(A)),setTimeout(()=>{Oi.resetButtonStyles(A),Oi.resetButtonStyles(t)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(t){var A;if(!t)return;const e=this.context.renderer.xr.getSession();if(e){const i=t.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!i)return;this._currentHeadPose=i;const g=i?.transform;g&&this._transformOrientation.set(g.orientation.x,g.orientation.y,g.orientation.z,g.orientation.w),Oi._isInXr===!1&&e&&this.onEnterXR(e,t);for(const I of this.controllers)I.onUpdate(e);this._isInAR&&((A=this.webAR)==null||A.onUpdate(e,t))}Oi.events.dispatchEvent({type:"xrUpdate",frame:t,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let t=0;t<2;t++)mi.Create(this,t,this.gameObject,RE.PhysicalDevice);Oi.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(ue(this.context.mainCamera)),this._originalCameraRotation.copy(Ti(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){const t=tA.findObjectOfType(Ey,this.context);t?(this.rig=t.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new co,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(t,A){var e,i;console.log("[XR] session begin",t,A),Oi._isInXr=!0,this.ensureRig();const g=this.context.renderer.xr.getReferenceSpace();if(g&&this.rig){const s=A.getViewerPose(g),C=s?.transform.orientation;if(C){const a=new xA(C.x,C.y,C.z,C.w),n=new og().setFromQuaternion(a);this.rig.rotateY(n.y)}}const I=this.context.renderer.xr;if(this.context.mainCamera){const s=I.getCamera();YR&&console.log("WebXRCamera",s);const C=(e=this.context.mainCameraComponent)==null?void 0:e.cullingMask;if(s&&C!==void 0){for(const a of s.cameras)a.layers.mask=C;s.layers.mask=C}else if(s){for(const a of s.cameras)a.layers.enableAll();s.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const o=this._requestedAR?Si.AR:Si.VR;switch(Ws.Global.Set(o),o){case Si.AR:this.context.xrSessionMode=gl.ImmersiveAR,this._isInAR=!0,(i=this.webAR)==null||i.onBegin(t);break;case Si.VR:this.context.xrSessionMode=gl.ImmersiveVR,this._isInVR=!0,this.onEnterVR(t);break}t.addEventListener("end",()=>{console.log("[XR] session end"),Oi._isInXr=!1,this.onExitXR(t)}),this.onEnterXR_HandleMirrorWindow(t),Oi.events.dispatchEvent({type:"xrStarted",session:t})}onExitXR(t){var A,e,i,g;const I=this._isInAR;t&&(this._isInAR?(A=this.webAR)==null||A.onEnd(t):(e=this.context.mainCameraComponent)==null||e.applyClearFlagsIfIsActiveCamera()),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&((i=this._originalCameraParent)==null||i.add(this.context.mainCamera),ai(this.context.mainCamera,this._originalCameraPosition),uI(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),I&&((g=this._originalXRRigParent)==null||g.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Ws.Global.Set(Si.Browser|Si.ThirdPerson),Oi.events.dispatchEvent({type:"xrStopped",session:t})}onEnterVR(t){}destroyControllers(){var t;for(let A=this.controllers.length-1;A>=0;A-=1)(t=this.controllers[A])==null||t.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(t){oA("mirror")&&setTimeout(()=>{if(!Oi.IsInWebXR)return;const A=new URL(window.location.href);Yh(A.searchParams,xw,1),Yh(A.searchParams,"isMirror",1);const e=A.toString();this.xrMirrorWindow=window.open(e,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Oi.IsInWebXR&&t.end()})})},1e3)}},r(NE,"_isInXr",!1),r(NE,"events",new qi),r(NE,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),r(NE,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),NE);let Se=Oi;FE([y()],Se.prototype,"enableVR",2),FE([y()],Se.prototype,"enableAR",2),FE([y(Kg)],Se.prototype,"defaultAvatar",2),FE([y()],Se.prototype,"handModelPath",2),FE([y()],Se.prototype,"createVRButton",2),FE([y()],Se.prototype,"createARButton",2);const Tl=class{constructor(t){r(this,"_webxr"),r(this,"reticle",null),r(this,"reticleParent",null),r(this,"hitTestSource",null),r(this,"reticleActive",!0),r(this,"previousBackground",null),r(this,"previousEnvironment",null),r(this,"sessionRoot",null),r(this,"_previousParent",null),r(this,"arDomOverlay",null),r(this,"arOverlayElement",null),r(this,"noHitTestAvailable",!1),r(this,"didPlaceARSessionRoot",!1),this._webxr=t}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const t=this.arDomOverlay;return t.getAROverlayContainer?this.arOverlayElement=t.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(t){this.reticleActive=t}async onBegin(t){var A,e,i,g;const I=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const o=(A=navigator.userAgent)!=null&&A.includes("OculusBrowser")?RE.PhysicalDevice:RE.Touch,s=o===RE.Touch?4:2;for(let a=0;a<s;a++)mi.Create(this.webxr,a,this.webxr.gameObject,o);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=tA.findObjectOfType(js,I)),!this.sessionRoot){const a=this.webxr.gameObject;this.sessionRoot=tA.addNewComponent(a,js),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=I.scene.background,this.previousEnvironment=I.scene.environment,I.scene.background=null,t.requestReferenceSpace("viewer").then(a=>{var n,B;(B=(n=t.requestHitTestSource)==null?void 0:n.call(t,{space:a}))==null||B.then(Q=>{this.hitTestSource=Q}).catch(Q=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",Q)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new fA(new cp(.07,.09,32).rotateX(-Math.PI/2),new Et),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new vA,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,Tl.tempWebXRObject||(Tl.tempWebXRObject=new vA),this.context.scene.add(Tl.tempWebXRObject),tA.addComponent(Tl.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(e=this.sessionRoot)==null||e.onBegin(t)):console.warn("No WebARSessionRoot found in scene");const C=this.context.domElement;(i=C?.onEnterAR)==null||i.call(C,t,this.arOverlayElement),(g=this.context.mainCameraComponent)==null||g.applyClearFlagsIfIsActiveCamera()}onEnd(t){var A,e;this._previousParent&&(tA.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const i=this.webxr.context;i.scene.background=this.previousBackground,i.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,t);const g=this.context.domElement;(A=g.onExitAR)==null||A.call(g,t),(e=this.context.mainCameraComponent)==null||e.applyClearFlagsIfIsActiveCamera()}onUpdate(t,A){var e,i;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const I=this.webxr.Rig,o=fgA.clone();(e=this.sessionRoot)==null||e.placeAt(I,o)}return}if(!this.hitTestSource)return;const g=A.getHitTestResults(this.hitTestSource);if(g.length){const I=g[0],o=this.webxr.context.renderer.xr.getReferenceSpace();if(o){const s=I.getPose(o);if(this.sessionRoot){const C=this.sessionRoot.onUpdate(this.webxr.Rig,t,s);this.didPlaceARSessionRoot=C}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&s)){const C=s.transform.matrix;this.reticle.matrix.fromArray(C),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(i=this.sessionRoot)==null||i.onUpdate(this.webxr.Rig,t,null),this.reticle&&(this.reticle.visible=!1)}};let Yl=Tl;r(Yl,"tempWebXRObject");const fgA=new JA().identity().makeTranslation(0,0,0);class Ja{constructor(A,e){r(this,"used",!1),r(this,"inputSource"),r(this,"object"),r(this,"pointerId"),r(this,"isDown"),r(this,"isUp"),r(this,"isPressed"),r(this,"isClicked"),r(this,"input"),r(this,"event"),this.event=e,this.input=A}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var A;(A=this.event)==null||A.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var A;(A=this.event)==null||A.stopImmediatePropagation()}clone(){const A=new Ja(this.input,this.event);return Object.assign(A,this),A}}class KE extends UA{awake(){ZI.createIfNoneExists(this.context)}onEnable(){var A;(A=ZI.get(this.context))==null||A.register(this)}onDisable(){var A;(A=ZI.get(this.context))==null||A.unregister(this)}performRaycast(A=null){return null}}class aa extends KE{constructor(){super(...arguments),r(this,"targets",null),r(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(A=null){return this.targets?(A??(A=new es),A.targets=this.targets,A.results=this.raycastHits,this.context.physics.raycast(A)):null}}class HR extends aa{}const Hl=oA("debugeventsystem");var OR=(t=>(t.BeforeHandleInput="BeforeHandleInput",t.AfterHandleInput="AfterHandleInput",t))(OR||{});const na=class extends UA{constructor(){super(),r(this,"raycaster",[]),r(this,"_selectStartFn"),r(this,"_selectEndFn"),r(this,"_selectUpdateFn"),r(this,"_handleEventFn"),r(this,"lastPointerEvent",null),r(this,"objectsHoveredThisFrame",[]),r(this,"objectsHoveredLastFrame",[]),r(this,"raisedPointerDownEvents",[]),r(this,"raisedPointerDownObjects",[]),r(this,"_didMove",!1),r(this,"_tempComponentsArray",[]),r(this,"_sortedHits",[]),r(this,"_sortingBuffer",[]),r(this,"_noDepthTestingResults",[]),r(this,"handleEventsArray",[]),r(this,"out",{}),r(this,"currentActiveMeshUIComponents",[]),na.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,na.systems.length<=0&&na.systems.push(...tA.findObjectsOfType(na,t)));for(const e of na.systems)if(e.context===t)return;const A=new vA;tA.addNewComponent(A,na),t.scene.add(A)}static get systems(){const t=be.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const A=this._eventSystemMap.get(t);return A&&A.length>0?A[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,A){ra.update(t,A)}static markUIDirty(t){ra.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){na.systems.splice(na.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!tA.findObjectOfType(KE,this.context)){const t=tA.addNewComponent(this.context.scene,aa);this.raycaster.push(t),$t()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(t){var A;t&&this.raycaster&&!this.raycaster.includes(t)&&((A=this.raycaster)==null||A.push(t))}unregister(t){var A,e;const i=(A=this.raycaster)==null?void 0:A.indexOf(t);i!==void 0&&i!==-1&&((e=this.raycaster)==null||e.splice(i,1))}onEnable(){const t=new Map;this._selectStartFn??(this._selectStartFn=(e,i)=>{if(!i.grab)return;ra.resetLastSelected();const g=new Ja(this.context.input);g.inputSource=e,g.pointerId=0,g.isDown=e.selectionDown,g.isUp=e.selectionUp,g.isPressed=e.selectionPressed,g.isClicked=!1,t.set(e,i.grab),i.grab&&!this.handleEvents(i.grab,g)&&(i.grab=null)}),this._selectEndFn??(this._selectEndFn=(e,i)=>{var g;if(!i.grab)return;const I=new Ja(this.context.input);I.inputSource=e,I.pointerId=0,I.isDown=e.selectionDown,I.isUp=e.selectionUp,I.isPressed=e.selectionPressed,I.isClicked=e.selectionClick,this.handleEvents(i.grab,I);const o=t.get(e);if(t.set(e,null),o)for(let s=0;s<this.raisedPointerDownEvents.length;s++){const C=this.raisedPointerDownEvents[s];this.raisedPointerDownObjects[s]===o&&C&&((g=C.onPointerUp)==null||g.call(C,I),this.raisedPointerDownEvents.splice(s,1),this.raisedPointerDownObjects.splice(s,1),s--)}});const A=new es;this._selectUpdateFn??(this._selectUpdateFn=e=>{A.ray=e.getRay();const i=this.performRaycast(A);if(!i)return;const g=new Ja(this.context.input);g.inputSource=e,this.handleIntersections(i,g)}),mi.addEventListener(sa.SelectStart,this._selectStartFn),mi.addEventListener(sa.SelectEnd,this._selectEndFn),mi.addEventListener(sa.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){mi.removeEventListener(sa.SelectStart,this._selectStartFn),mi.removeEventListener(sa.SelectEnd,this._selectEndFn),mi.removeEventListener(sa.Update,this._selectUpdateFn),this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._handleEventFn),1)}onHandleEvents(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),Se.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const I=this.context.input.getPointerPositionRC(0);if(I&&I.x===0&&I.y===0)return;this._didMove=!0}let t=0;for(const I of this.context.input.foreachPointerId()){const o=this.context.input.getPointerDown(I),s=this.context.input.getPointerUp(I);if(o||s){t=I;break}}const A=this.context.input.getPointerEvent(t),e=new Ja(this.context.input,A);e.inputSource=this.context.input,e.pointerId=t,e.isClicked=this.context.input.getPointerClicked(t),e.isDown=this.context.input.getPointerDown(t),e.isUp=this.context.input.getPointerUp(t),e.isPressed=this.context.input.getPointerPressed(t),Hl&&e.isClicked&&console.log("CLICK",t);const i=this.performRaycast(null);if(!i)return;this.lastPointerEvent=e;const g={sender:this,args:e,hasActiveUI:this.currentActiveMeshUIComponents.length>0};Hl&&e.isClicked&&pi("EventSystem: "+e.pointerId+" - "+this.context.time.frame+" - Up:"+e.isUp+", Down:"+e.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:g})),this.handleIntersections(i,e),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:g}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const A of this.raisedPointerDownEvents)A.onPointerUp&&A.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const A of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(A)<0){this._tempComponentsArray.length=0;const e=tA.getComponentsInParent(A,UA,this._tempComponentsArray);this.lastPointerEvent.object=A;for(let i=0;i<e.length;i++){const g=e[i];if(!g.gameObject||g.destroyed)continue;const I=g;I.onPointerExit&&I.onPointerExit(this.lastPointerEvent)}}const t=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=t}performRaycast(t){if(!this.raycaster)return null;this._sortedHits.length=0;for(const A of this.raycaster){if(!A.activeAndEnabled)continue;const e=A.performRaycast(t);e&&e.length>0&&this._sortedHits.push(...e)}return this._sortedHits.sort((A,e)=>A.distance-e.distance),this._sortedHits}handleIntersections(t,A){if(!t||t.length<=0)return!1;t=this.sortCandidates(t);for(const e of t){const{object:i}=e;if(this.handleEvents(i,A))return!0}return!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let A=0;A<t.length;A++){const e=t[A],i=e.object;if(i.material&&i.material.depthTest===!1){this._noDepthTestingResults.push(e);continue}this._sortingBuffer.push(e)}for(const A of this._sortingBuffer)this._noDepthTestingResults.push(A);return this._noDepthTestingResults}handleEvents(t,A){if(!this.testIsVisible(t))return A.isClicked&&Hl&&console.log("not allowed",t),!1;const e=t;A.object=t,this.lastPointerEvent=A;const i=t.parent;let g=!1;const I=A.isClicked??!1;let o=null;if(i&&i.isUI){const s=(A.isPressed||A.isClicked)??!1;if(i[$s]){const C=i[$s].gameObject;if(C){if(!ME.isInteractable(C,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,s),t=C,g=!0}}if(!g&&this.handleMeshUiObjectWithoutShadowDom(i,s))return!0}if(I&&Hl&&console.log(this.context.time.frame,t),this.objectsHoveredThisFrame.push(t),o===null||o.interactable){const s=this.objectsHoveredLastFrame.indexOf(t)>=0;this.handleEventsArray.length=0;const C=tA.getComponentsInParent(t,UA,this.handleEventsArray);for(let a=0;a<C.length;a++){if(A.used)return!0;if(C[a].destroyed)continue;const n=C[a];if(n.interactable!==!1){if(n.onPointerEnter&&(s||n.onPointerEnter(A)),n.onPointerMove&&n.onPointerMove(A),A.isDown&&n.onPointerDown&&!this.raisedPointerDownEvents.includes(n)&&(n.onPointerDown(A),this.raisedPointerDownEvents.push(n),this.raisedPointerDownObjects.push(e)),A.isUp&&n.onPointerUp){const B=this.raisedPointerDownEvents.indexOf(n);B!==-1&&this.raisedPointerDownEvents.splice(B,1),n.onPointerUp(A)}A.isClicked&&n.onPointerClick&&n.onPointerClick(A)}}}return!0}handleMeshUiObjectWithoutShadowDom(t,A){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,A)}handleMeshUIIntersection(t,A){const e=ra.updateState(t,A);return e&&this.currentActiveMeshUIComponents.push(e),e!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&ra.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const A=this.currentActiveMeshUIComponents[t];ra.resetState(A)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?tA.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let ZI=na;r(ZI,"_eventSystemMap",new Map),r(ZI,"didSearchEventSystem",!1);class ra{static markDirty(){this.needsUpdate=!0}static update(A,e){const i=e.time.frameCount;for(const g of this.lastUpdateFrame)if(g.context===e){if(i===g.frame)return;g.frame=i;let I=this.needsUpdate||i<1;g.nextUpdate===e.time.frameCount&&(I=!0),I&&(Hl&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:i,nextUpdate:i}],A.update()}static updateState(A,e){let i=null;if(A&&(i=this.findBlockInParent(A),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}r(ra,"lastSelected",null),r(ra,"lastUpdateFrame",[]),r(ra,"needsUpdate",!1);const cy=Symbol("cameraController");function mgA(t){return t[cy]}function U2(t,A,e){e?t[cy]=A:t[cy]===A&&(t[cy]=null)}var kgA=Object.defineProperty,GgA=Object.getOwnPropertyDescriptor,MgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?GgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&kgA(A,e,g),g};const ly=oA("freecam"),_R=oA("debugcamerafit"),RgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let PR;class Ba extends UA{constructor(){super(...arguments),r(this,"autoRotate",!1),r(this,"autoRotateSpeed",1),r(this,"enableKeys",!0),r(this,"enableDamping",!0),r(this,"dampingFactor",.1),r(this,"enableZoom",!0),r(this,"minZoom",0),r(this,"maxZoom",1/0),r(this,"enablePan",!0),r(this,"lookAtConstraint",null),r(this,"lookAtConstraint01",1),r(this,"middleClickToFocus",!0),r(this,"doubleClickToFocus",!0),r(this,"useSlerp",!0),r(this,"debugLog",!1),r(this,"targetLerpSpeed",5),r(this,"_lookTargetPosition"),r(this,"_controls",null),r(this,"_cameraObject",null),r(this,"_lerpToTargetPosition",!1),r(this,"_lerpCameraToTarget",!1),r(this,"_cameraTargetPosition",null),r(this,"_inputs",0),r(this,"_enableTime",0),r(this,"_startedListeningToKeyEvents",!1),r(this,"_eventSystem"),r(this,"_afterHandleInputFn"),r(this,"_camera",null),r(this,"_syncedTransform"),r(this,"targetElement",null),r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),r(this,"_shouldDisable",!1),r(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(A){var e;(e=this.controls)==null||e.addEventListener("start",A)}awake(){this._lookTargetPosition=new S,this._startedListeningToKeyEvents=!1}start(){if(this._controls){const A=tA.getComponent(this.gameObject,Tt);if(A&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const e=ue(A.cam).length(),i=new S(0,0,-e).applyMatrix4(A.cam.matrixWorld);this.setTarget(i,!0)}}this.startCoroutine(this.startRaycastDelayed()),this._eventSystem=ZI.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(OR.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var A,e;(A=this._controls)==null||A.dispose(),(e=this._eventSystem)==null||e.removeEventListener(OR.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const A=tA.getComponent(this.gameObject,Tt);this._camera=A;const e=A?.cam;if(e&&U2(e,this,!0),!this._controls){console.assert(e!=null,"Missing camera",this),e&&(this._cameraObject=e);const i=this.targetElement??this.context.domElement,g=e?.quaternion.clone();this._controls=new M$(e,i),e?.quaternion.copy(g),PR===void 0&&(PR={...this._controls.keys})}this._controls&&(ly&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Ha()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),e?.type==="PerspectiveCamera"?ly||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):ly||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=tA.getComponent(this.gameObject,Kn)??void 0}onDisable(){var A;(A=this._camera)!=null&&A.cam&&U2(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(A){A.detail.args.pointerId===0&&(A.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!A.detail.args.isPressed||A.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,!this.setFromTargetPosition()){const A=new es;A.screenPoint=new Z(0,0),A.lineThreshold=.1;const e=this.context.physics.raycast(A);e.length>0&&this.setTarget(e[0].point,!0)}}onBeforeRender(){var A,e,i;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.autoRotate=!1,this._controls.autoRotate=!1,this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let g=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(g||(g=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),g?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const I=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const o=(A=this._cameraObject)==null?void 0:A.position;bv(o,this._cameraTargetPosition,I)}else(e=this._cameraObject)==null||e.position.lerp(this._cameraTargetPosition,I);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,I),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!ly&&(i=this.lookAtConstraint)!=null&&i.locked&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls&&(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.enableDamping=this.enableDamping,this._controls.keys=this.enableKeys?PR:RgA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this.context.isInXR||this._controls.update())}setCameraTarget(A,e=!1){var i;A?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=A.clone(),e&&this._cameraTargetPosition&&((i=this.controllerObject)==null||i.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(A=0,e=1){var i;if(!this._controls)return!1;const g=(i=this.lookAtConstraint)==null?void 0:i.sources;if(g&&g.length>0){const I=g[A];if(I)return I.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,e),!0}return!1}setTarget(A=null,e=!1){this._controls&&(A!==null&&this._lookTargetPosition.copy(A),e?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(A,e){this._controls&&this._controls.target.lerp(A,e)}distanceToTarget(A){return this._controls?this._controls.target.distanceTo(A):-1}setTargetFromRaycast(){var A,e;if(!this.controls)return;const i=this.context.physics.raycast();for(const g of i)if(g.distance>0&&tA.isActiveInHierarchy(g.object)){if(this._lookTargetPosition.copy(g.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const I=ue(this.context.mainCamera);this._cameraTargetPosition=I.clone().sub(this.controls.target).add(this._lookTargetPosition),(e=(A=this._cameraObject)==null?void 0:A.parent)==null||e.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(A,e=1.1){const i=this._cameraObject,g=this._controls;if(A!=null&&A.length||(A=this.context.scene.children),A.length<=0||!i||!g)return;const I=new S,o=new S,s=new vi;s.makeEmpty();for(const l of A)l instanceof Mk||l instanceof Gk||s.expandByObject(l,!0);if(i.updateMatrixWorld(),i.updateProjectionMatrix(),s.getCenter(o),s.applyMatrix4(i.matrixWorldInverse),s.getSize(I),s.setFromCenterAndSize(o,I),I.length()<=1e-10){_R&&console.warn("Camera fit size is zero",s,[...A]);return}const C=i.fov,a=2*Math.atan(Math.tan(C*Math.PI/360/2)*i.aspect)/Math.PI*360,n=I.y/(2*Math.atan(Math.PI*C/360)),B=I.x/(2*Math.atan(Math.PI*a/360)),Q=e*Math.max(n,B)+I.z/2;_R&&console.log("Fit camera to objects",n,B,"distance",Q);const E=ue(i),h=g.target.clone().sub(E).normalize().multiplyScalar(Q);if(g.maxDistance=Q*10,g.minDistance=Q*.01,g.target.copy(o),i.near=Q/100,i.far=Q*100,i.updateMatrixWorld(),i.updateProjectionMatrix(),ai(i,g.target.clone().sub(h)),_R){const l=new Mk(s);this.context.scene.add(l),Pv(l,cD(i)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",d=>{d.code==="KeyF"&&this.fitCamera(A)}))}g.update()}}MgA([y(Dl)],Ba.prototype,"lookAtConstraint",2);var UgA=Object.defineProperty,FgA=Object.getOwnPropertyDescriptor,Ko=(t,A,e,i)=>{for(var g=i>1?void 0:i?FgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&UgA(A,e,g),g},F2=(t=>(t[t.Skybox=1]="Skybox",t[t.SolidColor=2]="SolidColor",t[t.Uninitialized=4]="Uninitialized",t))(F2||{});const Ol=oA("debugcam"),N2=oA("debugscreenpointtoray");var dy;const _l=(dy=class extends UA{constructor(){super(...arguments),r(this,"_nearClipPlane",.1),r(this,"_farClipPlane",1e3),r(this,"orthographic",!1),r(this,"orthographicSize",5),r(this,"ARBackgroundAlpha",0),r(this,"_cullingMask",4294967295),r(this,"_backgroundBlurriness"),r(this,"_backgroundIntensity"),r(this,"_targetTexture",null),r(this,"_backgroundColor"),r(this,"_fov"),r(this,"_cam",null),r(this,"_clearFlags",2),r(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof ze?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof ze?this._cam.fov:this._fov}set fieldOfView(t){const A=this.fieldOfView!=t;if(this._fov=t,A&&this._cam&&this._cam instanceof ze){if(this._fov===void 0){console.error("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(t){const A=this._nearClipPlane!=t;this._nearClipPlane=t,this._cam&&A&&(this._cam.near=t,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(t){const A=this._farClipPlane!=t;this._farClipPlane=t,this._cam&&A&&(this._cam.far=t,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(t){t!==this._clearFlags&&(this._clearFlags=t,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(t){this._cullingMask=t,this._cam&&(this._cam.layers.mask=t)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(t){t!==this._backgroundBlurriness&&(t===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(t,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(t){t!==this._backgroundIntensity&&(t===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(t,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(t){if(t){if(this._backgroundColor)this._backgroundColor.copy(t);else{if(!t.clone)return;this._backgroundColor=t.clone()}t.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(t){this._targetTexture=t}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(t,A,e){let i=this.cam;const g=_l._origin;g.set(t,A,-1),this.context.input.convertScreenspaceToRaycastSpace(g),N2&&console.log("screenPointToRay",t.toFixed(2),A.toFixed(2),"now:",g.x.toFixed(2),g.y.toFixed(2),"isInXR:"+this.context.isInXR),g.z=-1,g.unproject(i);const I=_l._direction.set(g.x,g.y,g.z),o=ue(i);return I.sub(o),I.normalize(),e?(e.set(o,I),e):new qs(o.clone(),I.clone())}awake(){N2&&window.addEventListener("pointerdown",t=>{const A=t.clientX,e=t.clientY;console.log("touch",A.toFixed(2),e.toFixed(2));const i=this.screenPointToRay(A,e),g="#"+Math.floor(Math.random()*16777215).toString(16);zC.DrawRay(i.origin,i.direction,g,10)})}onEnable(){Ol&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),KgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const t=this.context.renderer;t&&this._targetTexture.render(this.context.scene,this._cam,t)}}buildCamera(){if(this._cam)return;const t=this.gameObject.isCamera;let A=null;if(t?(A=this.gameObject,A?.layers.enableAll(),A instanceof ze&&(this._fov=A.fov)):A=this.gameObject.children[0],A&&A.isCamera)A instanceof ze&&(this._fov&&(A.fov=this._fov),A.near=this._nearClipPlane,A.far=this._farClipPlane,A.updateProjectionMatrix());else if(!this.orthographic)A=new ze(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(A.fov=this.fieldOfView),this.gameObject.add(A);else{const e=this.orthographicSize*100;A=new Fr(window.innerWidth/-e,window.innerWidth/e,window.innerHeight/e,window.innerHeight/-e,this._nearClipPlane,this._farClipPlane),this.gameObject.add(A)}this._cam=A,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){Ol&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,Ol&&pi("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(_l.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let t=this._backgroundColor.alpha;_l.backgroundShouldBeTransparent(this.context)&&(t=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,t)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new NgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(t){var A,e,i,g;const I=(A=t.renderer.xr)==null?void 0:A.getSession();if(!I)return!1;const o=I.environmentBlendMode;Ol&&pi("Environment blend mode: "+o+" on "+navigator.userAgent);const s=o==="additive"||o==="alpha-blend";return t.xrSessionMode===gl.ImmersiveAR&&o==="opaque"&&((e=navigator.userAgent)!=null&&e.includes("OculusBrowser")||(i=navigator.userAgent)!=null&&i.includes("Mozilla")&&(g=navigator.userAgent)!=null&&g.includes("Mobile WebXRViewer/v2"))?!0:s}},r(dy,"_origin",new S),r(dy,"_direction",new S),dy);let Tt=_l;Ko([y()],Tt.prototype,"fieldOfView",1),Ko([y()],Tt.prototype,"nearClipPlane",1),Ko([y()],Tt.prototype,"farClipPlane",1),Ko([y()],Tt.prototype,"clearFlags",1),Ko([y()],Tt.prototype,"orthographic",2),Ko([y()],Tt.prototype,"orthographicSize",2),Ko([y()],Tt.prototype,"ARBackgroundAlpha",2),Ko([y()],Tt.prototype,"cullingMask",1),Ko([y()],Tt.prototype,"backgroundBlurriness",1),Ko([y()],Tt.prototype,"backgroundIntensity",1),Ko([y(yt)],Tt.prototype,"backgroundColor",1),Ko([y(QE)],Tt.prototype,"targetTexture",1);class NgA{constructor(A){r(this,"_camera"),r(this,"_skybox"),this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Ol&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=Ie,this._skybox.mapping=no,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function KgA(t){oA("freecam")&&t.context.mainCameraComponent===t&&tA.getOrAddComponent(t.gameObject,Ba)}class JE extends UA{constructor(){super(...arguments),r(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new wk),this._listener}awake(){yi.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const A=this.listener;if(A==null||A.parent)return;const e=tA.getComponentInParent(this.gameObject,Tt);e?e.cam.add(A):this.gameObject.add(A)})}}var JgA=Object.defineProperty,qgA=Object.getOwnPropertyDescriptor,py=(t,A,e,i)=>{for(var g=i>1?void 0:i?qgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&JgA(A,e,g),g};const vgA=oA("debugsignals");class Pl{constructor(){r(this,"guid")}}py([y()],Pl.prototype,"guid",2);class qE{constructor(){r(this,"signal"),r(this,"reaction")}}py([y(Pl)],qE.prototype,"signal",2),py([y(SI)],qE.prototype,"reaction",2);var jR;const Qa=(jR=class extends UA{constructor(){super(...arguments),r(this,"events")}static invoke(t){if(Qa.receivers[t]){const A=Qa.receivers[t];if(!A)return;for(const e of A)e.invoke(t)}}awake(){vgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const t of this.events)Qa.receivers[t.signal.guid]||(Qa.receivers[t.signal.guid]=[]),Qa.receivers[t.signal.guid].push(this)}onDisable(){if(this.events){for(const t of this.events)if(Qa.receivers[t.signal.guid]){const A=Qa.receivers[t.signal.guid].indexOf(this);A>=0&&Qa.receivers[t.signal.guid].splice(A,1)}}}invoke(t){if(!this.events||!Array.isArray(this.events))return;let A=typeof t=="object"?t.guid:t;for(const e of this.events)if(e.signal.guid===A)try{if(e.reaction){if(!e.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",e,this);continue}}else{console.warn("Missing reaction for signal",e,this);continue}e.reaction.invoke()}catch(i){console.error(i)}}},r(jR,"receivers",{}),jR);let vE=Qa;py([y(qE)],vE.prototype,"events",2);var XI=(t=>(t.Activation="ActivationTrack",t.Animation="AnimationTrack",t.Audio="AudioTrack",t.Control="ControlTrack",t.Marker="MarkerTrack",t.Signal="SignalTrack",t))(XI||{}),eC=(t=>(t[t.None=0]="None",t[t.Hold=1]="Hold",t[t.Loop=2]="Loop",t[t.PingPong=3]="PingPong",t[t.Continue=4]="Continue",t))(eC||{}),WR=(t=>(t.Signal="SignalEmitter",t))(WR||{});const jl=oA("debugtimeline"),VR=class extends UA{constructor(){super(...arguments),r(this,"playableAsset"),r(this,"playOnAwake"),r(this,"extrapolationMode",1),r(this,"waitForAudio",!0),r(this,"_visibilityChangeEvt"),r(this,"_clonedPlayableAsset",!1),r(this,"_speed",1),r(this,"_guidsMap"),r(this,"_isPlaying",!1),r(this,"_internalUpdateRoutine"),r(this,"_isPaused",!1),r(this,"_time",0),r(this,"_duration",0),r(this,"_weight",1),r(this,"_animationTracks",[]),r(this,"_audioTracks",[]),r(this,"_signalTracks",[]),r(this,"_controlTracks",[]),r(this,"_customTracks",[]),r(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks])}static registerCreateTrack(t,A){this.createTrackFunctions[t]=A}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(jl||Yg())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,A,e;jl&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(A=this.playableAsset)==null?void 0:A.tracks,Array.isArray((e=this.playableAsset)==null?void 0:e.tracks),this)}onEnable(){var t,A;for(const e of this._audioTracks)(t=e.onEnable)==null||t.call(e);for(const e of this._customTracks)(A=e.onEnable)==null||A.call(e);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,A;this.stop();for(const e of this._audioTracks)(t=e.onDisable)==null||t.call(e);for(const e of this._customTracks)(A=e.onDisable)==null||A.call(e);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const A of this._allTracks)for(const e of A)(t=e.onDestroy)==null||t.call(e)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const A=[];for(const e of this._audioTracks){const i=e.loadAudio(this._time,1,0);i&&A.push(i)}if(A.length>0&&(await Promise.all(A),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!yi.userInteractionRegistered&&this.waitForAudio;)await Hh(200)}this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate())}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks()))}stop(){for(const e of this._audioTracks)e.stop();const t=this._isPaused==!0,A=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!A&&this.invokePauseChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null}evaluate(){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}this.internalEvaluate(t)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const A of t)yield A}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onPauseChanged)==null||t.call(A)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(t){for(const A of this.playableAsset.tracks)if(!A.muted)switch(A.type){case XI.Activation:for(let e=0;e<A.outputs.length;e++){const i=A.outputs[e];if(typeof i=="object"){let g=!1;for(const o of A.clips)o.start<=t&&t<=o.end&&(g=!0);const I=i;I.visible!==void 0&&(I.visible=g)}}break}for(const A of this._animationTracks)A.evaluate(t);for(const A of this._audioTracks)A.evaluate(t);for(const A of this._signalTracks)A.evaluate(t);for(const A of this._controlTracks)A.evaluate(t);for(const A of this._customTracks)A.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Gp(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const A of this.playableAsset.tracks){for(let e=A.outputs.length-1;e>=0;e--){let i=A.outputs[e];if(typeof i=="string"){this._guidsMap&&this._guidsMap[i]&&(i=this._guidsMap[i]);const g=tA.findByGuid(i,t);g===null||typeof g!="object"?(A.outputs.splice(e,1),console.warn("Failed to resolve binding",i,A.name,A.type)):(jl&&console.log("Resolved binding",i,"to",g),A.outputs[e]=g)}else if(i===null){if(A.outputs.splice(e,1),VR.createTrackFunctions[A.type])continue;A.type!==XI.Audio&&A.type!==XI.Control&&A.type!==XI.Marker&&A.type!==XI.Signal&&console.warn("Missing binding",i,A.name,A.type,this.name,this.playableAsset.name)}}if(A.type===XI.Control)for(let e=0;e<A.clips.length;e++){const i=A.clips[e];let g=i.asset.sourceObject;if(typeof g=="string"){this._guidsMap&&this._guidsMap[g]&&(g=this._guidsMap[g]);const I=tA.findByGuid(g,t);I===null||typeof I!="object"?console.warn("Failed to resolve sourceObject binding",g,A.name,i):(jl&&console.log("Resolved binding",g,"to",I),i.asset.sourceObject=I)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){for(const A of t.clips)A.end>this._duration&&(this._duration=A.end);for(const A of t.markers)A.time>this._duration&&(this._duration=A.time+.001)}}}setupAndCreateTrackHandlers(){var t,A;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const e=tA.findObjectOfType(JE,this.context);for(const i of this.playableAsset.tracks){const g=i.type,I=VR.createTrackFunctions[g];if(I!=null){const o=I(this,i);if(typeof o.evaluate=="function"){o.director=this,o.track=i,this._customTracks.push(o);continue}}if(i.type===XI.Animation){if(i.clips.length<=0){jl&&console.warn("Animation track has no clips",i);continue}for(let o=i.outputs.length-1;o>=0;o--){let s=i.outputs[o];if(s instanceof vA){const a=tA.getOrAddComponent(s,tI);a&&(s=a)}const C=(t=s?.gameObject)==null?void 0:t.animations;if(C){const a=new uy;a.trackOffset=i.trackOffset,a.director=this,a.track=i;for(let n=0;n<i.clips.length;n++){const B=i.clips[n],Q=B.asset;if(!Q){console.error("MISSING anim model?","clip#"+n,B,i,this.playableAsset,this.name);continue}const E=Q.clip;let h=E;if((typeof h=="string"||typeof h=="number")&&(h=C.find(d=>d.name===E)),!h){console.warn("Could not find animationClip for model",B,i.name,this.name,(A=this.playableAsset)==null?void 0:A.name);continue}a.mixer||(a.mixer=new tD(s.gameObject)),a.clips.push(h),a.mixer.uncacheAction(h),a.createHooks(B.asset,h);const l=a.mixer.clipAction(h);a.actions.push(l),a.models.push(B)}this._animationTracks.push(a)}}}else if(i.type===XI.Audio){if(i.clips.length<=0)continue;const o=new zl;if(o.director=this,o.track=i,this._audioTracks.push(o),!e)continue;o.listener=e.listener;for(let s=0;s<i.clips.length;s++){const C=i.clips[s];o.addModel(C)}}else if(i.type===XI.Marker){const o=new Zl;o.director=this,o.track=i;for(const s of i.markers)switch(s.type){case WR.Signal:o.models.push(s),o.didTrigger.push(!1);break}if(o!==null&&o.models.length>0){const s=tA.getComponent(this.gameObject,vE);s&&(o.receivers.push(s),this._signalTracks.push(o))}}else if(i.type===XI.Signal){const o=new Zl;o.director=this,o.track=i;for(const s of i.markers)o.models.push(s),o.didTrigger.push(!1);for(const s of i.outputs)o.receivers.push(s);this._signalTracks.push(o)}else if(i.type===XI.Control){const o=new Dy;o.director=this,o.track=i;for(const s of i.clips)o.models.push(s);o.resolveSourceObjects(this.context),this._controlTracks.push(o)}}}setAudioTracksAllowPlaying(t){for(const A of this._audioTracks)A.onAllowAudioChanged(t)}};let nB=VR;r(nB,"createTrackFunctions",{});const rB=oA("debugtimeline");class Wl{constructor(){r(this,"director"),r(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,i,g=!0){if(e<0||e>=i.length)return 0;const I=i[e];if(g||A>=I.start&&A<=I.end){let o=1,s=!1;if(I.easeInDuration>0){const C=Math.min((A-I.start)/I.easeInDuration,1);o*=C}if(I.easeOutDuration>0&&!s){const C=Math.min((I.end-A)/I.easeOutDuration,1);o*=C}return o}return 0}}class bgA{constructor(A){r(this,"clip"),r(this,"rootPositionOffset"),r(this,"rootQuaternionOffset"),r(this,"rootStartPosition"),r(this,"rootEndPosition"),r(this,"rootStartQuaternion"),r(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const i=A.getRoot(),g=i.name+".position",I=i.name+".quaternion";rB&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new S().fromArray(o.values,0),this.rootEndPosition=new S().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),rB&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new xA().fromArray(o.values,0),this.rootEndQuaternion=new xA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),rB)){const s=new og().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class uy extends Wl{constructor(){super(...arguments),r(this,"models",[]),r(this,"trackOffset"),r(this,"target"),r(this,"mixer"),r(this,"clips",[]),r(this,"actions",[]),r(this,"_actionOffsets",[]),r(this,"_didBind",!1),r(this,"_animator",null),r(this,"_animatorWasEnabled",!1),r(this,"_useclipOffsets",!0),r(this,"_totalOffsetPosition",new S),r(this,"_totalOffsetRotation",new xA),r(this,"_totalOffsetPosition2",new S),r(this,"_totalOffsetRotation2",new xA),r(this,"_summedPos",new S),r(this,"_tempPos",new S),r(this,"_summedRot",new xA),r(this,"_tempRot",new xA),r(this,"_clipRotQuat",new xA)}onPauseChanged(){this._animator&&this._animatorWasEnabled!==void 0&&(this._animator.enabled=this.director.isPlaying===!1?this._animatorWasEnabled:!1)}createHooks(A,e){var i,g;if(((i=e.tracks)==null?void 0:i.length)<=0){console.warn("No tracks in AnimationClip",e);return}const I=e.tracks[0].name.split("."),o=I[I.length-2],s=o+".position",C=o+".quaternion";let a=!1,n=!1;for(const B of e.tracks)B.name.endsWith(s)?(a=!0,this.createPositionInterpolant(e,A,B)):B.name.endsWith(C)&&(n=!0,this.createRotationInterpolant(e,A,B));if(!a||!n){const B=(g=this.mixer)==null?void 0:g.getRoot(),Q=e.tracks[0],E=Q.name.lastIndexOf("."),h=Q.name.substring(0,E),l=h.substring(h.lastIndexOf(".")+1),d=B.getObjectByName(l);if(d)if(a){if(!n){const c=e.tracks[0].name.substring(0,E)+".quaternion";rB&&console.warn("Create quaternion track",l,d);const u=d.quaternion,p=new vs(c,[0,e.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);e.tracks.push(p),this.createRotationInterpolant(e,A,p)}}else{const c=h+".position";rB&&console.warn("Create position track",l,d);const u=d.position,p=new on(c,[0,e.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);e.tracks.push(p),this.createPositionInterpolant(e,A,p)}}}bind(){if(!this._didBind){this._didBind=!0,rB&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const A of this.actions){const e=new bgA(A);this._actionOffsets.push(e)}this.target&&(this._animator=tA.getComponent(this.target,tI)??null,this._animator?(this._animatorWasEnabled=this._animator.enabled,this._animator.enabled=!1):this._animatorWasEnabled=!1);for(const A of this.models){const e=A.asset,i=e.position,g=e.rotation;i&&i.x!==void 0&&(i.isVector3||(e.position=new S(i.x,i.y,i.z)),g.isQuaternion||(e.rotation=new xA(g.x,g.y,g.z,g.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const A=this.trackOffset.position;A&&(A.isVector3||(this.trackOffset.position=new S(A.x,A.y,A.z)));const e=this.trackOffset.rotation;e&&(e.isQuaternion||(this.trackOffset.rotation=new xA(e.x,e.y,e.z,e.w)))}}evaluate(A){if(this.track.muted||!this.mixer)return;this.bind(),this._animator&&this.director.isPlaying&&this.director.weight>0&&(this._animator.enabled=!1),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let e=0,i=0,g=!1,I=!1;for(let o=0;o<this.clips.length;o++){const s=this.models[o],C=this.actions[o],a=s.asset;C.weight=0;const n=A>=s.start&&A<=s.end,B=s.preExtrapolationMode,Q=s.postExtrapolationMode,E=o<this.clips.length-1?this.models[o+1]:null;let h=n,l=!1;if(!h&&!g&&s.end<A&&Q!==eC.None?(!E||E.start>A)&&(h=!0,g=!0):o==0&&!h&&!I&&s.start>A&&B!==eC.None&&(!E||E.start<A)&&(h=!0,l=!0,I=!0),h){let d=1;d*=this.evaluateWeight(A,o,this.models,h),d*=this.director.weight;let c=n;if(l)switch(B){case eC.Hold:break;case eC.Loop:A+=s.start,c=!0;break;default:A+=s.start,c=!0;break}let u=this.getClipTime(A,s),p=0;const D=a.duration;if(l&&B===eC.Hold&&(u=0),c){if(a.loop)for(p+=Math.floor(u/(D+1e-6));u>D;)u-=D}else if(!n&&g)switch(Q){case eC.Hold:u=this.getClipTime(s.end,s);break;case eC.Loop:u%=D;break;case eC.PingPong:const m=Math.floor(u/D)%2!==0;u%=D,m&&(u=D-u);break}s.reversed===!0?C.time=C.getClip().duration-u:C.time=u,C.timeScale=0;const w=d;if(C.weight=w,C.clampWhenFinished=!0,C.isRunning()||C.play(),this._useclipOffsets){const m=e==0?this._totalOffsetPosition:this._totalOffsetPosition2,M=e==0?this._totalOffsetRotation:this._totalOffsetRotation2;e<1&&(i=1-d),e+=1;const F=this._summedPos.set(0,0,0),k=this._tempPos.set(0,0,0),f=this._summedRot.identity(),b=this._tempRot.identity(),O=a.rotation;O&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(O,d));const L=this._actionOffsets[o];if(L.hasOffsets)for(let T=0;T<p;T++)L.rootPositionOffset?k.copy(L.rootPositionOffset):k.set(0,0,0),k.applyQuaternion(f),this._clipRotQuat&&k.applyQuaternion(this._clipRotQuat),L.rootQuaternionOffset&&(b.copy(L.rootQuaternionOffset),f.multiply(b)),F.add(k);this._clipRotQuat&&M.multiply(this._clipRotQuat),M.multiply(f),a.position&&F.add(a.position),m.add(F)}}}this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,i),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,i)),this.mixer.update(A)}createRotationInterpolant(A,e,i){var g;const I=i.createInterpolant.bind(i),o=new xA;this.ensureTrackOffsets();const s=(g=this.trackOffset)==null?void 0:g.rotation;i.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=n=>{const B=a(n);return o.set(B[0],B[1],B[2],B[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),B[0]=o.x,B[1]=o.y,B[2]=o.z,B[3]=o.w,B},C}}createPositionInterpolant(A,e,i){var g,I;const o=i.createInterpolant.bind(i),s=new S;this.ensureTrackOffsets();const C=(g=this.trackOffset)==null?void 0:g.rotation,a=(I=this.trackOffset)==null?void 0:I.position;let n;i.createInterpolant=()=>{const B=o(),Q=B.evaluate.bind(B);return B.evaluate=E=>{var h,l;const d=Q(E);return s.set(d[0],d[1],d[2]),e.removeStartOffset&&(n===void 0?(n=null,n=(l=(h=this._actionOffsets.find(c=>c.clip===A))==null?void 0:h.rootStartPosition)==null?void 0:l.clone()):n!=null&&n.isVector3&&s.sub(n)),s.applyQuaternion(this._totalOffsetRotation),s.add(this._totalOffsetPosition),C&&s.applyQuaternion(C),a&&(s.x-=a.x,s.y+=a.y,s.z+=a.z),d[0]=s.x,d[1]=s.y,d[2]=s.z,d},B}}}const LgA=oA("mutetimeline"),Vl=class extends Wl{constructor(){super(...arguments),r(this,"models",[]),r(this,"listener"),r(this,"audio",[]),r(this,"audioContextTimeOffset",[]),r(this,"lastTime",0),r(this,"_audioLoader",null)}getAudioFilePath(t){const A=this.director.sourceId;return Ya(A,t)}onAllowAudioChanged(t){for(let A=0;A<this.models.length;A++){const e=this.models[A];this.audio[A].setVolume(t?e.asset.volume:0)}}addModel(t){const A=new eD(this.listener);this.audio.push(A),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&t?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}evaluate(t){if(LgA||this.track.muted||this.director.speed<0)return;const A=this.director.context.application.muted,e=A?.1:0;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=this.audio[i];if((!I||!I.buffer)&&this.isInTimeRange(g,t-1,t+1)&&this.handleAudioLoading(g,I),yi.userInteractionRegistered!==!1&&!(I===null||!I.buffer))if(I.playbackRate=this.director.context.time.timeScale,I.loop=g.asset.loop,t>=g.start&&t<=g.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(I.isPlaying&&I.stop(),this.lastTime===t)continue}else if(!I.isPlaying)I.offset=g.clipIn+(t-g.start)*g.timeScale,I.play(e);else{const s=g.clipIn+(t-g.start)*g.timeScale,C=I.context.currentTime-I._startedAt+I.offset;Math.abs(s-C)>.3&&(I.offset=s,I.stop(),I.play(e))}let o=g.asset.volume;if(A&&(o=0),g.easeInDuration>0){const s=Math.min((t-g.start)/g.easeInDuration,1);o*=s}if(g.easeOutDuration>0){const s=Math.min((g.end-t)/g.easeOutDuration,1);o*=s}I.setVolume(o*this.director.weight)}else I.isPlaying&&I.stop()}this.lastTime=t}loadAudio(t,A=0,e=0){let i=null;const g=t-e,I=t+A;for(const o of this.models)if(this.isInTimeRange(o,g,I)){const s=this.audio[this.models.indexOf(o)],C=this.handleAudioLoading(o,s);C!==null&&(i===null&&(i=[]),i.push(C))}return i!==null?Promise.all(i):null}isInTimeRange(t,A,e){return A<=t.start&&e>=t.end||A>=t.start&&A<=t.end||e>=t.start&&e<=t.end}static dispose(){Vl._audioBuffers.clear()}handleAudioLoading(t,A){this._audioLoader||(this._audioLoader=new $u);const e=this.getAudioFilePath(t.asset.clip);if(Vl._audioBuffers.get(e)){const g=Vl._audioBuffers.get(e);return g.then(I=>{I&&A.setBuffer(I)}),g}rB&&console.warn("LOAD audio track",e,this.director.sourceId);const i=new Promise((g,I)=>{this._audioLoader.load(e,o=>{A.setBuffer(o),g(o)},void 0,o=>{console.error("Error loading audio",o),g(null)})});return Vl._audioBuffers.set(e,i),i}};let zl=Vl;r(zl,"_audioBuffers",new Map);class Zl extends Wl{constructor(){super(...arguments),r(this,"models",[]),r(this,"didTrigger",[]),r(this,"receivers",[])}evaluate(A){var e;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=this.didTrigger[g],s=I.time-A;let C=!1;if(I.retroActive)C=s<=1e-6;else{const a=Math.abs(s);a>=1e-5&&a<i&&(C=!0)}if(C){if(!o)if(this.didTrigger[g]=!0,((e=this.receivers)==null?void 0:e.length)<=0)vE.invoke(I.asset);else for(const a of this.receivers)a&&a.invoke(I.asset)}else I.emitOnce||(this.didTrigger[g]=!1)}}}class Dy extends Wl{constructor(){super(...arguments),r(this,"models",[]),r(this,"timelines",[]),r(this,"_previousActiveModel",null)}resolveSourceObjects(A){for(let e=this.models.length-1;e>=0;e--){const i=this.models[e].asset;if(!i.sourceObject||typeof i.sourceObject!="object"){console.log("no source object, removing model",e,i),this.models.splice(e,1);continue}else{const g=tA.getComponent(i.sourceObject,nB);this.timelines.push(g),g&&i.updateDirector&&(g.playOnAwake=!1)}}}evaluate(A){var e;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=g.asset;if(A>=g.start&&A<=g.end){this._previousActiveModel=g;const o=this.getClipTime(A,g);if(I.controlActivation){const s=I.sourceObject;s.visible=!0}if(I.updateDirector){const s=this.timelines[i];s&&(s.isPlaying&&s.pause(),s.time=o,s.evaluate())}}else{const o=(e=this._previousActiveModel)==null?void 0:e.asset;if(I.controlActivation){const s=I.sourceObject;o?.sourceObject!==s&&(s.visible=!1)}}}}}var xgA=Object.defineProperty,TgA=Object.getOwnPropertyDescriptor,K2=(t,A,e,i)=>{for(var g=i>1?void 0:i?TgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&xgA(A,e,g),g};class ke{constructor(A){r(this,"_active",!0),r(this,"_value"),r(this,"_valueRaw"),r(this,"_defaultValue"),r(this,"valueProcessor"),r(this,"onValueChanged"),this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const i=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged&&this.onValueChanged(A,i,this)}testIfValueChanged(A){return this._valueRaw!==A}}K2([y()],ke.prototype,"overrideState",1),K2([y()],ke.prototype,"value",1);var YgA=Object.defineProperty,HgA=Object.getOwnPropertyDescriptor,OgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?HgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&YgA(A,e,g),g};const _gA=oA("debugpost");class vg extends ln{constructor(A=void 0){if(super(),r(this,"active",!0),r(this,"_result"),r(this,"_didCreateVolumeParameters",!1),A){this.ensureVolumeParameters();for(const e of Object.keys(A)){const i=A[e],g=this[e];g instanceof ke&&(g.value=i)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var A;return this.ensureVolumeParameters(),this._result||(this._result=(A=this.onCreateEffect)==null?void 0:A.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){_gA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(A=>A.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const A=Object.keys(this);for(const e of A){const i=this[e];i instanceof ke&&i.__init()}}onAfterDeserialize(A,e){if(typeof A=="object"){const i=this.$serializedTypes;if(i){for(const g of Object.keys(i))if(i[g]===ke){const I=A[g];if(I!==void 0){const o=this[g];o.value=I}}}}}onEditorModification(A){const e=A.propertyName;if(this[e]instanceof ke){const i=A.value;return this[e].value=i,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const A=this.$serializedTypes;if(A)for(const e of Object.keys(A))A[e]===ke&&(this[e]||(this[e]=new ke))}}OgA([y()],vg.prototype,"active",2);var PgA=Object.defineProperty,jgA=Object.getOwnPropertyDescriptor,WgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?jgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&PgA(A,e,g),g};const VgA=oA("debugpost"),zR={};function Jo(t,A){zR[t]=A}function zgA(t){return t.__type in zR?zR[t.__type]:(VgA&&t.__type&&console.warn("Unknown postprocessing type",t.__type,t),vg)}class Xl{constructor(){r(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}WgA([rE([t=>zgA(t),vg])],Xl.prototype,"components",2);var ZgA=Object.defineProperty,XgA=Object.getOwnPropertyDescriptor,$gA=(t,A,e,i)=>{for(var g=i>1?void 0:i?XgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ZgA(A,e,g),g};class $l extends vg{constructor(){super(...arguments),r(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const A=new n9({preset:$Q.HIGH,edgeDetectionMode:SG.DEPTH});return this.preset.onValueChanged=e=>{A.applyPreset(e)},A}}$gA([y(ke)],$l.prototype,"preset",2),Jo("Antialiasing",$l);class wy{constructor(){r(this,"files",[])}get extensionName(){return"Audio"}onExportObject(A,e,i){const g=tA.getComponents(A,yi);if(g.length)for(const I of g){if(!I.clip||!I.playOnAwake)continue;const o=I.clip.split("/").pop();this.files.includes(I.clip)||this.files.push(I.clip),e.addEventListener("serialize",(s,C)=>{s.appendLine(),s.beginBlock(`def SpatialAudio "${e.name}"`),s.appendLine(`uniform asset filePath = @audio/${o}@`),s.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),s.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),s.appendLine(`uniform float gain = ${I.volume}`),s.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const i=e.split("/").pop(),g=await(await(await fetch(e)).blob()).arrayBuffer(),I=new Uint8Array(g);A.files["audio/"+i]=I}}}var AIA=Object.defineProperty,eIA=Object.getOwnPropertyDescriptor,J2=(t,A,e,i)=>{for(var g=i>1?void 0:i?eIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&AIA(A,e,g),g};const tIA=oA("debugmouth");class Ad extends UA{constructor(){super(...arguments),r(this,"idle",[]),r(this,"talking",[]),r(this,"marker",null),r(this,"voip",null),r(this,"lastMouthChangeTime",0),r(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=tA.findObjectOfType(Ka,this.context),this.marker||(this.marker=tA.getComponentInParent(this.gameObject,qg))},3e3)}update(){var A;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((A=this.marker)==null?void 0:A.connectionId)??null;if(!e){tIA&&(e=null);return}const i=this.voip.getFrequency(e)??0;this.updateLips(i)}updateLips(A){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&A>30){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,e)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,e)}}}setMouthShapeActive(A,e){if(A){A!=this.idle?this.idle.map(i=>i.visible=!1):this.talking.map(i=>i.visible=!1);for(let i=0;i<A.length;i++){const g=A[i];g&&(g.visible=i===e)}}}}J2([y(vA)],Ad.prototype,"idle",2),J2([y(vA)],Ad.prototype,"talking",2);class ZR extends UA{constructor(){super(...arguments),r(this,"voip",null),r(this,"marker",null),r(this,"_startPosition",null)}awake(){this.voip=tA.findObjectOfType(Ka,this.context),this.marker=tA.getComponentInParent(this.gameObject,qg)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const A=this.marker.connectionId,e=this.voip.getFrequency(A);if(e==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());let i=e/100;this.gameObject.position.y=this._startPosition.y+i*.07}}var iIA=Object.defineProperty,gIA=Object.getOwnPropertyDescriptor,yy=(t,A,e,i)=>{for(var g=i>1?void 0:i?gIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&iIA(A,e,g),g};class BB extends UA{constructor(){super(...arguments),r(this,"eyes",[]),r(this,"lastBlinkTime",0),r(this,"blinkLength",0),r(this,"eyesOpen",!0),r(this,"state",null)}awake(){this.state=tA.getComponentInParent(this.gameObject,iI)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const A of this.eyes)A&&(A.visible=this.eyesOpen)}}}yy([y(vA)],BB.prototype,"eyes",2),yy([y()],BB.prototype,"lastBlinkTime",2),yy([y()],BB.prototype,"blinkLength",2),yy([y()],BB.prototype,"eyesOpen",2);var IIA=Object.defineProperty,oIA=Object.getOwnPropertyDescriptor,XR=(t,A,e,i)=>{for(var g=i>1?void 0:i?oIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&IIA(A,e,g),g},$R;const q2=($R=class extends UA{constructor(){super(...arguments),r(this,"head",null),r(this,"eyes",null),r(this,"target",null),r(this,"brain",null),r(this,"vec",new S),r(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=tA.getComponentInParent(this.gameObject,Sl)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=tA.addNewComponent(this.gameObject,Sl)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const t=this.target;if(t&&this.head){const A=this.eyes;if(A){const e=ue(t);this.currentTargetPoint.lerp(e,this.context.time.deltaTime/.1);const i=ue(this.head),g=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(g.length()<.1)return;const I=q2.forward;if(I.set(0,0,1),I.applyQuaternion(Ti(this.head)),I.dot(g)>.45)for(let o=0;o<A.length;o++)A[o].lookAt(this.currentTargetPoint)}}}},r($R,"forward",new S(0,0,1)),$R);let bE=q2;XR([y(vA)],bE.prototype,"head",2),XR([y(vA)],bE.prototype,"eyes",2),XR([y(vA)],bE.prototype,"target",2);var sIA=Object.defineProperty,CIA=Object.getOwnPropertyDescriptor,AU=(t,A,e,i)=>{for(var g=i>1?void 0:i?CIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&sIA(A,e,g),g};class LE extends UA{constructor(){super(...arguments),r(this,"length",1),r(this,"depthTest",!0),r(this,"isGizmo",!0),r(this,"_axes",null)}onEnable(){if(this.isGizmo&&!Mc)return;this._axes||(this._axes=new YQ(this.length)),this.gameObject.add(this._axes);const A=this._axes.material;A&&A.depthTest!==void 0&&(A.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}AU([y()],LE.prototype,"length",2),AU([y()],LE.prototype,"depthTest",2),AU([y()],LE.prototype,"isGizmo",2);class eU extends UA{constructor(){super(...arguments),r(this,"from"),r(this,"to"),r(this,"hint"),r(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;let A=ue(this.to).clone(),e=ue(this.from).clone(),i=A.distanceTo(e),g=A.clone();g.sub(e);let I=e.clone();I.add(A),I.multiplyScalar(.5);let o=ue(this.hint).clone();o.sub(I);let s=new S;s.crossVectors(o,g),s.crossVectors(g,s),s.normalize();let C=i*.5,a=Math.max(this.desiredDistance,C),n=Math.sqrt(a*a-C*C),B=s.clone();B.multiplyScalar(n),B.add(I),ai(this.gameObject,B);let Q=I.clone();Q.sub(s),this.gameObject.lookAt(Q)}}class Sy{constructor(){r(this,"behaviours",[]),r(this,"behaviourComponents",[]),r(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(i=>{tA.foreachComponent(i,g=>{var I;const o=g;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const s=(I=o.beforeCreateDocument)==null?void 0:I.call(o,this,A);s instanceof Promise&&e.push(s)}},!1)}),Promise.all(e)}onExportObject(A,e,i){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.call(I,this,e,i)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var i;if((i=this.behaviours)!=null&&i.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){console.log("onAfterSerialize",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)console.log("behaviour",e),typeof e.afterSerialize=="function"&&(console.log("beh has afterSerialize",e),e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A))}}var aIA=Object.defineProperty,nIA=Object.getOwnPropertyDescriptor,tU=(t,A,e,i)=>{for(var g=i>1?void 0:i?nIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&aIA(A,e,g),g};class QB extends vg{constructor(){super(...arguments),r(this,"threshold"),r(this,"intensity"),r(this,"scatter"),r(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>1*Math.PI*(1-A)):(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>100*(1-A))}onCreateEffect(){let A;if(this.selectiveBloom){const e=A=new kx(this.context.scene,this.context.mainCamera,{blendFunction:qe.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});e.inverted=!0}else A=new RG;return this.intensity.onValueChanged=e=>{A.intensity=e},this.threshold.onValueChanged=e=>{A.luminanceMaterial.threshold=e},this.scatter.onValueChanged=e=>{A.luminancePass.enabled=!0,A.luminanceMaterial.smoothing=e},A}}tU([y(ke)],QB.prototype,"threshold",2),tU([y(ke)],QB.prototype,"intensity",2),tU([y(ke)],QB.prototype,"scatter",2),Jo("Bloom",QB);var rIA=Object.defineProperty,BIA=Object.getOwnPropertyDescriptor,hs=(t,A,e,i)=>{for(var g=i>1?void 0:i?BIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&rIA(A,e,g),g};class tC extends UA{constructor(){super(...arguments),r(this,"attachedRigidbody",null),r(this,"isTrigger",!1),r(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Wt))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Wt))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Wt))}onDisable(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}}hs([y(Wt)],tC.prototype,"attachedRigidbody",2),hs([y()],tC.prototype,"isTrigger",2),hs([y()],tC.prototype,"sharedMaterial",2);class ed extends tC{constructor(){super(...arguments),r(this,"radius",.5),r(this,"center",new S(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addSphereCollider(this,this.center,this.radius)}}hs([y()],ed.prototype,"radius",2),hs([y(S)],ed.prototype,"center",2);class td extends tC{constructor(){super(...arguments),r(this,"size",new S(1,1,1)),r(this,"center",new S(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addBoxCollider(this,this.center,this.size)}}hs([y(S)],td.prototype,"size",2),hs([y(S)],td.prototype,"center",2);class id extends tC{constructor(){super(...arguments),r(this,"sharedMesh"),r(this,"convex",!1)}onEnable(){var A,e,i,g,I;if(super.onEnable(),(A=this.sharedMesh)!=null&&A.isMesh||this.gameObject instanceof fA&&(this.sharedMesh=this.gameObject),(e=this.sharedMesh)!=null&&e.isMesh)(i=this.context.physics.engine)==null||i.addMeshCollider(this,this.sharedMesh,this.convex,Cg(this.gameObject));else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${(g=this.sharedMesh)==null?void 0:g.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const s in o.children){const C=o.children[s];C.isMesh&&((I=this.context.physics.engine)==null||I.addMeshCollider(this,C,this.convex,Cg(this.gameObject)))}}}}}hs([y()],id.prototype,"convex",2);class vn extends tC{constructor(){super(...arguments),r(this,"center",new S(0,0,0)),r(this,"radius",.5),r(this,"height",2)}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addCapsuleCollider(this,this.center,this.height,this.radius)}}hs([y(S)],vn.prototype,"center",2),hs([y()],vn.prototype,"radius",2),hs([y()],vn.prototype,"height",2);function iU(t){return t[$s]||(t.parent?iU(t.parent):null)}function fy(t,A){if(!t)return;const e=t.material;if(e?.isMaterial===!0){const i=t.parent;i&&i.isText,e.side=A.doubleSided??!0?Ut:kg,e.shadowSide=A.doubleSided?Ut:kg,t.castShadow=A.castShadows?A.castShadows:!1,t.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const i of t.children)fy(i,A)}function xE(t,A,e){t[A]===void 0&&console.warn("Field",A,"is undefined on",t);const i=Proxy.revocable(t[A],{set(o,s,C,a){const n=o[s],B=Reflect.set(o,s,C,a);return e(C,n),B}}),g=i.revoke,I=t[A];return i.revoke=()=>{t[A]=I,g()},t[A]=i.proxy,i}const v2=Symbol("Scheduled action");function QIA(t,A,e=WI.OnBeforeRender){let i=t[v2];i||(i=t[v2]={});const g=A.name;i[e]||(i[e]={});const I=i[e];if(I[g])return;function*o(){A?.call(t),I[g]=null}const s=t.startCoroutine(o(),e);I[g]=s}var EIA=Object.defineProperty,hIA=Object.getOwnPropertyDescriptor,EB=(t,A,e,i)=>{for(var g=i>1?void 0:i?hIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&EIA(A,e,g),g};const gU=oA("debugui"),IU=oA("debuguilayout");class oU{constructor(){r(this,"width"),r(this,"height")}}class sU{constructor(){r(this,"x"),r(this,"y"),r(this,"width"),r(this,"height")}}const cs=new S,gd=new JA,my=new xA,b2=class extends ms{constructor(){super(...arguments),r(this,"_anchoredPosition"),r(this,"sizeDelta",new Z(100,100)),r(this,"pivot",new Z(.5,.5)),r(this,"anchorMin",new Z(0,0)),r(this,"anchorMax",new Z(1,1)),r(this,"offsetMin",new Z(0,0)),r(this,"offsetMax",new Z(0,0)),r(this,"lastMatrix"),r(this,"rectBlock"),r(this,"_transformNeedsUpdate",!1),r(this,"_initialPosition"),r(this,"_parentRectTransform"),r(this,"_lastUpdateFrame",-1),r(this,"_lastAnchoring"),r(this,"_createdBlocks",[]),r(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new Z),this._anchoredPosition}set anchoredPosition(t){this._anchoredPosition=t}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const t=this._parentRectTransform.width,A=this.anchorMax.x-this.anchorMin.x;let e=t*A;return e+=this.sizeDelta.x,e}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const t=this._parentRectTransform.height,A=this.anchorMax.y-this.anchorMin.y;let e=t*A;return e+=this.sizeDelta.y,e}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new Z),this.lastMatrix=new JA,this.rectBlock=new vA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,xE(this,"_anchoredPosition",()=>{this.markDirty()}),xE(this,"sizeDelta",()=>{this.markDirty()}),xE(this,"pivot",()=>{this.markDirty()}),xE(this,"anchorMin",()=>{this.markDirty()}),xE(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var t;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(t=this.Canvas)==null||t.registerTransform(this)}onDisable(){var t;super.onDisable(),this.removeShadowComponent(),(t=this.Canvas)==null||t.unregisterTransform(this)}onParentRectTransformChanged(t){this._transformNeedsUpdate||this.onApplyTransform(IU?`${t.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(IU&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(t){var A;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=tA.getComponentInParent(this.gameObject.parent,b2):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,IU&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+t),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,cs.set(0,0,0),this.applyPivot(cs),e.matrix.setPosition(cs.x,cs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(my.copy(this.gameObject.quaternion),my.x*=-1,my.z*=-1,gd.makeRotationFromQuaternion(my),e.matrix.premultiply(gd)),cs.set(0,0,0),this.applyAnchoring(cs),(A=this.Canvas)!=null&&A.screenspace?cs.z+=.1:cs.z+=.01,gd.identity(),gd.setPosition(cs.x,cs.y,cs.z),e.matrix.premultiply(gd),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const g of dG(this.gameObject,ms,i,1)){if(g===this||!g.activeAndEnabled)continue;const I=g;I.onParentRectTransformChanged&&I.onParentRectTransformChanged(this)}}applyAnchoring(t){this._lastAnchoring||(this._lastAnchoring=new Z);const A=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=A.x,this.gameObject.position.y+=A.y,this._lastAnchoring.copy(this._anchoredPosition),t.x+=this._initialPosition.x-this.gameObject.position.x,t.y+=this._initialPosition.y-this.gameObject.position.y,t.z+=this._initialPosition.z-this.gameObject.position.z;const e=this._parentRectTransform;if(e){let i=0;const g=1-this.anchorMax.y-this.anchorMin.y;i-=e.height*.5*g,t.y+=i;let I=0;const o=1-this.anchorMax.x-this.anchorMin.x;I-=e.width*.5*o,t.x+=I}}applyPivot(t){if(this.pivot&&!this.isRoot()){const A=this.pivot.x-.5;t.x-=A*this.sizeDelta.x*this.gameObject.scale.x;const e=this.pivot.y-.5;t.y-=e*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const t={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(t),t}ensureValidSize(t,A=1e-4){return t.width<=0&&(t.width=A),t.height<=0&&(t.height=1e-4),t}createNewBlock(t){t={...this.getBasicOptions(),...t},gU&&console.log(this.name,t);const A=new qR(t);return this._createdBlocks.push(A),A}createNewText(t){gU&&console.log(t),t={...this.getBasicOptions(),...t},gU&&console.log(this.name,t);const A=new m2(t);return this._createdTextBlocks.push(A),A}};let hg=b2;EB([y(Z)],hg.prototype,"anchoredPosition",1),EB([y(Z)],hg.prototype,"sizeDelta",2),EB([y(Z)],hg.prototype,"pivot",2),EB([y(Z)],hg.prototype,"anchorMin",2),EB([y(Z)],hg.prototype,"anchorMax",2),EB([y(Z)],hg.prototype,"offsetMin",2),EB([y(Z)],hg.prototype,"offsetMax",2);class cIA extends f2{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const i in e)for(const g in e[i])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].push(i);for(const i of A._components)A._simpleState__statesProperties[i.id]&&(A._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const i=[];for(const g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],i.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)i.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const i in A)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=A[i]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var lIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,L2=(t,A,e,i)=>{for(var g=i>1?void 0:i?dIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lIA(A,e,g),g};class TE extends UA{constructor(){super(...arguments),r(this,"effectColor"),r(this,"effectDistance")}}L2([y(yt)],TE.prototype,"effectColor",2),L2([y(Z)],TE.prototype,"effectDistance",2);var pIA=Object.defineProperty,uIA=Object.getOwnPropertyDescriptor,x2=(t,A,e,i)=>{for(var g=i>1?void 0:i?uIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&pIA(A,e,g),g};const ky={backgroundColor:new wA(1,1,1),backgroundOpacity:1,borderColor:new wA(1,1,1),borderOpacity:1};var CU;const Gy=(CU=class extends ms{constructor(){super(...arguments),r(this,"_alphaFactor",1),r(this,"raycastTarget",!0),r(this,"uiObject",null),r(this,"_color",null),r(this,"_rect",null),r(this,"_stateManager",null),r(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new yt(1,1,1,1)),this._color}set color(t){(!this._color||this._color.r!==t.r||this._color.g!==t.g||this._color.b!==t.b||this._color.alpha!==t.alpha)&&(this._color||(this._color=new yt(1,1,1,1)),this._color.copy(t))}setAlphaFactor(t){this._alphaFactor=t,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(ky.backgroundColor=this._color,ky.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(ky,this._alphaFactor),this.uiObject.set(ky),this.markDirty())}get m_Color(){return this._color}get rectTransform(){return this._rect||(this._rect=tA.getComponent(this.gameObject,hg)),this._rect}onParentRectTransformChanged(){var t;(t=this.uiObject)==null||t.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(t){this.makePanel(),this.uiObject&&(this.uiObject.setState(t),this==null||this.markDirty())}setupState(t){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new cIA(this.uiObject)),this.uiObject.setupState(t.state,t.attributes))}setOptions(t){this.makePanel(),this.uiObject&&this.uiObject.set(t)}awake(){super.awake(),this.makePanel(),xE(this,"_color",()=>QIA(this,this.onColorChanged))}onEnable(){var t;super.onEnable(),this.uiObject&&((t=this.rectTransform.shadowComponent)==null||t.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;let t=.015;const A={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:t};this.onBeforeCreate(A),this.applyEffects(A),this.onCreate(A),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(t){}onCreate(t){this.uiObject=this.rectTransform.createNewBlock(t),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(t,A=1){var e;const i=(e=this.gameObject)==null?void 0:e.getComponent(TE);i&&(i.effectDistance&&(t.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(t.borderColor=i.effectColor,t.borderOpacity=i.effectColor.alpha*A))}async setTexture(t){if(this.setOptions({backgroundOpacity:0}),t){if(t.colorSpace===Ie)if(Gy.textureCache.has(t))t=Gy.textureCache.get(t);else{const A=t.clone();A.colorSpace=zi,Gy.textureCache.set(t,A),t=A}this.setOptions({backgroundImage:t,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},r(CU,"textureCache",new Map),CU);let hB=Gy;x2([y(yt)],hB.prototype,"color",1),x2([y()],hB.prototype,"raycastTarget",2);class Id extends hB{constructor(){super(...arguments),r(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var DIA=Object.defineProperty,wIA=Object.getOwnPropertyDescriptor,My=(t,A,e,i)=>{for(var g=i>1?void 0:i?wIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&DIA(A,e,g),g};let aU=class{constructor(){r(this,"texture",null),r(this,"rect")}};My([y(_e)],aU.prototype,"texture",2);let YE=class extends Id{constructor(){super(...arguments),r(this,"_sprite"),r(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new aU),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,A,e,i,g,I,o,s;switch((A=(t=this.sprite)==null?void 0:t.texture)==null?void 0:A.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((g=(i=(e=this.sprite)==null?void 0:e.texture)==null?void 0:i.image)==null?void 0:g.width)===32&&((s=(o=(I=this.sprite)==null?void 0:I.texture)==null?void 0:o.image)==null?void 0:s.height)===32}onBeforeCreate(t){var A,e;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((e=(A=this.sprite)==null?void 0:A.texture)==null?void 0:e.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};My([y(aU)],YE.prototype,"sprite",1),My([y()],YE.prototype,"pixelsPerUnitMultiplier",2);class Ry extends Id{constructor(){super(...arguments),r(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(A){this._mainTexture!==A&&(this._mainTexture=A,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}My([y(_e)],Ry.prototype,"mainTexture",1);var yIA=Object.defineProperty,SIA=Object.getOwnPropertyDescriptor,$I=(t,A,e,i)=>{for(var g=i>1?void 0:i?SIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&yIA(A,e,g),g};const HE=oA("debugbutton");class cB{constructor(){r(this,"colorMultiplier"),r(this,"disabledColor"),r(this,"fadeDuration"),r(this,"highlightedColor"),r(this,"normalColor"),r(this,"pressedColor"),r(this,"selectedColor")}}$I([y()],cB.prototype,"colorMultiplier",2),$I([y(yt)],cB.prototype,"disabledColor",2),$I([y()],cB.prototype,"fadeDuration",2),$I([y(yt)],cB.prototype,"highlightedColor",2),$I([y(yt)],cB.prototype,"normalColor",2),$I([y(yt)],cB.prototype,"pressedColor",2),$I([y(yt)],cB.prototype,"selectedColor",2);class Ea extends UA{constructor(){super(...arguments),r(this,"onClick"),r(this,"_isHovered",!1),r(this,"colors"),r(this,"transition"),r(this,"animationTriggers"),r(this,"animator"),r(this,"_interactable",!0),r(this,"_requestedAnimatorTrigger"),r(this,"_isInit",!1),r(this,"_image")}onPointerEnter(A){var e,i;HE&&console.log("Button Enter",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var A,e;HE&&console.log("Button Exit",(A=this.animationTriggers)==null?void 0:A.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((e=this._image)==null||e.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(A){var e,i;HE&&console.log("Button Down",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("pressed")))}onPointerUp(A){var e,i;HE&&console.warn("Button Up",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState(this._isHovered?"hovered":"normal")))}onPointerClick(A){var e;this.interactable&&A.pointerId===0&&(HE&&(console.warn("Button Click",this.onClick),pi("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(e=this.onClick)==null||e.invoke())}set interactable(A){this._interactable=A,this._image&&(this._image.setInteractable(A),A?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(A){this.interactable=A}awake(){super.awake(),HE&&console.log(this),this._isInit=!1,this.init()}start(){var A;(A=this._image)==null||A.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(A){var e;this._requestedAnimatorTrigger=A,yield,yield,this._requestedAnimatorTrigger==A&&((e=this.animator)==null||e.SetTrigger(A))}init(){this._isInit||(this._isInit=!0,this._image=tA.getComponent(this.gameObject,YE),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(A){var e,i,g,I,o;A.setInteractable(this.interactable);const s=this.getFinalColor(A.color,(e=this.colors)==null?void 0:e.normalColor),C={state:"normal",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};A.setupState(C);const a=this.getFinalColor(A.color,(i=this.colors)==null?void 0:i.highlightedColor),n={state:"hovered",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};A.setupState(n);const B=this.getFinalColor(A.color,(g=this.colors)==null?void 0:g.pressedColor),Q={state:"pressed",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};A.setupState(Q);const E=this.getFinalColor(A.color,(I=this.colors)==null?void 0:I.selectedColor),h={state:"selected",attributes:{backgroundColor:E,backgroundOpacity:E.alpha}};A.setupState(h);const l=this.getFinalColor(A.color,(o=this.colors)==null?void 0:o.disabledColor),d={state:"disabled",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};A.setupState(d)}getFinalColor(A,e){return e?A.clone().multiply(e):A.clone()}}$I([y(SI)],Ea.prototype,"onClick",2),$I([y()],Ea.prototype,"colors",2),$I([y()],Ea.prototype,"transition",2),$I([y()],Ea.prototype,"animationTriggers",2),$I([y(tI)],Ea.prototype,"animator",2),$I([y()],Ea.prototype,"interactable",1);var fIA=Object.defineProperty,mIA=Object.getOwnPropertyDescriptor,ki=(t,A,e,i)=>{for(var g=i>1?void 0:i?mIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&fIA(A,e,g),g};const T2=oA("debuguilayout");class bn{constructor(){r(this,"left",0),r(this,"right",0),r(this,"top",0),r(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}ki([y()],bn.prototype,"left",2),ki([y()],bn.prototype,"right",2),ki([y()],bn.prototype,"top",2),ki([y()],bn.prototype,"bottom",2);class Ao extends UA{constructor(){super(...arguments),r(this,"_rectTransform",null),r(this,"_needsUpdate",!1),r(this,"childAlignment",0),r(this,"reverseArrangement",!1),r(this,"spacing",0),r(this,"padding"),r(this,"minWidth",0),r(this,"minHeight",0),r(this,"flexibleHeight",0),r(this,"flexibleWidth",0),r(this,"preferredHeight",0),r(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(A){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(T2&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){T2&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(hg);const A=this.gameObject.getComponentInParent(cg);A&&A.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const A=this.gameObject.getComponentInParent(cg);A&&A.unregisterLayoutGroup(this)}set m_Spacing(A){A!==this.spacing&&(this._needsUpdate=!0,this.spacing=A)}get m_Spacing(){return this.spacing}}ki([y()],Ao.prototype,"childAlignment",2),ki([y()],Ao.prototype,"reverseArrangement",2),ki([y()],Ao.prototype,"spacing",2),ki([y(bn)],Ao.prototype,"padding",2),ki([y()],Ao.prototype,"minWidth",2),ki([y()],Ao.prototype,"minHeight",2),ki([y()],Ao.prototype,"flexibleHeight",2),ki([y()],Ao.prototype,"flexibleWidth",2),ki([y()],Ao.prototype,"preferredHeight",2),ki([y()],Ao.prototype,"preferredWidth",2);class Ln extends Ao{constructor(){super(...arguments),r(this,"childControlHeight",!0),r(this,"childControlWidth",!0),r(this,"childForceExpandHeight",!1),r(this,"childForceExpandWidth",!1),r(this,"childScaleHeight",!1),r(this,"childScaleWidth",!1)}onCalculateLayout(A){var e;const i=this.primaryAxis,g=A.width;let I=g;const o=A.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const C=i==="x",a=C?"y":"x",n=C?this.childControlWidth:this.childControlHeight,B=C?this.childControlHeight:this.childControlWidth,Q=C?this.childForceExpandWidth:this.childForceExpandHeight,E=C?this.childForceExpandHeight:this.childForceExpandWidth,h=C?s:I,l=C?g:o,d=.5*(C?this.childAlignment%3:Math.floor(this.childAlignment/3));let c=0;C?c+=this.padding.left:c+=this.padding.top;let u=0,p=0;for(let F=0;F<this.gameObject.children.length;F++){const k=this.gameObject.children[F],f=tA.getComponent(k,hg);f!=null&&f.activeAndEnabled&&(p+=1,C?u+=f.width:u+=f.height)}let D=0;const w=this.spacing*(p-1);if(Q||n){let F=0;C?F=I-=w:F=s-=w,p>0&&(D=F/p)}let m=0;m+=this.padding.left,m-=this.padding.right,d!==0&&(c=l-u,c*=d,c-=w*d,C?(c-=this.padding.right*d,c+=this.padding.left*(1-d),c<this.padding.left&&(c=this.padding.left)):(c-=this.padding.bottom*d,c+=this.padding.top*(1-d),c<this.padding.top&&(c=this.padding.top)));let M=1;for(let F=0;F<this.gameObject.children.length;F++){const k=this.gameObject.children[F],f=tA.getComponent(k,hg);if(f!=null&&f.activeAndEnabled){(e=f.pivot)==null||e.set(.5,.5),f.anchorMin.set(0,1),f.anchorMax.set(0,1);const b=g*.5+m*.5;f.anchoredPosition.x!==b&&(f.anchoredPosition.x=b);const O=o*-.5;f.anchoredPosition.y!==O&&(f.anchoredPosition.y=O),E&&B&&f.sizeDelta[a]!==h&&(f.sizeDelta[a]=h),Q&&n&&f.sizeDelta[i]!==D&&(f.sizeDelta[i]=D);const L=C?f.width:f.height;let T=L*.5;if(c+=T,Q){let iA=D*M-D*.5;iA>c&&(c=iA-D*.5+L+this.padding.left,c-=T)}let W=c;i==="y"&&(W=-W),f.anchoredPosition[i]!==W&&(f.anchoredPosition[i]=W),c+=T,c+=this.spacing,M+=1}}}}ki([y()],Ln.prototype,"childControlHeight",2),ki([y()],Ln.prototype,"childControlWidth",2),ki([y()],Ln.prototype,"childForceExpandHeight",2),ki([y()],Ln.prototype,"childForceExpandWidth",2),ki([y()],Ln.prototype,"childScaleHeight",2),ki([y()],Ln.prototype,"childScaleWidth",2);class nU extends Ln{get primaryAxis(){return"y"}}class rU extends Ln{get primaryAxis(){return"x"}}class BU extends Ao{onCalculateLayout(){}}var kIA=Object.defineProperty,GIA=Object.getOwnPropertyDescriptor,iC=(t,A,e,i)=>{for(var g=i>1?void 0:i?GIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&kIA(A,e,g),g},Y2=(t=>(t[t.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",t[t.ScreenSpaceCamera=1]="ScreenSpaceCamera",t[t.WorldSpace=2]="WorldSpace",t[t.Undefined=-1]="Undefined",t))(Y2||{});const QU=oA("debuguilayout"),H2=class extends Jl{constructor(){super(...arguments),r(this,"_renderOnTop"),r(this,"_depthWrite",!1),r(this,"_doubleSided",!0),r(this,"_castShadows",!1),r(this,"_receiveShadows",!1),r(this,"_renderMode",-1),r(this,"_rootCanvas"),r(this,"_scaleFactor",1),r(this,"worldCamera"),r(this,"planeDistance",-1),r(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),r(this,"previousParent",null),r(this,"_lastMatrixWorld",null),r(this,"_rectTransforms",[]),r(this,"_layoutGroups",new Map),r(this,"onBeforeRenderRoutine",()=>{var t,A,e,i;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(A=this.shadowComponent)==null||A.updateWorldMatrix(!0,!0),ZI.ensureUpdateMeshUI(bR,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(i=this.shadowComponent)==null||i.updateWorldMatrix(!0,!0),ZI.ensureUpdateMeshUI(bR,this.context))}),r(this,"onAfterRenderRoutine",()=>{var t,A;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const g=this.context.mainCamera;g?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const e=this.context.renderer.autoClear,i=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),ZI.ensureUpdateMeshUI(bR,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=e,this.context.renderer.autoClearColor=i,this.previousParent.add(this.gameObject)}(A=this._lastMatrixWorld)==null||A.copy(this.gameObject.matrixWorld)}}),r(this,"_updateRenderSettingsRoutine"),r(this,"_activeRenderMode",-1),r(this,"_lastWidth",-1),r(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(t){t!==this._renderOnTop&&(this._renderOnTop=t,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(t){this._depthWrite!==t&&(this._depthWrite=t,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(t){this._doubleSided!==t&&(this._doubleSided=t,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(t){this._castShadows!==t&&(this._castShadows=t,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(t){this._receiveShadows!==t&&(this._receiveShadows=t,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode!==t&&(this._renderMode=t,this.onRenderSettingsChanged())}set rootCanvas(t){this._rootCanvas instanceof H2||(this._rootCanvas=t)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(t){this._scaleFactor=t}awake(){var t;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,QU&&console.log("Canvas.Awake()",((t=this.previousParent)==null?void 0:t.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new JA,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);t!==-1&&this.context.pre_render_callbacks.splice(t,1);const A=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);A!==-1&&this.context.post_render_callbacks.splice(A,1)}registerTransform(t){this._rectTransforms.push(t)}unregisterTransform(t){const A=this._rectTransforms.indexOf(t);A!==-1&&this._rectTransforms.splice(A,1)}registerLayoutGroup(t){const A=t.gameObject;this._layoutGroups.set(A,t)}unregisterLayoutGroup(t){const A=t.gameObject;this._layoutGroups.delete(A)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new JA);const t=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);QU&&t&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);let A=!1;for(const e of this._rectTransforms){t&&e.markDirty();let i=this._layoutGroups.get(e.gameObject);e.isDirty&&!i&&(i=e.gameObject.getComponentInParent(Ao)),(e.isDirty||i!=null&&i.isDirty)&&(QU&&!A&&console.log("CANVAS UPDATE ### "+e.name+" ##################################### "+this.context.time.frame),i?.updateLayout(),e.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),WI.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),fy(this.shadowComponent,this);for(const t of tA.getComponentsInChildren(this.gameObject,ms))fy(t.shadowComponent,this)}}onUpdateRenderMode(t=!1){if(!t&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let A=this.context.mainCameraComponent,e=10;switch(A&&A.nearClipPlane>0&&A.farClipPlane>0&&(e=te.lerp(A.nearClipPlane,A.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(A=this.worldCamera),this.planeDistance>0&&(e=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!A)return;const i=e+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-i,this.gameObject.quaternion.identity();const g=this.gameObject.getComponent(hg);let I=!1;g.sizeDelta.x!==this.context.domWidth&&(I=!0),g.sizeDelta.y!==this.context.domHeight&&(I=!0);const o=A.fieldOfView*Math.PI/180,s=2*Math.tan(o/2)*Math.abs(i);this.gameObject.scale.x=s/this.context.domHeight,this.gameObject.scale.y=s/this.context.domHeight,this.gameObject.scale.z=.01,I&&(g.sizeDelta.x=this.context.domWidth,g.sizeDelta.y=this.context.domHeight,g?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let cg=H2;iC([y()],cg.prototype,"renderOnTop",1),iC([y()],cg.prototype,"depthWrite",1),iC([y()],cg.prototype,"doubleSided",1),iC([y()],cg.prototype,"castShadows",1),iC([y()],cg.prototype,"receiveShadows",1),iC([y()],cg.prototype,"renderMode",1),iC([y(cg)],cg.prototype,"rootCanvas",1),iC([y()],cg.prototype,"scaleFactor",1),iC([y(Tt)],cg.prototype,"worldCamera",2),iC([y()],cg.prototype,"planeDistance",2);var MIA=Object.defineProperty,RIA=Object.getOwnPropertyDescriptor,EU=(t,A,e,i)=>{for(var g=i>1?void 0:i?RIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&MIA(A,e,g),g};class xn extends UA{constructor(){super(...arguments),r(this,"_alpha",1),r(this,"interactable",!0),r(this,"blocksRaycasts",!0),r(this,"_isDirty",!1),r(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(A){A!==this._alpha&&(this._alpha=A,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),WI.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const A of tA.getComponentsInChildren(this.gameObject,ms,this._buffer)){const e=A;e.setAlphaFactor&&e.setAlphaFactor(this._alpha)}}}EU([y()],xn.prototype,"alpha",1),EU([y()],xn.prototype,"interactable",2),EU([y()],xn.prototype,"blocksRaycasts",2);var UIA=Object.defineProperty,FIA=Object.getOwnPropertyDescriptor,Nt=(t,A,e,i)=>{for(var g=i>1?void 0:i?FIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&UIA(A,e,g),g};class lB extends UA{constructor(){super(...arguments),r(this,"object"),r(this,"target"),r(this,"duration",1),r(this,"relativeMotion",!1),r(this,"coroutine",null),r(this,"targetPos",new S),r(this,"targetRot",new xA),r(this,"targetScale",new S)}*moveToTarget(){if(!this.target||!this.object)return;const A=ue(this.object).clone(),e=ue(this.target).clone(),i=Ti(this.object).clone(),g=Ti(this.target).clone(),I=Cg(this.object).clone(),o=Cg(this.target).clone(),s=A.distanceTo(e),C=i.angleTo(g),a=I.distanceTo(o);if(s<.01&&C<.01&&a<.01){ai(this.object,e),uI(this.object,g),Hk(this.object,o),this.coroutine=null;return}let n=0,B=0;for(;n<1;)n+=this.context.time.deltaTime/this.duration,n>1&&(n=1),B=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,this.targetPos.lerpVectors(A,e,B),this.targetRot.slerpQuaternions(i,g,B),this.targetScale.lerpVectors(I,o,B),ai(this.object,this.targetPos),uI(this.object,this.targetRot),Hk(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const A=this.object.position.clone(),e=this.object.quaternion.clone(),i=this.object.scale.clone(),g=this.target.position.clone(),I=this.target.quaternion.clone(),o=this.target.scale.clone();g.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(g),this.targetRot.copy(this.object.quaternion).multiply(I),this.targetScale.copy(this.object.scale).multiply(o);let s=0,C=0;for(;s<1;)s+=this.context.time.deltaTime/this.duration,s>1&&(s=1),C=s<.5?4*s*s*s:1-Math.pow(-2*s+2,3)/2,this.object.position.lerpVectors(A,this.targetPos,C),this.object.quaternion.slerpQuaternions(e,this.targetRot,C),this.object.scale.lerpVectors(i,this.targetScale,C),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(A){var e;if(this.target&&this.object&&this.gameObject){const i=new eI("Move to "+((e=this.target)==null?void 0:e.name),fI.tapTrigger(this.gameObject),Bt.transformAction(this.object,this.target,this.duration,this.relativeMotion?JM.Relative:JM.Absolute));A.addBehavior(i)}}}Nt([y(vA)],lB.prototype,"object",2),Nt([y(vA)],lB.prototype,"target",2),Nt([y()],lB.prototype,"duration",2),Nt([y()],lB.prototype,"relativeMotion",2);var hU;const dB=(hU=class extends UA{constructor(){super(...arguments),r(this,"materialToSwitch"),r(this,"variantMaterial"),r(this,"fadeDuration",0),r(this,"_objectsWithThisMaterial",[]),r(this,"selfModel"),r(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const t=tA.findObjectsOfType(bt);for(const A of t)A.sharedMaterial===this.materialToSwitch&&this._objectsWithThisMaterial.push(A)}}onPointerClick(){if(this.variantMaterial)for(const t of this._objectsWithThisMaterial)t.sharedMaterial=this.variantMaterial}async beforeCreateDocument(t,A){this.targetModels=[],dB._materialTriggersPerId={},this.materialToSwitch&&await Cs.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Cs.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(t,A,e){this._objectsWithThisMaterial.find(i=>i.gameObject.uuid===A.uuid)&&this.targetModels.push(A),this.gameObject.uuid===A.uuid&&(this.selfModel=A,this.materialToSwitch&&(dB._materialTriggersPerId[this.materialToSwitch.uuid]||(dB._materialTriggersPerId[this.materialToSwitch.uuid]=[]),dB._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(t,A){if(!this.materialToSwitch)return;const e=dB._materialTriggersPerId[this.materialToSwitch.uuid];if(e){const i={};for(const I of e){const o=I.createVariants();o&&o.length>0&&(i[I.selfModel.uuid]=o)}const g=[];for(const I of e){for(const o in i)o!==I.selfModel.uuid&&g.push(i[o]);I.createAndAttachBehaviors(t,i[I.selfModel.uuid],g)}}delete dB._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(t,A,e){const i=[],g=[],I=Math.max(0,this.fadeDuration);for(const o of this.targetModels){const s=Bt.fadeAction(o,I,!1);g.push(s)}for(const o of e)g.push(Bt.fadeAction(o,I,!1));for(const o of A)i.push(Bt.fadeAction(o,I,!1)),g.push(Bt.fadeAction(o,I,!0));t.addBehavior(new eI("Select "+this.selfModel.name,fI.tapTrigger(this.selfModel),Bt.parallel(...g))),t.addBehavior(new eI("Start hidden "+this.selfModel.name,fI.sceneStartTrigger(),Bt.parallel(...i)))}createVariants(){if(!this.variantMaterial)return null;const t=[];for(const A of this.targetModels){const e=A.clone();e.name+=" variant_"+this.variantMaterial.name,e.name=e.name.replace(/\s/g,"_"),e.material=this.variantMaterial,e.geometry=A.geometry,e.matrix=A.matrix,(!A.parent||!A.parent.isEmpty())&&mo.createEmptyParent(A),A.parent&&A.parent.add(e),t.push(e)}return t}},r(hU,"_materialTriggersPerId",{}),hU);let OE=dB;Nt([y(Ue)],OE.prototype,"materialToSwitch",2),Nt([y(Ue)],OE.prototype,"variantMaterial",2),Nt([y()],OE.prototype,"fadeDuration",2);class _E extends UA{constructor(){super(...arguments),r(this,"target"),r(this,"toggleOnClick",!1),r(this,"targetState",!0),r(this,"hideSelf",!0),r(this,"selfModel"),r(this,"otherModel"),r(this,"toggleModel"),r(this,"stateBeforeCreatingDocument",!1)}onPointerClick(){!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(A,e,i){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(A,e){if(this.target){if(this.otherModel=e.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let i=this.hideSelf;this.targetState,this.toggleOnClick&&(i=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&lY.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const g=[];if(i&&g.push(Bt.fadeAction(this.selfModel,0,!1)),this.toggleModel&&g.push(Bt.fadeAction(this.toggleModel,0,!0)),g.push(Bt.fadeAction(this.otherModel,0,this.targetState)),A.addBehavior(new eI("Toggle_"+this.selfModel.name+"_hideSelf",fI.tapTrigger(this.selfModel),Bt.sequence(...g))),this.toggleOnClick&&this.toggleModel){const I=[];I.push(Bt.fadeAction(this.toggleModel,0,!1)),I.push(Bt.fadeAction(this.selfModel,0,!0)),I.push(Bt.fadeAction(this.otherModel,0,!this.targetState)),A.addBehavior(new eI("Toggle_"+this.selfModel.name+"_toggleSelf",fI.tapTrigger(this.toggleModel),Bt.sequence(...I))),A.addBehavior(new eI("HideOnStart_"+this.gameObject.name,fI.sceneStartTrigger(),Bt.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Nt([y(vA)],_E.prototype,"target",2),Nt([y()],_E.prototype,"targetState",2),Nt([y()],_E.prototype,"hideSelf",2);class cU extends UA{start(){this.gameObject.visible=!1}createBehaviours(A,e,i){e.uuid===this.gameObject.uuid&&A.addBehavior(new eI("HideOnStart_"+this.gameObject.name,fI.sceneStartTrigger(),Bt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class PE extends UA{constructor(){super(...arguments),r(this,"target"),r(this,"duration",.5),r(this,"motionType",KM.bounce)}beforeCreateDocument(){}createBehaviours(A,e,i){if(this.target&&e.uuid===this.gameObject.uuid){const g=new eI("emphasize "+this.name,fI.tapTrigger(this.gameObject),Bt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));A.addBehavior(g)}}afterCreateDocument(A,e){}}Nt([y()],PE.prototype,"target",2),Nt([y()],PE.prototype,"duration",2),Nt([y()],PE.prototype,"motionType",2);class jE extends UA{constructor(){super(...arguments),r(this,"target"),r(this,"clip",""),r(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const A=this.gameObject.addNewComponent(yi);A&&(A.spatialBlend=1,A.volume=1,A.loop=!1,this.target=A)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(A,e,i){if(!(!this.target&&!this.clip)&&e.uuid===this.gameObject.uuid){const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g)return;const I=this.target?this.target.gameObject:this.gameObject,o=g.split("/").pop(),s=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?vM.NonSpatial:vM.Spatial,a=new eI("playAudio "+this.name,fI.tapTrigger(this.gameObject),Bt.playAudioAction(I,"audio/"+o,RY.Play,s,C));A.addBehavior(a)}}async afterSerialize(A,e){if(!this.target&&!this.clip)return;const i=this.clip?this.clip:this.target?this.target.clip:void 0;if(!i)return;const g=i.split("/").pop(),I=await(await(await fetch(this.clip)).blob()).arrayBuffer(),o=new Uint8Array(I);e.files["audio/"+g]=o}}Nt([y(yi)],jE.prototype,"target",2),Nt([y(URL)],jE.prototype,"clip",2),Nt([y()],jE.prototype,"toggleOnClick",2);var lU;const WE=(lU=class extends UA{constructor(){super(...arguments),r(this,"target"),r(this,"animator"),r(this,"stateName"),r(this,"stateNameAfterPlaying"),r(this,"loopAfterPlaying",!1),r(this,"selfModel"),r(this,"stateAnimationModel"),r(this,"stateAnimation"),r(this,"stateAfterPlayingAnimationModel"),r(this,"stateAfterPlayingAnimation")}onPointerClick(){var t;this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(t,A,e){A.uuid===this.gameObject.uuid&&(this.selfModel=A)}onAfterHierarchy(){WE.animationActions=[]}afterCreateDocument(t,A){!this.stateAnimation||!this.stateAnimationModel||A.document.traverse(e=>{var i,g;if(e.uuid===((i=this.target)==null?void 0:i.uuid)&&this.stateAnimation){const I=[];let o=WE.animationActions.find(C=>C.affectedObjects==e&&C.start==this.stateAnimation.start&&C.duration==this.stateAnimation.duration);if(o||(o=Bt.startAnimationAction(e,this.stateAnimation.start,this.stateAnimation.duration),WE.animationActions.push(o)),I.push(o),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let C=WE.animationActions.find(n=>n.affectedObjects==e&&n.start==this.stateAfterPlayingAnimation.start&&n.duration==this.stateAfterPlayingAnimation.duration);C||(C=Bt.startAnimationAction(e,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),WE.animationActions.push(C));const a=Bt.sequence(C);this.loopAfterPlaying&&a.makeLooping(),I.push(a)}const s=new eI("tap "+this.name+" for "+this.stateName+" on "+((g=this.target)==null?void 0:g.name),fI.tapTrigger(this.selfModel),Bt.sequence(...I));t.addBehavior(s)}})}createAnimation(t,A,e){var i,g,I,o;if(this.target&&this.animator){const s=(g=(i=this.animator)==null?void 0:i.runtimeAnimatorController)==null?void 0:g.findState(this.stateName);this.stateAnimationModel=A,this.stateAnimation=t.registerAnimation(this.target,s?.motion.clip);const C=(o=(I=this.animator)==null?void 0:I.runtimeAnimatorController)==null?void 0:o.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=A,this.stateAfterPlayingAnimation=t.registerAnimation(this.target,C?.motion.clip)}}},r(lU,"animationActions",[]),lU);let Tn=WE;Nt([y(vA)],Tn.prototype,"target",2),Nt([y(tI)],Tn.prototype,"animator",2),Nt([y()],Tn.prototype,"stateName",2),Nt([y()],Tn.prototype,"stateNameAfterPlaying",2),Nt([y()],Tn.prototype,"loopAfterPlaying",2);class VE extends UA{constructor(){super(...arguments),r(this,"target")}getType(){}getDuration(){}}Nt([y(vA)],VE.prototype,"target",2);class od extends UA{constructor(){super(...arguments),r(this,"target")}}Nt([y(VE)],od.prototype,"target",2);class sd extends VE{constructor(){super(...arguments),r(this,"type",1),r(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Nt([y()],sd.prototype,"type",2),Nt([y()],sd.prototype,"duration",2);class dU extends od{}var NIA=Object.defineProperty,KIA=Object.getOwnPropertyDescriptor,ha=(t,A,e,i)=>{for(var g=i>1?void 0:i?KIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&NIA(A,e,g),g};class pB extends UA{constructor(){super(...arguments),r(this,"center",new S(0,0,0)),r(this,"radius",.5),r(this,"height",2),r(this,"_rigidbody",null),r(this,"_activeGroundCollisions",new Set)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Wt),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Wt)),this.rigidbody)}onEnable(){let A=this.rigidbody,e=this.gameObject.getComponent(vn);e||(e=this.gameObject.addNewComponent(vn)),e.center.copy(this.center),e.radius=this.radius,e.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,A.lockRotationX=!0,A.lockRotationY=!0,A.lockRotationZ=!0}move(A){this.gameObject.position.add(A)}onCollisionEnter(A){for(const e of A.contacts)if(e.normal.y>.1){this._activeGroundCollisions.add(A);break}}onCollisionExit(A){this._activeGroundCollisions.delete(A)}get isGrounded(){return this._activeGroundCollisions.size>0}}ha([y(S)],pB.prototype,"center",2),ha([y()],pB.prototype,"radius",2),ha([y()],pB.prototype,"height",2);class ca extends UA{constructor(){super(...arguments),r(this,"controller"),r(this,"movementSpeed",2),r(this,"rotationSpeed",2),r(this,"jumpForce",1),r(this,"doubleJumpForce",2),r(this,"animator"),r(this,"lookForward",!0),r(this,"_currentSpeed",new S(0,0,0)),r(this,"_currentAngularSpeed",new S(0,0,0)),r(this,"_temp",new S(0,0,0)),r(this,"_jumpCount",0),r(this,"_currentRotation"),r(this,"_raycastOptions",new es)}awake(){this._currentRotation=new xA}update(){var A,e,i,g,I,o,s,C,a,n,B;(A=this.controller)!=null&&A.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((e=this.animator)==null||e.setBool("doubleJump",!1)));const Q=this.context.input.isKeyPressed("w"),E=this.context.input.isKeyPressed("s"),h=this.context.input.isKeyPressed("a"),l=this.context.input.isKeyPressed("d"),d=this.context.input.isKeyDown(" "),c=(Q?1:0)+(E?-1:0);this._currentSpeed.z+=c*this.movementSpeed*this.context.time.deltaTime,(i=this.animator)==null||i.setBool("running",c!=0),(I=this.animator)==null||I.setBool("jumping",((g=this.controller)==null?void 0:g.isGrounded)===!0&&d),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp);const u=(h?1:0)+(l?-1:0);if(this._currentAngularSpeed.y+=te.toRadians(u*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const p=this.context.mainCameraComponent.forward;p.y=0,p.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),p),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&d&&this.jumpForce>0){let p=(o=this.controller)==null?void 0:o.isGrounded;if(this.doubleJumpForce>0&&!((s=this.controller)!=null&&s.isGrounded)&&this._jumpCount===1&&(p=!0,(C=this.animator)==null||C.setBool("doubleJump",!0)),p){this._jumpCount+=1;const D=this.controller.rigidbody,w=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;D.applyImpulse(new S(0,1,0).multiplyScalar(w))}}if(this.controller){const p=(a=this.controller)==null?void 0:a.rigidbody.getVelocity().y;if(p<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new qs),this._raycastOptions.ray.origin.copy(ue(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const D=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const w=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(D),(w.length&&w[0].distance>2||p<-10)&&((n=this.animator)==null||n.setBool("falling",!0))}else(B=this.animator)==null||B.setBool("falling",!1)}}}ha([y(pB)],ca.prototype,"controller",2),ha([y()],ca.prototype,"movementSpeed",2),ha([y()],ca.prototype,"rotationSpeed",2),ha([y()],ca.prototype,"jumpForce",2),ha([y()],ca.prototype,"doubleJumpForce",2),ha([y(tI)],ca.prototype,"animator",2);var JIA=Object.defineProperty,qIA=Object.getOwnPropertyDescriptor,vIA=(t,A,e,i)=>{for(var g=i>1?void 0:i?qIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&JIA(A,e,g),g};class Cd extends vg{constructor(){super(...arguments),r(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const A=new yx;return A.offset=new Z(0,0),A.radialModulation=!0,A.modulationOffset=.15,this.intensity.valueProcessor=e=>e*.02,this.intensity.onValueChanged=e=>{A.offset.x=-e,A.offset.y=e},A}}vIA([y(ke)],Cd.prototype,"intensity",2),Jo("ChromaticAberration",Cd);var bIA=Object.defineProperty,LIA=Object.getOwnPropertyDescriptor,Uy=(t,A,e,i)=>{for(var g=i>1?void 0:i?LIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&bIA(A,e,g),g};class Yn extends vg{constructor(){super(...arguments),r(this,"postExposure"),r(this,"contrast"),r(this,"hueShift"),r(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=A=>(A=Math.pow(2,A),A),this.postExposure.defaultValue=0,this.contrast.valueProcessor=A=>{let e=1;return A>0?e=200:A<0&&(e=100),A/e},this.contrast.defaultValue=0,this.hueShift.valueProcessor=A=>Math.PI*A/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=A=>A<0?A/100:A/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Hg&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Wh);const A=new wx;this.postExposure.onValueChanged=i=>{this.context.renderer.toneMapping===Hg&&(this.context.renderer.toneMapping=Wh),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=i)},this.contrast.onValueChanged=i=>{A.contrast=i};const e=new fx;return this.hueShift.onValueChanged=i=>e.hue=i,this.saturation.onValueChanged=i=>e.saturation=i,[e,A]}}Uy([y(ke)],Yn.prototype,"postExposure",2),Uy([y(ke)],Yn.prototype,"contrast",2),Uy([y(ke)],Yn.prototype,"hueShift",2),Uy([y(ke)],Yn.prototype,"saturation",2),Jo("ColorAdjustments",Yn);const xIA=(Math.sqrt(5)-1)/4,lg=(5-Math.sqrt(5))/20,Fy=t=>Math.floor(t)|0,Ny=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function TIA(t=Math.random){const A=YIA(t),e=new Float64Array(A).map(o=>Ny[o%32*4]),i=new Float64Array(A).map(o=>Ny[o%32*4+1]),g=new Float64Array(A).map(o=>Ny[o%32*4+2]),I=new Float64Array(A).map(o=>Ny[o%32*4+3]);return function(o,s,C,a){let n,B,Q,E,h;const l=(o+s+C+a)*xIA,d=Fy(o+l),c=Fy(s+l),u=Fy(C+l),p=Fy(a+l),D=(d+c+u+p)*lg,w=d-D,m=c-D,M=u-D,F=p-D,k=o-w,f=s-m,b=C-M,O=a-F;let L=0,T=0,W=0,iA=0;k>f?L++:T++,k>b?L++:W++,k>O?L++:iA++,f>b?T++:W++,f>O?T++:iA++,b>O?W++:iA++;const AA=L>=3?1:0,eA=T>=3?1:0,EA=W>=3?1:0,rA=iA>=3?1:0,V=L>=2?1:0,sA=T>=2?1:0,mA=W>=2?1:0,RA=iA>=2?1:0,bA=L>=1?1:0,YA=T>=1?1:0,ee=W>=1?1:0,XA=iA>=1?1:0,VA=k-AA+lg,we=f-eA+lg,lA=b-EA+lg,_=O-rA+lg,LA=k-V+2*lg,yA=f-sA+2*lg,uA=b-mA+2*lg,HA=O-RA+2*lg,pA=k-bA+3*lg,ZA=f-YA+3*lg,ge=b-ee+3*lg,re=O-XA+3*lg,Ve=k-1+4*lg,It=f-1+4*lg,v=b-1+4*lg,J=O-1+4*lg,QA=d&255,NA=c&255,KA=u&255,Y=p&255;let DA=.6-k*k-f*f-b*b-O*O;if(DA<0)n=0;else{const SA=QA+A[NA+A[KA+A[Y]]];DA*=DA,n=DA*DA*(e[SA]*k+i[SA]*f+g[SA]*b+I[SA]*O)}let GA=.6-VA*VA-we*we-lA*lA-_*_;if(GA<0)B=0;else{const SA=QA+AA+A[NA+eA+A[KA+EA+A[Y+rA]]];GA*=GA,B=GA*GA*(e[SA]*VA+i[SA]*we+g[SA]*lA+I[SA]*_)}let hA=.6-LA*LA-yA*yA-uA*uA-HA*HA;if(hA<0)Q=0;else{const SA=QA+V+A[NA+sA+A[KA+mA+A[Y+RA]]];hA*=hA,Q=hA*hA*(e[SA]*LA+i[SA]*yA+g[SA]*uA+I[SA]*HA)}let jA=.6-pA*pA-ZA*ZA-ge*ge-re*re;if(jA<0)E=0;else{const SA=QA+bA+A[NA+YA+A[KA+ee+A[Y+XA]]];jA*=jA,E=jA*jA*(e[SA]*pA+i[SA]*ZA+g[SA]*ge+I[SA]*re)}let zA=.6-Ve*Ve-It*It-v*v-J*J;if(zA<0)h=0;else{const SA=QA+1+A[NA+1+A[KA+1+A[Y+1]]];zA*=zA,h=zA*zA*(e[SA]*Ve+i[SA]*It+g[SA]*v+I[SA]*J)}return 27*(n+B+Q+E+h)}}function YIA(t){const A=new Uint8Array(512);for(let e=0;e<512/2;e++)A[e]=e;for(let e=0;e<512/2-1;e++){const i=e+~~(t()*(256-e)),g=A[e];A[e]=A[i],A[i]=g}for(let e=256;e<512;e++)A[e]=A[e-256];return A}var HIA=Object.defineProperty,OIA=Object.getOwnPropertyDescriptor,$=(t,A,e,i)=>{for(var g=i>1?void 0:i?OIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&HIA(A,e,g),g};const Ky=oA("debugparticles");var la=(t=>(t[t.Billboard=0]="Billboard",t[t.Stretch=1]="Stretch",t[t.HorizontalBillboard=2]="HorizontalBillboard",t[t.VerticalBillboard=3]="VerticalBillboard",t[t.Mesh=4]="Mesh",t))(la||{});class Hn{constructor(){r(this,"alphaKeys"),r(this,"colorKeys")}get duration(){return 1}evaluate(A,e){let i,g=0,I=null,o=0;for(let s=0;s<this.alphaKeys.length;s++){const C=this.alphaKeys[s];(C.time<A||!i)&&(i=C,g=s)}for(let s=0;s<this.colorKeys.length;s++){const C=this.colorKeys[s];(C.time<A||!I)&&(I=C,o=s)}if(I)if(o+1<this.colorKeys.length){const s=this.colorKeys[o+1],C=te.remap(A,I.time,s.time,0,1);e.r=te.lerp(I.color.r,s.color.r,C),e.g=te.lerp(I.color.g,s.color.g,C),e.b=te.lerp(I.color.b,s.color.b,C)}else e.r=I.color.r,e.g=I.color.g,e.b=I.color.b;if(i)if(g+1<this.alphaKeys.length){const s=this.alphaKeys[g+1],C=te.remap(A,i.time,s.time,0,1);e.alpha=te.lerp(i.alpha,s.alpha,C)}else e.alpha=i.alpha;return e}}$([y()],Hn.prototype,"alphaKeys",2),$([y()],Hn.prototype,"colorKeys",2);var Jy=(t=>(t[t.Local=0]="Local",t[t.World=1]="World",t[t.Custom=2]="Custom",t))(Jy||{}),O2=(t=>(t[t.Sphere=0]="Sphere",t[t.SphereShell=1]="SphereShell",t[t.Hemisphere=2]="Hemisphere",t[t.HemisphereShell=3]="HemisphereShell",t[t.Cone=4]="Cone",t[t.Box=5]="Box",t[t.Mesh=6]="Mesh",t[t.ConeShell=7]="ConeShell",t[t.ConeVolume=8]="ConeVolume",t[t.ConeVolumeShell=9]="ConeVolumeShell",t[t.Circle=10]="Circle",t[t.CircleEdge=11]="CircleEdge",t[t.SingleSidedEdge=12]="SingleSidedEdge",t[t.MeshRenderer=13]="MeshRenderer",t[t.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",t[t.BoxShell=15]="BoxShell",t[t.BoxEdge=16]="BoxEdge",t[t.Donut=17]="Donut",t[t.Rectangle=18]="Rectangle",t[t.Sprite=19]="Sprite",t[t.SpriteRenderer=20]="SpriteRenderer",t))(O2||{});class ae{constructor(){r(this,"mode"),r(this,"constant"),r(this,"constantMin"),r(this,"constantMax"),r(this,"curve"),r(this,"curveMin"),r(this,"curveMax"),r(this,"curveMultiplier")}evaluate(A,e){const i=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return A=te.clamp01(A),this.curve.evaluate(A)*this.curveMultiplier;case 2:const g=A*this.curveMin.duration,I=A*this.curveMax.duration;return te.lerp(this.curveMin.evaluate(g),this.curveMax.evaluate(I),i%1)*this.curveMultiplier;case 3:return te.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(A)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(A){if(!A)return 0;let e=Number.MIN_VALUE;for(let i=0;i<A.keys.length;i++){const g=A.keys[i];g.value>e&&(e=g.value)}return e}}$([y()],ae.prototype,"mode",2),$([y()],ae.prototype,"constant",2),$([y()],ae.prototype,"constantMin",2),$([y()],ae.prototype,"constantMax",2),$([y(IB)],ae.prototype,"curve",2),$([y(IB)],ae.prototype,"curveMin",2),$([y(IB)],ae.prototype,"curveMax",2),$([y()],ae.prototype,"curveMultiplier",2);var qy;const ls=(qy=class{constructor(){r(this,"mode"),r(this,"color"),r(this,"colorMin"),r(this,"colorMax"),r(this,"gradient"),r(this,"gradientMin"),r(this,"gradientMax")}evaluate(t,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(t,ls._temp),ls._temp;case 2:return ls._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(t,ls._temp),this.gradientMax.evaluate(t,ls._temp2),ls._temp.lerp(ls._temp2,e)}return ls._temp.set(16711935),ls._temp.alpha=1,ls._temp}},r(qy,"_temp",new yt(0,0,0,1)),r(qy,"_temp2",new yt(0,0,0,1)),qy);let MI=ls;$([y(yt)],MI.prototype,"color",2),$([y(yt)],MI.prototype,"colorMin",2),$([y(yt)],MI.prototype,"colorMax",2),$([y(Hn)],MI.prototype,"gradient",2),$([y(Hn)],MI.prototype,"gradientMin",2),$([y(Hn)],MI.prototype,"gradientMax",2);class dg{constructor(){r(this,"cullingMode"),r(this,"duration"),r(this,"emitterVelocityMode"),r(this,"flipRotation"),r(this,"gravityModifier"),r(this,"gravityModifierMultiplier"),r(this,"loop"),r(this,"maxParticles"),r(this,"playOnAwake"),r(this,"prewarm"),r(this,"ringBufferLoopRange"),r(this,"ringBufferMode"),r(this,"scalingMode"),r(this,"simulationSpace"),r(this,"simulationSpeed"),r(this,"startColor"),r(this,"startDelay"),r(this,"startDelayMultiplier"),r(this,"startLifetime"),r(this,"startLifetimeMultiplier"),r(this,"startRotation"),r(this,"startRotationMultiplier"),r(this,"startRotation3D"),r(this,"startRotationX"),r(this,"startRotationXMultiplier"),r(this,"startRotationY"),r(this,"startRotationYMultiplier"),r(this,"startRotationZ"),r(this,"startRotationZMultiplier"),r(this,"startSize"),r(this,"startSize3D"),r(this,"startSizeMultiplier"),r(this,"startSizeX"),r(this,"startSizeXMultiplier"),r(this,"startSizeY"),r(this,"startSizeYMultiplier"),r(this,"startSizeZ"),r(this,"startSizeZMultiplier"),r(this,"startSpeed"),r(this,"startSpeedMultiplier"),r(this,"stopAction"),r(this,"useUnscaledTime")}}$([y(ae)],dg.prototype,"gravityModifier",2),$([y(MI)],dg.prototype,"startColor",2),$([y(ae)],dg.prototype,"startDelay",2),$([y(ae)],dg.prototype,"startLifetime",2),$([y(ae)],dg.prototype,"startRotation",2),$([y(ae)],dg.prototype,"startRotationX",2),$([y(ae)],dg.prototype,"startRotationY",2),$([y(ae)],dg.prototype,"startRotationZ",2),$([y(ae)],dg.prototype,"startSize",2),$([y(ae)],dg.prototype,"startSizeX",2),$([y(ae)],dg.prototype,"startSizeY",2),$([y(ae)],dg.prototype,"startSizeZ",2),$([y(ae)],dg.prototype,"startSpeed",2);class ad{constructor(){r(this,"cycleCount"),r(this,"maxCount"),r(this,"minCount"),r(this,"probability"),r(this,"repeatInterval"),r(this,"time"),r(this,"count"),r(this,"_performed",0)}reset(){this._performed=0}run(A){if(A<=this.time)return 0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(A>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=te.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:const g=Math.random();e=te.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class gC{constructor(){r(this,"enabled"),r(this,"bursts"),r(this,"rateOverTime"),r(this,"rateOverTimeMultiplier"),r(this,"rateOverDistance"),r(this,"rateOverDistanceMultiplier"),r(this,"system")}get burstCount(){var A;return((A=this.bursts)==null?void 0:A.length)??0}reset(){var A;(A=this.bursts)==null||A.forEach(e=>e.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){const i=this.bursts[e];this.system.main.loop&&i.time>=this.system.time&&i.reset(),A+=Math.round(i.run(this.system.time))}return A}}$([y()],gC.prototype,"enabled",2),$([y()],gC.prototype,"bursts",2),$([y(ae)],gC.prototype,"rateOverTime",2),$([y()],gC.prototype,"rateOverTimeMultiplier",2),$([y(ae)],gC.prototype,"rateOverDistance",2),$([y()],gC.prototype,"rateOverDistanceMultiplier",2);class nd{constructor(){r(this,"enabled"),r(this,"color")}}$([y(MI)],nd.prototype,"color",2);class On{constructor(){r(this,"enabled"),r(this,"separateAxes"),r(this,"size"),r(this,"sizeMultiplier"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier"),r(this,"_time",0),r(this,"_temp",new S)}evaluate(A,e,i){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,i)*this.xMultiplier,e.y=this.y.evaluate(A,i)*this.yMultiplier,e.z=this.z.evaluate(A,i)*this.zMultiplier;else{const g=this.size.evaluate(A,i)*this.sizeMultiplier;e.x=g}return e}}$([y(ae)],On.prototype,"size",2),$([y(ae)],On.prototype,"x",2),$([y(ae)],On.prototype,"y",2),$([y(ae)],On.prototype,"z",2);var vy;const rd=(vy=class{constructor(){r(this,"shapeType",5),r(this,"enabled",!0),r(this,"alignToDirection",!1),r(this,"angle",0),r(this,"arc",360),r(this,"arcSpread"),r(this,"arcSpeedMultiplier"),r(this,"arcMode"),r(this,"boxThickness"),r(this,"position"),r(this,"rotation"),r(this,"_rotation",new og),r(this,"scale"),r(this,"radius"),r(this,"radiusThickness"),r(this,"sphericalDirectionAmount"),r(this,"randomDirectionAmount"),r(this,"randomPositionAmount"),r(this,"system"),r(this,"_space"),r(this,"_worldSpaceMatrix",new JA),r(this,"_worldSpaceMatrixInverse",new JA),r(this,"_vector",new S(0,0,0)),r(this,"_temp",new S(0,0,0)),r(this,"_dir",new S),r(this,"_loopTime",0),r(this,"_loopDirection",1),Ky&&console.log(this)}get type(){return O2[this.shapeType]}initialize(t){this.getPosition(),t.position.copy(this._vector)}toJSON(){return this}clone(){return new rd}update(t,A,e,i){this.system=t,this._space=e,e===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(t){const A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=te.toRadians(this.rotation.x),this._rotation.y=te.toRadians(this.rotation.y),this._rotation.z=te.toRadians(this.rotation.z),this._rotation.order="ZYX",t.applyEuler(this._rotation)),A}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const t=this._temp.copy(this.position),A=this._space===1;A&&t.applyQuaternion(this.system.worldQuaternion);let e=this.radius;if(A&&(e*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Ky&&zC.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(t);break;case 4:this.randomConePoint(this.position,this.angle,e,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),A&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Ky&&zC.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(t){var A;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const e=t.x,i=t.y,g=t.z;this._dir.set(e,i,g),(A=this.system)!=null&&A.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),Ky&&(zC.DrawSphere(t,.01,8925952,.5,!0),zC.DrawDirection(t,this._dir,8925952,.5,!0)),this._dir}randomizePosition(t,A){if(A<=0)return;const e=rd._tempVec;e.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),e.x*=A*this.scale.x,e.y*=A*this.scale.y,e.z*=A*this.scale.z,t.add(e)}randomizeDirection(t,A){if(A===0)return;const e=rd._randomQuat,i=rd._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(i,A*Math.random()*Math.PI),t.applyQuaternion(e)}spherizeDirection(t,A){if(A===0)return;const e=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),g=Math.sin(i)*Math.cos(e),I=Math.sin(i)*Math.sin(e),o=Math.cos(i),s=new S(g,I,o);t.lerp(s,A)}randomSpherePoint(t,A,e,i,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(i/360),C=Math.acos(2*o-1),a=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,n=t.x+this.scale.x*(-a*Math.sin(C)*Math.cos(s)),B=t.y+this.scale.y*(a*Math.sin(C)*Math.sin(s)),Q=t.z+this.scale.z*(a*Math.cos(C));g.x=n,g.y=B,g.z=Q}randomCirclePoint(t,A,e,i,g){const I=Math.random(),o=2*Math.PI*I*(i/360),s=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,C=t.x+this.scale.x*s*Math.cos(o),a=t.y+this.scale.y*s*Math.sin(o),n=t.z;g.x=C,g.y=a,g.z=n}randomConePoint(t,A,e,i,g,I,o){let s=0,C=0;switch(I){case 0:s=Math.random(),C=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,C=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let a=2*Math.PI*s*(g/360);switch(I){case 2:case 1:a+=Math.PI+.5,a+=this._loopTime*Math.PI*2,a%=te.toRadians(g);break}const n=Math.acos(2*C-1),B=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*e,Q=t.x+-B*Math.sin(n)*Math.cos(a),E=t.y+B*Math.sin(n)*Math.sin(a),h=t.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=h*this.scale.z}},r(vy,"_randomQuat",new xA),r(vy,"_tempVec",new S),vy);let Bi=rd;$([y()],Bi.prototype,"shapeType",2),$([y()],Bi.prototype,"enabled",2),$([y()],Bi.prototype,"alignToDirection",2),$([y()],Bi.prototype,"angle",2),$([y()],Bi.prototype,"arc",2),$([y()],Bi.prototype,"arcSpread",2),$([y()],Bi.prototype,"arcSpeedMultiplier",2),$([y()],Bi.prototype,"arcMode",2),$([y(S)],Bi.prototype,"boxThickness",2),$([y(S)],Bi.prototype,"position",2),$([y(S)],Bi.prototype,"rotation",2),$([y(S)],Bi.prototype,"scale",2),$([y()],Bi.prototype,"radius",2),$([y()],Bi.prototype,"radiusThickness",2),$([y()],Bi.prototype,"sphericalDirectionAmount",2),$([y()],Bi.prototype,"randomDirectionAmount",2),$([y()],Bi.prototype,"randomPositionAmount",2);class dt{constructor(){r(this,"damping"),r(this,"enabled"),r(this,"frequency"),r(this,"octaveCount"),r(this,"octaveMultiplier"),r(this,"octaveScale"),r(this,"positionAmount"),r(this,"quality"),r(this,"remap"),r(this,"remapEnabled"),r(this,"remapMultiplier"),r(this,"remapX"),r(this,"remapXMultiplier"),r(this,"remapY"),r(this,"remapYMultiplier"),r(this,"remapZ"),r(this,"remapZMultiplier"),r(this,"scrollSpeedMultiplier"),r(this,"separateAxes"),r(this,"strengthMultiplier"),r(this,"strengthX"),r(this,"strengthXMultiplier"),r(this,"strengthY"),r(this,"strengthYMultiplier"),r(this,"strengthZ"),r(this,"strengthZMultiplier"),r(this,"_noise"),r(this,"_time",0),r(this,"_temp",new S)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,i,g,I,o){if(!this.enabled)return;this._noise||(this._noise=TIA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),C=this._noise(s.x,s.y,s.z,this._time),a=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),n=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(C,a,n).normalize();const B=I/o;let Q=this.positionAmount.evaluate(B);this.separateAxes?(this._temp.x*=Q*this.strengthXMultiplier,this._temp.y*=Q*this.strengthYMultiplier,this._temp.z*=Q*this.strengthZMultiplier):(this.strengthX&&(Q*=this.strengthX.evaluate(B)*1.5),this._temp.multiplyScalar(Q)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}$([y()],dt.prototype,"damping",2),$([y()],dt.prototype,"enabled",2),$([y()],dt.prototype,"frequency",2),$([y()],dt.prototype,"octaveCount",2),$([y()],dt.prototype,"octaveMultiplier",2),$([y()],dt.prototype,"octaveScale",2),$([y(ae)],dt.prototype,"positionAmount",2),$([y()],dt.prototype,"quality",2),$([y(ae)],dt.prototype,"remap",2),$([y()],dt.prototype,"remapEnabled",2),$([y()],dt.prototype,"remapMultiplier",2),$([y(ae)],dt.prototype,"remapX",2),$([y()],dt.prototype,"remapXMultiplier",2),$([y(ae)],dt.prototype,"remapY",2),$([y()],dt.prototype,"remapYMultiplier",2),$([y(ae)],dt.prototype,"remapZ",2),$([y()],dt.prototype,"remapZMultiplier",2),$([y()],dt.prototype,"scrollSpeedMultiplier",2),$([y()],dt.prototype,"separateAxes",2),$([y()],dt.prototype,"strengthMultiplier",2),$([y(ae)],dt.prototype,"strengthX",2),$([y()],dt.prototype,"strengthXMultiplier",2),$([y(ae)],dt.prototype,"strengthY",2),$([y()],dt.prototype,"strengthYMultiplier",2),$([y(ae)],dt.prototype,"strengthZ",2),$([y()],dt.prototype,"strengthZMultiplier",2);class Yt{constructor(){r(this,"enabled"),r(this,"attachRibbonToTransform",!1),r(this,"colorOverLifetime"),r(this,"colorOverTrail"),r(this,"dieWithParticles",!0),r(this,"inheritParticleColor",!0),r(this,"lifetime"),r(this,"lifetimeMultiplier"),r(this,"minVertexDistance",.2),r(this,"mode",0),r(this,"ratio",1),r(this,"ribbonCount",1),r(this,"shadowBias",0),r(this,"sizeAffectsLifetime",!1),r(this,"sizeAffectsWidth",!1),r(this,"splitSubEmitterRibbons",!1),r(this,"textureMode",0),r(this,"widthOverTrail"),r(this,"widthOverTrailMultiplier"),r(this,"worldSpace",!1)}getWidth(A,e,i,g){let I=this.widthOverTrail.evaluate(i,g);return A*=I,A}getColor(A,e,i){const g=this.colorOverTrail.evaluate(i),I=this.colorOverLifetime.evaluate(e);A.x*=g.r*I.r,A.y*=g.g*I.g,A.z*=g.b*I.b,A.w*=g.alpha*I.alpha}}$([y()],Yt.prototype,"enabled",2),$([y()],Yt.prototype,"attachRibbonToTransform",2),$([y(MI)],Yt.prototype,"colorOverLifetime",2),$([y(MI)],Yt.prototype,"colorOverTrail",2),$([y()],Yt.prototype,"dieWithParticles",2),$([y()],Yt.prototype,"inheritParticleColor",2),$([y(ae)],Yt.prototype,"lifetime",2),$([y()],Yt.prototype,"lifetimeMultiplier",2),$([y()],Yt.prototype,"minVertexDistance",2),$([y()],Yt.prototype,"mode",2),$([y()],Yt.prototype,"ratio",2),$([y()],Yt.prototype,"ribbonCount",2),$([y()],Yt.prototype,"shadowBias",2),$([y()],Yt.prototype,"sizeAffectsLifetime",2),$([y()],Yt.prototype,"sizeAffectsWidth",2),$([y()],Yt.prototype,"splitSubEmitterRibbons",2),$([y()],Yt.prototype,"textureMode",2),$([y(ae)],Yt.prototype,"widthOverTrail",2),$([y()],Yt.prototype,"widthOverTrailMultiplier",2),$([y()],Yt.prototype,"worldSpace",2);class Vt{constructor(){r(this,"enabled"),r(this,"space",0),r(this,"orbitalX"),r(this,"orbitalY"),r(this,"orbitalZ"),r(this,"orbitalXMultiplier"),r(this,"orbitalYMultiplier"),r(this,"orbitalZMultiplier"),r(this,"orbitalOffsetX"),r(this,"orbitalOffsetY"),r(this,"orbitalOffsetZ"),r(this,"speedModifier"),r(this,"speedModifierMultiplier"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier"),r(this,"_system"),r(this,"_temp",new S),r(this,"_temp2",new S),r(this,"_temp3",new S),r(this,"_hasOrbital",!1),r(this,"_index",0),r(this,"_orbitalMatrix",new JA)}update(A){this._system=A}init(A){this._index==0&&(A.debug=!0),this._index+=1,A.orbitx=this.orbitalX.evaluate(Math.random()),A.orbity=this.orbitalY.evaluate(Math.random()),A.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=A.orbitx!=0||A.orbity!=0||A.orbitz!=0}apply(A,e,i,g,I,o,s){var C;if(!this.enabled)return;const a=o/s,n=this.speedModifier.evaluate(a)*this.speedModifierMultiplier,B=this.x.evaluate(a),Q=this.y.evaluate(a),E=this.z.evaluate(a);if(this._temp.set(-B,Q,E),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((C=this._system)==null?void 0:C.worldPos)){const h=this._temp2.set(i.x,i.y,i.z),l=this.orbitalXMultiplier,d=this.orbitalYMultiplier,c=this.orbitalZMultiplier,u=n*Math.PI*2*10,p=Math.cos(u*l),D=Math.sin(u*l),w=Math.cos(u*d),m=Math.sin(u*d),M=Math.cos(u*c),F=Math.sin(u*c),k=h.x*(w*M)+h.y*(w*F)+h.z*-m,f=h.x*(D*m*M-p*F)+h.y*(D*m*F+p*M)+h.z*(D*w),b=h.x*(p*m*M+D*F)+h.y*(p*m*F-D*M)+h.z*(p*w),O=this._temp3.set(h.x-k,h.y-f,h.z-b);O.normalize(),O.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=O.x,g.y+=O.y,g.z+=O.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=n,g.y*=n,g.z*=n}}$([y()],Vt.prototype,"enabled",2),$([y()],Vt.prototype,"space",2),$([y(ae)],Vt.prototype,"orbitalX",2),$([y(ae)],Vt.prototype,"orbitalY",2),$([y(ae)],Vt.prototype,"orbitalZ",2),$([y()],Vt.prototype,"orbitalXMultiplier",2),$([y()],Vt.prototype,"orbitalYMultiplier",2),$([y()],Vt.prototype,"orbitalZMultiplier",2),$([y()],Vt.prototype,"orbitalOffsetX",2),$([y()],Vt.prototype,"orbitalOffsetY",2),$([y()],Vt.prototype,"orbitalOffsetZ",2),$([y(ae)],Vt.prototype,"speedModifier",2),$([y()],Vt.prototype,"speedModifierMultiplier",2),$([y(ae)],Vt.prototype,"x",2),$([y()],Vt.prototype,"xMultiplier",2),$([y(ae)],Vt.prototype,"y",2),$([y()],Vt.prototype,"yMultiplier",2),$([y(ae)],Vt.prototype,"z",2),$([y()],Vt.prototype,"zMultiplier",2);class pg{constructor(){r(this,"animation"),r(this,"enabled"),r(this,"cycleCount"),r(this,"frameOverTime"),r(this,"frameOverTimeMultiplier"),r(this,"numTilesX"),r(this,"numTilesY"),r(this,"startFrame"),r(this,"startFrameMultiplier"),r(this,"rowMode"),r(this,"rowIndex"),r(this,"spriteCount"),r(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){const e=this.numTilesX*this.numTilesY;A=A*this.cycleCount;let i=this.frameOverTime.evaluate(A%1);return i*=this.frameOverTimeMultiplier,i*=e,i=i%e,i=Math.floor(i),i}}$([y()],pg.prototype,"animation",2),$([y()],pg.prototype,"enabled",2),$([y()],pg.prototype,"cycleCount",2),$([y(ae)],pg.prototype,"frameOverTime",2),$([y()],pg.prototype,"frameOverTimeMultiplier",2),$([y()],pg.prototype,"numTilesX",2),$([y()],pg.prototype,"numTilesY",2),$([y(ae)],pg.prototype,"startFrame",2),$([y()],pg.prototype,"startFrameMultiplier",2),$([y()],pg.prototype,"rowMode",2),$([y()],pg.prototype,"rowIndex",2),$([y()],pg.prototype,"spriteCount",2),$([y()],pg.prototype,"timeMode",2);class qo{constructor(){r(this,"enabled"),r(this,"separateAxes"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}$([y()],qo.prototype,"enabled",2),$([y()],qo.prototype,"separateAxes",2),$([y(ae)],qo.prototype,"x",2),$([y()],qo.prototype,"xMultiplier",2),$([y(ae)],qo.prototype,"y",2),$([y()],qo.prototype,"yMultiplier",2),$([y(ae)],qo.prototype,"z",2),$([y()],qo.prototype,"zMultiplier",2);class eo{constructor(){r(this,"enabled"),r(this,"range"),r(this,"separateAxes"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const i=te.lerp(this.range.x,this.range.y,e);return this.z.evaluate(i)*-1}return 0}}$([y()],eo.prototype,"enabled",2),$([y()],eo.prototype,"range",2),$([y()],eo.prototype,"separateAxes",2),$([y(ae)],eo.prototype,"x",2),$([y()],eo.prototype,"xMultiplier",2),$([y(ae)],eo.prototype,"y",2),$([y()],eo.prototype,"yMultiplier",2),$([y(ae)],eo.prototype,"z",2),$([y()],eo.prototype,"zMultiplier",2);class Gi{constructor(){r(this,"enabled"),r(this,"dampen"),r(this,"drag"),r(this,"dragMultiplier"),r(this,"limit"),r(this,"limitMultiplier"),r(this,"separateAxes"),r(this,"limitX"),r(this,"limitXMultiplier"),r(this,"limitY"),r(this,"limitYMultiplier"),r(this,"limitZ"),r(this,"limitZMultiplier"),r(this,"multiplyDragByParticleSize",!1),r(this,"multiplyDragByParticleVelocity",!1),r(this,"space"),r(this,"_temp",new S),r(this,"_temp2",new S)}apply(A,e,i,g,I,o,s){if(this.enabled){const C=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>C){this._temp.copy(e).normalize().multiplyScalar(C);let a=this.dampen*.5;e.x=te.lerp(e.x,this._temp.x,a),e.y=te.lerp(e.y,this._temp.y,a),e.z=te.lerp(e.z,this._temp.z,a),i.x=te.lerp(i.x,this._temp.x,a),i.y=te.lerp(i.y,this._temp.y,a),i.z=te.lerp(i.z,this._temp.z,a)}}}}$([y()],Gi.prototype,"enabled",2),$([y()],Gi.prototype,"dampen",2),$([y(ae)],Gi.prototype,"drag",2),$([y()],Gi.prototype,"dragMultiplier",2),$([y(ae)],Gi.prototype,"limit",2),$([y()],Gi.prototype,"limitMultiplier",2),$([y()],Gi.prototype,"separateAxes",2),$([y(ae)],Gi.prototype,"limitX",2),$([y()],Gi.prototype,"limitXMultiplier",2),$([y(ae)],Gi.prototype,"limitY",2),$([y()],Gi.prototype,"limitYMultiplier",2),$([y(ae)],Gi.prototype,"limitZ",2),$([y()],Gi.prototype,"limitZMultiplier",2),$([y()],Gi.prototype,"multiplyDragByParticleSize",2),$([y()],Gi.prototype,"multiplyDragByParticleVelocity",2),$([y()],Gi.prototype,"space",2);class _n{constructor(){r(this,"enabled"),r(this,"curve"),r(this,"curveMultiplier"),r(this,"mode"),r(this,"system"),r(this,"_lastWorldPosition"),r(this,"_velocity",new S),r(this,"_temp",new S)}update(A){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(A){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),A.add(this._temp)}}applyCurrent(A,e,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const g=this.curve.evaluate(e,i);this._temp.copy(this._velocity).multiplyScalar(g),A.add(this._temp)}}}$([y()],_n.prototype,"enabled",2),$([y(ae)],_n.prototype,"curve",2),$([y()],_n.prototype,"curveMultiplier",2),$([y()],_n.prototype,"mode",2);class oI{constructor(){r(this,"enabled"),r(this,"range"),r(this,"separateAxes"),r(this,"size"),r(this,"sizeMultiplier"),r(this,"x"),r(this,"xMultiplier"),r(this,"y"),r(this,"yMultiplier"),r(this,"z"),r(this,"zMultiplier")}evaluate(A,e,i,g){const I=A.length(),o=te.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,i);return g*s}}$([y()],oI.prototype,"enabled",2),$([y(Z)],oI.prototype,"range",2),$([y()],oI.prototype,"separateAxes",2),$([y(ae)],oI.prototype,"size",2),$([y()],oI.prototype,"sizeMultiplier",2),$([y(ae)],oI.prototype,"x",2),$([y()],oI.prototype,"xMultiplier",2),$([y(ae)],oI.prototype,"y",2),$([y()],oI.prototype,"yMultiplier",2),$([y(ae)],oI.prototype,"z",2),$([y()],oI.prototype,"zMultiplier",2);class uB{constructor(){r(this,"enabled"),r(this,"range"),r(this,"color")}evaluate(A,e,i){const g=A.length(),I=te.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}$([y()],uB.prototype,"enabled",2),$([y(Z)],uB.prototype,"range",2),$([y(MI)],uB.prototype,"color",2);function _IA(t){const A=t.domElement.querySelector("link[rel='ar']");if(A)return A;const e=document.createElement("div");e.classList.add("menu"),e.classList.add("quicklook-menu"),e.style.display="none",e.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",e.appendChild(i);const g=document.createElement("a");g.id="needle-usdz-link",g.style.display="none",g.rel="ar",g.href="",e.appendChild(g);const I=document.createElement("img");return I.id="button",g.appendChild(I),t.domElement.appendChild(e),g}function PIA(){var t=new Date;const A=t.getMonth()+1,e=t.getDate(),i=t.getHours(),g=t.getMinutes(),I=t.getSeconds(),o=(A<10?"0":"")+A,s=(e<10?"0":"")+e,C=(i<10?"0":"")+i,a=(g<10?"0":"")+g,n=(I<10?"0":"")+I;return t.getFullYear()+o+s+"-"+C+a+n}const by=oA("debugusdz");function jIA(t,A){const e=[],i=tA.getComponentsInChildren(t,tI);let g=!1;by&&console.log(i);for(const I of i){if(!I||!I.runtimeAnimatorController)continue;by&&console.log(I);const o=[];for(const s of I.runtimeAnimatorController.enumerateActions()){by&&console.log(s);const C=s.getClip();if(!g&&C.tracks.length>0){g=!0;const a=C.tracks[0],n=a.name.substring(0,a.name.lastIndexOf(".")),B=new PI(n+".position",[0,.01],[0,0,0,0,0,0]),Q=new PI(n+".quaternion",[0,.01],[0,0,0,1,0,0,0,1]);o.push(new jg("rest",.01,[B,Q]))}o.includes(C)||o.push(C)}e.push({root:I.gameObject,clips:o})}by&&console.log(e);for(const I of e)for(const o of I.clips)A.registerAnimation(I.root,o)}var WIA=Object.defineProperty,VIA=Object.getOwnPropertyDescriptor,da=(t,A,e,i)=>{for(var g=i>1?void 0:i?VIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&WIA(A,e,g),g};const DB=oA("debugtext");var _i=(t=>(t[t.UpperLeft=0]="UpperLeft",t[t.UpperCenter=1]="UpperCenter",t[t.UpperRight=2]="UpperRight",t[t.MiddleLeft=3]="MiddleLeft",t[t.MiddleCenter=4]="MiddleCenter",t[t.MiddleRight=5]="MiddleRight",t[t.LowerLeft=6]="LowerLeft",t[t.LowerCenter=7]="LowerCenter",t[t.LowerRight=8]="LowerRight",t))(_i||{}),_2=(t=>(t[t.Normal=0]="Normal",t[t.Bold=1]="Bold",t[t.Italic=2]="Italic",t[t.BoldAndItalic=3]="BoldAndItalic",t))(_2||{});class sI extends hB{constructor(){super(...arguments),r(this,"alignment",0),r(this,"verticalOverflow",0),r(this,"horizontalOverflow",0),r(this,"lineSpacing",1),r(this,"supportRichText",!1),r(this,"font"),r(this,"fontStyle",0),r(this,"_text",""),r(this,"_fontSize",12),r(this,"_textMeshUi",null),r(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(A){var e;super.setAlphaFactor(A),(e=this.uiObject)==null||e.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(A){A!==this._text&&(this._text=A,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(A){this.text=A}get fontSize(){return this._fontSize}set fontSize(A){var e;this._fontSize=A,(e=this.uiObject)==null||e.set({fontSize:A})}onColorChanged(){var A;(A=this.uiObject)==null||A.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var A;this.uiObject&&((A=this.Canvas)!=null&&A.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var A;const e=(A=this.uiObject)==null?void 0:A._overflow;e&&(e._needsUpdate=!0,this.markDirty())}onCreate(A){DB&&console.log(this),this.horizontalOverflow==1&&(A.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,A.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,A.lineHeight=this.lineSpacing,delete A.backgroundOpacity,delete A.backgroundColor,DB&&(A.backgroundColor=16750848,A.backgroundOpacity=.5);const e=this.rectTransform;A={...A,...this.getTextOpts()},this.getAlignment(A),DB&&(A.backgroundColor=Math.random()*16777215,A.backgroundOpacity=.1),this.uiObject=e.createNewText(A),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let A=this.fontSize;const e={color:this.color,fontOpacity:this.color.alpha,fontSize:A,fontKerning:"normal"};return this.setFont(e,this.fontStyle),e}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(A){switch(A.flexDirection="column",this.alignment){case 0:case 3:case 6:A.textAlign="left";break;case 1:case 4:case 7:A.textAlign="center";break;case 2:case 5:case 8:A.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:A.alignItems="start";break;case 3:case 4:case 5:A.alignItems="center";break;case 6:case 7:case 8:A.alignItems="end";break}return A}feedText(A,e){var i,g,I;if(DB&&console.log("feedText",this.uiObject,A,e),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!e||A.length===0)this.uiObject.textContent=A;else{let o=this.getNextTag(A);if(o){if(o.startIndex>0){for(let a=this.uiObject.children.length-1;a>=0;a--){const n=this.uiObject.children[a];n.isUI&&(this.uiObject.remove(n),n.clear())}const C=new ry({textContent:A.substring(0,o.startIndex),color:"inherit"});this.uiObject.add(C)}}else{this.uiObject.textContent="",this.setOptions({textContent:A});return}const s=[];for(;o;){const C=this.getNextTag(A,o.endIndex),a={fontFamily:(i=this.uiObject)==null?void 0:i.get("fontFamily"),color:"inherit",textContent:""};if(C){a.textContent=this.getText(A,o,C),this.handleTag(o,a,s);const n=new ry(a);(g=this.uiObject)==null||g.add(n)}else{a.textContent=A.substring(o.endIndex),this.handleTag(o,a,s);const n=new ry(a);(I=this.uiObject)==null||I.add(n)}o=C}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const A=[],e=this.canvas,i={renderOnTop:e.renderOnTop,depthWrite:e.depthWrite,doubleSided:e.doubleSided};for(;;){let g=!1;if(this._textMeshUi)for(let I=0;I<this._textMeshUi.length;I++){if(A[I]===!0)continue;g=!0;const o=this._textMeshUi[I];o.textContent&&(fy(o,i),A[I]=!0)}if(!g)break;yield}}handleTag(A,e,i){if(!A.isEndTag){if(A.type.includes("color")){const g=new pU(A,{color:e.color});if(i.push(g),A.type.length>6){const I=parseInt("0x"+A.type.substring(7));e.color=I}else e.color=new wA(1,1,1)}else if(A.type=="b"){this.setFont(e,1);const g=new pU(A,{fontWeight:700});i.push(g)}else if(A.type=="i"){this.setFont(e,2);const g=new pU(A,{fontStyle:"italic"});i.push(g)}}}getText(A,e,i){return A.substring(e.endIndex,i.startIndex)}getNextTag(A,e=0){const i=A.indexOf("<",e),g=A.indexOf(">",i);if(i>=0&&g>=0){const I=A.substring(i+1,g);return{type:I,startIndex:i,endIndex:g+1,isEndTag:I.startsWith("/")}}return null}setFont(A,e){if(!this.font)return;let i=this.font,g=this.getFamilyNameWithCorrectSuffix(i,e);DB&&console.log("Selected font family:"+g);let I=vR.getFontFamily(g);switch(I||(I=vR.addFontFamily(g)),A.fontFamily=I,e){default:case 0:A.fontWeight=400,A.fontStyle="normal";break;case 1:A.fontWeight=700,A.fontStyle="normal";break;case 2:A.fontWeight=400,A.fontStyle="italic";break;case 3:A.fontStyle="italic",A.fontWeight=400}let o=I.getVariant(A.fontWeight,A.fontStyle);if(!o){let s=g;s!=null&&s.endsWith("-msdf.json")||(s+="-msdf.json");let C=g;C!=null&&C.endsWith(".png")||(C+=".png"),o=I.addVariant(A.fontWeight,A.fontStyle,s,C),o?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(A,e){var i;const g=A.lastIndexOf("-");if(g<0)return A;const I=(i=A.substring(g+1))==null?void 0:i.toLowerCase();if(zIA.includes(I))return DB&&console.warn("Unsupported font style: "+I),A;const o=A.lastIndexOf("/");let s=A;o>=0&&(s=s.substring(o+1));let C=s[0]===s[0].toUpperCase();const a=A.substring(0,g);switch(DB&&console.log("Select font: ",A,_2[e],s,C,a),e){case 0:return C?a+"-Regular":a+"-regular";case 1:return C?a+"-Bold":a+"-bold";case 2:return C?a+"-Italic":a+"-italic";case 3:return C?a+"-BoldItalic":a+"-bolditalic";default:return A}}}da([y()],sI.prototype,"alignment",2),da([y()],sI.prototype,"verticalOverflow",2),da([y()],sI.prototype,"horizontalOverflow",2),da([y()],sI.prototype,"lineSpacing",2),da([y()],sI.prototype,"supportRichText",2),da([y(URL)],sI.prototype,"font",2),da([y()],sI.prototype,"fontStyle",2),da([y()],sI.prototype,"text",1),da([y()],sI.prototype,"fontSize",1);class pU{constructor(A,e){r(this,"tag"),r(this,"previousValues"),this.tag=A,this.previousValues=e}}const zIA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Pn{constructor(A){r(this,"id"),r(this,"content",""),r(this,"font",[]),r(this,"pointSize",144),r(this,"width"),r(this,"height"),r(this,"depth"),r(this,"wrapMode"),r(this,"horizontalAlignment"),r(this,"verticalAlignment"),r(this,"material"),this.id=A}static getId(){return this.global_id++}setDepth(A){return this.depth=A,this}setPointSize(A){return this.pointSize=A,this}setHorizontalAlignment(A){return this.horizontalAlignment=A,this}setVerticalAlignment(A){return this.verticalAlignment=A,this}writeTo(A,e){var i;e.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&e.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(i=this.font)==null||i.push("sans-serif"));const g=this.font.map(I=>`"${I}"`).join(", ");e.appendLine(`string[] font = [ ${g} ]`),e.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&e.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&e.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&e.appendLine(`double depth = ${this.depth}`),this.wrapMode&&e.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&e.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&e.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&e.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),e.closeBlock()}}r(Pn,"global_id",0);class Ly{static singleLine(A,e,i){const g=new Pn("text_"+Pn.getId());return g.content=A,e&&(g.pointSize=e),i&&(g.depth=i),g}static multiLine(A,e,i,g,I,o){const s=new Pn("text_"+Pn.getId());return s.content=A,s.width=e,s.height=i,s.horizontalAlignment=g,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const ZIA=new JA().makeRotationY(Math.PI),XIA=new JA().makeScale(-1,1,-1);class Bd{get extensionName(){return"text"}onExportObject(A,e,i){}exportText(A,e,i){const g=tA.getComponent(A,sI);if(!g)return;const I=tA.getComponent(A,hg);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=ZIA.clone(),I&&e.matrix.premultiply(XIA);const C=new wA().copySRGBToLinear(g.color);e.material=new Xo({color:C,emissive:C}),e.addEventListener("serialize",(a,n)=>{let B=g.text;B=B.replace(/\n/g,"\\n");const Q=Ly.multiLine(B,o,s,"center","bottom","flowing");this.setTextAlignment(Q,g.alignment),this.setOverflow(Q,g),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(g.fontSize),Q.depth=.001,Q.writeTo(void 0,a)})}convertToTextSize(A){return 1/.0502*144*A}setOverflow(A,e){e.horizontalOverflow?A.wrapMode="singleLine":A.wrapMode="flowing"}setTextAlignment(A,e){switch(e){case _i.LowerLeft:case _i.MiddleLeft:case _i.UpperLeft:A.horizontalAlignment="left";break;case _i.LowerCenter:case _i.MiddleCenter:case _i.UpperCenter:A.horizontalAlignment="center";break;case _i.LowerRight:case _i.MiddleRight:case _i.UpperRight:A.horizontalAlignment="right";break}switch(e){case _i.LowerLeft:case _i.LowerCenter:case _i.LowerRight:A.verticalAlignment="bottom";break;case _i.MiddleLeft:case _i.MiddleCenter:case _i.MiddleRight:A.verticalAlignment="middle";break;case _i.UpperLeft:case _i.UpperCenter:case _i.UpperRight:A.verticalAlignment="top";break}}}class xy{get extensionName(){return"tmui"}onExportObject(A,e,i){const g=tA.getComponent(A,cg);if(g&&g.activeAndEnabled&&g.renderMode===Y2.WorldSpace){const I=new Bd,o=tA.getComponent(A,hg),s=tA.getComponent(A,xn);if(o){o.width,o.height;const C=mo.createEmpty(),a=o.shadowComponent;if(e.add(C),a){const n=a.matrix;C.matrix.copy(n);const B=new Map,Q=new Map;B.set(a,C),Q.set(a,s?s.alpha:1),a.traverse(E=>{if(E===a)return;const h=mo.createEmpty();h.matrix.copy(E.matrix);const l=E.parent,d=l&&typeof l.textContent=="string"&&l.textContent.length;let c=Q.get(l)||1;const u=tA.getComponent(E,xn);if(u&&(c*=u.alpha),E instanceof fA&&d){const D=E[$s].gameObject;I.exportText(D,h,i)}if(E instanceof fA&&!d){const D=E.geometry.clone();D.scale(1,1,-1),this.flipWindingOrder(D),h.geometry=D;const w=new wA,m=E.material.opacity;w.copy(E.material.color),h.material=new Et({color:w,opacity:m*c,map:E.material.map,transparent:!0})}B.set(E,h),Q.set(E,c);const p=B.get(l);if(!p){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}p.add(h)})}}}}flipWindingOrder(A){const e=A.index.array;for(let i=0,g=e.length/3;i<g;i++){let I=e[i*3];e[i*3]=e[i*3+2],e[i*3+2]=I}A.index.needsUpdate=!0}}var $IA=Object.defineProperty,AoA=Object.getOwnPropertyDescriptor,to=(t,A,e,i)=>{for(var g=i>1?void 0:i?AoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&$IA(A,e,g),g};const Ag=oA("debugusdz");class jn{constructor(){r(this,"callToAction"),r(this,"checkoutTitle"),r(this,"checkoutSubtitle"),r(this,"callToActionURL")}}to([y()],jn.prototype,"callToAction",2),to([y()],jn.prototype,"checkoutTitle",2),to([y()],jn.prototype,"checkoutSubtitle",2),to([y()],jn.prototype,"callToActionURL",2);class io extends UA{constructor(){super(...arguments),r(this,"objectToExport"),r(this,"autoExportAnimations",!1),r(this,"exportFileName"),r(this,"customUsdzFile"),r(this,"customBranding"),r(this,"anchoringType","plane"),r(this,"planeAnchoringAlignment","horizontal"),r(this,"interactive",!0),r(this,"extensions",[]),r(this,"allowCreateQuicklookButton",!0),r(this,"link"),r(this,"webxr"),r(this,"onClickedOpenInARElement",A=>{A.preventDefault(),this.exportAsync()}),r(this,"lastCallback"),r(this,"_quicklookButton"),r(this,"_quicklookButtonContainer",null)}start(){var A,e,i;Ag&&(console.log(this),console.log("Debug USDZ, press 't' to export"),window.addEventListener("keydown",g=>{switch(g.key){case"t":this.exportAsync();break}}),Ha()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((e=(A=this.objectToExport)==null?void 0:A.children)!=null&&e.length)&&!((i=this.objectToExport)!=null&&i.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Sy),this.extensions.push(new wy),this.extensions.push(new Bd),this.extensions.push(new xy))}onEnable(){var A;const e=Oh(),i=wC();(Ag||e&&i)&&((Ag||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=_IA(this.context),this.link.addEventListener("message",this.lastCallback)),Ag&&pi("USDZ Exporter enabled: "+this.name),(A=document.getElementById("open-in-ar"))==null||A.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var A,e;(A=this.link)==null||A.removeEventListener("message",this.lastCallback);const i=Oh(),g=wC();(Ag||i&&g)&&this.removeQuicklookButton(),Ag&&pi("USDZ Exporter disabled: "+this.name),(e=document.getElementById("open-in-ar"))==null||e.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var A;let e=this.exportFileName??((A=this.objectToExport)==null?void 0:A.name)??this.name;if(tE()||(e+="-MadeWithNeedle"),e+="-"+PIA(),this.customUsdzFile){Ag&&console.log("Exporting custom usdz",this.customUsdzFile);const l=this.buildQuicklookOverlay();Ag&&console.log(l);const d=l.callToAction?encodeURIComponent(l.callToAction):"",c=l.checkoutTitle?encodeURIComponent(l.checkoutTitle):"",u=l.checkoutSubtitle?encodeURIComponent(l.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${d}&checkoutTitle=${c}&checkoutSubtitle=${u}&callToActionURL=${l.callToActionURL}`,Ag&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click();return}if(!this.objectToExport)return;const i=tA.getComponentsInChildren(this.objectToExport,bt),g=new Array;for(const l of i)for(const d of l.sharedMaterials)if(d){const c=l.loadProgressiveTextures(d);c instanceof Promise&&g.push(c)}Ag&&pi("Load textures: "+g.length),await Promise.all(g),Ag&&pi("Load textures: done"),this.applyWebARSessionRoot();const I=new X7,o=[...this.extensions],s=new qw;o.push(s),this.autoExportAnimations&&jIA(this.objectToExport,s);const C={self:this,exporter:I,extensions:o,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:C})),I.debug=Ag,this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal");const a=await I.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:o,quickLookCompatible:!0}),n=new Blob([a],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:C}));const B=this.buildQuicklookOverlay();Ag&&console.log(B);const Q=B.callToAction?encodeURIComponent(B.callToAction):"",E=B.checkoutTitle?encodeURIComponent(B.checkoutTitle):"",h=B.checkoutSubtitle?encodeURIComponent(B.checkoutSubtitle):"";this.link.href=URL.createObjectURL(n)+`#callToAction=${Q}&checkoutTitle=${E}&checkoutSubtitle=${h}&callToActionURL=${B.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}quicklookCallback(A){if(A?.data=="_apple_ar_quicklook_button_tapped"){Ag&&Do("Quicklook closed via call to action button");var e=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(e),!e.defaultPrevented){const i=new URLSearchParams(this.link.href);if(i){const g=i.get("callToActionURL");Ag&&pi("Quicklook url: "+g),g&&(tE()?globalThis.open(g,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",g))}}}}buildQuicklookOverlay(){var A,e,i,g,I,o;const s={};return this.customBranding&&Object.assign(s,this.customBranding),tE()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),s.callToAction="Close",s.checkoutTitle="\u{1F335} Made with Needle",s.checkoutSubtitle="_"),(((A=s.callToAction)==null?void 0:A.length)||((e=s.checkoutTitle)==null?void 0:e.length)||((i=s.checkoutSubtitle)==null?void 0:i.length))&&((g=s.callToAction)!=null&&g.length||(s.callToAction="\0"),(I=s.checkoutTitle)!=null&&I.length||(s.checkoutTitle="\0"),(o=s.checkoutSubtitle)!=null&&o.length||(s.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:s})),s}async createQuicklookButton(){var A,e;if(!this.webxr)if(await Hh(1),this.webxr=tA.findObjectOfType(Se)??void 0,this.webxr)if(this.webxr.VRButton&&((A=this.webxr.VRButton.parentElement)==null||A.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const i=(e=this.webxr.ARButton.parentElement)==null?void 0:e.querySelector("a");i&&(i.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",g=>{g.preventDefault(),this.exportAsync()}),this.webxr.ARButton.classList.add("quicklook-ar-button"),this._quicklookButtonContainer=this.webxr.ARButton.parentElement,this.dispatchEvent(new CustomEvent("created-button",{detail:this.webxr.ARButton}))}else{this.webxr.createARButton=!1,this.webxr.createVRButton=!1;let i=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");i||(i=document.createElement("div"),i.classList.add("webxr-buttons"));const g=document.createElement("button");g.innerText="Open in Quicklook",g.addEventListener("click",()=>{this.exportAsync()}),g.classList.add("webxr-ar-button"),g.classList.add("webxr-button"),g.classList.add("quicklook-ar-button"),this._quicklookButton=g,i.appendChild(g),this._quicklookButtonContainer=i,this.dispatchEvent(new CustomEvent("created-button",{detail:g}))}else console.warn("Could not find WebXR component: will not create Quicklook button",be.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var A;(A=this._quicklookButton)==null||A.remove()}applyWebARSessionRoot(){if(Ag&&console.log("applyWebARSessionRoot"),!this.objectToExport)return;let A=tA.getComponentInParent(this.objectToExport,js);const e=A!=null;if(A||(A=tA.getComponentInChildren(this.objectToExport,js)),!A){Ag&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const i=e?this.objectToExport:A.gameObject,g=1/A.arScale;Ag&&console.log("Scale",g,i),i.matrix.makeScale(g,g,g),A.invertForward&&i.matrix.multiply(new JA().makeRotationY(Math.PI))}}to([y(vA)],io.prototype,"objectToExport",2),to([y()],io.prototype,"autoExportAnimations",2),to([y()],io.prototype,"exportFileName",2),to([y(URL)],io.prototype,"customUsdzFile",2),to([y(jn)],io.prototype,"customBranding",2),to([y()],io.prototype,"anchoringType",2),to([y()],io.prototype,"planeAnchoringAlignment",2),to([y()],io.prototype,"interactive",2),to([y()],io.prototype,"allowCreateQuicklookButton",2);const P2=oA("debugdeletable");class Ty extends Ps{}class uU extends UA{constructor(){super(...arguments),r(this,"deleteBoxes",[])}awake(){this.deleteBoxes=tA.findObjectsOfType(Ty,this.context)}update(){for(const A of this.deleteBoxes){const e=this.gameObject;if(A.isInBox(e)===!0){const i=tA.getComponentInParent(this.gameObject,wE);i?P2&&console.warn("Can not delete object with usage marker",this.guid,i):(P2&&console.log("DESTROY",this.gameObject),OD(this.gameObject,this.context.connection))}}}}var eoA=Object.defineProperty,toA=Object.getOwnPropertyDescriptor,wB=(t,A,e,i)=>{for(var g=i>1?void 0:i?toA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&eoA(A,e,g),g};class ds extends vg{constructor(){super(...arguments),r(this,"mode"),r(this,"focusDistance"),r(this,"focalLength"),r(this,"aperture"),r(this,"gaussianMaxRadius"),r(this,"resolutionScale"),r(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=e=>{const i=e/300,g=2;return te.lerp(g,.01,i)};const A=20;this.aperture.valueProcessor=e=>{const i=1-e/32;return te.lerp(1,A,i)}}onCreateEffect(){if(this.mode===0)return;const A=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let i=1;Ha()&&(i=.6),this.resolutionScale=new ke(i*A)}const e=new Sx(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=i=>{e.circleOfConfusionMaterial.worldFocusDistance=i},this.focalLength.onValueChanged=i=>e.circleOfConfusionMaterial.worldFocusRange=i,this.aperture.onValueChanged=i=>e.bokehScale=i,this.resolutionScale&&(this.resolutionScale.onValueChanged=i=>e.resolution.scale=i),[e]}unapply(){}}wB([y()],ds.prototype,"mode",2),wB([y(ke)],ds.prototype,"focusDistance",2),wB([y(ke)],ds.prototype,"focalLength",2),wB([y(ke)],ds.prototype,"aperture",2),wB([y(ke)],ds.prototype,"gaussianMaxRadius",2),wB([y(ke)],ds.prototype,"resolutionScale",2),wB([y(ke)],ds.prototype,"bokehScale",2),Jo("DepthOfField",ds);var ioA=Object.defineProperty,goA=Object.getOwnPropertyDescriptor,IoA=(t,A,e,i)=>{for(var g=i>1?void 0:i?goA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ioA(A,e,g),g};class Yy extends UA{constructor(){super(...arguments),r(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||tA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:ooA()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}IoA([y()],Yy.prototype,"visibleOn",2);let Hy;function ooA(){if(Hy===!0||Hy===!1)return Hy;let t=!1;return function(A){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(A)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(A.substr(0,4)))&&(t=!0)}(navigator.userAgent||navigator.vendor||window.opera),Hy=t,t}class DU{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var soA=Object.defineProperty,CoA=Object.getOwnPropertyDescriptor,j2=(t,A,e,i)=>{for(var g=i>1?void 0:i?CoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&soA(A,e,g),g},W2=(t=>(t.SelectStart="selectstart",t.SelectEnd="selectend",t))(W2||{}),Oy;const Wn=(Oy=class extends DE{constructor(){super(),r(this,"showGizmo",!0),r(this,"useViewAngle",!0),r(this,"transformSelf",!0),r(this,"orbit",null),r(this,"selectStartEventListener",[]),r(this,"selectEndEventListener",[]),r(this,"_dragHelper",null),r(this,"_draggingRigidbodies",[]),r(this,"_waitingForDragStart",null),r(this,"_isDragging",!1),r(this,"_marker",null),r(this,"_dragDelta"),r(this,"_didDrag",!1),r(this,"_activePointerId"),this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new Z}static get HasAnySelected(){return this._active>0}addDragEventListener(t,A){switch(t){case"selectstart":this.selectStartEventListener.push(A);break;case"selectend":this.selectEndEventListener.push(A);break}}start(){this.orbit=tA.findObjectOfType(Ba,this.context),this.gameObject.getComponentInParent(aa)||this.gameObject.addNewComponent(aa)}allowEdit(t=null){return this.context.connection.allowEditing}onPointerEnter(t){if(!this.allowEdit(this.gameObject)||Se.IsInWebXR)return;const A=tA.getComponentInParent(t.object,Wn);!A||A!==this||(Wn.lastHovered=t.object,this.context.domElement.style.cursor="pointer")}onPointerExit(t){this.allowEdit(this.gameObject)&&(Se.IsInWebXR||Wn.lastHovered===t.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(t){this.allowEdit(this.gameObject)&&(Se.IsInWebXR||(Wn._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=t.clone(),t.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(t){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(Wn._active>0&&(Wn._active-=1),!Se.IsInWebXR&&(this.onDragEnd(t),t.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var t;if(!Se.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const e=this.context.input.getPointerPositionDelta(0);if(e&&this._dragDelta.add(e),this._dragDelta.length()>2)this._didDrag=!0;else return}const A=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(A)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((t=this._dragHelper)==null?void 0:t.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(t){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new z2(this.context.mainCamera);else return;if(!t||!t.object)return;const A=tA.getComponentInParent(t.object,Wn);if(!A||A!==this)return;let e=t.object;this.transformSelf&&(e=this.gameObject);const i={selected:e,attached:e};for(const s of this.selectStartEventListener)s(this,i);if(this._activePointerId=t.pointerId,!i.attached)return;i.attached,e=i.attached,this._isDragging=!0,this._dragHelper.setSelected(e,this.context),this.orbit&&(this.orbit.enabled=!1);const g=tA.getComponentInChildren(e,Kn);g&&(g.fastMode=!0,g?.requestOwnership()),this._marker=tA.addNewComponent(e,wE),this._draggingRigidbodies.length=0;const I=tA.getComponentsInChildren(e,Wt);I&&this._draggingRigidbodies.push(...I);const o=kp();tA.invokeOnChildren(this._dragHelper.selected,o("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const t of this._draggingRigidbodies)t.wakeUp(),t.resetVelocities()}}onDragEnd(t){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const i of this._draggingRigidbodies)i.setVelocity(i.smoothedVelocity);this._draggingRigidbodies.length=0;const A=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),t!=null&&t.object){const i=tA.getComponentInChildren(t.object,Kn);i&&(i.fastMode=!1)}this._marker&&this._marker.destroy();for(const i of this.selectEndEventListener)i(this);const e=kp();tA.invokeOnChildren(A,e("onDragEnd"))}},r(Oy,"_active",0),r(Oy,"lastHovered"),Oy);let zE=Wn;j2([y()],zE.prototype,"showGizmo",2),j2([y()],zE.prototype,"useViewAngle",2);const V2=class{constructor(t){r(this,"showGizmo",!0),r(this,"useViewAngle",!0),r(this,"_selected",null),r(this,"_context",null),r(this,"_camera"),r(this,"_cameraPlane",new ho),r(this,"_hasGroundPlane",!1),r(this,"_groundPlane",new ho),r(this,"_groundOffset",new S),r(this,"_groundOffsetFactor",0),r(this,"_groundDistance",0),r(this,"_groundPlanePoint",new S),r(this,"_raycaster",new TQ),r(this,"_cameraPlaneOffset",new S),r(this,"_intersection",new S),r(this,"_worldPosition",new S),r(this,"_inverseMatrix",new JA),r(this,"_rbs",[]),r(this,"_groundLine"),r(this,"_groundMarker"),r(this,"_groundOffsetVector",new S(0,1,0)),r(this,"_requireUpdateGroundPlane",!0),r(this,"_didDragOnGroundPlaneLastFrame",!1),this._camera=t;const A=new si(V2.geometry),e=A.material;e.color=new wA(.4,.4,.4),A.layers.set(2),A.name="line",A.scale.y=1,this._groundLine=A;const i=new Yo(.5,22,22),g=new Et({color:e.color}),I=new fA(i,g);I.visible=!1,I.layers.set(2),this._groundMarker=I}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(t,A){if(this._selected&&A)for(const e of this._rbs)e.wakeUp(),e.setVelocity(0,0,0);if(this._selected&&gI.Remove(A,this._selected),this._selected=t,this._context=A,this._rbs.length=0,t?(A.scene.add(this._groundLine),A.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!A){console.error("DragHelper: no context");return}gI.Add(A,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(t){var A,e,i,g,I;if(!this._context)return;const o="Space",s="KeyD",C=((A=this._context)==null?void 0:A.input.isKeyPressed(o))||((e=this._context)==null?void 0:e.input.isKeyPressed(s)),a=this._context.input.getTouchesPressedCount()>=2||C;if(a){const B=this._context.input.getPointerPositionDelta(0);B&&(this._groundOffsetVector.set(0,1,0),(i=this._selected)==null||i.rotateOnWorldAxis(this._groundOffsetVector,B.x*this._context.time.deltaTime))}const n=this._context.input.getPointerPositionRC(0);if(n&&(this._raycaster.setFromCamera(n,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const B=ue(this._camera).clone().sub(ue(this._selected)).normalize(),Q=Math.abs(B.dot(this._groundOffsetVector)),E=((g=this._context)==null?void 0:g.input.isKeyPressed(o))||((I=this._context)==null?void 0:I.input.isKeyPressed(s));let h=!this.useViewAngle||Q>.2;(a||E||this._context.input.getPointerPressedCount()>1)&&(h=!1);const l=this._didDragOnGroundPlaneLastFrame!==h;if(this._didDragOnGroundPlaneLastFrame=h,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!h||l)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const d=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=d,h){this._groundOffsetVector.set(0,1,0);const c=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(c,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);l&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(t,A,e){if(this._selected){if(e){const i=ue(this._selected);i.y=t.y,t=i}if(ai(this._selected,t),ai(this._groundLine,t),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=A!==null&&this.showGizmo,A){const i=ue(this._camera).distanceTo(A)*.01;this._groundMarker.scale.set(i,i,i),ai(this._groundMarker,A)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const t=this._context.input.getPointerPositionRC(0);t&&(this._raycaster.setFromCamera(t,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;const t=ue(this._selected),A=new qs(new S(0,.1,0).add(t),new S(0,-1,0)),e=new es;e.ignore=[this._selected];const i=this._context.physics.raycastFromRay(A,e);for(let g=0;g<i.length;g++){const I=i[g];if(!I.face||this.contains(this._selected,I.object))continue;const o=new S(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(o,I.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(A.direction.multiplyScalar(-1),A.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(t),this._groundOffset.copy(this._intersection).sub(t)}onDidUpdate(){qI.markDirty(this._selected);for(const t of this._rbs)t.wakeUp(),t.resetForcesAndTorques(),t.setAngularVelocity(0,0,0)}contains(t,A){if(t===A)return!0;if(t.children){for(const e of t.children)if(this.contains(e,A))return!0}return!1}};let z2=V2;r(z2,"geometry",new pe().setFromPoints([new S(0,0,0),new S(0,-1,0)]));function wU(t,A,e){console.warn("Adding components on object has been temporarily disabled")}var Z2=(t=>(t.File_Spawned="file-spawned",t))(Z2||{});class X2{constructor(A,e,i,g,I,o,s,C){r(this,"guid"),r(this,"file_name"),r(this,"file_hash"),r(this,"file_size"),r(this,"position"),r(this,"seed"),r(this,"sender"),r(this,"serverUrl"),r(this,"parentGuid"),r(this,"boundsSize"),this.seed=e,this.guid=i,this.file_name=g,this.file_hash=I,this.file_size=o,this.position=s,this.sender=A,this.serverUrl=C}}async function $2(t,A,e){const i=t.name;return i.endsWith(".gltf")||i.endsWith(".glb")?new Promise((g,I)=>{const o=new FileReader;o.readAsArrayBuffer(t),o.onloadend=async s=>{const C=o.result,a=_D(),n=new EI(a),B=await gs().parseSync(A,C,t.name,n);if(B&&B.scene){const Q=B.scene;if(!Q.guid){const E=new EI(a);Q.guid=E.generateUUID()}e&&aoA(A.connection,t,a,Q,e),wU(),g(B)}}}):(console.warn("Unsupported file type: "+i,t),null)}async function AO(t,A){return new Promise(async(e,i)=>{const g=_D(),I=new EI(g),o=t.toString(),s=await gs().loadSync(A,o,o,I);s&&s.scene?(s.scene,wU(),e(s)):console.warn("Unsupported file type: "+t.toString())})}Rt.registerCallback(mg.ContextCreated,t=>{eO(t.context)});function eO(t){t.connection.beginListen("file-spawned",async A=>{if(A.sender!==t.connection.connectionId){console.log("received file event",A),noA(A,t);let e=null;try{e=await JG(A.file_name,A.file_hash,A.file_size,A.serverUrl)}finally{roA(A)}if(e){const i=new EI(A.seed),g=await gs().parseSync(t,e,A.file_name,i);if(g&&g.scene){const I=g.scene;if(wU(),A.parentGuid){const o=Zc(A.parentGuid,t.scene);o&&"add"in o&&o.add(I)}I.parent||t.scene.add(I),A.position!==null&&I.position.copy(A.position)}}else console.error("download didnt return file")}})}async function aoA(t,A,e,i,g){if(!t.connectionId){console.error("Can not upload file - no connection id");return}if(!i.guid){console.error("Can not upload file - no guid",i,i.guid);return}const I=await Yx(A,g);if(!I)return;if(!I.filename){console.error("Can not send upload event - no filename",A.name);return}if(!I.hash){console.error("Can not send upload event - no hash",A.name);return}const o=new X2(t.connectionId,e,i.guid,I.filename,I.hash,A.size,i.position,I.url??g);i.parent&&(o.parentGuid=i.parent.guid),t.send("file-spawned",o)}const yU={};function noA(t,A){const e=new Dt,i=new fA(e,new Et({color:65280})),g=new CD(i,5592405);if(yU[t.guid]=g,A.scene.add(g),t.parentGuid){const I=Zc(t.parentGuid,A.scene);I&&I.add(g)}t.position&&g.position.copy(t.position)}function roA(t,A){const e=t.guid,i=yU[e];i&&(delete yU[e],i.removeFromParent())}var BoA=Object.defineProperty,QoA=Object.getOwnPropertyDescriptor,SU=(t,A,e,i)=>{for(var g=i>1?void 0:i?QoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&BoA(A,e,g),g};const EoA=oA("debugnet"),fU=class extends UA{constructor(){super(...arguments),r(this,"url",null),r(this,"urlParameterName",null),r(this,"localhost",null)}awake(){EoA&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let t=this.url?fU.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const e=oA(this.urlParameterName);e&&typeof e=="string"&&(t=e)}if(!t)return null;const A=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(t);return A!=null&&A.groups?A?.groups.socket_prefix?t:"wss://"+A?.groups.url:null}static GetUrl(t,A){let e=t;const i=fU.IsLocalNetwork()&&A;return i&&(e=A),t!=null&&t.startsWith("/")&&(e=(i?e:window.location.origin)+t),e}static IsLocalNetwork(t=window.location.hostname){return Yg(t)}};let yB=fU;SU([y()],yB.prototype,"url",2),SU([y()],yB.prototype,"urlParameterName",2),SU([y()],yB.prototype,"localhost",2);var hoA=Object.defineProperty,coA=Object.getOwnPropertyDescriptor,tO=(t,A,e,i)=>{for(var g=i>1?void 0:i?coA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&hoA(A,e,g),g};const ZE=oA("debugdroplistener");class Qd extends UA{constructor(){super(...arguments),r(this,"filesBackendUrl"),r(this,"localhost"),r(this,"onDrag",A=>{A.preventDefault()}),r(this,"onDrop",async A=>{if(ZE&&console.log(A),!A.dataTransfer)return;A.preventDefault();const e=A.dataTransfer.items;if(e)for(const i in e){const g=e[i];if(g.kind==="file"){const I=g.getAsFile();if(!I)continue;await this.addFiles(I)}else g.kind==="string"&&g.type=="text/plain"&&g.getAsString(async I=>{ZE&&console.log("dropped url",I);try{const o=new URL(I);if(!o)return;const s=await AO(o,this.context);s&&this.addObject(A,s)}catch{console.log("dropped string is not a valid URL!",I)}})}})}onEnable(){this.filesBackendUrl=yB.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,ZE&&console.log(this,this.filesBackendUrl),this.context.domElement.addEventListener("dragover",this.onDrag),this.context.domElement.addEventListener("drop",this.onDrop)}onDisable(){this.context.domElement.removeEventListener("dragover",this.onDrag),this.context.domElement.removeEventListener("drop",this.onDrop)}async addFiles(...A){if(ZE&&console.log("Add files",A),!!Array.isArray(A)&&A.length)for(const e of A){if(!e)continue;ZE&&console.log("Register file "+e.name+" to",this.filesBackendUrl,e);const i=await $2(e,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:e})),i&&this.addObject(void 0,i)}}async addObject(A,e){ZE&&console.log("Dropped",e);const i=e.scene;if(A!==void 0){const g=new es;g.setMask(16777215),g.screenPointFromOffset(A.offsetX,A.offsetY);const I=this.context.physics.raycast(g);if(I&&I.length>0)for(const o of I){i.position.copy(o.point);break}}this.gameObject.add(i),this.dispatchEvent(new CustomEvent("object-added",{detail:e}))}}tO([y()],Qd.prototype,"filesBackendUrl",2),tO([y()],Qd.prototype,"localhost",2);var loA=Object.defineProperty,doA=Object.getOwnPropertyDescriptor,_y=(t,A,e,i)=>{for(var g=i>1?void 0:i?doA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&loA(A,e,g),g};class SB extends DE{constructor(){super(...arguments),r(this,"parent",null),r(this,"object",null),r(this,"limitCount",10),r(this,"limitInterval",60),r(this,"_currentCount",0),r(this,"_startPosition",null),r(this,"_startQuaternion",null)}awake(){var A,e;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((A=this.object.position)==null?void 0:A.clone())??new S(0,0,0),this._startQuaternion=((e=this.object.quaternion)==null?void 0:e.clone())??new xA(0,0,0,1)}const i=tA.getComponentInParent(this.gameObject,zE);i?i.addDragEventListener(W2.SelectStart,(g,I)=>{if(this._currentCount>=this.limitCount){I.attached=null;return}const o=this.handleDuplication(I.selected);o&&(console.assert(o!==I.selected,"Duplicated object is original"),I.attached=o)}):console.warn("Could no find drag controls in parent",this.name),mi.addEventListener(sa.SelectStart,(g,I)=>{if(this._currentCount>=this.limitCount){I.grab=null;return}const o=this.handleDuplication(I.selected);o&&(I.grab=o)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(A){var e;if(this._currentCount>=this.limitCount||!this.object)return null;if(A===this.gameObject||this.handleMultiObject(A)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const i=new Ys;this.parent||(this.parent=this.gameObject.parent),this.parent&&(i.parent=this.parent.guid??((e=this.parent.userData)==null?void 0:e.guid),i.keepWorldPosition=!0),i.position=this.worldPosition,i.rotation=this.worldQuaternion,i.context=this.context,this._currentCount+=1;const g=tA.instantiateSynced(this.object,i);return console.assert(g!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),g}return null}handleMultiObject(A){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,A):!1}isInChildren(A,e){if(!A)return!1;if(A===e)return!0;if(A.children){for(let i of A.children)if(this.isInChildren(i,e))return!0}return!1}}_y([y(vA)],SB.prototype,"parent",2),_y([y(vA)],SB.prototype,"object",2),_y([y()],SB.prototype,"limitCount",2),_y([y()],SB.prototype,"limitInterval",2);var XE=(t=>(t[t.PointerEnter=0]="PointerEnter",t[t.PointerExit=1]="PointerExit",t[t.PointerDown=2]="PointerDown",t[t.PointerUp=3]="PointerUp",t[t.PointerClick=4]="PointerClick",t[t.Drag=5]="Drag",t[t.Drop=6]="Drop",t[t.Scroll=7]="Scroll",t[t.UpdateSelected=8]="UpdateSelected",t[t.Select=9]="Select",t[t.Deselect=10]="Deselect",t[t.Move=11]="Move",t[t.InitializePotentialDrag=12]="InitializePotentialDrag",t[t.BeginDrag=13]="BeginDrag",t[t.EndDrag=14]="EndDrag",t[t.Submit=15]="Submit",t[t.Cancel=16]="Cancel",t))(XE||{}),poA=Object.defineProperty,uoA=Object.getOwnPropertyDescriptor,mU=(t,A,e,i)=>{for(var g=i>1?void 0:i?uoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&poA(A,e,g),g};class kU{constructor(){r(this,"eventID"),r(this,"callback")}}mU([y()],kU.prototype,"eventID",2),mU([y(SI)],kU.prototype,"callback",2);class Py extends UA{constructor(){super(...arguments),r(this,"triggers")}invoke(A){if(this.triggers)for(const e of this.triggers)e.eventID===A&&e.callback.invoke()}onPointerClick(A){this.invoke(XE.PointerClick)}onPointerEnter(A){this.invoke(XE.PointerEnter)}onPointerExit(A){this.invoke(XE.PointerExit)}onPointerDown(A){this.invoke(XE.PointerDown)}onPointerUp(A){this.invoke(XE.PointerUp)}}mU([y(kU)],Py.prototype,"triggers",2);var DoA=Object.defineProperty,woA=Object.getOwnPropertyDescriptor,GU=(t,A,e,i)=>{for(var g=i>1?void 0:i?woA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&DoA(A,e,g),g};class MU extends UA{constructor(){super(...arguments),r(this,"connectedBody"),r(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(Wt)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}GU([y(Wt)],MU.prototype,"connectedBody",2);class RU extends MU{createJoint(A,e){var i;(i=this.context.physics.engine)==null||i.addFixedJoint(A,e)}}class Ed extends MU{constructor(){super(...arguments),r(this,"anchor"),r(this,"axis")}createJoint(A,e){var i;this.axis&&this.anchor&&((i=this.context.physics.engine)==null||i.addHingeJoint(A,e,this.anchor,this.axis))}}GU([y(S)],Ed.prototype,"anchor",2),GU([y(S)],Ed.prototype,"axis",2);const yoA={type:"change"};let SoA=class extends qi{constructor(t,A){super(),this.object=t,this.domElement=A,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const e=this,i=1e-6,g=new xA,I=new S;this.tmpQuaternion=new xA,this.status=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new S(0,0,0),this.rotationVector=new S(0,0,0),this.keydown=function(Q){if(!(Q.altKey||this.enabled===!1)){switch(Q.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this.moveState.forward=1;break;case"KeyS":this.moveState.back=1;break;case"KeyA":this.moveState.left=1;break;case"KeyD":this.moveState.right=1;break;case"KeyR":this.moveState.up=1;break;case"KeyF":this.moveState.down=1;break;case"ArrowUp":this.moveState.pitchUp=1;break;case"ArrowDown":this.moveState.pitchDown=1;break;case"ArrowLeft":this.moveState.yawLeft=1;break;case"ArrowRight":this.moveState.yawRight=1;break;case"KeyQ":this.moveState.rollLeft=1;break;case"KeyE":this.moveState.rollRight=1;break}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(Q){if(this.enabled!==!1){switch(Q.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this.moveState.forward=0;break;case"KeyS":this.moveState.back=0;break;case"KeyA":this.moveState.left=0;break;case"KeyD":this.moveState.right=0;break;case"KeyR":this.moveState.up=0;break;case"KeyF":this.moveState.down=0;break;case"ArrowUp":this.moveState.pitchUp=0;break;case"ArrowDown":this.moveState.pitchDown=0;break;case"ArrowLeft":this.moveState.yawLeft=0;break;case"ArrowRight":this.moveState.yawRight=0;break;case"KeyQ":this.moveState.rollLeft=0;break;case"KeyE":this.moveState.rollRight=0;break}this.updateMovementVector(),this.updateRotationVector()}},this.pointerdown=function(Q){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(Q.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(Q){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const E=this.getContainerDimensions(),h=E.size[0]/2,l=E.size[1]/2;this.moveState.yawLeft=-(Q.pageX-E.offset[0]-h)/h,this.moveState.pitchDown=(Q.pageY-E.offset[1]-l)/l,this.updateRotationVector()}},this.pointerup=function(Q){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(Q.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(Q){this.enabled!==!1&&Q.preventDefault()},this.update=function(Q){if(this.enabled===!1)return;const E=Q*e.movementSpeed,h=Q*e.rollSpeed;e.object.translateX(e.moveVector.x*E),e.object.translateY(e.moveVector.y*E),e.object.translateZ(e.moveVector.z*E),e.tmpQuaternion.set(e.rotationVector.x*h,e.rotationVector.y*h,e.rotationVector.z*h,1).normalize(),e.object.quaternion.multiply(e.tmpQuaternion),(I.distanceToSquared(e.object.position)>i||8*(1-g.dot(e.object.quaternion))>i)&&(e.dispatchEvent(yoA),g.copy(e.object.quaternion),I.copy(e.object.position))},this.updateMovementVector=function(){const Q=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-Q+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",o),this.domElement.removeEventListener("pointerdown",C),this.domElement.removeEventListener("pointermove",s),this.domElement.removeEventListener("pointerup",a),window.removeEventListener("keydown",n),window.removeEventListener("keyup",B)};const o=this.contextMenu.bind(this),s=this.pointermove.bind(this),C=this.pointerdown.bind(this),a=this.pointerup.bind(this),n=this.keydown.bind(this),B=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",o),this.domElement.addEventListener("pointerdown",C),this.domElement.addEventListener("pointermove",s),this.domElement.addEventListener("pointerup",a),window.addEventListener("keydown",n),window.addEventListener("keyup",B),this.updateMovementVector(),this.updateRotationVector()}};class UU extends UA{constructor(){super(...arguments),r(this,"_controls",null)}onEnable(){var A;const e=(A=tA.getComponent(this.gameObject,Tt))==null?void 0:A.cam;this._controls=new SoA(e,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var A;(A=this._controls)==null||A.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var foA=Object.defineProperty,moA=Object.getOwnPropertyDescriptor,FU=(t,A,e,i)=>{for(var g=i>1?void 0:i?moA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&foA(A,e,g),g};class $E extends UA{constructor(){super(...arguments),r(this,"_fog")}get fog(){return this._fog||(this._fog=new xm(0,0,50)),this._fog}get mode(){return 1}set near(A){this.fog.near=A}get near(){return this.fog.near}set far(A){this.fog.far=A}get far(){return this.fog.far}set color(A){this.fog.color.copy(A)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}FU([y()],$E.prototype,"near",1),FU([y()],$E.prototype,"far",1),FU([y(wA)],$E.prototype,"color",1);let jy,NU,Ah,Wy;function KU(t,A=1/0,e=null){NU||(NU=new HI(2,2,1,1)),Ah||(Ah=new Je({uniforms:{blitTexture:new FA(t)},vertexShader:`
|
|
5022
5022
|
varying vec2 vUv;
|
|
5023
5023
|
void main(){
|
|
5024
5024
|
vUv = uv;
|