@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.
@@ -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(t);const s=wT;wT&&console.log("ARSupported?",lv,"VRSupported?",cv),(s||this.createARButton&&this.enableAR&&lv)&&(i=ks.createARButton(this),this._arButton=i,t.appendChild(i)),(s||this.createVRButton&&this.enableVR&&cv)&&(e=ks.createVRButton(this),this._vrButton=e,t.appendChild(e)),setTimeout(()=>{ks.resetButtonStyles(e),ks.resetButtonStyles(i)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(i){var e;if(!i)return;const t=this.context.renderer.xr.getSession();if(t){const s=i.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!s)return;this._currentHeadPose=s;const r=s?.transform;r&&this._transformOrientation.set(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w),ks._isInXr===!1&&t&&this.onEnterXR(t,i);for(const n of this.controllers)n.onUpdate(t);this._isInAR&&((e=this.webAR)==null||e.onUpdate(t,i))}ks.events.dispatchEvent({type:"xrUpdate",frame:i,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 i=0;i<2;i++)vs.Create(this,i,this.gameObject,nf.PhysicalDevice);ks.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(yt(this.context.mainCamera)),this._originalCameraRotation.copy(Rs(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 i=ee.findObjectOfType(Px,this.context);i?(this.rig=i.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new ro,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(i,e){var t,s;console.log("[XR] session begin",i,e),ks._isInXr=!0,this.ensureRig();const r=this.context.renderer.xr.getReferenceSpace();if(r&&this.rig){const a=e.getViewerPose(r),l=a?.transform.orientation;if(l){const c=new Ue(l.x,l.y,l.z,l.w),h=new Ys().setFromQuaternion(c);this.rig.rotateY(h.y)}}const n=this.context.renderer.xr;if(this.context.mainCamera){const a=n.getCamera();wT&&console.log("WebXRCamera",a);const l=(t=this.context.mainCameraComponent)==null?void 0:t.cullingMask;if(a&&l!==void 0){for(const c of a.cameras)c.layers.mask=l;a.layers.mask=l}else if(a){for(const c of a.cameras)c.layers.enableAll();a.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const o=this._requestedAR?ms.AR:ms.VR;switch(Da.Global.Set(o),o){case ms.AR:this.context.xrSessionMode=Mg.ImmersiveAR,this._isInAR=!0,(s=this.webAR)==null||s.onBegin(i);break;case ms.VR:this.context.xrSessionMode=Mg.ImmersiveVR,this._isInVR=!0,this.onEnterVR(i);break}i.addEventListener("end",()=>{console.log("[XR] session end"),ks._isInXr=!1,this.onExitXR(i)}),this.onEnterXR_HandleMirrorWindow(i),ks.events.dispatchEvent({type:"xrStarted",session:i})}onExitXR(i){var e,t,s,r;const n=this._isInAR;i&&(this._isInAR?(e=this.webAR)==null||e.onEnd(i):(t=this.context.mainCameraComponent)==null||t.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&&((s=this._originalCameraParent)==null||s.add(this.context.mainCamera),is(this.context.mainCamera,this._originalCameraPosition),cn(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),n&&((r=this._originalXRRigParent)==null||r.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Da.Global.Set(ms.Browser|ms.ThirdPerson),ks.events.dispatchEvent({type:"xrStopped",session:i})}onEnterVR(i){}destroyControllers(){var i;for(let e=this.controllers.length-1;e>=0;e-=1)(i=this.controllers[e])==null||i.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(i){re("mirror")&&setTimeout(()=>{if(!ks.IsInWebXR)return;const e=new URL(window.location.href);um(e.searchParams,sx,1),um(e.searchParams,"isMirror",1);const t=e.toString();this.xrMirrorWindow=window.open(t,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{ks.IsInWebXR&&i.end()})})},1e3)}},u(lf,"_isInXr",!1),u(lf,"events",new Cs),u(lf,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),u(lf,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),lf);let wt=ks;af([w()],wt.prototype,"enableVR",2),af([w()],wt.prototype,"enableAR",2),af([w(wr)],wt.prototype,"defaultAvatar",2),af([w()],wt.prototype,"handModelPath",2),af([w()],wt.prototype,"createVRButton",2),af([w()],wt.prototype,"createARButton",2);const hv=class{constructor(i){u(this,"_webxr"),u(this,"reticle",null),u(this,"reticleParent",null),u(this,"hitTestSource",null),u(this,"reticleActive",!0),u(this,"previousBackground",null),u(this,"previousEnvironment",null),u(this,"sessionRoot",null),u(this,"_previousParent",null),u(this,"arDomOverlay",null),u(this,"arOverlayElement",null),u(this,"noHitTestAvailable",!1),u(this,"didPlaceARSessionRoot",!1),this._webxr=i}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const i=this.arDomOverlay;return i.getAROverlayContainer?this.arOverlayElement=i.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(i){this.reticleActive=i}async onBegin(i){var e,t,s,r;const n=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const o=(e=navigator.userAgent)!=null&&e.includes("OculusBrowser")?nf.PhysicalDevice:nf.Touch,a=o===nf.Touch?4:2;for(let c=0;c<a;c++)vs.Create(this.webxr,c,this.webxr.gameObject,o);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=ee.findObjectOfType(ka,n)),!this.sessionRoot){const c=this.webxr.gameObject;this.sessionRoot=ee.addNewComponent(c,ka),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=n.scene.background,this.previousEnvironment=n.scene.environment,n.scene.background=null,i.requestReferenceSpace("viewer").then(c=>{var h,d;(d=(h=i.requestHitTestSource)==null?void 0:h.call(i,{space:c}))==null||d.then(p=>{this.hitTestSource=p}).catch(p=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",p)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new xe(new DA(.07,.09,32).rotateX(-Math.PI/2),new hi),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new De,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,hv.tempWebXRObject||(hv.tempWebXRObject=new De),this.context.scene.add(hv.tempWebXRObject),ee.addComponent(hv.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(t=this.sessionRoot)==null||t.onBegin(i)):console.warn("No WebARSessionRoot found in scene");const l=this.context.domElement;(s=l?.onEnterAR)==null||s.call(l,i,this.arOverlayElement),(r=this.context.mainCameraComponent)==null||r.applyClearFlagsIfIsActiveCamera()}onEnd(i){var e,t;this._previousParent&&(ee.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const s=this.webxr.context;s.scene.background=this.previousBackground,s.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,i);const r=this.context.domElement;(e=r.onExitAR)==null||e.call(r,i),(t=this.context.mainCameraComponent)==null||t.applyClearFlagsIfIsActiveCamera()}onUpdate(i,e){var t,s;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const n=this.webxr.Rig,o=ese.clone();(t=this.sessionRoot)==null||t.placeAt(n,o)}return}if(!this.hitTestSource)return;const r=e.getHitTestResults(this.hitTestSource);if(r.length){const n=r[0],o=this.webxr.context.renderer.xr.getReferenceSpace();if(o){const a=n.getPose(o);if(this.sessionRoot){const l=this.sessionRoot.onUpdate(this.webxr.Rig,i,a);this.didPlaceARSessionRoot=l}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&a)){const l=a.transform.matrix;this.reticle.matrix.fromArray(l),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(s=this.sessionRoot)==null||s.onUpdate(this.webxr.Rig,i,null),this.reticle&&(this.reticle.visible=!1)}};let uv=hv;u(uv,"tempWebXRObject");const ese=new Be().identity().makeTranslation(0,0,0);class bc{constructor(e,t){u(this,"used",!1),u(this,"inputSource"),u(this,"object"),u(this,"pointerId"),u(this,"isDown"),u(this,"isUp"),u(this,"isPressed"),u(this,"isClicked"),u(this,"input"),u(this,"event"),this.event=t,this.input=e}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}clone(){const e=new bc(this.input,this.event);return Object.assign(e,this),e}}class cf extends Me{awake(){Fn.createIfNoneExists(this.context)}onEnable(){var e;(e=Fn.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Fn.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class Yl extends cf{constructor(){super(...arguments),u(this,"targets",null),u(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(e=null){return this.targets?(e??(e=new Go),e.targets=this.targets,e.results=this.raycastHits,this.context.physics.raycast(e)):null}}class ST extends Yl{}const dv=re("debugeventsystem");var CT=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(CT||{});const Jl=class extends Me{constructor(){super(),u(this,"raycaster",[]),u(this,"_selectStartFn"),u(this,"_selectEndFn"),u(this,"_selectUpdateFn"),u(this,"_handleEventFn"),u(this,"lastPointerEvent",null),u(this,"objectsHoveredThisFrame",[]),u(this,"objectsHoveredLastFrame",[]),u(this,"raisedPointerDownEvents",[]),u(this,"raisedPointerDownObjects",[]),u(this,"_didMove",!1),u(this,"_tempComponentsArray",[]),u(this,"_sortedHits",[]),u(this,"_sortingBuffer",[]),u(this,"_noDepthTestingResults",[]),u(this,"handleEventsArray",[]),u(this,"out",{}),u(this,"currentActiveMeshUIComponents",[]),Jl.systems.push(this)}static createIfNoneExists(i){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Jl.systems.length<=0&&Jl.systems.push(...ee.findObjectsOfType(Jl,i)));for(const t of Jl.systems)if(t.context===i)return;const e=new De;ee.addNewComponent(e,Jl),i.scene.add(e)}static get systems(){const i=Lt.Current;return this._eventSystemMap.has(i)||this._eventSystemMap.set(i,[]),this._eventSystemMap.get(i)}static get(i){const e=this._eventSystemMap.get(i);return e&&e.length>0?e[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(i,e){Kl.update(i,e)}static markUIDirty(i){Kl.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){Jl.systems.splice(Jl.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ee.findObjectOfType(cf,this.context)){const i=ee.addNewComponent(this.context.scene,Yl);this.raycaster.push(i),qi()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(i){var e;i&&this.raycaster&&!this.raycaster.includes(i)&&((e=this.raycaster)==null||e.push(i))}unregister(i){var e,t;const s=(e=this.raycaster)==null?void 0:e.indexOf(i);s!==void 0&&s!==-1&&((t=this.raycaster)==null||t.splice(s,1))}onEnable(){const i=new Map;this._selectStartFn??(this._selectStartFn=(t,s)=>{if(!s.grab)return;Kl.resetLastSelected();const r=new bc(this.context.input);r.inputSource=t,r.pointerId=0,r.isDown=t.selectionDown,r.isUp=t.selectionUp,r.isPressed=t.selectionPressed,r.isClicked=!1,i.set(t,s.grab),s.grab&&!this.handleEvents(s.grab,r)&&(s.grab=null)}),this._selectEndFn??(this._selectEndFn=(t,s)=>{var r;if(!s.grab)return;const n=new bc(this.context.input);n.inputSource=t,n.pointerId=0,n.isDown=t.selectionDown,n.isUp=t.selectionUp,n.isPressed=t.selectionPressed,n.isClicked=t.selectionClick,this.handleEvents(s.grab,n);const o=i.get(t);if(i.set(t,null),o)for(let a=0;a<this.raisedPointerDownEvents.length;a++){const l=this.raisedPointerDownEvents[a];this.raisedPointerDownObjects[a]===o&&l&&((r=l.onPointerUp)==null||r.call(l,n),this.raisedPointerDownEvents.splice(a,1),this.raisedPointerDownObjects.splice(a,1),a--)}});const e=new Go;this._selectUpdateFn??(this._selectUpdateFn=t=>{e.ray=t.getRay();const s=this.performRaycast(e);if(!s)return;const r=new bc(this.context.input);r.inputSource=t,this.handleIntersections(s,r)}),vs.addEventListener(ql.SelectStart,this._selectStartFn),vs.addEventListener(ql.SelectEnd,this._selectEndFn),vs.addEventListener(ql.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){vs.removeEventListener(ql.SelectStart,this._selectStartFn),vs.removeEventListener(ql.SelectEnd,this._selectEndFn),vs.removeEventListener(ql.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(),wt.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const n=this.context.input.getPointerPositionRC(0);if(n&&n.x===0&&n.y===0)return;this._didMove=!0}let i=0;for(const n of this.context.input.foreachPointerId()){const o=this.context.input.getPointerDown(n),a=this.context.input.getPointerUp(n);if(o||a){i=n;break}}const e=this.context.input.getPointerEvent(i),t=new bc(this.context.input,e);t.inputSource=this.context.input,t.pointerId=i,t.isClicked=this.context.input.getPointerClicked(i),t.isDown=this.context.input.getPointerDown(i),t.isUp=this.context.input.getPointerUp(i),t.isPressed=this.context.input.getPointerPressed(i),dv&&t.isClicked&&console.log("CLICK",i);const s=this.performRaycast(null);if(!s)return;this.lastPointerEvent=t;const r={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};dv&&t.isClicked&&hs("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:r})),this.handleIntersections(s,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:r}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const e of this.raisedPointerDownEvents)e.onPointerUp&&e.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const e of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(e)<0){this._tempComponentsArray.length=0;const t=ee.getComponentsInParent(e,Me,this._tempComponentsArray);this.lastPointerEvent.object=e;for(let s=0;s<t.length;s++){const r=t[s];if(!r.gameObject||r.destroyed)continue;const n=r;n.onPointerExit&&n.onPointerExit(this.lastPointerEvent)}}const i=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=i}performRaycast(i){if(!this.raycaster)return null;this._sortedHits.length=0;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;const t=e.performRaycast(i);t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.distance),this._sortedHits}handleIntersections(i,e){if(!i||i.length<=0)return!1;i=this.sortCandidates(i);for(const t of i){const{object:s}=t;if(this.handleEvents(s,e))return!0}return!1}sortCandidates(i){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<i.length;e++){const t=i[e],s=t.object;if(s.material&&s.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEvents(i,e){if(!this.testIsVisible(i))return e.isClicked&&dv&&console.log("not allowed",i),!1;const t=i;e.object=i,this.lastPointerEvent=e;const s=i.parent;let r=!1;const n=e.isClicked??!1;let o=null;if(s&&s.isUI){const a=(e.isPressed||e.isClicked)??!1;if(s[Na]){const l=s[Na].gameObject;if(l){if(!rf.isInteractable(l,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(i,a),i=l,r=!0}}if(!r&&this.handleMeshUiObjectWithoutShadowDom(s,a))return!0}if(n&&dv&&console.log(this.context.time.frame,i),this.objectsHoveredThisFrame.push(i),o===null||o.interactable){const a=this.objectsHoveredLastFrame.indexOf(i)>=0;this.handleEventsArray.length=0;const l=ee.getComponentsInParent(i,Me,this.handleEventsArray);for(let c=0;c<l.length;c++){if(e.used)return!0;if(l[c].destroyed)continue;const h=l[c];if(h.interactable!==!1){if(h.onPointerEnter&&(a||h.onPointerEnter(e)),h.onPointerMove&&h.onPointerMove(e),e.isDown&&h.onPointerDown&&!this.raisedPointerDownEvents.includes(h)&&(h.onPointerDown(e),this.raisedPointerDownEvents.push(h),this.raisedPointerDownObjects.push(t)),e.isUp&&h.onPointerUp){const d=this.raisedPointerDownEvents.indexOf(h);d!==-1&&this.raisedPointerDownEvents.splice(d,1),h.onPointerUp(e)}e.isClicked&&h.onPointerClick&&h.onPointerClick(e)}}}return!0}handleMeshUiObjectWithoutShadowDom(i,e){return!i||!i.isUI?!0:this.handleMeshUIIntersection(i,e)}handleMeshUIIntersection(i,e){const t=Kl.updateState(i,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Kl.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let i=0;i<this.currentActiveMeshUIComponents.length;i++){const e=this.currentActiveMeshUIComponents[i];Kl.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(i){return i?ee.isActiveSelf(i)?this.testIsVisible(i.parent):!1:!0}};let Fn=Jl;u(Fn,"_eventSystemMap",new Map),u(Fn,"didSearchEventSystem",!1);class Kl{static markDirty(){this.needsUpdate=!0}static update(e,t){const s=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(s===r.frame)return;r.frame=s;let n=this.needsUpdate||s<1;r.nextUpdate===t.time.frameCount&&(n=!0),n&&(dv&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:s,nextUpdate:s}],e.update()}static updateState(e,t){let s=null;if(e&&(s=this.findBlockInParent(e),s&&s!==this.lastSelected)){if(s.interactable===!1)return null;this.needsUpdate=!0}return s}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}u(Kl,"lastSelected",null),u(Kl,"lastUpdateFrame",[]),u(Kl,"needsUpdate",!1);const kx=Symbol("cameraController");function tse(i){return i[kx]}function V3(i,e,t){t?i[kx]=e:i[kx]===e&&(i[kx]=null)}var ise=Object.defineProperty,sse=Object.getOwnPropertyDescriptor,rse=(i,e,t,s)=>{for(var r=s>1?void 0:s?sse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ise(e,t,r),r};const Dx=re("freecam"),ET=re("debugcamerafit"),nse={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let MT;class Zl extends Me{constructor(){super(...arguments),u(this,"autoRotate",!1),u(this,"autoRotateSpeed",1),u(this,"enableKeys",!0),u(this,"enableDamping",!0),u(this,"dampingFactor",.1),u(this,"enableZoom",!0),u(this,"minZoom",0),u(this,"maxZoom",1/0),u(this,"enablePan",!0),u(this,"lookAtConstraint",null),u(this,"lookAtConstraint01",1),u(this,"middleClickToFocus",!0),u(this,"doubleClickToFocus",!0),u(this,"useSlerp",!0),u(this,"debugLog",!1),u(this,"targetLerpSpeed",5),u(this,"_lookTargetPosition"),u(this,"_controls",null),u(this,"_cameraObject",null),u(this,"_lerpToTargetPosition",!1),u(this,"_lerpCameraToTarget",!1),u(this,"_cameraTargetPosition",null),u(this,"_inputs",0),u(this,"_enableTime",0),u(this,"_startedListeningToKeyEvents",!1),u(this,"_eventSystem"),u(this,"_afterHandleInputFn"),u(this,"_camera",null),u(this,"_syncedTransform"),u(this,"targetElement",null),u(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),u(this,"_shouldDisable",!1),u(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}awake(){this._lookTargetPosition=new S,this._startedListeningToKeyEvents=!1}start(){if(this._controls){const e=ee.getComponent(this.gameObject,Di);if(e&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const t=yt(e.cam).length(),s=new S(0,0,-t).applyMatrix4(e.cam.matrixWorld);this.setTarget(s,!0)}}this.startCoroutine(this.startRaycastDelayed()),this._eventSystem=Fn.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(CT.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(CT.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=ee.getComponent(this.gameObject,Di);this._camera=e;const t=e?.cam;if(t&&V3(t,this,!0),!this._controls){console.assert(t!=null,"Missing camera",this),t&&(this._cameraObject=t);const s=this.targetElement??this.context.domElement,r=t?.quaternion.clone();this._controls=new rZ(t,s),t?.quaternion.copy(r),MT===void 0&&(MT={...this._controls.keys})}this._controls&&(Dx&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Cc()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?Dx||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Dx||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=ee.getComponent(this.gameObject,mh)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&V3(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,!this.setFromTargetPosition()){const e=new Go;e.screenPoint=new Y(0,0),e.lineThreshold=.1;const t=this.context.physics.raycast(e);t.length>0&&this.setTarget(t[0].point,!0)}}onBeforeRender(){var e,t,s;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 r=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(r||(r=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),r?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const n=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const o=(e=this._cameraObject)==null?void 0:e.position;Zk(o,this._cameraTargetPosition,n)}else(t=this._cameraObject)==null||t.position.lerp(this._cameraTargetPosition,n);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,n),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!Dx&&(s=this.lookAtConstraint)!=null&&s.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?MT:nse,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(e,t=!1){var s;e?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=e.clone(),t&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(e=0,t=1){var s;if(!this._controls)return!1;const r=(s=this.lookAtConstraint)==null?void 0:s.sources;if(r&&r.length>0){const n=r[e];if(n)return n.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,t),!0}return!1}setTarget(e=null,t=!1){this._controls&&(e!==null&&this._lookTargetPosition.copy(e),t?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(e,t){this._controls&&this._controls.target.lerp(e,t)}distanceToTarget(e){return this._controls?this._controls.target.distanceTo(e):-1}setTargetFromRaycast(){var e,t;if(!this.controls)return;const s=this.context.physics.raycast();for(const r of s)if(r.distance>0&&ee.isActiveInHierarchy(r.object)){if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const n=yt(this.context.mainCamera);this._cameraTargetPosition=n.clone().sub(this.controls.target).add(this._lookTargetPosition),(t=(e=this._cameraObject)==null?void 0:e.parent)==null||t.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(e,t=1.1){const s=this._cameraObject,r=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!s||!r)return;const n=new S,o=new S,a=new Es;a.makeEmpty();for(const v of e)v instanceof hC||v instanceof cC||a.expandByObject(v,!0);if(s.updateMatrixWorld(),s.updateProjectionMatrix(),a.getCenter(o),a.applyMatrix4(s.matrixWorldInverse),a.getSize(n),a.setFromCenterAndSize(o,n),n.length()<=1e-10){ET&&console.warn("Camera fit size is zero",a,[...e]);return}const l=s.fov,c=2*Math.atan(Math.tan(l*Math.PI/360/2)*s.aspect)/Math.PI*360,h=n.y/(2*Math.atan(Math.PI*l/360)),d=n.x/(2*Math.atan(Math.PI*c/360)),p=t*Math.max(h,d)+n.z/2;ET&&console.log("Fit camera to objects",h,d,"distance",p);const f=yt(s),m=r.target.clone().sub(f).normalize().multiplyScalar(p);if(r.maxDistance=p*10,r.minDistance=p*.01,r.target.copy(o),s.near=p/100,s.far=p*100,s.updateMatrixWorld(),s.updateProjectionMatrix(),is(s,r.target.clone().sub(m)),ET){const v=new hC(a);this.context.scene.add(v),oD(v,ky(s)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",A=>{A.code==="KeyF"&&this.fitCamera(e)}))}r.update()}}rse([w(Hg)],Zl.prototype,"lookAtConstraint",2);var ose=Object.defineProperty,ase=Object.getOwnPropertyDescriptor,_o=(i,e,t,s)=>{for(var r=s>1?void 0:s?ase(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ose(e,t,r),r},W3=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(W3||{});const pv=re("debugcam"),q3=re("debugscreenpointtoray");var Ox;const fv=(Ox=class extends Me{constructor(){super(...arguments),u(this,"_nearClipPlane",.1),u(this,"_farClipPlane",1e3),u(this,"orthographic",!1),u(this,"orthographicSize",5),u(this,"ARBackgroundAlpha",0),u(this,"_cullingMask",4294967295),u(this,"_backgroundBlurriness"),u(this,"_backgroundIntensity"),u(this,"_targetTexture",null),u(this,"_backgroundColor"),u(this,"_fov"),u(this,"_cam",null),u(this,"_clearFlags",2),u(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof Xt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof Xt?this._cam.fov:this._fov}set fieldOfView(i){const e=this.fieldOfView!=i;if(this._fov=i,e&&this._cam&&this._cam instanceof Xt){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(i){const e=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&e&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const e=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&e&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,e,t){let s=this.cam;const r=fv._origin;r.set(i,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),q3&&console.log("screenPointToRay",i.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const n=fv._direction.set(r.x,r.y,r.z),o=yt(s);return n.sub(o),n.normalize(),t?(t.set(o,n),t):new _a(o.clone(),n.clone())}awake(){q3&&window.addEventListener("pointerdown",i=>{const e=i.clientX,t=i.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const s=this.screenPointToRay(e,t),r="#"+Math.floor(Math.random()*16777215).toString(16);Ll.DrawRay(s.origin,s.direction,r,10)})}onEnable(){pv&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),cse(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 i=this.context.renderer;i&&this._targetTexture.render(this.context.scene,this._cam,i)}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let e=null;if(i?(e=this.gameObject,e?.layers.enableAll(),e instanceof Xt&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Xt&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Xt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new cu(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){pv&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,pv&&hs("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(fv.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 i=this._backgroundColor.alpha;fv.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,i)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new lse(this)),this._skybox.enable()}static backgroundShouldBeTransparent(i){var e,t,s,r;const n=(e=i.renderer.xr)==null?void 0:e.getSession();if(!n)return!1;const o=n.environmentBlendMode;pv&&hs("Environment blend mode: "+o+" on "+navigator.userAgent);const a=o==="additive"||o==="alpha-blend";return i.xrSessionMode===Mg.ImmersiveAR&&o==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))?!0:a}},u(Ox,"_origin",new S),u(Ox,"_direction",new S),Ox);let Di=fv;_o([w()],Di.prototype,"fieldOfView",1),_o([w()],Di.prototype,"nearClipPlane",1),_o([w()],Di.prototype,"farClipPlane",1),_o([w()],Di.prototype,"clearFlags",1),_o([w()],Di.prototype,"orthographic",2),_o([w()],Di.prototype,"orthographicSize",2),_o([w()],Di.prototype,"ARBackgroundAlpha",2),_o([w()],Di.prototype,"cullingMask",1),_o([w()],Di.prototype,"backgroundBlurriness",1),_o([w()],Di.prototype,"backgroundIntensity",1),_o([w(Ai)],Di.prototype,"backgroundColor",1),_o([w(Qp)],Di.prototype,"targetTexture",1);class lse{constructor(e){u(this,"_camera"),u(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(pv&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=st,this._skybox.mapping=Zn,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function cse(i){re("freecam")&&i.context.mainCameraComponent===i&&ee.getOrAddComponent(i.gameObject,Zl)}class hf extends Me{constructor(){super(...arguments),u(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new sC),this._listener}awake(){fs.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=ee.getComponentInParent(this.gameObject,Di);t?t.cam.add(e):this.gameObject.add(e)})}}var hse=Object.defineProperty,use=Object.getOwnPropertyDescriptor,Lx=(i,e,t,s)=>{for(var r=s>1?void 0:s?use(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&hse(e,t,r),r};const dse=re("debugsignals");class mv{constructor(){u(this,"guid")}}Lx([w()],mv.prototype,"guid",2);class uf{constructor(){u(this,"signal"),u(this,"reaction")}}Lx([w(mv)],uf.prototype,"signal",2),Lx([w(pn)],uf.prototype,"reaction",2);var TT;const $l=(TT=class extends Me{constructor(){super(...arguments),u(this,"events")}static invoke(i){if($l.receivers[i]){const e=$l.receivers[i];if(!e)return;for(const t of e)t.invoke(i)}}awake(){dse&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)$l.receivers[i.signal.guid]||($l.receivers[i.signal.guid]=[]),$l.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if($l.receivers[i.signal.guid]){const e=$l.receivers[i.signal.guid].indexOf(this);e>=0&&$l.receivers[i.signal.guid].splice(e,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;let e=typeof i=="object"?i.guid:i;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(s){console.error(s)}}},u(TT,"receivers",{}),TT);let df=$l;Lx([w(uf)],df.prototype,"events",2);var Nn=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(Nn||{}),Qa=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Qa||{}),IT=(i=>(i.Signal="SignalEmitter",i))(IT||{});const gv=re("debugtimeline"),RT=class extends Me{constructor(){super(...arguments),u(this,"playableAsset"),u(this,"playOnAwake"),u(this,"extrapolationMode",1),u(this,"waitForAudio",!0),u(this,"_visibilityChangeEvt"),u(this,"_clonedPlayableAsset",!1),u(this,"_speed",1),u(this,"_guidsMap"),u(this,"_isPlaying",!1),u(this,"_internalUpdateRoutine"),u(this,"_isPaused",!1),u(this,"_time",0),u(this,"_duration",0),u(this,"_weight",1),u(this,"_animationTracks",[]),u(this,"_audioTracks",[]),u(this,"_signalTracks",[]),u(this,"_controlTracks",[]),u(this,"_customTracks",[]),u(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks])}static registerCreateTrack(i,e){this.createTrackFunctions[i]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(gv||Rr())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,e,t;gv&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var i,e;for(const t of this._audioTracks)(i=t.onEnable)==null||i.call(t);for(const t of this._customTracks)(e=t.onEnable)==null||e.call(t);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 i,e;this.stop();for(const t of this._audioTracks)(i=t.onDisable)==null||i.call(t);for(const t of this._customTracks)(e=t.onDisable)==null||e.call(t);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const e of this._allTracks)for(const t of e)(i=t.onDestroy)==null||i.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,i&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const e=[];for(const t of this._audioTracks){const s=t.loadAudio(this._time,1,0);s&&e.push(s)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!fs.userInteractionRegistered&&this.waitForAudio;)await dm(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 t of this._audioTracks)t.stop();const i=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!e&&this.invokePauseChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null}evaluate(){if(!this.isValid())return;let i=this._time;switch(this.extrapolationMode){case 0:this._speed>0?i=Math.min(i,this._duration):this._speed<0&&(i=Math.max(i,0)),this._time=i;break;case 1:i%=this._duration,this._time=i;break;case 2:if(i>this._duration){this.stop();return}break}this.internalEvaluate(i)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const i of this._allTracks)for(const e of i)yield e}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onPauseChanged)==null||i.call(e)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(i){for(const e of this.playableAsset.tracks)if(!e.muted)switch(e.type){case Nn.Activation:for(let t=0;t<e.outputs.length;t++){const s=e.outputs[t];if(typeof s=="object"){let r=!1;for(const o of e.clips)o.start<=i&&i<=o.end&&(r=!0);const n=s;n.visible!==void 0&&(n.visible=r)}}break}for(const e of this._animationTracks)e.evaluate(i);for(const e of this._audioTracks)e.evaluate(i);for(const e of this._signalTracks)e.evaluate(i);for(const e of this._controlTracks)e.evaluate(i);for(const e of this._customTracks)e.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=VA(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let s=e.outputs[t];if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const r=ee.findByGuid(s,i);r===null||typeof r!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",s,e.name,e.type)):(gv&&console.log("Resolved binding",s,"to",r),e.outputs[t]=r)}else if(s===null){if(e.outputs.splice(t,1),RT.createTrackFunctions[e.type])continue;e.type!==Nn.Audio&&e.type!==Nn.Control&&e.type!==Nn.Marker&&e.type!==Nn.Signal&&console.warn("Missing binding",s,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===Nn.Control)for(let t=0;t<e.clips.length;t++){const s=e.clips[t];let r=s.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const n=ee.findByGuid(r,i);n===null||typeof n!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,s):(gv&&console.log("Resolved binding",r,"to",n),s.asset.sourceObject=n)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){for(const e of i.clips)e.end>this._duration&&(this._duration=e.end);for(const e of i.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var i,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=ee.findObjectOfType(hf,this.context);for(const s of this.playableAsset.tracks){const r=s.type,n=RT.createTrackFunctions[r];if(n!=null){const o=n(this,s);if(typeof o.evaluate=="function"){o.director=this,o.track=s,this._customTracks.push(o);continue}}if(s.type===Nn.Animation){if(s.clips.length<=0){gv&&console.warn("Animation track has no clips",s);continue}for(let o=s.outputs.length-1;o>=0;o--){let a=s.outputs[o];if(a instanceof De){const c=ee.getOrAddComponent(a,Vr);c&&(a=c)}const l=(i=a?.gameObject)==null?void 0:i.animations;if(l){const c=new Ux;c.trackOffset=s.trackOffset,c.director=this,c.track=s;for(let h=0;h<s.clips.length;h++){const d=s.clips[h],p=d.asset;if(!p){console.error("MISSING anim model?","clip#"+h,d,s,this.playableAsset,this.name);continue}const f=p.clip;let m=f;if((typeof m=="string"||typeof m=="number")&&(m=l.find(A=>A.name===f)),!m){console.warn("Could not find animationClip for model",d,s.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}c.mixer||(c.mixer=new yy(a.gameObject)),c.clips.push(m),c.mixer.uncacheAction(m),c.createHooks(d.asset,m);const v=c.mixer.clipAction(m);c.actions.push(v),c.models.push(d)}this._animationTracks.push(c)}}}else if(s.type===Nn.Audio){if(s.clips.length<=0)continue;const o=new yv;if(o.director=this,o.track=s,this._audioTracks.push(o),!t)continue;o.listener=t.listener;for(let a=0;a<s.clips.length;a++){const l=s.clips[a];o.addModel(l)}}else if(s.type===Nn.Marker){const o=new bv;o.director=this,o.track=s;for(const a of s.markers)switch(a.type){case IT.Signal:o.models.push(a),o.didTrigger.push(!1);break}if(o!==null&&o.models.length>0){const a=ee.getComponent(this.gameObject,df);a&&(o.receivers.push(a),this._signalTracks.push(o))}}else if(s.type===Nn.Signal){const o=new bv;o.director=this,o.track=s;for(const a of s.markers)o.models.push(a),o.didTrigger.push(!1);for(const a of s.outputs)o.receivers.push(a);this._signalTracks.push(o)}else if(s.type===Nn.Control){const o=new Fx;o.director=this,o.track=s;for(const a of s.clips)o.models.push(a);o.resolveSourceObjects(this.context),this._controlTracks.push(o)}}}setAudioTracksAllowPlaying(i){for(const e of this._audioTracks)e.onAllowAudioChanged(i)}};let Qu=RT;u(Qu,"createTrackFunctions",{});const ju=re("debugtimeline");class vv{constructor(){u(this,"director"),u(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let s=this.track.clips.length-1;s>=0;s--)yield this.track.clips[s];else for(const s of this.track.clips)yield s}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,s,r=!0){if(t<0||t>=s.length)return 0;const n=s[t];if(r||e>=n.start&&e<=n.end){let o=1,a=!1;if(n.easeInDuration>0){const l=Math.min((e-n.start)/n.easeInDuration,1);o*=l}if(n.easeOutDuration>0&&!a){const l=Math.min((n.end-e)/n.easeOutDuration,1);o*=l}return o}return 0}}class pse{constructor(e){u(this,"clip"),u(this,"rootPositionOffset"),u(this,"rootQuaternionOffset"),u(this,"rootStartPosition"),u(this,"rootEndPosition"),u(this,"rootStartQuaternion"),u(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const s=e.getRoot(),r=s.name+".position",n=s.name+".quaternion";ju&&console.log(t.name,t.tracks,r);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(r))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),ju&&console.log(this.rootPositionOffset);else if(o.name.endsWith(n)&&(this.rootStartQuaternion=new Ue().fromArray(o.values,0),this.rootEndQuaternion=new Ue().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),ju)){const a=new Ys().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Ux extends vv{constructor(){super(...arguments),u(this,"models",[]),u(this,"trackOffset"),u(this,"target"),u(this,"mixer"),u(this,"clips",[]),u(this,"actions",[]),u(this,"_actionOffsets",[]),u(this,"_didBind",!1),u(this,"_animator",null),u(this,"_animatorWasEnabled",!1),u(this,"_useclipOffsets",!0),u(this,"_totalOffsetPosition",new S),u(this,"_totalOffsetRotation",new Ue),u(this,"_totalOffsetPosition2",new S),u(this,"_totalOffsetRotation2",new Ue),u(this,"_summedPos",new S),u(this,"_tempPos",new S),u(this,"_summedRot",new Ue),u(this,"_tempRot",new Ue),u(this,"_clipRotQuat",new Ue)}onPauseChanged(){this._animator&&this._animatorWasEnabled!==void 0&&(this._animator.enabled=this.director.isPlaying===!1?this._animatorWasEnabled:!1)}createHooks(e,t){var s,r;if(((s=t.tracks)==null?void 0:s.length)<=0){console.warn("No tracks in AnimationClip",t);return}const n=t.tracks[0].name.split("."),o=n[n.length-2],a=o+".position",l=o+".quaternion";let c=!1,h=!1;for(const d of t.tracks)d.name.endsWith(a)?(c=!0,this.createPositionInterpolant(t,e,d)):d.name.endsWith(l)&&(h=!0,this.createRotationInterpolant(t,e,d));if(!c||!h){const d=(r=this.mixer)==null?void 0:r.getRoot(),p=t.tracks[0],f=p.name.lastIndexOf("."),m=p.name.substring(0,f),v=m.substring(m.lastIndexOf(".")+1),A=d.getObjectByName(v);if(A)if(c){if(!h){const g=t.tracks[0].name.substring(0,f)+".quaternion";ju&&console.warn("Create quaternion track",v,A);const b=A.quaternion,y=new wa(g,[0,t.duration],[b.x,b.y,b.z,b.w,b.x,b.y,b.z,b.w]);t.tracks.push(y),this.createRotationInterpolant(t,e,y)}}else{const g=m+".position";ju&&console.warn("Create position track",v,A);const b=A.position,y=new Qc(g,[0,t.duration],[b.x,b.y,b.z,b.x,b.y,b.z]);t.tracks.push(y),this.createPositionInterpolant(t,e,y)}}}bind(){if(!this._didBind){this._didBind=!0,ju&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new pse(e);this._actionOffsets.push(t)}this.target&&(this._animator=ee.getComponent(this.target,Vr)??null,this._animator?(this._animatorWasEnabled=this._animator.enabled,this._animator.enabled=!1):this._animatorWasEnabled=!1);for(const e of this.models){const t=e.asset,s=t.position,r=t.rotation;s&&s.x!==void 0&&(s.isVector3||(t.position=new S(s.x,s.y,s.z)),r.isQuaternion||(t.rotation=new Ue(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new S(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Ue(t.x,t.y,t.z,t.w)))}}evaluate(e){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 t=0,s=0,r=!1,n=!1;for(let o=0;o<this.clips.length;o++){const a=this.models[o],l=this.actions[o],c=a.asset;l.weight=0;const h=e>=a.start&&e<=a.end,d=a.preExtrapolationMode,p=a.postExtrapolationMode,f=o<this.clips.length-1?this.models[o+1]:null;let m=h,v=!1;if(!m&&!r&&a.end<e&&p!==Qa.None?(!f||f.start>e)&&(m=!0,r=!0):o==0&&!m&&!n&&a.start>e&&d!==Qa.None&&(!f||f.start<e)&&(m=!0,v=!0,n=!0),m){let A=1;A*=this.evaluateWeight(e,o,this.models,m),A*=this.director.weight;let g=h;if(v)switch(d){case Qa.Hold:break;case Qa.Loop:e+=a.start,g=!0;break;default:e+=a.start,g=!0;break}let b=this.getClipTime(e,a),y=0;const x=c.duration;if(v&&d===Qa.Hold&&(b=0),g){if(c.loop)for(y+=Math.floor(b/(x+1e-6));b>x;)b-=x}else if(!h&&r)switch(p){case Qa.Hold:b=this.getClipTime(a.end,a);break;case Qa.Loop:b%=x;break;case Qa.PingPong:const E=Math.floor(b/x)%2!==0;b%=x,E&&(b=x-b);break}a.reversed===!0?l.time=l.getClip().duration-b:l.time=b,l.timeScale=0;const _=A;if(l.weight=_,l.clampWhenFinished=!0,l.isRunning()||l.play(),this._useclipOffsets){const E=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,I=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(s=1-A),t+=1;const P=this._summedPos.set(0,0,0),M=this._tempPos.set(0,0,0),C=this._summedRot.identity(),U=this._tempRot.identity(),G=c.rotation;G&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(G,A));const F=this._actionOffsets[o];if(F.hasOffsets)for(let z=0;z<y;z++)F.rootPositionOffset?M.copy(F.rootPositionOffset):M.set(0,0,0),M.applyQuaternion(C),this._clipRotQuat&&M.applyQuaternion(this._clipRotQuat),F.rootQuaternionOffset&&(U.copy(F.rootQuaternionOffset),C.multiply(U)),P.add(M);this._clipRotQuat&&I.multiply(this._clipRotQuat),I.multiply(C),c.position&&P.add(c.position),E.add(P)}}}this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.mixer.update(e)}createRotationInterpolant(e,t,s){var r;const n=s.createInterpolant.bind(s),o=new Ue;this.ensureTrackOffsets();const a=(r=this.trackOffset)==null?void 0:r.rotation;s.createInterpolant=()=>{const l=n(),c=l.evaluate.bind(l);return l.evaluate=h=>{const d=c(h);return o.set(d[0],d[1],d[2],d[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),d[0]=o.x,d[1]=o.y,d[2]=o.z,d[3]=o.w,d},l}}createPositionInterpolant(e,t,s){var r,n;const o=s.createInterpolant.bind(s),a=new S;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation,c=(n=this.trackOffset)==null?void 0:n.position;let h;s.createInterpolant=()=>{const d=o(),p=d.evaluate.bind(d);return d.evaluate=f=>{var m,v;const A=p(f);return a.set(A[0],A[1],A[2]),t.removeStartOffset&&(h===void 0?(h=null,h=(v=(m=this._actionOffsets.find(g=>g.clip===e))==null?void 0:m.rootStartPosition)==null?void 0:v.clone()):h!=null&&h.isVector3&&a.sub(h)),a.applyQuaternion(this._totalOffsetRotation),a.add(this._totalOffsetPosition),l&&a.applyQuaternion(l),c&&(a.x-=c.x,a.y+=c.y,a.z+=c.z),A[0]=a.x,A[1]=a.y,A[2]=a.z,A},d}}}const fse=re("mutetimeline"),Av=class extends vv{constructor(){super(...arguments),u(this,"models",[]),u(this,"listener"),u(this,"audio",[]),u(this,"audioContextTimeOffset",[]),u(this,"lastTime",0),u(this,"_audioLoader",null)}getAudioFilePath(i){const e=this.director.sourceId;return Sc(e,i)}onAllowAudioChanged(i){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(i?t.asset.volume:0)}}addModel(i){const e=new Ay(this.listener);this.audio.push(e),this.models.push(i)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop()}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}evaluate(i){if(fse||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=e?.1:0;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=this.audio[s];if((!n||!n.buffer)&&this.isInTimeRange(r,i-1,i+1)&&this.handleAudioLoading(r,n),fs.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale,n.loop=r.asset.loop,i>=r.start&&i<=r.end&&i<this.director.duration){if(this.director.isPlaying==!1){if(n.isPlaying&&n.stop(),this.lastTime===i)continue}else if(!n.isPlaying)n.offset=r.clipIn+(i-r.start)*r.timeScale,n.play(t);else{const a=r.clipIn+(i-r.start)*r.timeScale,l=n.context.currentTime-n._startedAt+n.offset;Math.abs(a-l)>.3&&(n.offset=a,n.stop(),n.play(t))}let o=r.asset.volume;if(e&&(o=0),r.easeInDuration>0){const a=Math.min((i-r.start)/r.easeInDuration,1);o*=a}if(r.easeOutDuration>0){const a=Math.min((r.end-i)/r.easeOutDuration,1);o*=a}n.setVolume(o*this.director.weight)}else n.isPlaying&&n.stop()}this.lastTime=i}loadAudio(i,e=0,t=0){let s=null;const r=i-t,n=i+e;for(const o of this.models)if(this.isInTimeRange(o,r,n)){const a=this.audio[this.models.indexOf(o)],l=this.handleAudioLoading(o,a);l!==null&&(s===null&&(s=[]),s.push(l))}return s!==null?Promise.all(s):null}isInTimeRange(i,e,t){return e<=i.start&&t>=i.end||e>=i.start&&e<=i.end||t>=i.start&&t<=i.end}static dispose(){Av._audioBuffers.clear()}handleAudioLoading(i,e){this._audioLoader||(this._audioLoader=new gy);const t=this.getAudioFilePath(i.asset.clip);if(Av._audioBuffers.get(t)){const r=Av._audioBuffers.get(t);return r.then(n=>{n&&e.setBuffer(n)}),r}ju&&console.warn("LOAD audio track",t,this.director.sourceId);const s=new Promise((r,n)=>{this._audioLoader.load(t,o=>{e.setBuffer(o),r(o)},void 0,o=>{console.error("Error loading audio",o),r(null)})});return Av._audioBuffers.set(t,s),s}};let yv=Av;u(yv,"_audioBuffers",new Map);class bv extends vv{constructor(){super(...arguments),u(this,"models",[]),u(this,"didTrigger",[]),u(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const s=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const n=this.models[r],o=this.didTrigger[r],a=n.time-e;let l=!1;if(n.retroActive)l=a<=1e-6;else{const c=Math.abs(a);c>=1e-5&&c<s&&(l=!0)}if(l){if(!o)if(this.didTrigger[r]=!0,((t=this.receivers)==null?void 0:t.length)<=0)df.invoke(n.asset);else for(const c of this.receivers)c&&c.invoke(n.asset)}else n.emitOnce||(this.didTrigger[r]=!1)}}}class Fx extends vv{constructor(){super(...arguments),u(this,"models",[]),u(this,"timelines",[]),u(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const s=this.models[t].asset;if(!s.sourceObject||typeof s.sourceObject!="object"){console.log("no source object, removing model",t,s),this.models.splice(t,1);continue}else{const r=ee.getComponent(s.sourceObject,Qu);this.timelines.push(r),r&&s.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const o=this.getClipTime(e,r);if(n.controlActivation){const a=n.sourceObject;a.visible=!0}if(n.updateDirector){const a=this.timelines[s];a&&(a.isPlaying&&a.pause(),a.time=o,a.evaluate())}}else{const o=(t=this._previousActiveModel)==null?void 0:t.asset;if(n.controlActivation){const a=n.sourceObject;o?.sourceObject!==a&&(a.visible=!1)}}}}}var mse=Object.defineProperty,gse=Object.getOwnPropertyDescriptor,X3=(i,e,t,s)=>{for(var r=s>1?void 0:s?gse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&mse(e,t,r),r};class Et{constructor(e){u(this,"_active",!0),u(this,"_value"),u(this,"_valueRaw"),u(this,"_defaultValue"),u(this,"valueProcessor"),u(this,"onValueChanged"),this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const s=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,s,this)}testIfValueChanged(e){return this._valueRaw!==e}}X3([w()],Et.prototype,"overrideState",1),X3([w()],Et.prototype,"value",1);var vse=Object.defineProperty,Ase=Object.getOwnPropertyDescriptor,yse=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ase(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&vse(e,t,r),r};const bse=re("debugpost");class Er extends Zc{constructor(e=void 0){if(super(),u(this,"active",!0),u(this,"_result"),u(this,"_didCreateVolumeParameters",!1),e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const s=e[t],r=this[t];r instanceof Et&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){bse&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const s=this[t];s instanceof Et&&s.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Et){const n=e[r];if(n!==void 0){const o=this[r];o.value=n}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Et){const s=e.value;return this[t].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Et&&(this[t]||(this[t]=new Et))}}yse([w()],Er.prototype,"active",2);var xse=Object.defineProperty,_se=Object.getOwnPropertyDescriptor,wse=(i,e,t,s)=>{for(var r=s>1?void 0:s?_se(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&xse(e,t,r),r};const Sse=re("debugpost"),PT={};function wo(i,e){PT[i]=e}function Cse(i){return i.__type in PT?PT[i.__type]:(Sse&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),Er)}class xv{constructor(){u(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}wse([Np([i=>Cse(i),Er])],xv.prototype,"components",2);var Ese=Object.defineProperty,Mse=Object.getOwnPropertyDescriptor,Tse=(i,e,t,s)=>{for(var r=s>1?void 0:s?Mse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Ese(e,t,r),r};class _v extends Er{constructor(){super(...arguments),u(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new N7({preset:Mp.HIGH,edgeDetectionMode:nE.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}Tse([w(Et)],_v.prototype,"preset",2),wo("Antialiasing",_v);class Nx{constructor(){u(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,s){const r=ee.getComponents(e,fs);if(r.length)for(const n of r){if(!n.clip||!n.playOnAwake)continue;const o=n.clip.split("/").pop();this.files.includes(n.clip)||this.files.push(n.clip),t.addEventListener("serialize",(a,l)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${n.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${n.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${n.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const s=t.split("/").pop(),r=await(await(await fetch(t)).blob()).arrayBuffer(),n=new Uint8Array(r);e.files["audio/"+s]=n}}}var Ise=Object.defineProperty,Rse=Object.getOwnPropertyDescriptor,Y3=(i,e,t,s)=>{for(var r=s>1?void 0:s?Rse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Ise(e,t,r),r};const Pse=re("debugmouth");class wv extends Me{constructor(){super(...arguments),u(this,"idle",[]),u(this,"talking",[]),u(this,"marker",null),u(this,"voip",null),u(this,"lastMouthChangeTime",0),u(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=ee.findObjectOfType(yc,this.context),this.marker||(this.marker=ee.getComponentInParent(this.gameObject,Cr))},3e3)}update(){var e;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((e=this.marker)==null?void 0:e.connectionId)??null;if(!t){Pse&&(t=null);return}const s=this.voip.getFrequency(t)??0;this.updateLips(s)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<e.length;s++){const r=e[s];r&&(r.visible=s===t)}}}}Y3([w(De)],wv.prototype,"idle",2),Y3([w(De)],wv.prototype,"talking",2);class BT extends Me{constructor(){super(...arguments),u(this,"voip",null),u(this,"marker",null),u(this,"_startPosition",null)}awake(){this.voip=ee.findObjectOfType(yc,this.context),this.marker=ee.getComponentInParent(this.gameObject,Cr)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());let s=t/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var Bse=Object.defineProperty,kse=Object.getOwnPropertyDescriptor,zx=(i,e,t,s)=>{for(var r=s>1?void 0:s?kse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Bse(e,t,r),r};class Gu extends Me{constructor(){super(...arguments),u(this,"eyes",[]),u(this,"lastBlinkTime",0),u(this,"blinkLength",0),u(this,"eyesOpen",!0),u(this,"state",null)}awake(){this.state=ee.getComponentInParent(this.gameObject,Wr)}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 e of this.eyes)e&&(e.visible=this.eyesOpen)}}}zx([w(De)],Gu.prototype,"eyes",2),zx([w()],Gu.prototype,"lastBlinkTime",2),zx([w()],Gu.prototype,"blinkLength",2),zx([w()],Gu.prototype,"eyesOpen",2);var Dse=Object.defineProperty,Ose=Object.getOwnPropertyDescriptor,kT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ose(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Dse(e,t,r),r},DT;const J3=(DT=class extends Me{constructor(){super(...arguments),u(this,"head",null),u(this,"eyes",null),u(this,"target",null),u(this,"brain",null),u(this,"vec",new S),u(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=ee.getComponentInParent(this.gameObject,qg)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=ee.addNewComponent(this.gameObject,qg)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const i=this.target;if(i&&this.head){const e=this.eyes;if(e){const t=yt(i);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const s=yt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const n=J3.forward;if(n.set(0,0,1),n.applyQuaternion(Rs(this.head)),n.dot(r)>.45)for(let o=0;o<e.length;o++)e[o].lookAt(this.currentTargetPoint)}}}},u(DT,"forward",new S(0,0,1)),DT);let pf=J3;kT([w(De)],pf.prototype,"head",2),kT([w(De)],pf.prototype,"eyes",2),kT([w(De)],pf.prototype,"target",2);var Lse=Object.defineProperty,Use=Object.getOwnPropertyDescriptor,OT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Use(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Lse(e,t,r),r};class ff extends Me{constructor(){super(...arguments),u(this,"length",1),u(this,"depthTest",!0),u(this,"isGizmo",!0),u(this,"_axes",null)}onEnable(){if(this.isGizmo&&!Zm)return;this._axes||(this._axes=new gp(this.length)),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}OT([w()],ff.prototype,"length",2),OT([w()],ff.prototype,"depthTest",2),OT([w()],ff.prototype,"isGizmo",2);class LT extends Me{constructor(){super(...arguments),u(this,"from"),u(this,"to"),u(this,"hint"),u(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;let e=yt(this.to).clone(),t=yt(this.from).clone(),s=e.distanceTo(t),r=e.clone();r.sub(t);let n=t.clone();n.add(e),n.multiplyScalar(.5);let o=yt(this.hint).clone();o.sub(n);let a=new S;a.crossVectors(o,r),a.crossVectors(r,a),a.normalize();let l=s*.5,c=Math.max(this.desiredDistance,l),h=Math.sqrt(c*c-l*l),d=a.clone();d.multiplyScalar(h),d.add(n),is(this.gameObject,d);let p=n.clone();p.sub(a),this.gameObject.lookAt(p)}}class Qx{constructor(){u(this,"behaviours",[]),u(this,"behaviourComponents",[]),u(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(s=>{ee.foreachComponent(s,r=>{var n;const o=r;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const a=(n=o.beforeCreateDocument)==null?void 0:n.call(o,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,s){var r;for(const n of this.behaviourComponents)(r=n.createBehaviours)==null||r.call(n,this,t,s)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var s;if((s=this.behaviours)!=null&&s.length){t.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){console.log("onAfterSerialize",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)console.log("behaviour",t),typeof t.afterSerialize=="function"&&(console.log("beh has afterSerialize",t),t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e))}}var Fse=Object.defineProperty,Nse=Object.getOwnPropertyDescriptor,UT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Nse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Fse(e,t,r),r};class Hu extends Er{constructor(){super(...arguments),u(this,"threshold"),u(this,"intensity"),u(this,"scatter"),u(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=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new QL(this.context.scene,this.context.mainCamera,{blendFunction:Dt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new uE;return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}}UT([w(Et)],Hu.prototype,"threshold",2),UT([w(Et)],Hu.prototype,"intensity",2),UT([w(Et)],Hu.prototype,"scatter",2),wo("Bloom",Hu);var zse=Object.defineProperty,Qse=Object.getOwnPropertyDescriptor,sa=(i,e,t,s)=>{for(var r=s>1?void 0:s?Qse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&zse(e,t,r),r};class ja extends Me{constructor(){super(...arguments),u(this,"attachedRigidbody",null),u(this,"isTrigger",!1),u(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ji))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ji))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ji))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}}sa([w(ji)],ja.prototype,"attachedRigidbody",2),sa([w()],ja.prototype,"isTrigger",2),sa([w()],ja.prototype,"sharedMaterial",2);class Sv extends ja{constructor(){super(...arguments),u(this,"radius",.5),u(this,"center",new S(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this,this.center,this.radius)}}sa([w()],Sv.prototype,"radius",2),sa([w(S)],Sv.prototype,"center",2);class Cv extends ja{constructor(){super(...arguments),u(this,"size",new S(1,1,1)),u(this,"center",new S(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.center,this.size)}}sa([w(S)],Cv.prototype,"size",2),sa([w(S)],Cv.prototype,"center",2);class Ev extends ja{constructor(){super(...arguments),u(this,"sharedMesh"),u(this,"convex",!1)}onEnable(){var e,t,s,r,n;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof xe&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,Ks(this.gameObject));else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${(r=this.sharedMesh)==null?void 0:r.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const a in o.children){const l=o.children[a];l.isMesh&&((n=this.context.physics.engine)==null||n.addMeshCollider(this,l,this.convex,Ks(this.gameObject)))}}}}}sa([w()],Ev.prototype,"convex",2);class Ah extends ja{constructor(){super(...arguments),u(this,"center",new S(0,0,0)),u(this,"radius",.5),u(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.center,this.height,this.radius)}}sa([w(S)],Ah.prototype,"center",2),sa([w()],Ah.prototype,"radius",2),sa([w()],Ah.prototype,"height",2);function FT(i){return i[Na]||(i.parent?FT(i.parent):null)}function jx(i,e){if(!i)return;const t=i.material;if(t?.isMaterial===!0){const s=i.parent;s&&s.isText,t.side=e.doubleSided??!0?Si:gr,t.shadowSide=e.doubleSided?Si:gr,i.castShadow=e.castShadows?e.castShadows:!1,i.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const s of i.children)jx(s,e)}function mf(i,e,t){i[e]===void 0&&console.warn("Field",e,"is undefined on",i);const s=Proxy.revocable(i[e],{set(o,a,l,c){const h=o[a],d=Reflect.set(o,a,l,c);return t(l,h),d}}),r=s.revoke,n=i[e];return s.revoke=()=>{i[e]=n,r()},i[e]=s.proxy,s}const K3=Symbol("Scheduled action");function jse(i,e,t=On.OnBeforeRender){let s=i[K3];s||(s=i[K3]={});const r=e.name;s[t]||(s[t]={});const n=s[t];if(n[r])return;function*o(){e?.call(i),n[r]=null}const a=i.startCoroutine(o(),t);n[r]=a}var Gse=Object.defineProperty,Hse=Object.getOwnPropertyDescriptor,Vu=(i,e,t,s)=>{for(var r=s>1?void 0:s?Hse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Gse(e,t,r),r};const NT=re("debugui"),zT=re("debuguilayout");class QT{constructor(){u(this,"width"),u(this,"height")}}class jT{constructor(){u(this,"x"),u(this,"y"),u(this,"width"),u(this,"height")}}const ra=new S,Mv=new Be,Gx=new Ue,Z3=class extends fa{constructor(){super(...arguments),u(this,"_anchoredPosition"),u(this,"sizeDelta",new Y(100,100)),u(this,"pivot",new Y(.5,.5)),u(this,"anchorMin",new Y(0,0)),u(this,"anchorMax",new Y(1,1)),u(this,"offsetMin",new Y(0,0)),u(this,"offsetMax",new Y(0,0)),u(this,"lastMatrix"),u(this,"rectBlock"),u(this,"_transformNeedsUpdate",!1),u(this,"_initialPosition"),u(this,"_parentRectTransform"),u(this,"_lastUpdateFrame",-1),u(this,"_lastAnchoring"),u(this,"_createdBlocks",[]),u(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 Y),this._anchoredPosition}set anchoredPosition(i){this._anchoredPosition=i}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const i=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;let t=i*e;return t+=this.sizeDelta.x,t}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const i=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;let t=i*e;return t+=this.sizeDelta.y,t}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new Y),this.lastMatrix=new Be,this.rectBlock=new De,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,mf(this,"_anchoredPosition",()=>{this.markDirty()}),mf(this,"sizeDelta",()=>{this.markDirty()}),mf(this,"pivot",()=>{this.markDirty()}),mf(this,"anchorMin",()=>{this.markDirty()}),mf(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var i;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(i=this.Canvas)==null||i.registerTransform(this)}onDisable(){var i;super.onDisable(),this.removeShadowComponent(),(i=this.Canvas)==null||i.unregisterTransform(this)}onParentRectTransformChanged(i){this._transformNeedsUpdate||this.onApplyTransform(zT?`${i.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(zT&&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(i){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=ee.getComponentInParent(this.gameObject.parent,Z3):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,zT&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+i),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,ra.set(0,0,0),this.applyPivot(ra),t.matrix.setPosition(ra.x,ra.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Gx.copy(this.gameObject.quaternion),Gx.x*=-1,Gx.z*=-1,Mv.makeRotationFromQuaternion(Gx),t.matrix.premultiply(Mv)),ra.set(0,0,0),this.applyAnchoring(ra),(e=this.Canvas)!=null&&e.screenspace?ra.z+=.1:ra.z+=.01,Mv.identity(),Mv.setPosition(ra.x,ra.y,ra.z),t.matrix.premultiply(Mv),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const s=!0;for(const r of $C(this.gameObject,fa,s,1)){if(r===this||!r.activeAndEnabled)continue;const n=r;n.onParentRectTransformChanged&&n.onParentRectTransformChanged(this)}}applyAnchoring(i){this._lastAnchoring||(this._lastAnchoring=new Y);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),i.x+=this._initialPosition.x-this.gameObject.position.x,i.y+=this._initialPosition.y-this.gameObject.position.y,i.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=t.height*.5*r,i.y+=s;let n=0;const o=1-this.anchorMax.x-this.anchorMin.x;n-=t.width*.5*o,i.x+=n}}applyPivot(i){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;i.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;i.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const i={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(i),i}ensureValidSize(i,e=1e-4){return i.width<=0&&(i.width=e),i.height<=0&&(i.height=1e-4),i}createNewBlock(i){i={...this.getBasicOptions(),...i},NT&&console.log(this.name,i);const e=new vT(i);return this._createdBlocks.push(e),e}createNewText(i){NT&&console.log(i),i={...this.getBasicOptions(),...i},NT&&console.log(this.name,i);const e=new z3(i);return this._createdTextBlocks.push(e),e}};let rr=Z3;Vu([w(Y)],rr.prototype,"anchoredPosition",1),Vu([w(Y)],rr.prototype,"sizeDelta",2),Vu([w(Y)],rr.prototype,"pivot",2),Vu([w(Y)],rr.prototype,"anchorMin",2),Vu([w(Y)],rr.prototype,"anchorMax",2),Vu([w(Y)],rr.prototype,"offsetMin",2),Vu([w(Y)],rr.prototype,"offsetMax",2);class Vse extends N3{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const s in t)for(const r in t[s])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(s);for(const s of e._components)e._simpleState__statesProperties[s.id]&&(e._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const s=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],s.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)s.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const s in e)this._simpleState__statesProperties[s]&&(this._simpleState__normalStyles[s]=e[s]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var Wse=Object.defineProperty,qse=Object.getOwnPropertyDescriptor,$3=(i,e,t,s)=>{for(var r=s>1?void 0:s?qse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Wse(e,t,r),r};class gf extends Me{constructor(){super(...arguments),u(this,"effectColor"),u(this,"effectDistance")}}$3([w(Ai)],gf.prototype,"effectColor",2),$3([w(Y)],gf.prototype,"effectDistance",2);var Xse=Object.defineProperty,Yse=Object.getOwnPropertyDescriptor,ez=(i,e,t,s)=>{for(var r=s>1?void 0:s?Yse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Xse(e,t,r),r};const Hx={backgroundColor:new Ae(1,1,1),backgroundOpacity:1,borderColor:new Ae(1,1,1),borderOpacity:1};var GT;const Vx=(GT=class extends fa{constructor(){super(...arguments),u(this,"_alphaFactor",1),u(this,"raycastTarget",!0),u(this,"uiObject",null),u(this,"_color",null),u(this,"_rect",null),u(this,"_stateManager",null),u(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Ai(1,1,1,1)),this._color}set color(i){(!this._color||this._color.r!==i.r||this._color.g!==i.g||this._color.b!==i.b||this._color.alpha!==i.alpha)&&(this._color||(this._color=new Ai(1,1,1,1)),this._color.copy(i))}setAlphaFactor(i){this._alphaFactor=i,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(Hx.backgroundColor=this._color,Hx.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Hx,this._alphaFactor),this.uiObject.set(Hx),this.markDirty())}get m_Color(){return this._color}get rectTransform(){return this._rect||(this._rect=ee.getComponent(this.gameObject,rr)),this._rect}onParentRectTransformChanged(){var i;(i=this.uiObject)==null||i.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(i){this.makePanel(),this.uiObject&&(this.uiObject.setState(i),this==null||this.markDirty())}setupState(i){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Vse(this.uiObject)),this.uiObject.setupState(i.state,i.attributes))}setOptions(i){this.makePanel(),this.uiObject&&this.uiObject.set(i)}awake(){super.awake(),this.makePanel(),mf(this,"_color",()=>jse(this,this.onColorChanged))}onEnable(){var i;super.onEnable(),this.uiObject&&((i=this.rectTransform.shadowComponent)==null||i.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 i=.015;const e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:i};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(i){}onCreate(i){this.uiObject=this.rectTransform.createNewBlock(i),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(i,e=1){var t;const s=(t=this.gameObject)==null?void 0:t.getComponent(gf);s&&(s.effectDistance&&(i.borderWidth=Math.max(Math.abs(s.effectDistance.x),Math.abs(s.effectDistance.y))),s.effectColor&&(i.borderColor=s.effectColor,i.borderOpacity=s.effectColor.alpha*e))}async setTexture(i){if(this.setOptions({backgroundOpacity:0}),i){if(i.colorSpace===st)if(Vx.textureCache.has(i))i=Vx.textureCache.get(i);else{const e=i.clone();e.colorSpace=Fs,Vx.textureCache.set(i,e),i=e}this.setOptions({backgroundImage:i,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)}},u(GT,"textureCache",new Map),GT);let Wu=Vx;ez([w(Ai)],Wu.prototype,"color",1),ez([w()],Wu.prototype,"raycastTarget",2);class Tv extends Wu{constructor(){super(...arguments),u(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var Jse=Object.defineProperty,Kse=Object.getOwnPropertyDescriptor,Wx=(i,e,t,s)=>{for(var r=s>1?void 0:s?Kse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Jse(e,t,r),r};let HT=class{constructor(){u(this,"texture",null),u(this,"rect")}};Wx([w(Gt)],HT.prototype,"texture",2);let vf=class extends Tv{constructor(){super(...arguments),u(this,"_sprite"),u(this,"pixelsPerUnitMultiplier",1)}set image(i){this.sprite||(this.sprite=new HT),this.sprite.texture=i,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(i){this._sprite!==i&&(this._sprite=i,this.onAfterCreated())}isBuiltinSprite(){var i,e,t,s,r,n,o,a;switch((e=(i=this.sprite)==null?void 0:i.texture)==null?void 0:e.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((r=(s=(t=this.sprite)==null?void 0:t.texture)==null?void 0:s.image)==null?void 0:r.width)===32&&((a=(o=(n=this.sprite)==null?void 0:n.texture)==null?void 0:o.image)==null?void 0:a.height)===32}onBeforeCreate(i){var e,t;super.onBeforeCreate(i),this.isBuiltinSprite()&&(i.borderRadius=5/this.pixelsPerUnitMultiplier,((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name)==="Knob"&&(i.borderRadius=999))}onAfterCreated(){var i;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((i=this.sprite)==null?void 0:i.texture))}};Wx([w(HT)],vf.prototype,"sprite",1),Wx([w()],vf.prototype,"pixelsPerUnitMultiplier",2);class qx extends Tv{constructor(){super(...arguments),u(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Wx([w(Gt)],qx.prototype,"mainTexture",1);var Zse=Object.defineProperty,$se=Object.getOwnPropertyDescriptor,zn=(i,e,t,s)=>{for(var r=s>1?void 0:s?$se(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Zse(e,t,r),r};const Af=re("debugbutton");class qu{constructor(){u(this,"colorMultiplier"),u(this,"disabledColor"),u(this,"fadeDuration"),u(this,"highlightedColor"),u(this,"normalColor"),u(this,"pressedColor"),u(this,"selectedColor")}}zn([w()],qu.prototype,"colorMultiplier",2),zn([w(Ai)],qu.prototype,"disabledColor",2),zn([w()],qu.prototype,"fadeDuration",2),zn([w(Ai)],qu.prototype,"highlightedColor",2),zn([w(Ai)],qu.prototype,"normalColor",2),zn([w(Ai)],qu.prototype,"pressedColor",2),zn([w(Ai)],qu.prototype,"selectedColor",2);class ec extends Me{constructor(){super(...arguments),u(this,"onClick"),u(this,"_isHovered",!1),u(this,"colors"),u(this,"transition"),u(this,"animationTriggers"),u(this,"animator"),u(this,"_interactable",!0),u(this,"_requestedAnimatorTrigger"),u(this,"_isInit",!1),u(this,"_image")}onPointerEnter(e){var t,s;Af&&console.log("Button Enter",(t=this.animationTriggers)==null?void 0:t.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&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;Af&&console.log("Button Exit",(e=this.animationTriggers)==null?void 0:e.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&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(e){var t,s;Af&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(e){var t,s;Af&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.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&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){var t;this.interactable&&e.pointerId===0&&(Af&&(console.warn("Button Click",this.onClick),hs("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(t=this.onClick)==null||t.invoke())}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Af&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=ee.getComponent(this.gameObject,vf),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var t,s,r,n,o;e.setInteractable(this.interactable);const a=this.getFinalColor(e.color,(t=this.colors)==null?void 0:t.normalColor),l={state:"normal",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};e.setupState(l);const c=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.highlightedColor),h={state:"hovered",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};e.setupState(h);const d=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),p={state:"pressed",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(p);const f=this.getFinalColor(e.color,(n=this.colors)==null?void 0:n.selectedColor),m={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(m);const v=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.disabledColor),A={state:"disabled",attributes:{backgroundColor:v,backgroundOpacity:v.alpha}};e.setupState(A)}getFinalColor(e,t){return t?e.clone().multiply(t):e.clone()}}zn([w(pn)],ec.prototype,"onClick",2),zn([w()],ec.prototype,"colors",2),zn([w()],ec.prototype,"transition",2),zn([w()],ec.prototype,"animationTriggers",2),zn([w(Vr)],ec.prototype,"animator",2),zn([w()],ec.prototype,"interactable",1);var ere=Object.defineProperty,tre=Object.getOwnPropertyDescriptor,As=(i,e,t,s)=>{for(var r=s>1?void 0:s?tre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ere(e,t,r),r};const tz=re("debuguilayout");class yh{constructor(){u(this,"left",0),u(this,"right",0),u(this,"top",0),u(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}As([w()],yh.prototype,"left",2),As([w()],yh.prototype,"right",2),As([w()],yh.prototype,"top",2),As([w()],yh.prototype,"bottom",2);class Qn extends Me{constructor(){super(...arguments),u(this,"_rectTransform",null),u(this,"_needsUpdate",!1),u(this,"childAlignment",0),u(this,"reverseArrangement",!1),u(this,"spacing",0),u(this,"padding"),u(this,"minWidth",0),u(this,"minHeight",0),u(this,"flexibleHeight",0),u(this,"flexibleWidth",0),u(this,"preferredHeight",0),u(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(tz&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){tz&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(rr);const e=this.gameObject.getComponentInParent(nr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(nr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}As([w()],Qn.prototype,"childAlignment",2),As([w()],Qn.prototype,"reverseArrangement",2),As([w()],Qn.prototype,"spacing",2),As([w(yh)],Qn.prototype,"padding",2),As([w()],Qn.prototype,"minWidth",2),As([w()],Qn.prototype,"minHeight",2),As([w()],Qn.prototype,"flexibleHeight",2),As([w()],Qn.prototype,"flexibleWidth",2),As([w()],Qn.prototype,"preferredHeight",2),As([w()],Qn.prototype,"preferredWidth",2);class bh extends Qn{constructor(){super(...arguments),u(this,"childControlHeight",!0),u(this,"childControlWidth",!0),u(this,"childForceExpandHeight",!1),u(this,"childForceExpandWidth",!1),u(this,"childScaleHeight",!1),u(this,"childScaleWidth",!1)}onCalculateLayout(e){var t;const s=this.primaryAxis,r=e.width;let n=r;const o=e.height;let a=o;n-=this.padding.horizontal,a-=this.padding.vertical,s==="x"?this.padding.horizontal:this.padding.vertical;const l=s==="x",c=l?"y":"x",h=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,p=l?this.childForceExpandWidth:this.childForceExpandHeight,f=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:n,v=l?r:o,A=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let g=0;l?g+=this.padding.left:g+=this.padding.top;let b=0,y=0;for(let P=0;P<this.gameObject.children.length;P++){const M=this.gameObject.children[P],C=ee.getComponent(M,rr);C!=null&&C.activeAndEnabled&&(y+=1,l?b+=C.width:b+=C.height)}let x=0;const _=this.spacing*(y-1);if(p||h){let P=0;l?P=n-=_:P=a-=_,y>0&&(x=P/y)}let E=0;E+=this.padding.left,E-=this.padding.right,A!==0&&(g=v-b,g*=A,g-=_*A,l?(g-=this.padding.right*A,g+=this.padding.left*(1-A),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*A,g+=this.padding.top*(1-A),g<this.padding.top&&(g=this.padding.top)));let I=1;for(let P=0;P<this.gameObject.children.length;P++){const M=this.gameObject.children[P],C=ee.getComponent(M,rr);if(C!=null&&C.activeAndEnabled){(t=C.pivot)==null||t.set(.5,.5),C.anchorMin.set(0,1),C.anchorMax.set(0,1);const U=r*.5+E*.5;C.anchoredPosition.x!==U&&(C.anchoredPosition.x=U);const G=o*-.5;C.anchoredPosition.y!==G&&(C.anchoredPosition.y=G),f&&d&&C.sizeDelta[c]!==m&&(C.sizeDelta[c]=m),p&&h&&C.sizeDelta[s]!==x&&(C.sizeDelta[s]=x);const F=l?C.width:C.height;let z=F*.5;if(g+=z,p){let te=x*I-x*.5;te>g&&(g=te-x*.5+F+this.padding.left,g-=z)}let q=g;s==="y"&&(q=-q),C.anchoredPosition[s]!==q&&(C.anchoredPosition[s]=q),g+=z,g+=this.spacing,I+=1}}}}As([w()],bh.prototype,"childControlHeight",2),As([w()],bh.prototype,"childControlWidth",2),As([w()],bh.prototype,"childForceExpandHeight",2),As([w()],bh.prototype,"childForceExpandWidth",2),As([w()],bh.prototype,"childScaleHeight",2),As([w()],bh.prototype,"childScaleWidth",2);class VT extends bh{get primaryAxis(){return"y"}}class WT extends bh{get primaryAxis(){return"x"}}class qT extends Qn{onCalculateLayout(){}}var ire=Object.defineProperty,sre=Object.getOwnPropertyDescriptor,Ga=(i,e,t,s)=>{for(var r=s>1?void 0:s?sre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ire(e,t,r),r},iz=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(iz||{});const XT=re("debuguilayout"),sz=class extends rv{constructor(){super(...arguments),u(this,"_renderOnTop"),u(this,"_depthWrite",!1),u(this,"_doubleSided",!0),u(this,"_castShadows",!1),u(this,"_receiveShadows",!1),u(this,"_renderMode",-1),u(this,"_rootCanvas"),u(this,"_scaleFactor",1),u(this,"worldCamera"),u(this,"planeDistance",-1),u(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),u(this,"previousParent",null),u(this,"_lastMatrixWorld",null),u(this,"_rectTransforms",[]),u(this,"_layoutGroups",new Map),u(this,"onBeforeRenderRoutine",()=>{var i,e,t,s;if(this.context.isInVR){(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(e=this.shadowComponent)==null||e.updateWorldMatrix(!0,!0),Fn.ensureUpdateMeshUI(yT,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),Fn.ensureUpdateMeshUI(yT,this.context))}),u(this,"onAfterRenderRoutine",()=>{var i,e;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const t=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),Fn.ensureUpdateMeshUI(yT,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=t,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(e=this._lastMatrixWorld)==null||e.copy(this.gameObject.matrixWorld)}}),u(this,"_updateRenderSettingsRoutine"),u(this,"_activeRenderMode",-1),u(this,"_lastWidth",-1),u(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(i){i!==this._renderOnTop&&(this._renderOnTop=i,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(i){this._depthWrite!==i&&(this._depthWrite=i,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(i){this._doubleSided!==i&&(this._doubleSided=i,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(i){this._castShadows!==i&&(this._castShadows=i,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(i){this._receiveShadows!==i&&(this._receiveShadows=i,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(i){this._renderMode!==i&&(this._renderMode=i,this.onRenderSettingsChanged())}set rootCanvas(i){this._rootCanvas instanceof sz||(this._rootCanvas=i)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(i){this._scaleFactor=i}awake(){var i;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,XT&&console.log("Canvas.Awake()",((i=this.previousParent)==null?void 0:i.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Be,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 i=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);i!==-1&&this.context.pre_render_callbacks.splice(i,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(i){this._rectTransforms.push(i)}unregisterTransform(i){const e=this._rectTransforms.indexOf(i);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(i){const e=i.gameObject;this._layoutGroups.set(e,i)}unregisterLayoutGroup(i){const e=i.gameObject;this._layoutGroups.delete(e)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Be);const i=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);XT&&i&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);let e=!1;for(const t of this._rectTransforms){i&&t.markDirty();let s=this._layoutGroups.get(t.gameObject);t.isDirty&&!s&&(s=t.gameObject.getComponentInParent(Qn)),(t.isDirty||s!=null&&s.isDirty)&&(XT&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),s?.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),On.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),jx(this.shadowComponent,this);for(const i of ee.getComponentsInChildren(this.gameObject,fa))jx(i.shadowComponent,this)}}onUpdateRenderMode(i=!1){if(!i&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=et.lerp(e.nearClipPlane,e.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const s=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(rr);let n=!1;r.sizeDelta.x!==this.context.domWidth&&(n=!0),r.sizeDelta.y!==this.context.domHeight&&(n=!0);const o=e.fieldOfView*Math.PI/180,a=2*Math.tan(o/2)*Math.abs(s);this.gameObject.scale.x=a/this.context.domHeight,this.gameObject.scale.y=a/this.context.domHeight,this.gameObject.scale.z=.01,n&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let nr=sz;Ga([w()],nr.prototype,"renderOnTop",1),Ga([w()],nr.prototype,"depthWrite",1),Ga([w()],nr.prototype,"doubleSided",1),Ga([w()],nr.prototype,"castShadows",1),Ga([w()],nr.prototype,"receiveShadows",1),Ga([w()],nr.prototype,"renderMode",1),Ga([w(nr)],nr.prototype,"rootCanvas",1),Ga([w()],nr.prototype,"scaleFactor",1),Ga([w(Di)],nr.prototype,"worldCamera",2),Ga([w()],nr.prototype,"planeDistance",2);var rre=Object.defineProperty,nre=Object.getOwnPropertyDescriptor,YT=(i,e,t,s)=>{for(var r=s>1?void 0:s?nre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&rre(e,t,r),r};class xh extends Me{constructor(){super(...arguments),u(this,"_alpha",1),u(this,"interactable",!0),u(this,"blocksRaycasts",!0),u(this,"_isDirty",!1),u(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),On.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of ee.getComponentsInChildren(this.gameObject,fa,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}YT([w()],xh.prototype,"alpha",1),YT([w()],xh.prototype,"interactable",2),YT([w()],xh.prototype,"blocksRaycasts",2);var ore=Object.defineProperty,are=Object.getOwnPropertyDescriptor,Ei=(i,e,t,s)=>{for(var r=s>1?void 0:s?are(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ore(e,t,r),r};class Xu extends Me{constructor(){super(...arguments),u(this,"object"),u(this,"target"),u(this,"duration",1),u(this,"relativeMotion",!1),u(this,"coroutine",null),u(this,"targetPos",new S),u(this,"targetRot",new Ue),u(this,"targetScale",new S)}*moveToTarget(){if(!this.target||!this.object)return;const e=yt(this.object).clone(),t=yt(this.target).clone(),s=Rs(this.object).clone(),r=Rs(this.target).clone(),n=Ks(this.object).clone(),o=Ks(this.target).clone(),a=e.distanceTo(t),l=s.angleTo(r),c=n.distanceTo(o);if(a<.01&&l<.01&&c<.01){is(this.object,t),cn(this.object,r),SC(this.object,o),this.coroutine=null;return}let h=0,d=0;for(;h<1;)h+=this.context.time.deltaTime/this.duration,h>1&&(h=1),d=h<.5?4*h*h*h:1-Math.pow(-2*h+2,3)/2,this.targetPos.lerpVectors(e,t,d),this.targetRot.slerpQuaternions(s,r,d),this.targetScale.lerpVectors(n,o,d),is(this.object,this.targetPos),cn(this.object,this.targetRot),SC(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),n=this.target.quaternion.clone(),o=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(n),this.targetScale.copy(this.object.scale).multiply(o);let a=0,l=0;for(;a<1;)a+=this.context.time.deltaTime/this.duration,a>1&&(a=1),l=a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,l),this.object.quaternion.slerpQuaternions(t,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),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(e){var t;if(this.target&&this.object&&this.gameObject){const s=new Hr("Move to "+((t=this.target)==null?void 0:t.name),fn.tapTrigger(this.gameObject),li.transformAction(this.object,this.target,this.duration,this.relativeMotion?gM.Relative:gM.Absolute));e.addBehavior(s)}}}Ei([w(De)],Xu.prototype,"object",2),Ei([w(De)],Xu.prototype,"target",2),Ei([w()],Xu.prototype,"duration",2),Ei([w()],Xu.prototype,"relativeMotion",2);var JT;const Yu=(JT=class extends Me{constructor(){super(...arguments),u(this,"materialToSwitch"),u(this,"variantMaterial"),u(this,"fadeDuration",0),u(this,"_objectsWithThisMaterial",[]),u(this,"selfModel"),u(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const i=ee.findObjectsOfType(Pi);for(const e of i)e.sharedMaterial===this.materialToSwitch&&this._objectsWithThisMaterial.push(e)}}onPointerClick(){if(this.variantMaterial)for(const i of this._objectsWithThisMaterial)i.sharedMaterial=this.variantMaterial}async beforeCreateDocument(i,e){this.targetModels=[],Yu._materialTriggersPerId={},this.materialToSwitch&&await Jo.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Jo.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(i,e,t){this._objectsWithThisMaterial.find(s=>s.gameObject.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(Yu._materialTriggersPerId[this.materialToSwitch.uuid]||(Yu._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Yu._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(i,e){if(!this.materialToSwitch)return;const t=Yu._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const s={};for(const n of t){const o=n.createVariants();o&&o.length>0&&(s[n.selfModel.uuid]=o)}const r=[];for(const n of t){for(const o in s)o!==n.selfModel.uuid&&r.push(s[o]);n.createAndAttachBehaviors(i,s[n.selfModel.uuid],r)}}delete Yu._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(i,e,t){const s=[],r=[],n=Math.max(0,this.fadeDuration);for(const o of this.targetModels){const a=li.fadeAction(o,n,!1);r.push(a)}for(const o of t)r.push(li.fadeAction(o,n,!1));for(const o of e)s.push(li.fadeAction(o,n,!1)),r.push(li.fadeAction(o,n,!0));i.addBehavior(new Hr("Select "+this.selfModel.name,fn.tapTrigger(this.selfModel),li.parallel(...r))),i.addBehavior(new Hr("Start hidden "+this.selfModel.name,fn.sceneStartTrigger(),li.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const i=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&fo.createEmptyParent(e),e.parent&&e.parent.add(t),i.push(t)}return i}},u(JT,"_materialTriggersPerId",{}),JT);let yf=Yu;Ei([w(It)],yf.prototype,"materialToSwitch",2),Ei([w(It)],yf.prototype,"variantMaterial",2),Ei([w()],yf.prototype,"fadeDuration",2);class bf extends Me{constructor(){super(...arguments),u(this,"target"),u(this,"toggleOnClick",!1),u(this,"targetState",!0),u(this,"hideSelf",!0),u(this,"selfModel"),u(this,"otherModel"),u(this,"toggleModel"),u(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(e,t,s){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(e,t){if(this.target){if(this.otherModel=t.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&PF.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(li.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(li.fadeAction(this.toggleModel,0,!0)),r.push(li.fadeAction(this.otherModel,0,this.targetState)),e.addBehavior(new Hr("Toggle_"+this.selfModel.name+"_hideSelf",fn.tapTrigger(this.selfModel),li.sequence(...r))),this.toggleOnClick&&this.toggleModel){const n=[];n.push(li.fadeAction(this.toggleModel,0,!1)),n.push(li.fadeAction(this.selfModel,0,!0)),n.push(li.fadeAction(this.otherModel,0,!this.targetState)),e.addBehavior(new Hr("Toggle_"+this.selfModel.name+"_toggleSelf",fn.tapTrigger(this.toggleModel),li.sequence(...n))),e.addBehavior(new Hr("HideOnStart_"+this.gameObject.name,fn.sceneStartTrigger(),li.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Ei([w(De)],bf.prototype,"target",2),Ei([w()],bf.prototype,"targetState",2),Ei([w()],bf.prototype,"hideSelf",2);class KT extends Me{start(){this.gameObject.visible=!1}createBehaviours(e,t,s){t.uuid===this.gameObject.uuid&&e.addBehavior(new Hr("HideOnStart_"+this.gameObject.name,fn.sceneStartTrigger(),li.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class xf extends Me{constructor(){super(...arguments),u(this,"target"),u(this,"duration",.5),u(this,"motionType",mM.bounce)}beforeCreateDocument(){}createBehaviours(e,t,s){if(this.target&&t.uuid===this.gameObject.uuid){const r=new Hr("emphasize "+this.name,fn.tapTrigger(this.gameObject),li.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,t){}}Ei([w()],xf.prototype,"target",2),Ei([w()],xf.prototype,"duration",2),Ei([w()],xf.prototype,"motionType",2);class _f extends Me{constructor(){super(...arguments),u(this,"target"),u(this,"clip",""),u(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const e=this.gameObject.addNewComponent(fs);e&&(e.spatialBlend=1,e.volume=1,e.loop=!1,this.target=e)}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(e,t,s){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const n=this.target?this.target.gameObject:this.gameObject,o=r.split("/").pop(),a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?AM.NonSpatial:AM.Spatial,c=new Hr("playAudio "+this.name,fn.tapTrigger(this.gameObject),li.playAudioAction(n,"audio/"+o,HF.Play,a,l));e.addBehavior(c)}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s)return;const r=s.split("/").pop(),n=await(await(await fetch(this.clip)).blob()).arrayBuffer(),o=new Uint8Array(n);t.files["audio/"+r]=o}}Ei([w(fs)],_f.prototype,"target",2),Ei([w(URL)],_f.prototype,"clip",2),Ei([w()],_f.prototype,"toggleOnClick",2);var ZT;const wf=(ZT=class extends Me{constructor(){super(...arguments),u(this,"target"),u(this,"animator"),u(this,"stateName"),u(this,"stateNameAfterPlaying"),u(this,"loopAfterPlaying",!1),u(this,"selfModel"),u(this,"stateAnimationModel"),u(this,"stateAnimation"),u(this,"stateAfterPlayingAnimationModel"),u(this,"stateAfterPlayingAnimation")}onPointerClick(){var i;this.target&&this.stateName&&((i=this.animator)==null||i.play(this.stateName,0,0,.1))}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}onAfterHierarchy(){wf.animationActions=[]}afterCreateDocument(i,e){!this.stateAnimation||!this.stateAnimationModel||e.document.traverse(t=>{var s,r;if(t.uuid===((s=this.target)==null?void 0:s.uuid)&&this.stateAnimation){const n=[];let o=wf.animationActions.find(l=>l.affectedObjects==t&&l.start==this.stateAnimation.start&&l.duration==this.stateAnimation.duration);if(o||(o=li.startAnimationAction(t,this.stateAnimation.start,this.stateAnimation.duration),wf.animationActions.push(o)),n.push(o),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let l=wf.animationActions.find(h=>h.affectedObjects==t&&h.start==this.stateAfterPlayingAnimation.start&&h.duration==this.stateAfterPlayingAnimation.duration);l||(l=li.startAnimationAction(t,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),wf.animationActions.push(l));const c=li.sequence(l);this.loopAfterPlaying&&c.makeLooping(),n.push(c)}const a=new Hr("tap "+this.name+" for "+this.stateName+" on "+((r=this.target)==null?void 0:r.name),fn.tapTrigger(this.selfModel),li.sequence(...n));i.addBehavior(a)}})}createAnimation(i,e,t){var s,r,n,o;if(this.target&&this.animator){const a=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);this.stateAnimationModel=e,this.stateAnimation=i.registerAnimation(this.target,a?.motion.clip);const l=(o=(n=this.animator)==null?void 0:n.runtimeAnimatorController)==null?void 0:o.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=e,this.stateAfterPlayingAnimation=i.registerAnimation(this.target,l?.motion.clip)}}},u(ZT,"animationActions",[]),ZT);let _h=wf;Ei([w(De)],_h.prototype,"target",2),Ei([w(Vr)],_h.prototype,"animator",2),Ei([w()],_h.prototype,"stateName",2),Ei([w()],_h.prototype,"stateNameAfterPlaying",2),Ei([w()],_h.prototype,"loopAfterPlaying",2);class Sf extends Me{constructor(){super(...arguments),u(this,"target")}getType(){}getDuration(){}}Ei([w(De)],Sf.prototype,"target",2);class Iv extends Me{constructor(){super(...arguments),u(this,"target")}}Ei([w(Sf)],Iv.prototype,"target",2);class Rv extends Sf{constructor(){super(...arguments),u(this,"type",1),u(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Ei([w()],Rv.prototype,"type",2),Ei([w()],Rv.prototype,"duration",2);class $T extends Iv{}var lre=Object.defineProperty,cre=Object.getOwnPropertyDescriptor,tc=(i,e,t,s)=>{for(var r=s>1?void 0:s?cre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&lre(e,t,r),r};class Ju extends Me{constructor(){super(...arguments),u(this,"center",new S(0,0,0)),u(this,"radius",.5),u(this,"height",2),u(this,"_rigidbody",null),u(this,"_activeGroundCollisions",new Set)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(ji),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(ji)),this.rigidbody)}onEnable(){let e=this.rigidbody,t=this.gameObject.getComponent(Ah);t||(t=this.gameObject.addNewComponent(Ah)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){for(const t of e.contacts)if(t.normal.y>.1){this._activeGroundCollisions.add(e);break}}onCollisionExit(e){this._activeGroundCollisions.delete(e)}get isGrounded(){return this._activeGroundCollisions.size>0}}tc([w(S)],Ju.prototype,"center",2),tc([w()],Ju.prototype,"radius",2),tc([w()],Ju.prototype,"height",2);class ic extends Me{constructor(){super(...arguments),u(this,"controller"),u(this,"movementSpeed",2),u(this,"rotationSpeed",2),u(this,"jumpForce",1),u(this,"doubleJumpForce",2),u(this,"animator"),u(this,"lookForward",!0),u(this,"_currentSpeed",new S(0,0,0)),u(this,"_currentAngularSpeed",new S(0,0,0)),u(this,"_temp",new S(0,0,0)),u(this,"_jumpCount",0),u(this,"_currentRotation"),u(this,"_raycastOptions",new Go)}awake(){this._currentRotation=new Ue}update(){var e,t,s,r,n,o,a,l,c,h,d;(e=this.controller)!=null&&e.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((t=this.animator)==null||t.setBool("doubleJump",!1)));const p=this.context.input.isKeyPressed("w"),f=this.context.input.isKeyPressed("s"),m=this.context.input.isKeyPressed("a"),v=this.context.input.isKeyPressed("d"),A=this.context.input.isKeyDown(" "),g=(p?1:0)+(f?-1:0);this._currentSpeed.z+=g*this.movementSpeed*this.context.time.deltaTime,(s=this.animator)==null||s.setBool("running",g!=0),(n=this.animator)==null||n.setBool("jumping",((r=this.controller)==null?void 0:r.isGrounded)===!0&&A),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 b=(m?1:0)+(v?-1:0);if(this._currentAngularSpeed.y+=et.toRadians(b*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const y=this.context.mainCameraComponent.forward;y.y=0,y.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),y),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&&A&&this.jumpForce>0){let y=(o=this.controller)==null?void 0:o.isGrounded;if(this.doubleJumpForce>0&&!((a=this.controller)!=null&&a.isGrounded)&&this._jumpCount===1&&(y=!0,(l=this.animator)==null||l.setBool("doubleJump",!0)),y){this._jumpCount+=1;const x=this.controller.rigidbody,_=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;x.applyImpulse(new S(0,1,0).multiplyScalar(_))}}if(this.controller){const y=(c=this.controller)==null?void 0:c.rigidbody.getVelocity().y;if(y<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new _a),this._raycastOptions.ray.origin.copy(yt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const x=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const _=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(x),(_.length&&_[0].distance>2||y<-10)&&((h=this.animator)==null||h.setBool("falling",!0))}else(d=this.animator)==null||d.setBool("falling",!1)}}}tc([w(Ju)],ic.prototype,"controller",2),tc([w()],ic.prototype,"movementSpeed",2),tc([w()],ic.prototype,"rotationSpeed",2),tc([w()],ic.prototype,"jumpForce",2),tc([w()],ic.prototype,"doubleJumpForce",2),tc([w(Vr)],ic.prototype,"animator",2);var hre=Object.defineProperty,ure=Object.getOwnPropertyDescriptor,dre=(i,e,t,s)=>{for(var r=s>1?void 0:s?ure(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&hre(e,t,r),r};class Pv extends Er{constructor(){super(...arguments),u(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new UL;return e.offset=new Y(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}dre([w(Et)],Pv.prototype,"intensity",2),wo("ChromaticAberration",Pv);var pre=Object.defineProperty,fre=Object.getOwnPropertyDescriptor,Xx=(i,e,t,s)=>{for(var r=s>1?void 0:s?fre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&pre(e,t,r),r};class wh extends Er{constructor(){super(...arguments),u(this,"postExposure"),u(this,"contrast"),u(this,"hueShift"),u(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Br&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=vm);const e=new LL;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Br&&(this.context.renderer.toneMapping=vm),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{e.contrast=s};const t=new NL;return this.hueShift.onValueChanged=s=>t.hue=s,this.saturation.onValueChanged=s=>t.saturation=s,[t,e]}}Xx([w(Et)],wh.prototype,"postExposure",2),Xx([w(Et)],wh.prototype,"contrast",2),Xx([w(Et)],wh.prototype,"hueShift",2),Xx([w(Et)],wh.prototype,"saturation",2),wo("ColorAdjustments",wh);const mre=(Math.sqrt(5)-1)/4,or=(5-Math.sqrt(5))/20,Yx=i=>Math.floor(i)|0,Jx=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 gre(i=Math.random){const e=vre(i),t=new Float64Array(e).map(o=>Jx[o%32*4]),s=new Float64Array(e).map(o=>Jx[o%32*4+1]),r=new Float64Array(e).map(o=>Jx[o%32*4+2]),n=new Float64Array(e).map(o=>Jx[o%32*4+3]);return function(o,a,l,c){let h,d,p,f,m;const v=(o+a+l+c)*mre,A=Yx(o+v),g=Yx(a+v),b=Yx(l+v),y=Yx(c+v),x=(A+g+b+y)*or,_=A-x,E=g-x,I=b-x,P=y-x,M=o-_,C=a-E,U=l-I,G=c-P;let F=0,z=0,q=0,te=0;M>C?F++:z++,M>U?F++:q++,M>G?F++:te++,C>U?z++:q++,C>G?z++:te++,U>G?q++:te++;const Z=F>=3?1:0,$=z>=3?1:0,he=q>=3?1:0,le=te>=3?1:0,X=F>=2?1:0,ne=z>=2?1:0,_e=q>=2?1:0,Ee=te>=2?1:0,Oe=F>=1?1:0,ze=z>=1?1:0,$e=q>=1?1:0,Je=te>=1?1:0,qe=M-Z+or,xt=C-$+or,pe=U-he+or,H=G-le+or,Le=M-X+2*or,ye=C-ne+2*or,ge=U-_e+2*or,Qe=G-Ee+2*or,me=M-Oe+3*or,Ye=C-ze+3*or,it=U-$e+3*or,ht=G-Je+3*or,qt=M-1+4*or,ti=C-1+4*or,L=U-1+4*or,D=G-1+4*or,ce=A&255,Re=g&255,Pe=b&255,Q=y&255;let ve=.6-M*M-C*C-U*U-G*G;if(ve<0)h=0;else{const be=ce+e[Re+e[Pe+e[Q]]];ve*=ve,h=ve*ve*(t[be]*M+s[be]*C+r[be]*U+n[be]*G)}let Se=.6-qe*qe-xt*xt-pe*pe-H*H;if(Se<0)d=0;else{const be=ce+Z+e[Re+$+e[Pe+he+e[Q+le]]];Se*=Se,d=Se*Se*(t[be]*qe+s[be]*xt+r[be]*pe+n[be]*H)}let ue=.6-Le*Le-ye*ye-ge*ge-Qe*Qe;if(ue<0)p=0;else{const be=ce+X+e[Re+ne+e[Pe+_e+e[Q+Ee]]];ue*=ue,p=ue*ue*(t[be]*Le+s[be]*ye+r[be]*ge+n[be]*Qe)}let Ve=.6-me*me-Ye*Ye-it*it-ht*ht;if(Ve<0)f=0;else{const be=ce+Oe+e[Re+ze+e[Pe+$e+e[Q+Je]]];Ve*=Ve,f=Ve*Ve*(t[be]*me+s[be]*Ye+r[be]*it+n[be]*ht)}let Xe=.6-qt*qt-ti*ti-L*L-D*D;if(Xe<0)m=0;else{const be=ce+1+e[Re+1+e[Pe+1+e[Q+1]]];Xe*=Xe,m=Xe*Xe*(t[be]*qt+s[be]*ti+r[be]*L+n[be]*D)}return 27*(h+d+p+f+m)}}function vre(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const s=t+~~(i()*(256-t)),r=e[t];e[t]=e[s],e[s]=r}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var Are=Object.defineProperty,yre=Object.getOwnPropertyDescriptor,K=(i,e,t,s)=>{for(var r=s>1?void 0:s?yre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Are(e,t,r),r};const Kx=re("debugparticles");var sc=(i=>(i[i.Billboard=0]="Billboard",i[i.Stretch=1]="Stretch",i[i.HorizontalBillboard=2]="HorizontalBillboard",i[i.VerticalBillboard=3]="VerticalBillboard",i[i.Mesh=4]="Mesh",i))(sc||{});class Sh{constructor(){u(this,"alphaKeys"),u(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let s,r=0,n=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const l=this.alphaKeys[a];(l.time<e||!s)&&(s=l,r=a)}for(let a=0;a<this.colorKeys.length;a++){const l=this.colorKeys[a];(l.time<e||!n)&&(n=l,o=a)}if(n)if(o+1<this.colorKeys.length){const a=this.colorKeys[o+1],l=et.remap(e,n.time,a.time,0,1);t.r=et.lerp(n.color.r,a.color.r,l),t.g=et.lerp(n.color.g,a.color.g,l),t.b=et.lerp(n.color.b,a.color.b,l)}else t.r=n.color.r,t.g=n.color.g,t.b=n.color.b;if(s)if(r+1<this.alphaKeys.length){const a=this.alphaKeys[r+1],l=et.remap(e,s.time,a.time,0,1);t.alpha=et.lerp(s.alpha,a.alpha,l)}else t.alpha=s.alpha;return t}}K([w()],Sh.prototype,"alphaKeys",2),K([w()],Sh.prototype,"colorKeys",2);var Zx=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(Zx||{}),rz=(i=>(i[i.Sphere=0]="Sphere",i[i.SphereShell=1]="SphereShell",i[i.Hemisphere=2]="Hemisphere",i[i.HemisphereShell=3]="HemisphereShell",i[i.Cone=4]="Cone",i[i.Box=5]="Box",i[i.Mesh=6]="Mesh",i[i.ConeShell=7]="ConeShell",i[i.ConeVolume=8]="ConeVolume",i[i.ConeVolumeShell=9]="ConeVolumeShell",i[i.Circle=10]="Circle",i[i.CircleEdge=11]="CircleEdge",i[i.SingleSidedEdge=12]="SingleSidedEdge",i[i.MeshRenderer=13]="MeshRenderer",i[i.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",i[i.BoxShell=15]="BoxShell",i[i.BoxEdge=16]="BoxEdge",i[i.Donut=17]="Donut",i[i.Rectangle=18]="Rectangle",i[i.Sprite=19]="Sprite",i[i.SpriteRenderer=20]="SpriteRenderer",i))(rz||{});class at{constructor(){u(this,"mode"),u(this,"constant"),u(this,"constantMin"),u(this,"constantMax"),u(this,"curve"),u(this,"curveMin"),u(this,"curveMax"),u(this,"curveMultiplier")}evaluate(e,t){const s=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=et.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const r=e*this.curveMin.duration,n=e*this.curveMax.duration;return et.lerp(this.curveMin.evaluate(r),this.curveMax.evaluate(n),s%1)*this.curveMultiplier;case 3:return et.lerp(this.constantMin,this.constantMax,s%1);default:this.curveMax.evaluate(e)*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(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let s=0;s<e.keys.length;s++){const r=e.keys[s];r.value>t&&(t=r.value)}return t}}K([w()],at.prototype,"mode",2),K([w()],at.prototype,"constant",2),K([w()],at.prototype,"constantMin",2),K([w()],at.prototype,"constantMax",2),K([w(Lu)],at.prototype,"curve",2),K([w(Lu)],at.prototype,"curveMin",2),K([w(Lu)],at.prototype,"curveMax",2),K([w()],at.prototype,"curveMultiplier",2);var $x;const na=($x=class{constructor(){u(this,"mode"),u(this,"color"),u(this,"colorMin"),u(this,"colorMax"),u(this,"gradient"),u(this,"gradientMin"),u(this,"gradientMax")}evaluate(i,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,na._temp),na._temp;case 2:return na._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(i,na._temp),this.gradientMax.evaluate(i,na._temp2),na._temp.lerp(na._temp2,t)}return na._temp.set(16711935),na._temp.alpha=1,na._temp}},u($x,"_temp",new Ai(0,0,0,1)),u($x,"_temp2",new Ai(0,0,0,1)),$x);let An=na;K([w(Ai)],An.prototype,"color",2),K([w(Ai)],An.prototype,"colorMin",2),K([w(Ai)],An.prototype,"colorMax",2),K([w(Sh)],An.prototype,"gradient",2),K([w(Sh)],An.prototype,"gradientMin",2),K([w(Sh)],An.prototype,"gradientMax",2);class ar{constructor(){u(this,"cullingMode"),u(this,"duration"),u(this,"emitterVelocityMode"),u(this,"flipRotation"),u(this,"gravityModifier"),u(this,"gravityModifierMultiplier"),u(this,"loop"),u(this,"maxParticles"),u(this,"playOnAwake"),u(this,"prewarm"),u(this,"ringBufferLoopRange"),u(this,"ringBufferMode"),u(this,"scalingMode"),u(this,"simulationSpace"),u(this,"simulationSpeed"),u(this,"startColor"),u(this,"startDelay"),u(this,"startDelayMultiplier"),u(this,"startLifetime"),u(this,"startLifetimeMultiplier"),u(this,"startRotation"),u(this,"startRotationMultiplier"),u(this,"startRotation3D"),u(this,"startRotationX"),u(this,"startRotationXMultiplier"),u(this,"startRotationY"),u(this,"startRotationYMultiplier"),u(this,"startRotationZ"),u(this,"startRotationZMultiplier"),u(this,"startSize"),u(this,"startSize3D"),u(this,"startSizeMultiplier"),u(this,"startSizeX"),u(this,"startSizeXMultiplier"),u(this,"startSizeY"),u(this,"startSizeYMultiplier"),u(this,"startSizeZ"),u(this,"startSizeZMultiplier"),u(this,"startSpeed"),u(this,"startSpeedMultiplier"),u(this,"stopAction"),u(this,"useUnscaledTime")}}K([w(at)],ar.prototype,"gravityModifier",2),K([w(An)],ar.prototype,"startColor",2),K([w(at)],ar.prototype,"startDelay",2),K([w(at)],ar.prototype,"startLifetime",2),K([w(at)],ar.prototype,"startRotation",2),K([w(at)],ar.prototype,"startRotationX",2),K([w(at)],ar.prototype,"startRotationY",2),K([w(at)],ar.prototype,"startRotationZ",2),K([w(at)],ar.prototype,"startSize",2),K([w(at)],ar.prototype,"startSizeX",2),K([w(at)],ar.prototype,"startSizeY",2),K([w(at)],ar.prototype,"startSizeZ",2),K([w(at)],ar.prototype,"startSpeed",2);class Bv{constructor(){u(this,"cycleCount"),u(this,"maxCount"),u(this,"minCount"),u(this,"probability"),u(this,"repeatInterval"),u(this,"time"),u(this,"count"),u(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const s=this.time+this.repeatInterval*this._performed;if(e>=s&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=et.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const r=Math.random();t=et.lerp(this.count.curveMin.evaluate(r),this.count.curveMax.evaluate(r),Math.random());break}}return t}}class Ha{constructor(){u(this,"enabled"),u(this,"bursts"),u(this,"rateOverTime"),u(this,"rateOverTimeMultiplier"),u(this,"rateOverDistance"),u(this,"rateOverDistanceMultiplier"),u(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const s=this.bursts[t];this.system.main.loop&&s.time>=this.system.time&&s.reset(),e+=Math.round(s.run(this.system.time))}return e}}K([w()],Ha.prototype,"enabled",2),K([w()],Ha.prototype,"bursts",2),K([w(at)],Ha.prototype,"rateOverTime",2),K([w()],Ha.prototype,"rateOverTimeMultiplier",2),K([w(at)],Ha.prototype,"rateOverDistance",2),K([w()],Ha.prototype,"rateOverDistanceMultiplier",2);class kv{constructor(){u(this,"enabled"),u(this,"color")}}K([w(An)],kv.prototype,"color",2);class Ch{constructor(){u(this,"enabled"),u(this,"separateAxes"),u(this,"size"),u(this,"sizeMultiplier"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier"),u(this,"_time",0),u(this,"_temp",new S)}evaluate(e,t,s){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,s)*this.xMultiplier,t.y=this.y.evaluate(e,s)*this.yMultiplier,t.z=this.z.evaluate(e,s)*this.zMultiplier;else{const r=this.size.evaluate(e,s)*this.sizeMultiplier;t.x=r}return t}}K([w(at)],Ch.prototype,"size",2),K([w(at)],Ch.prototype,"x",2),K([w(at)],Ch.prototype,"y",2),K([w(at)],Ch.prototype,"z",2);var e_;const Dv=(e_=class{constructor(){u(this,"shapeType",5),u(this,"enabled",!0),u(this,"alignToDirection",!1),u(this,"angle",0),u(this,"arc",360),u(this,"arcSpread"),u(this,"arcSpeedMultiplier"),u(this,"arcMode"),u(this,"boxThickness"),u(this,"position"),u(this,"rotation"),u(this,"_rotation",new Ys),u(this,"scale"),u(this,"radius"),u(this,"radiusThickness"),u(this,"sphericalDirectionAmount"),u(this,"randomDirectionAmount"),u(this,"randomPositionAmount"),u(this,"system"),u(this,"_space"),u(this,"_worldSpaceMatrix",new Be),u(this,"_worldSpaceMatrixInverse",new Be),u(this,"_vector",new S(0,0,0)),u(this,"_temp",new S(0,0,0)),u(this,"_dir",new S),u(this,"_loopTime",0),u(this,"_loopDirection",1),Kx&&console.log(this)}get type(){return rz[this.shapeType]}initialize(i){this.getPosition(),i.position.copy(this._vector)}toJSON(){return this}clone(){return new Dv}update(i,e,t,s){this.system=i,this._space=t,t===1&&(this._worldSpaceMatrix.copy(s.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=et.toRadians(this.rotation.x),this._rotation.y=et.toRadians(this.rotation.y),this._rotation.z=et.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const i=this._temp.copy(this.position),e=this._space===1;e&&i.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Kx&&Ll.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(i);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,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),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Kx&&Ll.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i){var e;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 t=i.x,s=i.y,r=i.z;this._dir.set(t,s,r),(e=this.system)!=null&&e.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),Kx&&(Ll.DrawSphere(i,.01,8925952,.5,!0),Ll.DrawDirection(i,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,e){if(e<=0)return;const t=Dv._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,i.add(t)}randomizeDirection(i,e){if(e===0)return;const t=Dv._randomQuat,s=Dv._tempVec;s.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(s,e*Math.random()*Math.PI),i.applyQuaternion(t)}spherizeDirection(i,e){if(e===0)return;const t=Math.random()*Math.PI*2,s=Math.acos(1-Math.random()*2),r=Math.sin(s)*Math.cos(t),n=Math.sin(s)*Math.sin(t),o=Math.cos(s),a=new S(r,n,o);i.lerp(a,e)}randomSpherePoint(i,e,t,s,r){const n=Math.random(),o=Math.random(),a=2*Math.PI*n*(s/360),l=Math.acos(2*o-1),c=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,h=i.x+this.scale.x*(-c*Math.sin(l)*Math.cos(a)),d=i.y+this.scale.y*(c*Math.sin(l)*Math.sin(a)),p=i.z+this.scale.z*(c*Math.cos(l));r.x=h,r.y=d,r.z=p}randomCirclePoint(i,e,t,s,r){const n=Math.random(),o=2*Math.PI*n*(s/360),a=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,l=i.x+this.scale.x*a*Math.cos(o),c=i.y+this.scale.y*a*Math.sin(o),h=i.z;r.x=l,r.y=c,r.z=h}randomConePoint(i,e,t,s,r,n,o){let a=0,l=0;switch(n){case 0:a=Math.random(),l=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,l=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let c=2*Math.PI*a*(r/360);switch(n){case 2:case 1:c+=Math.PI+.5,c+=this._loopTime*Math.PI*2,c%=et.toRadians(r);break}const h=Math.acos(2*l-1),d=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),s)*t,p=i.x+-d*Math.sin(h)*Math.cos(c),f=i.y+d*Math.sin(h)*Math.sin(c),m=i.z;o.x=p*this.scale.x,o.y=f*this.scale.y,o.z=m*this.scale.z}},u(e_,"_randomQuat",new Ue),u(e_,"_tempVec",new S),e_);let ns=Dv;K([w()],ns.prototype,"shapeType",2),K([w()],ns.prototype,"enabled",2),K([w()],ns.prototype,"alignToDirection",2),K([w()],ns.prototype,"angle",2),K([w()],ns.prototype,"arc",2),K([w()],ns.prototype,"arcSpread",2),K([w()],ns.prototype,"arcSpeedMultiplier",2),K([w()],ns.prototype,"arcMode",2),K([w(S)],ns.prototype,"boxThickness",2),K([w(S)],ns.prototype,"position",2),K([w(S)],ns.prototype,"rotation",2),K([w(S)],ns.prototype,"scale",2),K([w()],ns.prototype,"radius",2),K([w()],ns.prototype,"radiusThickness",2),K([w()],ns.prototype,"sphericalDirectionAmount",2),K([w()],ns.prototype,"randomDirectionAmount",2),K([w()],ns.prototype,"randomPositionAmount",2);class fi{constructor(){u(this,"damping"),u(this,"enabled"),u(this,"frequency"),u(this,"octaveCount"),u(this,"octaveMultiplier"),u(this,"octaveScale"),u(this,"positionAmount"),u(this,"quality"),u(this,"remap"),u(this,"remapEnabled"),u(this,"remapMultiplier"),u(this,"remapX"),u(this,"remapXMultiplier"),u(this,"remapY"),u(this,"remapYMultiplier"),u(this,"remapZ"),u(this,"remapZMultiplier"),u(this,"scrollSpeedMultiplier"),u(this,"separateAxes"),u(this,"strengthMultiplier"),u(this,"strengthX"),u(this,"strengthXMultiplier"),u(this,"strengthY"),u(this,"strengthYMultiplier"),u(this,"strengthZ"),u(this,"strengthZMultiplier"),u(this,"_noise"),u(this,"_time",0),u(this,"_temp",new S)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,s,r,n,o){if(!this.enabled)return;this._noise||(this._noise=gre(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),l=this._noise(a.x,a.y,a.z,this._time),c=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),h=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(l,c,h).normalize();const d=n/o;let p=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=p*this.strengthXMultiplier,this._temp.y*=p*this.strengthYMultiplier,this._temp.z*=p*this.strengthZMultiplier):(this.strengthX&&(p*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(p)),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}K([w()],fi.prototype,"damping",2),K([w()],fi.prototype,"enabled",2),K([w()],fi.prototype,"frequency",2),K([w()],fi.prototype,"octaveCount",2),K([w()],fi.prototype,"octaveMultiplier",2),K([w()],fi.prototype,"octaveScale",2),K([w(at)],fi.prototype,"positionAmount",2),K([w()],fi.prototype,"quality",2),K([w(at)],fi.prototype,"remap",2),K([w()],fi.prototype,"remapEnabled",2),K([w()],fi.prototype,"remapMultiplier",2),K([w(at)],fi.prototype,"remapX",2),K([w()],fi.prototype,"remapXMultiplier",2),K([w(at)],fi.prototype,"remapY",2),K([w()],fi.prototype,"remapYMultiplier",2),K([w(at)],fi.prototype,"remapZ",2),K([w()],fi.prototype,"remapZMultiplier",2),K([w()],fi.prototype,"scrollSpeedMultiplier",2),K([w()],fi.prototype,"separateAxes",2),K([w()],fi.prototype,"strengthMultiplier",2),K([w(at)],fi.prototype,"strengthX",2),K([w()],fi.prototype,"strengthXMultiplier",2),K([w(at)],fi.prototype,"strengthY",2),K([w()],fi.prototype,"strengthYMultiplier",2),K([w(at)],fi.prototype,"strengthZ",2),K([w()],fi.prototype,"strengthZMultiplier",2);class Oi{constructor(){u(this,"enabled"),u(this,"attachRibbonToTransform",!1),u(this,"colorOverLifetime"),u(this,"colorOverTrail"),u(this,"dieWithParticles",!0),u(this,"inheritParticleColor",!0),u(this,"lifetime"),u(this,"lifetimeMultiplier"),u(this,"minVertexDistance",.2),u(this,"mode",0),u(this,"ratio",1),u(this,"ribbonCount",1),u(this,"shadowBias",0),u(this,"sizeAffectsLifetime",!1),u(this,"sizeAffectsWidth",!1),u(this,"splitSubEmitterRibbons",!1),u(this,"textureMode",0),u(this,"widthOverTrail"),u(this,"widthOverTrailMultiplier"),u(this,"worldSpace",!1)}getWidth(e,t,s,r){let n=this.widthOverTrail.evaluate(s,r);return e*=n,e}getColor(e,t,s){const r=this.colorOverTrail.evaluate(s),n=this.colorOverLifetime.evaluate(t);e.x*=r.r*n.r,e.y*=r.g*n.g,e.z*=r.b*n.b,e.w*=r.alpha*n.alpha}}K([w()],Oi.prototype,"enabled",2),K([w()],Oi.prototype,"attachRibbonToTransform",2),K([w(An)],Oi.prototype,"colorOverLifetime",2),K([w(An)],Oi.prototype,"colorOverTrail",2),K([w()],Oi.prototype,"dieWithParticles",2),K([w()],Oi.prototype,"inheritParticleColor",2),K([w(at)],Oi.prototype,"lifetime",2),K([w()],Oi.prototype,"lifetimeMultiplier",2),K([w()],Oi.prototype,"minVertexDistance",2),K([w()],Oi.prototype,"mode",2),K([w()],Oi.prototype,"ratio",2),K([w()],Oi.prototype,"ribbonCount",2),K([w()],Oi.prototype,"shadowBias",2),K([w()],Oi.prototype,"sizeAffectsLifetime",2),K([w()],Oi.prototype,"sizeAffectsWidth",2),K([w()],Oi.prototype,"splitSubEmitterRibbons",2),K([w()],Oi.prototype,"textureMode",2),K([w(at)],Oi.prototype,"widthOverTrail",2),K([w()],Oi.prototype,"widthOverTrailMultiplier",2),K([w()],Oi.prototype,"worldSpace",2);class Gi{constructor(){u(this,"enabled"),u(this,"space",0),u(this,"orbitalX"),u(this,"orbitalY"),u(this,"orbitalZ"),u(this,"orbitalXMultiplier"),u(this,"orbitalYMultiplier"),u(this,"orbitalZMultiplier"),u(this,"orbitalOffsetX"),u(this,"orbitalOffsetY"),u(this,"orbitalOffsetZ"),u(this,"speedModifier"),u(this,"speedModifierMultiplier"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier"),u(this,"_system"),u(this,"_temp",new S),u(this,"_temp2",new S),u(this,"_temp3",new S),u(this,"_hasOrbital",!1),u(this,"_index",0),u(this,"_orbitalMatrix",new Be)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,s,r,n,o,a){var l;if(!this.enabled)return;const c=o/a,h=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,d=this.x.evaluate(c),p=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-d,p,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((l=this._system)==null?void 0:l.worldPos)){const m=this._temp2.set(s.x,s.y,s.z),v=this.orbitalXMultiplier,A=this.orbitalYMultiplier,g=this.orbitalZMultiplier,b=h*Math.PI*2*10,y=Math.cos(b*v),x=Math.sin(b*v),_=Math.cos(b*A),E=Math.sin(b*A),I=Math.cos(b*g),P=Math.sin(b*g),M=m.x*(_*I)+m.y*(_*P)+m.z*-E,C=m.x*(x*E*I-y*P)+m.y*(x*E*P+y*I)+m.z*(x*_),U=m.x*(y*E*I+x*P)+m.y*(y*E*P-x*I)+m.z*(y*_),G=this._temp3.set(m.x-M,m.y-C,m.z-U);G.normalize(),G.multiplyScalar(.2/n*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),r.x+=G.x,r.y+=G.y,r.z+=G.z}r.x+=this._temp.x,r.y+=this._temp.y,r.z+=this._temp.z,r.x*=h,r.y*=h,r.z*=h}}K([w()],Gi.prototype,"enabled",2),K([w()],Gi.prototype,"space",2),K([w(at)],Gi.prototype,"orbitalX",2),K([w(at)],Gi.prototype,"orbitalY",2),K([w(at)],Gi.prototype,"orbitalZ",2),K([w()],Gi.prototype,"orbitalXMultiplier",2),K([w()],Gi.prototype,"orbitalYMultiplier",2),K([w()],Gi.prototype,"orbitalZMultiplier",2),K([w()],Gi.prototype,"orbitalOffsetX",2),K([w()],Gi.prototype,"orbitalOffsetY",2),K([w()],Gi.prototype,"orbitalOffsetZ",2),K([w(at)],Gi.prototype,"speedModifier",2),K([w()],Gi.prototype,"speedModifierMultiplier",2),K([w(at)],Gi.prototype,"x",2),K([w()],Gi.prototype,"xMultiplier",2),K([w(at)],Gi.prototype,"y",2),K([w()],Gi.prototype,"yMultiplier",2),K([w(at)],Gi.prototype,"z",2),K([w()],Gi.prototype,"zMultiplier",2);class lr{constructor(){u(this,"animation"),u(this,"enabled"),u(this,"cycleCount"),u(this,"frameOverTime"),u(this,"frameOverTimeMultiplier"),u(this,"numTilesX"),u(this,"numTilesY"),u(this,"startFrame"),u(this,"startFrameMultiplier"),u(this,"rowMode"),u(this,"rowIndex"),u(this,"spriteCount"),u(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(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let s=this.frameOverTime.evaluate(e%1);return s*=this.frameOverTimeMultiplier,s*=t,s=s%t,s=Math.floor(s),s}}K([w()],lr.prototype,"animation",2),K([w()],lr.prototype,"enabled",2),K([w()],lr.prototype,"cycleCount",2),K([w(at)],lr.prototype,"frameOverTime",2),K([w()],lr.prototype,"frameOverTimeMultiplier",2),K([w()],lr.prototype,"numTilesX",2),K([w()],lr.prototype,"numTilesY",2),K([w(at)],lr.prototype,"startFrame",2),K([w()],lr.prototype,"startFrameMultiplier",2),K([w()],lr.prototype,"rowMode",2),K([w()],lr.prototype,"rowIndex",2),K([w()],lr.prototype,"spriteCount",2),K([w()],lr.prototype,"timeMode",2);class So{constructor(){u(this,"enabled"),u(this,"separateAxes"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}K([w()],So.prototype,"enabled",2),K([w()],So.prototype,"separateAxes",2),K([w(at)],So.prototype,"x",2),K([w()],So.prototype,"xMultiplier",2),K([w(at)],So.prototype,"y",2),K([w()],So.prototype,"yMultiplier",2),K([w(at)],So.prototype,"z",2),K([w()],So.prototype,"zMultiplier",2);class jn{constructor(){u(this,"enabled"),u(this,"range"),u(this,"separateAxes"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const s=et.lerp(this.range.x,this.range.y,t);return this.z.evaluate(s)*-1}return 0}}K([w()],jn.prototype,"enabled",2),K([w()],jn.prototype,"range",2),K([w()],jn.prototype,"separateAxes",2),K([w(at)],jn.prototype,"x",2),K([w()],jn.prototype,"xMultiplier",2),K([w(at)],jn.prototype,"y",2),K([w()],jn.prototype,"yMultiplier",2),K([w(at)],jn.prototype,"z",2),K([w()],jn.prototype,"zMultiplier",2);class ys{constructor(){u(this,"enabled"),u(this,"dampen"),u(this,"drag"),u(this,"dragMultiplier"),u(this,"limit"),u(this,"limitMultiplier"),u(this,"separateAxes"),u(this,"limitX"),u(this,"limitXMultiplier"),u(this,"limitY"),u(this,"limitYMultiplier"),u(this,"limitZ"),u(this,"limitZMultiplier"),u(this,"multiplyDragByParticleSize",!1),u(this,"multiplyDragByParticleVelocity",!1),u(this,"space"),u(this,"_temp",new S),u(this,"_temp2",new S)}apply(e,t,s,r,n,o,a){if(this.enabled){const l=this.limit.evaluate(n)*this.limitMultiplier;if(t.length()>l){this._temp.copy(t).normalize().multiplyScalar(l);let c=this.dampen*.5;t.x=et.lerp(t.x,this._temp.x,c),t.y=et.lerp(t.y,this._temp.y,c),t.z=et.lerp(t.z,this._temp.z,c),s.x=et.lerp(s.x,this._temp.x,c),s.y=et.lerp(s.y,this._temp.y,c),s.z=et.lerp(s.z,this._temp.z,c)}}}}K([w()],ys.prototype,"enabled",2),K([w()],ys.prototype,"dampen",2),K([w(at)],ys.prototype,"drag",2),K([w()],ys.prototype,"dragMultiplier",2),K([w(at)],ys.prototype,"limit",2),K([w()],ys.prototype,"limitMultiplier",2),K([w()],ys.prototype,"separateAxes",2),K([w(at)],ys.prototype,"limitX",2),K([w()],ys.prototype,"limitXMultiplier",2),K([w(at)],ys.prototype,"limitY",2),K([w()],ys.prototype,"limitYMultiplier",2),K([w(at)],ys.prototype,"limitZ",2),K([w()],ys.prototype,"limitZMultiplier",2),K([w()],ys.prototype,"multiplyDragByParticleSize",2),K([w()],ys.prototype,"multiplyDragByParticleVelocity",2),K([w()],ys.prototype,"space",2);class Eh{constructor(){u(this,"enabled"),u(this,"curve"),u(this,"curveMultiplier"),u(this,"mode"),u(this,"system"),u(this,"_lastWorldPosition"),u(this,"_velocity",new S),u(this,"_temp",new S)}update(e){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(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,s){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const r=this.curve.evaluate(t,s);this._temp.copy(this._velocity).multiplyScalar(r),e.add(this._temp)}}}K([w()],Eh.prototype,"enabled",2),K([w(at)],Eh.prototype,"curve",2),K([w()],Eh.prototype,"curveMultiplier",2),K([w()],Eh.prototype,"mode",2);class Yr{constructor(){u(this,"enabled"),u(this,"range"),u(this,"separateAxes"),u(this,"size"),u(this,"sizeMultiplier"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier")}evaluate(e,t,s,r){const n=e.length(),o=et.remap(n,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,s);return r*a}}K([w()],Yr.prototype,"enabled",2),K([w(Y)],Yr.prototype,"range",2),K([w()],Yr.prototype,"separateAxes",2),K([w(at)],Yr.prototype,"size",2),K([w()],Yr.prototype,"sizeMultiplier",2),K([w(at)],Yr.prototype,"x",2),K([w()],Yr.prototype,"xMultiplier",2),K([w(at)],Yr.prototype,"y",2),K([w()],Yr.prototype,"yMultiplier",2),K([w(at)],Yr.prototype,"z",2),K([w()],Yr.prototype,"zMultiplier",2);class Ku{constructor(){u(this,"enabled"),u(this,"range"),u(this,"color")}evaluate(e,t,s){const r=e.length(),n=et.remap(r,this.range.x,this.range.y,0,1),o=this.color.evaluate(n,t);s.x*=o.r,s.y*=o.g,s.z*=o.b,s.w*=o.alpha}}K([w()],Ku.prototype,"enabled",2),K([w(Y)],Ku.prototype,"range",2),K([w(An)],Ku.prototype,"color",2);function bre(i){const e=i.domElement.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const s=document.createElement("button");s.id="open-in-ar",s.innerText="Open in QuickLook",t.appendChild(s);const r=document.createElement("a");r.id="needle-usdz-link",r.style.display="none",r.rel="ar",r.href="",t.appendChild(r);const n=document.createElement("img");return n.id="button",r.appendChild(n),i.domElement.appendChild(t),r}function xre(){var i=new Date;const e=i.getMonth()+1,t=i.getDate(),s=i.getHours(),r=i.getMinutes(),n=i.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,l=(s<10?"0":"")+s,c=(r<10?"0":"")+r,h=(n<10?"0":"")+n;return i.getFullYear()+o+a+"-"+l+c+h}const t_=re("debugusdz");function _re(i,e){const t=[],s=ee.getComponentsInChildren(i,Vr);let r=!1;t_&&console.log(s);for(const n of s){if(!n||!n.runtimeAnimatorController)continue;t_&&console.log(n);const o=[];for(const a of n.runtimeAnimatorController.enumerateActions()){t_&&console.log(a);const l=a.getClip();if(!r&&l.tracks.length>0){r=!0;const c=l.tracks[0],h=c.name.substring(0,c.name.lastIndexOf(".")),d=new kn(h+".position",[0,.01],[0,0,0,0,0,0]),p=new kn(h+".quaternion",[0,.01],[0,0,0,1,0,0,0,1]);o.push(new Lr("rest",.01,[d,p]))}o.includes(l)||o.push(l)}t.push({root:n.gameObject,clips:o})}t_&&console.log(t);for(const n of t)for(const o of n.clips)e.registerAnimation(n.root,o)}var wre=Object.defineProperty,Sre=Object.getOwnPropertyDescriptor,rc=(i,e,t,s)=>{for(var r=s>1?void 0:s?Sre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&wre(e,t,r),r};const Zu=re("debugtext");var Ds=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Ds||{}),nz=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(nz||{});class Jr extends Wu{constructor(){super(...arguments),u(this,"alignment",0),u(this,"verticalOverflow",0),u(this,"horizontalOverflow",0),u(this,"lineSpacing",1),u(this,"supportRichText",!1),u(this,"font"),u(this,"fontStyle",0),u(this,"_text",""),u(this,"_fontSize",12),u(this,"_textMeshUi",null),u(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;(e=this.uiObject)==null||e.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var e;this.uiObject&&((e=this.Canvas)!=null&&e.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var e;const t=(e=this.uiObject)==null?void 0:e._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(e){Zu&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,Zu&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),Zu&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let e=this.fontSize;const t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var s,r,n;if(Zu&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let o=this.getNextTag(e);if(o){if(o.startIndex>0){for(let c=this.uiObject.children.length-1;c>=0;c--){const h=this.uiObject.children[c];h.isUI&&(this.uiObject.remove(h),h.clear())}const l=new Tx({textContent:e.substring(0,o.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const a=[];for(;o;){const l=this.getNextTag(e,o.endIndex),c={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(l){c.textContent=this.getText(e,o,l),this.handleTag(o,c,a);const h=new Tx(c);(r=this.uiObject)==null||r.add(h)}else{c.textContent=e.substring(o.endIndex),this.handleTag(o,c,a);const h=new Tx(c);(n=this.uiObject)==null||n.add(h)}o=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,s={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let n=0;n<this._textMeshUi.length;n++){if(e[n]===!0)continue;r=!0;const o=this._textMeshUi[n];o.textContent&&(jx(o,s),e[n]=!0)}if(!r)break;yield}}handleTag(e,t,s){if(!e.isEndTag){if(e.type.includes("color")){const r=new eI(e,{color:t.color});if(s.push(r),e.type.length>6){const n=parseInt("0x"+e.type.substring(7));t.color=n}else t.color=new Ae(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const r=new eI(e,{fontWeight:700});s.push(r)}else if(e.type=="i"){this.setFont(t,2);const r=new eI(e,{fontStyle:"italic"});s.push(r)}}}getText(e,t,s){return e.substring(t.endIndex,s.startIndex)}getNextTag(e,t=0){const s=e.indexOf("<",t),r=e.indexOf(">",s);if(s>=0&&r>=0){const n=e.substring(s+1,r);return{type:n,startIndex:s,endIndex:r+1,isEndTag:n.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;let s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,t);Zu&&console.log("Selected font family:"+r);let n=AT.getFontFamily(r);switch(n||(n=AT.addFontFamily(r)),e.fontFamily=n,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let o=n.getVariant(e.fontWeight,e.fontStyle);if(!o){let a=r;a!=null&&a.endsWith("-msdf.json")||(a+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),o=n.addVariant(e.fontWeight,e.fontStyle,a,l),o?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var s;const r=e.lastIndexOf("-");if(r<0)return e;const n=(s=e.substring(r+1))==null?void 0:s.toLowerCase();if(Cre.includes(n))return Zu&&console.warn("Unsupported font style: "+n),e;const o=e.lastIndexOf("/");let a=e;o>=0&&(a=a.substring(o+1));let l=a[0]===a[0].toUpperCase();const c=e.substring(0,r);switch(Zu&&console.log("Select font: ",e,nz[t],a,l,c),t){case 0:return l?c+"-Regular":c+"-regular";case 1:return l?c+"-Bold":c+"-bold";case 2:return l?c+"-Italic":c+"-italic";case 3:return l?c+"-BoldItalic":c+"-bolditalic";default:return e}}}rc([w()],Jr.prototype,"alignment",2),rc([w()],Jr.prototype,"verticalOverflow",2),rc([w()],Jr.prototype,"horizontalOverflow",2),rc([w()],Jr.prototype,"lineSpacing",2),rc([w()],Jr.prototype,"supportRichText",2),rc([w(URL)],Jr.prototype,"font",2),rc([w()],Jr.prototype,"fontStyle",2),rc([w()],Jr.prototype,"text",1),rc([w()],Jr.prototype,"fontSize",1);class eI{constructor(e,t){u(this,"tag"),u(this,"previousValues"),this.tag=e,this.previousValues=t}}const Cre=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Mh{constructor(e){u(this,"id"),u(this,"content",""),u(this,"font",[]),u(this,"pointSize",144),u(this,"width"),u(this,"height"),u(this,"depth"),u(this,"wrapMode"),u(this,"horizontalAlignment"),u(this,"verticalAlignment"),u(this,"material"),this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var s;t.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(s=this.font)==null||s.push("sans-serif"));const r=this.font.map(n=>`"${n}"`).join(", ");t.appendLine(`string[] font = [ ${r} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),t.closeBlock()}}u(Mh,"global_id",0);class i_{static singleLine(e,t,s){const r=new Mh("text_"+Mh.getId());return r.content=e,t&&(r.pointSize=t),s&&(r.depth=s),r}static multiLine(e,t,s,r,n,o){const a=new Mh("text_"+Mh.getId());return a.content=e,a.width=t,a.height=s,a.horizontalAlignment=r,a.verticalAlignment=n,o!==void 0&&(a.wrapMode=o),a}}const Ere=new Be().makeRotationY(Math.PI),Mre=new Be().makeScale(-1,1,-1);class Ov{get extensionName(){return"text"}onExportObject(e,t,s){}exportText(e,t,s){const r=ee.getComponent(e,Jr);if(!r)return;const n=ee.getComponent(e,rr);let o=100,a=100;n&&(o=n.width,a=n.height),t.matrix=Ere.clone(),n&&t.matrix.premultiply(Mre);const l=new Ae().copySRGBToLinear(r.color);t.material=new zo({color:l,emissive:l}),t.addEventListener("serialize",(c,h)=>{let d=r.text;d=d.replace(/\n/g,"\\n");const p=i_.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(p,r.alignment),this.setOverflow(p,r),t.material&&(p.material=t.material),p.pointSize=this.convertToTextSize(r.fontSize),p.depth=.001,p.writeTo(void 0,c)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case Ds.LowerLeft:case Ds.MiddleLeft:case Ds.UpperLeft:e.horizontalAlignment="left";break;case Ds.LowerCenter:case Ds.MiddleCenter:case Ds.UpperCenter:e.horizontalAlignment="center";break;case Ds.LowerRight:case Ds.MiddleRight:case Ds.UpperRight:e.horizontalAlignment="right";break}switch(t){case Ds.LowerLeft:case Ds.LowerCenter:case Ds.LowerRight:e.verticalAlignment="bottom";break;case Ds.MiddleLeft:case Ds.MiddleCenter:case Ds.MiddleRight:e.verticalAlignment="middle";break;case Ds.UpperLeft:case Ds.UpperCenter:case Ds.UpperRight:e.verticalAlignment="top";break}}}class s_{get extensionName(){return"tmui"}onExportObject(e,t,s){const r=ee.getComponent(e,nr);if(r&&r.activeAndEnabled&&r.renderMode===iz.WorldSpace){const n=new Ov,o=ee.getComponent(e,rr),a=ee.getComponent(e,xh);if(o){o.width,o.height;const l=fo.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const h=c.matrix;l.matrix.copy(h);const d=new Map,p=new Map;d.set(c,l),p.set(c,a?a.alpha:1),c.traverse(f=>{if(f===c)return;const m=fo.createEmpty();m.matrix.copy(f.matrix);const v=f.parent,A=v&&typeof v.textContent=="string"&&v.textContent.length;let g=p.get(v)||1;const b=ee.getComponent(f,xh);if(b&&(g*=b.alpha),f instanceof xe&&A){const x=f[Na].gameObject;n.exportText(x,m,s)}if(f instanceof xe&&!A){const x=f.geometry.clone();x.scale(1,1,-1),this.flipWindingOrder(x),m.geometry=x;const _=new Ae,E=f.material.opacity;_.copy(f.material.color),m.material=new hi({color:_,opacity:E*g,map:f.material.map,transparent:!0})}d.set(f,m),p.set(f,g);const y=d.get(v);if(!y){console.error("Error when exporting UI: shadow component parent not found!",f,f.parent);return}y.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let s=0,r=t.length/3;s<r;s++){let n=t[s*3];t[s*3]=t[s*3+2],t[s*3+2]=n}e.index.needsUpdate=!0}}var Tre=Object.defineProperty,Ire=Object.getOwnPropertyDescriptor,Gn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ire(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Tre(e,t,r),r};const js=re("debugusdz");class Th{constructor(){u(this,"callToAction"),u(this,"checkoutTitle"),u(this,"checkoutSubtitle"),u(this,"callToActionURL")}}Gn([w()],Th.prototype,"callToAction",2),Gn([w()],Th.prototype,"checkoutTitle",2),Gn([w()],Th.prototype,"checkoutSubtitle",2),Gn([w()],Th.prototype,"callToActionURL",2);class Hn extends Me{constructor(){super(...arguments),u(this,"objectToExport"),u(this,"autoExportAnimations",!1),u(this,"exportFileName"),u(this,"customUsdzFile"),u(this,"customBranding"),u(this,"anchoringType","plane"),u(this,"planeAnchoringAlignment","horizontal"),u(this,"interactive",!0),u(this,"extensions",[]),u(this,"allowCreateQuicklookButton",!0),u(this,"link"),u(this,"webxr"),u(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAsync()}),u(this,"lastCallback"),u(this,"_quicklookButton"),u(this,"_quicklookButtonContainer",null)}start(){var e,t,s;js&&(console.log(this),console.log("Debug USDZ, press 't' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),Cc()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((s=this.objectToExport)!=null&&s.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Qx),this.extensions.push(new Nx),this.extensions.push(new Ov),this.extensions.push(new s_))}onEnable(){var e;const t=pm(),s=ll();(js||t&&s)&&((js||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=bre(this.context),this.link.addEventListener("message",this.lastCallback)),js&&hs("USDZ Exporter enabled: "+this.name),(e=document.getElementById("open-in-ar"))==null||e.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var e,t;(e=this.link)==null||e.removeEventListener("message",this.lastCallback);const s=pm(),r=ll();(js||s&&r)&&this.removeQuicklookButton(),js&&hs("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var e;let t=this.exportFileName??((e=this.objectToExport)==null?void 0:e.name)??this.name;if(Rp()||(t+="-MadeWithNeedle"),t+="-"+xre(),this.customUsdzFile){js&&console.log("Exporting custom usdz",this.customUsdzFile);const v=this.buildQuicklookOverlay();js&&console.log(v);const A=v.callToAction?encodeURIComponent(v.callToAction):"",g=v.checkoutTitle?encodeURIComponent(v.checkoutTitle):"",b=v.checkoutSubtitle?encodeURIComponent(v.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${A}&checkoutTitle=${g}&checkoutSubtitle=${b}&callToActionURL=${v.callToActionURL}`,js&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click();return}if(!this.objectToExport)return;const s=ee.getComponentsInChildren(this.objectToExport,Pi),r=new Array;for(const v of s)for(const A of v.sharedMaterials)if(A){const g=v.loadProgressiveTextures(A);g instanceof Promise&&r.push(g)}js&&hs("Load textures: "+r.length),await Promise.all(r),js&&hs("Load textures: done"),this.applyWebARSessionRoot();const n=new MK,o=[...this.extensions],a=new $b;o.push(a),this.autoExportAnimations&&_re(this.objectToExport,a);const l={self:this,exporter:n,extensions:o,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:l})),n.debug=js,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 c=await n.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:o,quickLookCompatible:!0}),h=new Blob([c],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:l}));const d=this.buildQuicklookOverlay();js&&console.log(d);const p=d.callToAction?encodeURIComponent(d.callToAction):"",f=d.checkoutTitle?encodeURIComponent(d.checkoutTitle):"",m=d.checkoutSubtitle?encodeURIComponent(d.checkoutSubtitle):"";this.link.href=URL.createObjectURL(h)+`#callToAction=${p}&checkoutTitle=${f}&checkoutSubtitle=${m}&callToActionURL=${d.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click()}quicklookCallback(e){if(e?.data=="_apple_ar_quicklook_button_tapped"){js&&lo("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const s=new URLSearchParams(this.link.href);if(s){const r=s.get("callToActionURL");js&&hs("Quicklook url: "+r),r&&(Rp()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var e,t,s,r,n,o;const a={};return this.customBranding&&Object.assign(a,this.customBranding),Rp()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),a.callToAction="Close",a.checkoutTitle="\u{1F335} Made with Needle",a.checkoutSubtitle="_"),(((e=a.callToAction)==null?void 0:e.length)||((t=a.checkoutTitle)==null?void 0:t.length)||((s=a.checkoutSubtitle)==null?void 0:s.length))&&((r=a.callToAction)!=null&&r.length||(a.callToAction="\0"),(n=a.checkoutTitle)!=null&&n.length||(a.checkoutTitle="\0"),(o=a.checkoutSubtitle)!=null&&o.length||(a.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:a})),a}async createQuicklookButton(){var e,t;if(!this.webxr)if(await dm(1),this.webxr=ee.findObjectOfType(wt)??void 0,this.webxr)if(this.webxr.VRButton&&((e=this.webxr.VRButton.parentElement)==null||e.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const s=(t=this.webxr.ARButton.parentElement)==null?void 0:t.querySelector("a");s&&(s.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",r=>{r.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 s=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");s||(s=document.createElement("div"),s.classList.add("webxr-buttons"));const r=document.createElement("button");r.innerText="Open in Quicklook",r.addEventListener("click",()=>{this.exportAsync()}),r.classList.add("webxr-ar-button"),r.classList.add("webxr-button"),r.classList.add("quicklook-ar-button"),this._quicklookButton=r,s.appendChild(r),this._quicklookButtonContainer=s,this.dispatchEvent(new CustomEvent("created-button",{detail:r}))}else console.warn("Could not find WebXR component: will not create Quicklook button",Lt.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var e;(e=this._quicklookButton)==null||e.remove()}applyWebARSessionRoot(){if(js&&console.log("applyWebARSessionRoot"),!this.objectToExport)return;let e=ee.getComponentInParent(this.objectToExport,ka);const t=e!=null;if(e||(e=ee.getComponentInChildren(this.objectToExport,ka)),!e){js&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const s=t?this.objectToExport:e.gameObject,r=1/e.arScale;js&&console.log("Scale",r,s),s.matrix.makeScale(r,r,r),e.invertForward&&s.matrix.multiply(new Be().makeRotationY(Math.PI))}}Gn([w(De)],Hn.prototype,"objectToExport",2),Gn([w()],Hn.prototype,"autoExportAnimations",2),Gn([w()],Hn.prototype,"exportFileName",2),Gn([w(URL)],Hn.prototype,"customUsdzFile",2),Gn([w(Th)],Hn.prototype,"customBranding",2),Gn([w()],Hn.prototype,"anchoringType",2),Gn([w()],Hn.prototype,"planeAnchoringAlignment",2),Gn([w()],Hn.prototype,"interactive",2),Gn([w()],Hn.prototype,"allowCreateQuicklookButton",2);const oz=re("debugdeletable");class r_ extends Ba{}class tI extends Me{constructor(){super(...arguments),u(this,"deleteBoxes",[])}awake(){this.deleteBoxes=ee.findObjectsOfType(r_,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const s=ee.getComponentInParent(this.gameObject,Jp);s?oz&&console.warn("Can not delete object with usage marker",this.guid,s):(oz&&console.log("DESTROY",this.gameObject),ab(this.gameObject,this.context.connection))}}}}var Rre=Object.defineProperty,Pre=Object.getOwnPropertyDescriptor,$u=(i,e,t,s)=>{for(var r=s>1?void 0:s?Pre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Rre(e,t,r),r};class oa extends Er{constructor(){super(...arguments),u(this,"mode"),u(this,"focusDistance"),u(this,"focalLength"),u(this,"aperture"),u(this,"gaussianMaxRadius"),u(this,"resolutionScale"),u(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=t=>{const s=t/300,r=2;return et.lerp(r,.01,s)};const e=20;this.aperture.valueProcessor=t=>{const s=1-t/32;return et.lerp(1,e,s)}}onCreateEffect(){if(this.mode===0)return;const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;Cc()&&(s=.6),this.resolutionScale=new Et(s*e)}const t=new FL(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{t.circleOfConfusionMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>t.circleOfConfusionMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>t.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>t.resolution.scale=s),[t]}unapply(){}}$u([w()],oa.prototype,"mode",2),$u([w(Et)],oa.prototype,"focusDistance",2),$u([w(Et)],oa.prototype,"focalLength",2),$u([w(Et)],oa.prototype,"aperture",2),$u([w(Et)],oa.prototype,"gaussianMaxRadius",2),$u([w(Et)],oa.prototype,"resolutionScale",2),$u([w(Et)],oa.prototype,"bokehScale",2),wo("DepthOfField",oa);var Bre=Object.defineProperty,kre=Object.getOwnPropertyDescriptor,Dre=(i,e,t,s)=>{for(var r=s>1?void 0:s?kre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Bre(e,t,r),r};class n_ extends Me{constructor(){super(...arguments),u(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||ee.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Ore()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}Dre([w()],n_.prototype,"visibleOn",2);let o_;function Ore(){if(o_===!0||o_===!1)return o_;let i=!1;return function(e){(/(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(e)||/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(e.substr(0,4)))&&(i=!0)}(navigator.userAgent||navigator.vendor||window.opera),o_=i,i}class iI{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var Lre=Object.defineProperty,Ure=Object.getOwnPropertyDescriptor,az=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ure(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Lre(e,t,r),r},lz=(i=>(i.SelectStart="selectstart",i.SelectEnd="selectend",i))(lz||{}),a_;const Ih=(a_=class extends Yp{constructor(){super(),u(this,"showGizmo",!0),u(this,"useViewAngle",!0),u(this,"transformSelf",!0),u(this,"orbit",null),u(this,"selectStartEventListener",[]),u(this,"selectEndEventListener",[]),u(this,"_dragHelper",null),u(this,"_draggingRigidbodies",[]),u(this,"_waitingForDragStart",null),u(this,"_isDragging",!1),u(this,"_marker",null),u(this,"_dragDelta"),u(this,"_didDrag",!1),u(this,"_activePointerId"),this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new Y}static get HasAnySelected(){return this._active>0}addDragEventListener(i,e){switch(i){case"selectstart":this.selectStartEventListener.push(e);break;case"selectend":this.selectEndEventListener.push(e);break}}start(){this.orbit=ee.findObjectOfType(Zl,this.context),this.gameObject.getComponentInParent(Yl)||this.gameObject.addNewComponent(Yl)}allowEdit(i=null){return this.context.connection.allowEditing}onPointerEnter(i){if(!this.allowEdit(this.gameObject)||wt.IsInWebXR)return;const e=ee.getComponentInParent(i.object,Ih);!e||e!==this||(Ih.lastHovered=i.object,this.context.domElement.style.cursor="pointer")}onPointerExit(i){this.allowEdit(this.gameObject)&&(wt.IsInWebXR||Ih.lastHovered===i.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(i){this.allowEdit(this.gameObject)&&(wt.IsInWebXR||(Ih._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=i.clone(),i.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(i){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(Ih._active>0&&(Ih._active-=1),!wt.IsInWebXR&&(this.onDragEnd(i),i.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var i;if(!wt.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const t=this.context.input.getPointerPositionDelta(0);if(t&&this._dragDelta.add(t),this._dragDelta.length()>2)this._didDrag=!0;else return}const e=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(e)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((i=this._dragHelper)==null?void 0:i.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(i){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new hz(this.context.mainCamera);else return;if(!i||!i.object)return;const e=ee.getComponentInParent(i.object,Ih);if(!e||e!==this)return;let t=i.object;this.transformSelf&&(t=this.gameObject);const s={selected:t,attached:t};for(const a of this.selectStartEventListener)a(this,s);if(this._activePointerId=i.pointerId,!s.attached)return;s.attached,t=s.attached,this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const r=ee.getComponentInChildren(t,mh);r&&(r.fastMode=!0,r?.requestOwnership()),this._marker=ee.addNewComponent(t,Jp),this._draggingRigidbodies.length=0;const n=ee.getComponentsInChildren(t,ji);n&&this._draggingRigidbodies.push(...n);const o=HA();ee.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 i of this._draggingRigidbodies)i.wakeUp(),i.resetVelocities()}}onDragEnd(i){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const s of this._draggingRigidbodies)s.setVelocity(s.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),i!=null&&i.object){const s=ee.getComponentInChildren(i.object,mh);s&&(s.fastMode=!1)}this._marker&&this._marker.destroy();for(const s of this.selectEndEventListener)s(this);const t=HA();ee.invokeOnChildren(e,t("onDragEnd"))}},u(a_,"_active",0),u(a_,"lastHovered"),a_);let Cf=Ih;az([w()],Cf.prototype,"showGizmo",2),az([w()],Cf.prototype,"useViewAngle",2);const cz=class{constructor(i){u(this,"showGizmo",!0),u(this,"useViewAngle",!0),u(this,"_selected",null),u(this,"_context",null),u(this,"_camera"),u(this,"_cameraPlane",new so),u(this,"_hasGroundPlane",!1),u(this,"_groundPlane",new so),u(this,"_groundOffset",new S),u(this,"_groundOffsetFactor",0),u(this,"_groundDistance",0),u(this,"_groundPlanePoint",new S),u(this,"_raycaster",new mp),u(this,"_cameraPlaneOffset",new S),u(this,"_intersection",new S),u(this,"_worldPosition",new S),u(this,"_inverseMatrix",new Be),u(this,"_rbs",[]),u(this,"_groundLine"),u(this,"_groundMarker"),u(this,"_groundOffsetVector",new S(0,1,0)),u(this,"_requireUpdateGroundPlane",!0),u(this,"_didDragOnGroundPlaneLastFrame",!1),this._camera=i;const e=new es(cz.geometry),t=e.material;t.color=new Ae(.4,.4,.4),e.layers.set(2),e.name="line",e.scale.y=1,this._groundLine=e;const s=new Po(.5,22,22),r=new hi({color:t.color}),n=new xe(s,r);n.visible=!1,n.layers.set(2),this._groundMarker=n}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(i,e){if(this._selected&&e)for(const t of this._rbs)t.wakeUp(),t.setVelocity(0,0,0);if(this._selected&&qr.Remove(e,this._selected),this._selected=i,this._context=e,this._rbs.length=0,i?(e.scene.add(this._groundLine),e.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!e){console.error("DragHelper: no context");return}qr.Add(e,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(i){var e,t,s,r,n;if(!this._context)return;const o="Space",a="KeyD",l=((e=this._context)==null?void 0:e.input.isKeyPressed(o))||((t=this._context)==null?void 0:t.input.isKeyPressed(a)),c=this._context.input.getTouchesPressedCount()>=2||l;if(c){const d=this._context.input.getPointerPositionDelta(0);d&&(this._groundOffsetVector.set(0,1,0),(s=this._selected)==null||s.rotateOnWorldAxis(this._groundOffsetVector,d.x*this._context.time.deltaTime))}const h=this._context.input.getPointerPositionRC(0);if(h&&(this._raycaster.setFromCamera(h,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const d=yt(this._camera).clone().sub(yt(this._selected)).normalize(),p=Math.abs(d.dot(this._groundOffsetVector)),f=((r=this._context)==null?void 0:r.input.isKeyPressed(o))||((n=this._context)==null?void 0:n.input.isKeyPressed(a));let m=!this.useViewAngle||p>.2;(c||f||this._context.input.getPointerPressedCount()>1)&&(m=!1);const v=this._didDragOnGroundPlaneLastFrame!==m;if(this._didDragOnGroundPlaneLastFrame=m,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!m||v)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const A=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=A,m){this._groundOffsetVector.set(0,1,0);const g=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(g,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);v&&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(i,e,t){if(this._selected){if(t){const s=yt(this._selected);s.y=i.y,i=s}if(is(this._selected,i),is(this._groundLine,i),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=e!==null&&this.showGizmo,e){const s=yt(this._camera).distanceTo(e)*.01;this._groundMarker.scale.set(s,s,s),is(this._groundMarker,e)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const i=this._context.input.getPointerPositionRC(0);i&&(this._raycaster.setFromCamera(i,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 i=yt(this._selected),e=new _a(new S(0,.1,0).add(i),new S(0,-1,0)),t=new Go;t.ignore=[this._selected];const s=this._context.physics.raycastFromRay(e,t);for(let r=0;r<s.length;r++){const n=s[r];if(!n.face||this.contains(this._selected,n.object))continue;const o=new S(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(o,n.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(e.direction.multiplyScalar(-1),e.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(i),this._groundOffset.copy(this._intersection).sub(i)}onDidUpdate(){wn.markDirty(this._selected);for(const i of this._rbs)i.wakeUp(),i.resetForcesAndTorques(),i.setAngularVelocity(0,0,0)}contains(i,e){if(i===e)return!0;if(i.children){for(const t of i.children)if(this.contains(t,e))return!0}return!1}};let hz=cz;u(hz,"geometry",new At().setFromPoints([new S(0,0,0),new S(0,-1,0)]));function sI(i,e,t){console.warn("Adding components on object has been temporarily disabled")}var uz=(i=>(i.File_Spawned="file-spawned",i))(uz||{});class dz{constructor(e,t,s,r,n,o,a,l){u(this,"guid"),u(this,"file_name"),u(this,"file_hash"),u(this,"file_size"),u(this,"position"),u(this,"seed"),u(this,"sender"),u(this,"serverUrl"),u(this,"parentGuid"),u(this,"boundsSize"),this.seed=t,this.guid=s,this.file_name=r,this.file_hash=n,this.file_size=o,this.position=a,this.sender=e,this.serverUrl=l}}async function pz(i,e,t){const s=i.name;return s.endsWith(".gltf")||s.endsWith(".glb")?new Promise((r,n)=>{const o=new FileReader;o.readAsArrayBuffer(i),o.onloadend=async a=>{const l=o.result,c=lb(),h=new sn(c),d=await Wo().parseSync(e,l,i.name,h);if(d&&d.scene){const p=d.scene;if(!p.guid){const f=new sn(c);p.guid=f.generateUUID()}t&&Fre(e.connection,i,c,p,t),sI(),r(d)}}}):(console.warn("Unsupported file type: "+s,i),null)}async function fz(i,e){return new Promise(async(t,s)=>{const r=lb(),n=new sn(r),o=i.toString(),a=await Wo().loadSync(e,o,o,n);a&&a.scene?(a.scene,sI(),t(a)):console.warn("Unsupported file type: "+i.toString())})}Ii.registerCallback(Pr.ContextCreated,i=>{mz(i.context)});function mz(i){i.connection.beginListen("file-spawned",async e=>{if(e.sender!==i.connection.connectionId){console.log("received file event",e),Nre(e,i);let t=null;try{t=await gE(e.file_name,e.file_hash,e.file_size,e.serverUrl)}finally{zre(e)}if(t){const s=new sn(e.seed),r=await Wo().parseSync(i,t,e.file_name,s);if(r&&r.scene){const n=r.scene;if(sI(),e.parentGuid){const o=bg(e.parentGuid,i.scene);o&&"add"in o&&o.add(n)}n.parent||i.scene.add(n),e.position!==null&&n.position.copy(e.position)}}else console.error("download didnt return file")}})}async function Fre(i,e,t,s,r){if(!i.connectionId){console.error("Can not upload file - no connection id");return}if(!s.guid){console.error("Can not upload file - no guid",s,s.guid);return}const n=await iU(e,r);if(!n)return;if(!n.filename){console.error("Can not send upload event - no filename",e.name);return}if(!n.hash){console.error("Can not send upload event - no hash",e.name);return}const o=new dz(i.connectionId,t,s.guid,n.filename,n.hash,e.size,s.position,n.url??r);s.parent&&(o.parentGuid=s.parent.guid),i.send("file-spawned",o)}const rI={};function Nre(i,e){const t=new gi,s=new xe(t,new hi({color:65280})),r=new Cy(s,5592405);if(rI[i.guid]=r,e.scene.add(r),i.parentGuid){const n=bg(i.parentGuid,e.scene);n&&n.add(r)}i.position&&r.position.copy(i.position)}function zre(i,e){const t=i.guid,s=rI[t];s&&(delete rI[t],s.removeFromParent())}var Qre=Object.defineProperty,jre=Object.getOwnPropertyDescriptor,nI=(i,e,t,s)=>{for(var r=s>1?void 0:s?jre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Qre(e,t,r),r};const Gre=re("debugnet"),oI=class extends Me{constructor(){super(...arguments),u(this,"url",null),u(this,"urlParameterName",null),u(this,"localhost",null)}awake(){Gre&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let i=this.url?oI.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const t=re(this.urlParameterName);t&&typeof t=="string"&&(i=t)}if(!i)return null;const e=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(i);return e!=null&&e.groups?e?.groups.socket_prefix?i:"wss://"+e?.groups.url:null}static GetUrl(i,e){let t=i;const s=oI.IsLocalNetwork()&&e;return s&&(t=e),i!=null&&i.startsWith("/")&&(t=(s?t:window.location.origin)+i),t}static IsLocalNetwork(i=window.location.hostname){return Rr(i)}};let ed=oI;nI([w()],ed.prototype,"url",2),nI([w()],ed.prototype,"urlParameterName",2),nI([w()],ed.prototype,"localhost",2);var Hre=Object.defineProperty,Vre=Object.getOwnPropertyDescriptor,gz=(i,e,t,s)=>{for(var r=s>1?void 0:s?Vre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Hre(e,t,r),r};const Ef=re("debugdroplistener");class Lv extends Me{constructor(){super(...arguments),u(this,"filesBackendUrl"),u(this,"localhost"),u(this,"onDrag",e=>{e.preventDefault()}),u(this,"onDrop",async e=>{if(Ef&&console.log(e),!e.dataTransfer)return;e.preventDefault();const t=e.dataTransfer.items;if(t)for(const s in t){const r=t[s];if(r.kind==="file"){const n=r.getAsFile();if(!n)continue;await this.addFiles(n)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(async n=>{Ef&&console.log("dropped url",n);try{const o=new URL(n);if(!o)return;const a=await fz(o,this.context);a&&this.addObject(e,a)}catch{console.log("dropped string is not a valid URL!",n)}})}})}onEnable(){this.filesBackendUrl=ed.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,Ef&&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(...e){if(Ef&&console.log("Add files",e),!!Array.isArray(e)&&e.length)for(const t of e){if(!t)continue;Ef&&console.log("Register file "+t.name+" to",this.filesBackendUrl,t);const s=await pz(t,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:t})),s&&this.addObject(void 0,s)}}async addObject(e,t){Ef&&console.log("Dropped",t);const s=t.scene;if(e!==void 0){const r=new Go;r.setMask(16777215),r.screenPointFromOffset(e.offsetX,e.offsetY);const n=this.context.physics.raycast(r);if(n&&n.length>0)for(const o of n){s.position.copy(o.point);break}}this.gameObject.add(s),this.dispatchEvent(new CustomEvent("object-added",{detail:t}))}}gz([w()],Lv.prototype,"filesBackendUrl",2),gz([w()],Lv.prototype,"localhost",2);var Wre=Object.defineProperty,qre=Object.getOwnPropertyDescriptor,l_=(i,e,t,s)=>{for(var r=s>1?void 0:s?qre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Wre(e,t,r),r};class td extends Yp{constructor(){super(...arguments),u(this,"parent",null),u(this,"object",null),u(this,"limitCount",10),u(this,"limitInterval",60),u(this,"_currentCount",0),u(this,"_startPosition",null),u(this,"_startQuaternion",null)}awake(){var e,t;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((e=this.object.position)==null?void 0:e.clone())??new S(0,0,0),this._startQuaternion=((t=this.object.quaternion)==null?void 0:t.clone())??new Ue(0,0,0,1)}const s=ee.getComponentInParent(this.gameObject,Cf);s?s.addDragEventListener(lz.SelectStart,(r,n)=>{if(this._currentCount>=this.limitCount){n.attached=null;return}const o=this.handleDuplication(n.selected);o&&(console.assert(o!==n.selected,"Duplicated object is original"),n.attached=o)}):console.warn("Could no find drag controls in parent",this.name),vs.addEventListener(ql.SelectStart,(r,n)=>{if(this._currentCount>=this.limitCount){n.grab=null;return}const o=this.handleDuplication(n.selected);o&&(n.grab=o)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(e){var t;if(this._currentCount>=this.limitCount||!this.object)return null;if(e===this.gameObject||this.handleMultiObject(e)){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 s=new Ta;this.parent||(this.parent=this.gameObject.parent),this.parent&&(s.parent=this.parent.guid??((t=this.parent.userData)==null?void 0:t.guid),s.keepWorldPosition=!0),s.position=this.worldPosition,s.rotation=this.worldQuaternion,s.context=this.context,this._currentCount+=1;const r=ee.instantiateSynced(this.object,s);return console.assert(r!==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),r}return null}handleMultiObject(e){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,e):!1}isInChildren(e,t){if(!e)return!1;if(e===t)return!0;if(e.children){for(let s of e.children)if(this.isInChildren(s,t))return!0}return!1}}l_([w(De)],td.prototype,"parent",2),l_([w(De)],td.prototype,"object",2),l_([w()],td.prototype,"limitCount",2),l_([w()],td.prototype,"limitInterval",2);var Mf=(i=>(i[i.PointerEnter=0]="PointerEnter",i[i.PointerExit=1]="PointerExit",i[i.PointerDown=2]="PointerDown",i[i.PointerUp=3]="PointerUp",i[i.PointerClick=4]="PointerClick",i[i.Drag=5]="Drag",i[i.Drop=6]="Drop",i[i.Scroll=7]="Scroll",i[i.UpdateSelected=8]="UpdateSelected",i[i.Select=9]="Select",i[i.Deselect=10]="Deselect",i[i.Move=11]="Move",i[i.InitializePotentialDrag=12]="InitializePotentialDrag",i[i.BeginDrag=13]="BeginDrag",i[i.EndDrag=14]="EndDrag",i[i.Submit=15]="Submit",i[i.Cancel=16]="Cancel",i))(Mf||{}),Xre=Object.defineProperty,Yre=Object.getOwnPropertyDescriptor,aI=(i,e,t,s)=>{for(var r=s>1?void 0:s?Yre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Xre(e,t,r),r};class lI{constructor(){u(this,"eventID"),u(this,"callback")}}aI([w()],lI.prototype,"eventID",2),aI([w(pn)],lI.prototype,"callback",2);class c_ extends Me{constructor(){super(...arguments),u(this,"triggers")}invoke(e){if(this.triggers)for(const t of this.triggers)t.eventID===e&&t.callback.invoke()}onPointerClick(e){this.invoke(Mf.PointerClick)}onPointerEnter(e){this.invoke(Mf.PointerEnter)}onPointerExit(e){this.invoke(Mf.PointerExit)}onPointerDown(e){this.invoke(Mf.PointerDown)}onPointerUp(e){this.invoke(Mf.PointerUp)}}aI([w(lI)],c_.prototype,"triggers",2);var Jre=Object.defineProperty,Kre=Object.getOwnPropertyDescriptor,cI=(i,e,t,s)=>{for(var r=s>1?void 0:s?Kre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Jre(e,t,r),r};class hI extends Me{constructor(){super(...arguments),u(this,"connectedBody"),u(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(ji)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}cI([w(ji)],hI.prototype,"connectedBody",2);class uI extends hI{createJoint(e,t){var s;(s=this.context.physics.engine)==null||s.addFixedJoint(e,t)}}class Uv extends hI{constructor(){super(...arguments),u(this,"anchor"),u(this,"axis")}createJoint(e,t){var s;this.axis&&this.anchor&&((s=this.context.physics.engine)==null||s.addHingeJoint(e,t,this.anchor,this.axis))}}cI([w(S)],Uv.prototype,"anchor",2),cI([w(S)],Uv.prototype,"axis",2);const Zre={type:"change"};let $re=class extends Cs{constructor(i,e){super(),this.object=i,this.domElement=e,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const t=this,s=1e-6,r=new Ue,n=new S;this.tmpQuaternion=new Ue,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(p){if(!(p.altKey||this.enabled===!1)){switch(p.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(p){if(this.enabled!==!1){switch(p.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(p){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(p.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(p){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const f=this.getContainerDimensions(),m=f.size[0]/2,v=f.size[1]/2;this.moveState.yawLeft=-(p.pageX-f.offset[0]-m)/m,this.moveState.pitchDown=(p.pageY-f.offset[1]-v)/v,this.updateRotationVector()}},this.pointerup=function(p){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(p.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(p){this.enabled!==!1&&p.preventDefault()},this.update=function(p){if(this.enabled===!1)return;const f=p*t.movementSpeed,m=p*t.rollSpeed;t.object.translateX(t.moveVector.x*f),t.object.translateY(t.moveVector.y*f),t.object.translateZ(t.moveVector.z*f),t.tmpQuaternion.set(t.rotationVector.x*m,t.rotationVector.y*m,t.rotationVector.z*m,1).normalize(),t.object.quaternion.multiply(t.tmpQuaternion),(n.distanceToSquared(t.object.position)>s||8*(1-r.dot(t.object.quaternion))>s)&&(t.dispatchEvent(Zre),r.copy(t.object.quaternion),n.copy(t.object.position))},this.updateMovementVector=function(){const p=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=-p+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",l),this.domElement.removeEventListener("pointermove",a),this.domElement.removeEventListener("pointerup",c),window.removeEventListener("keydown",h),window.removeEventListener("keyup",d)};const o=this.contextMenu.bind(this),a=this.pointermove.bind(this),l=this.pointerdown.bind(this),c=this.pointerup.bind(this),h=this.keydown.bind(this),d=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",o),this.domElement.addEventListener("pointerdown",l),this.domElement.addEventListener("pointermove",a),this.domElement.addEventListener("pointerup",c),window.addEventListener("keydown",h),window.addEventListener("keyup",d),this.updateMovementVector(),this.updateRotationVector()}};class dI extends Me{constructor(){super(...arguments),u(this,"_controls",null)}onEnable(){var e;const t=(e=ee.getComponent(this.gameObject,Di))==null?void 0:e.cam;this._controls=new $re(t,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var e;(e=this._controls)==null||e.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var ene=Object.defineProperty,tne=Object.getOwnPropertyDescriptor,pI=(i,e,t,s)=>{for(var r=s>1?void 0:s?tne(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ene(e,t,r),r};class Tf extends Me{constructor(){super(...arguments),u(this,"_fog")}get fog(){return this._fog||(this._fog=new xS(0,0,50)),this._fog}get mode(){return 1}set near(e){this.fog.near=e}get near(){return this.fog.near}set far(e){this.fog.far=e}get far(){return this.fog.far}set color(e){this.fog.color.copy(e)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}pI([w()],Tf.prototype,"near",1),pI([w()],Tf.prototype,"far",1),pI([w(Ae)],Tf.prototype,"color",1);let h_,fI,If,u_;function mI(i,e=1/0,t=null){fI||(fI=new Rn(2,2,1,1)),If||(If=new kt({uniforms:{blitTexture:new Te(i)},vertexShader:`
5021
+ `,this.context.appendHTMLElement(t);const s=wT;wT&&console.log("ARSupported?",lv,"VRSupported?",cv),(s||this.createARButton&&this.enableAR&&lv)&&(i=ks.createARButton(this),this._arButton=i,t.appendChild(i)),(s||this.createVRButton&&this.enableVR&&cv)&&(e=ks.createVRButton(this),this._vrButton=e,t.appendChild(e)),setTimeout(()=>{ks.resetButtonStyles(e),ks.resetButtonStyles(i)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(i){var e;if(!i)return;const t=this.context.renderer.xr.getSession();if(t){const s=i.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!s)return;this._currentHeadPose=s;const r=s?.transform;r&&this._transformOrientation.set(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w),ks._isInXr===!1&&t&&this.onEnterXR(t,i);for(const n of this.controllers)n.onUpdate(t);this._isInAR&&((e=this.webAR)==null||e.onUpdate(t,i))}ks.events.dispatchEvent({type:"xrUpdate",frame:i,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 i=0;i<2;i++)vs.Create(this,i,this.gameObject,nf.PhysicalDevice);ks.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(yt(this.context.mainCamera)),this._originalCameraRotation.copy(Rs(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 i=ee.findObjectOfType(Px,this.context);i?(this.rig=i.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new ro,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(i,e){var t,s;console.log("[XR] session begin",i,e),ks._isInXr=!0,this.ensureRig();const r=this.context.renderer.xr.getReferenceSpace();if(r&&this.rig){const a=e.getViewerPose(r),l=a?.transform.orientation;if(l){const c=new Ue(l.x,l.y,l.z,l.w),h=new Ys().setFromQuaternion(c);this.rig.rotateY(h.y)}}const n=this.context.renderer.xr;if(this.context.mainCamera){const a=n.getCamera();wT&&console.log("WebXRCamera",a);const l=(t=this.context.mainCameraComponent)==null?void 0:t.cullingMask;if(a&&l!==void 0){for(const c of a.cameras)c.layers.mask=l;a.layers.mask=l}else if(a){for(const c of a.cameras)c.layers.enableAll();a.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const o=this._requestedAR?ms.AR:ms.VR;switch(Da.Global.Set(o),o){case ms.AR:this.context.xrSessionMode=Mg.ImmersiveAR,this._isInAR=!0,(s=this.webAR)==null||s.onBegin(i);break;case ms.VR:this.context.xrSessionMode=Mg.ImmersiveVR,this._isInVR=!0,this.onEnterVR(i);break}i.addEventListener("end",()=>{console.log("[XR] session end"),ks._isInXr=!1,this.onExitXR(i)}),this.onEnterXR_HandleMirrorWindow(i),ks.events.dispatchEvent({type:"xrStarted",session:i})}onExitXR(i){var e,t,s,r;const n=this._isInAR;i&&(this._isInAR?(e=this.webAR)==null||e.onEnd(i):(t=this.context.mainCameraComponent)==null||t.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&&((s=this._originalCameraParent)==null||s.add(this.context.mainCamera),is(this.context.mainCamera,this._originalCameraPosition),cn(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),n&&((r=this._originalXRRigParent)==null||r.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Da.Global.Set(ms.Browser|ms.ThirdPerson),ks.events.dispatchEvent({type:"xrStopped",session:i})}onEnterVR(i){}destroyControllers(){var i;for(let e=this.controllers.length-1;e>=0;e-=1)(i=this.controllers[e])==null||i.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(i){re("mirror")&&setTimeout(()=>{if(!ks.IsInWebXR)return;const e=new URL(window.location.href);um(e.searchParams,sx,1),um(e.searchParams,"isMirror",1);const t=e.toString();this.xrMirrorWindow=window.open(t,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{ks.IsInWebXR&&i.end()})})},1e3)}},u(lf,"_isInXr",!1),u(lf,"events",new Cs),u(lf,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),u(lf,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),lf);let wt=ks;af([w()],wt.prototype,"enableVR",2),af([w()],wt.prototype,"enableAR",2),af([w(wr)],wt.prototype,"defaultAvatar",2),af([w()],wt.prototype,"handModelPath",2),af([w()],wt.prototype,"createVRButton",2),af([w()],wt.prototype,"createARButton",2);const hv=class{constructor(i){u(this,"_webxr"),u(this,"reticle",null),u(this,"reticleParent",null),u(this,"hitTestSource",null),u(this,"reticleActive",!0),u(this,"previousBackground",null),u(this,"previousEnvironment",null),u(this,"sessionRoot",null),u(this,"_previousParent",null),u(this,"arDomOverlay",null),u(this,"arOverlayElement",null),u(this,"noHitTestAvailable",!1),u(this,"didPlaceARSessionRoot",!1),this._webxr=i}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const i=this.arDomOverlay;return i.getAROverlayContainer?this.arOverlayElement=i.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(i){this.reticleActive=i}async onBegin(i){var e,t,s,r;const n=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const o=(e=navigator.userAgent)!=null&&e.includes("OculusBrowser")?nf.PhysicalDevice:nf.Touch,a=o===nf.Touch?4:2;for(let c=0;c<a;c++)vs.Create(this.webxr,c,this.webxr.gameObject,o);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=ee.findObjectOfType(ka,n)),!this.sessionRoot){const c=this.webxr.gameObject;this.sessionRoot=ee.addNewComponent(c,ka),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=n.scene.background,this.previousEnvironment=n.scene.environment,n.scene.background=null,i.requestReferenceSpace("viewer").then(c=>{var h,d;(d=(h=i.requestHitTestSource)==null?void 0:h.call(i,{space:c}))==null||d.then(p=>{this.hitTestSource=p}).catch(p=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",p)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new xe(new DA(.07,.09,32).rotateX(-Math.PI/2),new hi),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new De,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,hv.tempWebXRObject||(hv.tempWebXRObject=new De),this.context.scene.add(hv.tempWebXRObject),ee.addComponent(hv.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(t=this.sessionRoot)==null||t.onBegin(i)):console.warn("No WebARSessionRoot found in scene");const l=this.context.domElement;(s=l?.onEnterAR)==null||s.call(l,i,this.arOverlayElement),(r=this.context.mainCameraComponent)==null||r.applyClearFlagsIfIsActiveCamera()}onEnd(i){var e,t;this._previousParent&&(ee.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const s=this.webxr.context;s.scene.background=this.previousBackground,s.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,i);const r=this.context.domElement;(e=r.onExitAR)==null||e.call(r,i),(t=this.context.mainCameraComponent)==null||t.applyClearFlagsIfIsActiveCamera()}onUpdate(i,e){var t,s;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const n=this.webxr.Rig,o=ese.clone();(t=this.sessionRoot)==null||t.placeAt(n,o)}return}if(!this.hitTestSource)return;const r=e.getHitTestResults(this.hitTestSource);if(r.length){const n=r[0],o=this.webxr.context.renderer.xr.getReferenceSpace();if(o){const a=n.getPose(o);if(this.sessionRoot){const l=this.sessionRoot.onUpdate(this.webxr.Rig,i,a);this.didPlaceARSessionRoot=l}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&a)){const l=a.transform.matrix;this.reticle.matrix.fromArray(l),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(s=this.sessionRoot)==null||s.onUpdate(this.webxr.Rig,i,null),this.reticle&&(this.reticle.visible=!1)}};let uv=hv;u(uv,"tempWebXRObject");const ese=new Be().identity().makeTranslation(0,0,0);class bc{constructor(e,t){u(this,"used",!1),u(this,"inputSource"),u(this,"object"),u(this,"pointerId"),u(this,"isDown"),u(this,"isUp"),u(this,"isPressed"),u(this,"isClicked"),u(this,"input"),u(this,"event"),this.event=t,this.input=e}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}clone(){const e=new bc(this.input,this.event);return Object.assign(e,this),e}}class cf extends Me{awake(){Fn.createIfNoneExists(this.context)}onEnable(){var e;(e=Fn.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Fn.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class Yl extends cf{constructor(){super(...arguments),u(this,"targets",null),u(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(e=null){return this.targets?(e??(e=new Go),e.targets=this.targets,e.results=this.raycastHits,this.context.physics.raycast(e)):null}}class ST extends Yl{}const dv=re("debugeventsystem");var CT=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(CT||{});const Jl=class extends Me{constructor(){super(),u(this,"raycaster",[]),u(this,"_selectStartFn"),u(this,"_selectEndFn"),u(this,"_selectUpdateFn"),u(this,"_handleEventFn"),u(this,"lastPointerEvent",null),u(this,"objectsHoveredThisFrame",[]),u(this,"objectsHoveredLastFrame",[]),u(this,"raisedPointerDownEvents",[]),u(this,"raisedPointerDownObjects",[]),u(this,"_didMove",!1),u(this,"_tempComponentsArray",[]),u(this,"_sortedHits",[]),u(this,"_sortingBuffer",[]),u(this,"_noDepthTestingResults",[]),u(this,"handleEventsArray",[]),u(this,"out",{}),u(this,"currentActiveMeshUIComponents",[]),Jl.systems.push(this)}static createIfNoneExists(i){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Jl.systems.length<=0&&Jl.systems.push(...ee.findObjectsOfType(Jl,i)));for(const t of Jl.systems)if(t.context===i)return;const e=new De;ee.addNewComponent(e,Jl),i.scene.add(e)}static get systems(){const i=Lt.Current;return this._eventSystemMap.has(i)||this._eventSystemMap.set(i,[]),this._eventSystemMap.get(i)}static get(i){const e=this._eventSystemMap.get(i);return e&&e.length>0?e[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(i,e){Kl.update(i,e)}static markUIDirty(i){Kl.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){Jl.systems.splice(Jl.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ee.findObjectOfType(cf,this.context)){const i=ee.addNewComponent(this.context.scene,Yl);this.raycaster.push(i),qi()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(i){var e;i&&this.raycaster&&!this.raycaster.includes(i)&&((e=this.raycaster)==null||e.push(i))}unregister(i){var e,t;const s=(e=this.raycaster)==null?void 0:e.indexOf(i);s!==void 0&&s!==-1&&((t=this.raycaster)==null||t.splice(s,1))}onEnable(){const i=new Map;this._selectStartFn??(this._selectStartFn=(t,s)=>{if(!s.grab)return;Kl.resetLastSelected();const r=new bc(this.context.input);r.inputSource=t,r.pointerId=0,r.isDown=t.selectionDown,r.isUp=t.selectionUp,r.isPressed=t.selectionPressed,r.isClicked=!1,i.set(t,s.grab),s.grab&&!this.handleEvents(s.grab,r)&&(s.grab=null)}),this._selectEndFn??(this._selectEndFn=(t,s)=>{var r;if(!s.grab)return;const n=new bc(this.context.input);n.inputSource=t,n.pointerId=0,n.isDown=t.selectionDown,n.isUp=t.selectionUp,n.isPressed=t.selectionPressed,n.isClicked=t.selectionClick,this.handleEvents(s.grab,n);const o=i.get(t);if(i.set(t,null),o)for(let a=0;a<this.raisedPointerDownEvents.length;a++){const l=this.raisedPointerDownEvents[a];this.raisedPointerDownObjects[a]===o&&l&&((r=l.onPointerUp)==null||r.call(l,n),this.raisedPointerDownEvents.splice(a,1),this.raisedPointerDownObjects.splice(a,1),a--)}});const e=new Go;this._selectUpdateFn??(this._selectUpdateFn=t=>{e.ray=t.getRay();const s=this.performRaycast(e);if(!s)return;const r=new bc(this.context.input);r.inputSource=t,this.handleIntersections(s,r)}),vs.addEventListener(ql.SelectStart,this._selectStartFn),vs.addEventListener(ql.SelectEnd,this._selectEndFn),vs.addEventListener(ql.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){vs.removeEventListener(ql.SelectStart,this._selectStartFn),vs.removeEventListener(ql.SelectEnd,this._selectEndFn),vs.removeEventListener(ql.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(),wt.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const n=this.context.input.getPointerPositionRC(0);if(n&&n.x===0&&n.y===0)return;this._didMove=!0}let i=0;for(const n of this.context.input.foreachPointerId()){const o=this.context.input.getPointerDown(n),a=this.context.input.getPointerUp(n);if(o||a){i=n;break}}const e=this.context.input.getPointerEvent(i),t=new bc(this.context.input,e);t.inputSource=this.context.input,t.pointerId=i,t.isClicked=this.context.input.getPointerClicked(i),t.isDown=this.context.input.getPointerDown(i),t.isUp=this.context.input.getPointerUp(i),t.isPressed=this.context.input.getPointerPressed(i),dv&&t.isClicked&&console.log("CLICK",i);const s=this.performRaycast(null);if(!s)return;this.lastPointerEvent=t;const r={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};dv&&t.isClicked&&hs("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:r})),this.handleIntersections(s,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:r}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const e of this.raisedPointerDownEvents)e.onPointerUp&&e.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const e of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(e)<0){this._tempComponentsArray.length=0;const t=ee.getComponentsInParent(e,Me,this._tempComponentsArray);this.lastPointerEvent.object=e;for(let s=0;s<t.length;s++){const r=t[s];if(!r.gameObject||r.destroyed)continue;const n=r;n.onPointerExit&&n.onPointerExit(this.lastPointerEvent)}}const i=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=i}performRaycast(i){if(!this.raycaster)return null;this._sortedHits.length=0;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;const t=e.performRaycast(i);t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.distance),this._sortedHits}handleIntersections(i,e){if(!i||i.length<=0)return!1;i=this.sortCandidates(i);for(const t of i){const{object:s}=t;if(this.handleEvents(s,e))return!0}return!1}sortCandidates(i){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<i.length;e++){const t=i[e],s=t.object;if(s.material&&s.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEvents(i,e){if(!this.testIsVisible(i))return e.isClicked&&dv&&console.log("not allowed",i),!1;const t=i;e.object=i,this.lastPointerEvent=e;const s=i.parent;let r=!1;const n=e.isClicked??!1;let o=null;if(s&&s.isUI){const a=(e.isPressed||e.isClicked)??!1;if(s[Na]){const l=s[Na].gameObject;if(l){if(!rf.isInteractable(l,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(i,a),i=l,r=!0}}if(!r&&this.handleMeshUiObjectWithoutShadowDom(s,a))return!0}if(n&&dv&&console.log(this.context.time.frame,i),this.objectsHoveredThisFrame.push(i),o===null||o.interactable){const a=this.objectsHoveredLastFrame.indexOf(i)>=0;this.handleEventsArray.length=0;const l=ee.getComponentsInParent(i,Me,this.handleEventsArray);for(let c=0;c<l.length;c++){if(e.used)return!0;if(l[c].destroyed)continue;const h=l[c];if(h.interactable!==!1){if(h.onPointerEnter&&(a||h.onPointerEnter(e)),h.onPointerMove&&h.onPointerMove(e),e.isDown&&h.onPointerDown&&!this.raisedPointerDownEvents.includes(h)&&(h.onPointerDown(e),this.raisedPointerDownEvents.push(h),this.raisedPointerDownObjects.push(t)),e.isUp&&h.onPointerUp){const d=this.raisedPointerDownEvents.indexOf(h);d!==-1&&this.raisedPointerDownEvents.splice(d,1),h.onPointerUp(e)}e.isClicked&&h.onPointerClick&&h.onPointerClick(e)}}}return!0}handleMeshUiObjectWithoutShadowDom(i,e){return!i||!i.isUI?!0:this.handleMeshUIIntersection(i,e)}handleMeshUIIntersection(i,e){const t=Kl.updateState(i,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Kl.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let i=0;i<this.currentActiveMeshUIComponents.length;i++){const e=this.currentActiveMeshUIComponents[i];Kl.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(i){return i?ee.isActiveSelf(i)?this.testIsVisible(i.parent):!1:!0}};let Fn=Jl;u(Fn,"_eventSystemMap",new Map),u(Fn,"didSearchEventSystem",!1);class Kl{static markDirty(){this.needsUpdate=!0}static update(e,t){const s=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(s===r.frame)return;r.frame=s;let n=this.needsUpdate||s<1;r.nextUpdate===t.time.frameCount&&(n=!0),n&&(dv&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:s,nextUpdate:s}],e.update()}static updateState(e,t){let s=null;if(e&&(s=this.findBlockInParent(e),s&&s!==this.lastSelected)){if(s.interactable===!1)return null;this.needsUpdate=!0}return s}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}u(Kl,"lastSelected",null),u(Kl,"lastUpdateFrame",[]),u(Kl,"needsUpdate",!1);const kx=Symbol("cameraController");function tse(i){return i[kx]}function V3(i,e,t){t?i[kx]=e:i[kx]===e&&(i[kx]=null)}var ise=Object.defineProperty,sse=Object.getOwnPropertyDescriptor,rse=(i,e,t,s)=>{for(var r=s>1?void 0:s?sse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ise(e,t,r),r};const Dx=re("freecam"),ET=re("debugcamerafit"),nse={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let MT;class Zl extends Me{constructor(){super(...arguments),u(this,"autoRotate",!1),u(this,"autoRotateSpeed",1),u(this,"enableKeys",!0),u(this,"enableDamping",!0),u(this,"dampingFactor",.1),u(this,"enableZoom",!0),u(this,"minZoom",0),u(this,"maxZoom",1/0),u(this,"enablePan",!0),u(this,"lookAtConstraint",null),u(this,"lookAtConstraint01",1),u(this,"middleClickToFocus",!0),u(this,"doubleClickToFocus",!0),u(this,"useSlerp",!0),u(this,"debugLog",!1),u(this,"targetLerpSpeed",5),u(this,"_lookTargetPosition"),u(this,"_controls",null),u(this,"_cameraObject",null),u(this,"_lerpToTargetPosition",!1),u(this,"_lerpCameraToTarget",!1),u(this,"_cameraTargetPosition",null),u(this,"_inputs",0),u(this,"_enableTime",0),u(this,"_startedListeningToKeyEvents",!1),u(this,"_eventSystem"),u(this,"_afterHandleInputFn"),u(this,"_camera",null),u(this,"_syncedTransform"),u(this,"targetElement",null),u(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),u(this,"_shouldDisable",!1),u(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}awake(){this._lookTargetPosition=new S,this._startedListeningToKeyEvents=!1}start(){if(this._controls){const e=ee.getComponent(this.gameObject,Di);if(e&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const t=yt(e.cam).length(),s=new S(0,0,-t).applyMatrix4(e.cam.matrixWorld);this.setTarget(s,!0)}}this.startCoroutine(this.startRaycastDelayed()),this._eventSystem=Fn.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(CT.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(CT.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=ee.getComponent(this.gameObject,Di);this._camera=e;const t=e?.cam;if(t&&V3(t,this,!0),!this._controls){console.assert(t!=null,"Missing camera",this),t&&(this._cameraObject=t);const s=this.targetElement??this.context.domElement,r=t?.quaternion.clone();this._controls=new rZ(t,s),t?.quaternion.copy(r),MT===void 0&&(MT={...this._controls.keys})}this._controls&&(Dx&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Cc()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?Dx||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Dx||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=ee.getComponent(this.gameObject,mh)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&V3(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,!this.setFromTargetPosition()){const e=new Go;e.screenPoint=new Y(0,0),e.lineThreshold=.1;const t=this.context.physics.raycast(e);t.length>0&&this.setTarget(t[0].point,!0)}}onBeforeRender(){var e,t,s;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 r=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(r||(r=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),r?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const n=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const o=(e=this._cameraObject)==null?void 0:e.position;Zk(o,this._cameraTargetPosition,n)}else(t=this._cameraObject)==null||t.position.lerp(this._cameraTargetPosition,n);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,n),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!Dx&&(s=this.lookAtConstraint)!=null&&s.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?MT:nse,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(e,t=!1){var s;e?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=e.clone(),t&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(e=0,t=1){var s;if(!this._controls)return!1;const r=(s=this.lookAtConstraint)==null?void 0:s.sources;if(r&&r.length>0){const n=r[e];if(n)return n.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,t),!0}return!1}setTarget(e=null,t=!1){this._controls&&(e!==null&&this._lookTargetPosition.copy(e),t?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(e,t){this._controls&&this._controls.target.lerp(e,t)}distanceToTarget(e){return this._controls?this._controls.target.distanceTo(e):-1}setTargetFromRaycast(){var e,t;if(!this.controls)return;const s=this.context.physics.raycast();for(const r of s)if(r.distance>0&&ee.isActiveInHierarchy(r.object)){if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const n=yt(this.context.mainCamera);this._cameraTargetPosition=n.clone().sub(this.controls.target).add(this._lookTargetPosition),(t=(e=this._cameraObject)==null?void 0:e.parent)==null||t.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(e,t=1.1){const s=this._cameraObject,r=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!s||!r)return;const n=new S,o=new S,a=new Es;a.makeEmpty();for(const v of e)v instanceof hC||v instanceof cC||a.expandByObject(v,!0);if(s.updateMatrixWorld(),s.updateProjectionMatrix(),a.getCenter(o),a.applyMatrix4(s.matrixWorldInverse),a.getSize(n),a.setFromCenterAndSize(o,n),n.length()<=1e-10){ET&&console.warn("Camera fit size is zero",a,[...e]);return}const l=s.fov,c=2*Math.atan(Math.tan(l*Math.PI/360/2)*s.aspect)/Math.PI*360,h=n.y/(2*Math.atan(Math.PI*l/360)),d=n.x/(2*Math.atan(Math.PI*c/360)),p=t*Math.max(h,d)+n.z/2;ET&&console.log("Fit camera to objects",h,d,"distance",p);const f=yt(s),m=r.target.clone().sub(f).normalize().multiplyScalar(p);if(r.maxDistance=p*10,r.minDistance=p*.01,r.target.copy(o),s.near=p/100,s.far=p*100,s.updateMatrixWorld(),s.updateProjectionMatrix(),is(s,r.target.clone().sub(m)),ET){const v=new hC(a);this.context.scene.add(v),oD(v,ky(s)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",A=>{A.code==="KeyF"&&this.fitCamera(e)}))}r.update()}}rse([w(Hg)],Zl.prototype,"lookAtConstraint",2);var ose=Object.defineProperty,ase=Object.getOwnPropertyDescriptor,_o=(i,e,t,s)=>{for(var r=s>1?void 0:s?ase(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ose(e,t,r),r},W3=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(W3||{});const pv=re("debugcam"),q3=re("debugscreenpointtoray");var Ox;const fv=(Ox=class extends Me{constructor(){super(...arguments),u(this,"_nearClipPlane",.1),u(this,"_farClipPlane",1e3),u(this,"orthographic",!1),u(this,"orthographicSize",5),u(this,"ARBackgroundAlpha",0),u(this,"_cullingMask",4294967295),u(this,"_backgroundBlurriness"),u(this,"_backgroundIntensity"),u(this,"_targetTexture",null),u(this,"_backgroundColor"),u(this,"_fov"),u(this,"_cam",null),u(this,"_clearFlags",2),u(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof Xt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof Xt?this._cam.fov:this._fov}set fieldOfView(i){const e=this.fieldOfView!=i;if(this._fov=i,e&&this._cam&&this._cam instanceof Xt){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(i){const e=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&e&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const e=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&e&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,e,t){let s=this.cam;const r=fv._origin;r.set(i,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),q3&&console.log("screenPointToRay",i.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const n=fv._direction.set(r.x,r.y,r.z),o=yt(s);return n.sub(o),n.normalize(),t?(t.set(o,n),t):new _a(o.clone(),n.clone())}awake(){q3&&window.addEventListener("pointerdown",i=>{const e=i.clientX,t=i.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const s=this.screenPointToRay(e,t),r="#"+Math.floor(Math.random()*16777215).toString(16);Ll.DrawRay(s.origin,s.direction,r,10)})}onEnable(){pv&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),cse(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 i=this.context.renderer;i&&this._targetTexture.render(this.context.scene,this._cam,i)}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let e=null;if(i?(e=this.gameObject,e?.layers.enableAll(),e instanceof Xt&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Xt&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Xt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new cu(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){pv&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,pv&&hs("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(fv.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 i=this._backgroundColor.alpha;fv.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,i)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new lse(this)),this._skybox.enable()}static backgroundShouldBeTransparent(i){var e,t,s,r;const n=(e=i.renderer.xr)==null?void 0:e.getSession();if(!n)return!1;const o=n.environmentBlendMode;pv&&hs("Environment blend mode: "+o+" on "+navigator.userAgent);const a=o==="additive"||o==="alpha-blend";return i.xrSessionMode===Mg.ImmersiveAR&&o==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))?!0:a}},u(Ox,"_origin",new S),u(Ox,"_direction",new S),Ox);let Di=fv;_o([w()],Di.prototype,"fieldOfView",1),_o([w()],Di.prototype,"nearClipPlane",1),_o([w()],Di.prototype,"farClipPlane",1),_o([w()],Di.prototype,"clearFlags",1),_o([w()],Di.prototype,"orthographic",2),_o([w()],Di.prototype,"orthographicSize",2),_o([w()],Di.prototype,"ARBackgroundAlpha",2),_o([w()],Di.prototype,"cullingMask",1),_o([w()],Di.prototype,"backgroundBlurriness",1),_o([w()],Di.prototype,"backgroundIntensity",1),_o([w(Ai)],Di.prototype,"backgroundColor",1),_o([w(Qp)],Di.prototype,"targetTexture",1);class lse{constructor(e){u(this,"_camera"),u(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(pv&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=st,this._skybox.mapping=Zn,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function cse(i){re("freecam")&&i.context.mainCameraComponent===i&&ee.getOrAddComponent(i.gameObject,Zl)}class hf extends Me{constructor(){super(...arguments),u(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new sC),this._listener}awake(){fs.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=ee.getComponentInParent(this.gameObject,Di);t?t.cam.add(e):this.gameObject.add(e)})}}var hse=Object.defineProperty,use=Object.getOwnPropertyDescriptor,Lx=(i,e,t,s)=>{for(var r=s>1?void 0:s?use(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&hse(e,t,r),r};const dse=re("debugsignals");class mv{constructor(){u(this,"guid")}}Lx([w()],mv.prototype,"guid",2);class uf{constructor(){u(this,"signal"),u(this,"reaction")}}Lx([w(mv)],uf.prototype,"signal",2),Lx([w(pn)],uf.prototype,"reaction",2);var TT;const $l=(TT=class extends Me{constructor(){super(...arguments),u(this,"events")}static invoke(i){if($l.receivers[i]){const e=$l.receivers[i];if(!e)return;for(const t of e)t.invoke(i)}}awake(){dse&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)$l.receivers[i.signal.guid]||($l.receivers[i.signal.guid]=[]),$l.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if($l.receivers[i.signal.guid]){const e=$l.receivers[i.signal.guid].indexOf(this);e>=0&&$l.receivers[i.signal.guid].splice(e,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;let e=typeof i=="object"?i.guid:i;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(s){console.error(s)}}},u(TT,"receivers",{}),TT);let df=$l;Lx([w(uf)],df.prototype,"events",2);var Nn=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(Nn||{}),Qa=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Qa||{}),IT=(i=>(i.Signal="SignalEmitter",i))(IT||{});const gv=re("debugtimeline"),RT=class extends Me{constructor(){super(...arguments),u(this,"playableAsset"),u(this,"playOnAwake"),u(this,"extrapolationMode",1),u(this,"waitForAudio",!0),u(this,"_visibilityChangeEvt"),u(this,"_clonedPlayableAsset",!1),u(this,"_speed",1),u(this,"_guidsMap"),u(this,"_isPlaying",!1),u(this,"_internalUpdateRoutine"),u(this,"_isPaused",!1),u(this,"_time",0),u(this,"_duration",0),u(this,"_weight",1),u(this,"_animationTracks",[]),u(this,"_audioTracks",[]),u(this,"_signalTracks",[]),u(this,"_controlTracks",[]),u(this,"_customTracks",[]),u(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks])}static registerCreateTrack(i,e){this.createTrackFunctions[i]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(gv||Rr())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,e,t;gv&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var i,e;for(const t of this._audioTracks)(i=t.onEnable)==null||i.call(t);for(const t of this._customTracks)(e=t.onEnable)==null||e.call(t);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 i,e;this.stop();for(const t of this._audioTracks)(i=t.onDisable)==null||i.call(t);for(const t of this._customTracks)(e=t.onDisable)==null||e.call(t);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const e of this._allTracks)for(const t of e)(i=t.onDestroy)==null||i.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,i&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const e=[];for(const t of this._audioTracks){const s=t.loadAudio(this._time,1,0);s&&e.push(s)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!fs.userInteractionRegistered&&this.waitForAudio;)await dm(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 t of this._audioTracks)t.stop();const i=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!e&&this.invokePauseChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null}evaluate(){if(!this.isValid())return;let i=this._time;switch(this.extrapolationMode){case 0:this._speed>0?i=Math.min(i,this._duration):this._speed<0&&(i=Math.max(i,0)),this._time=i;break;case 1:i%=this._duration,this._time=i;break;case 2:if(i>this._duration){this.stop();return}break}this.internalEvaluate(i)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const i of this._allTracks)for(const e of i)yield e}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onPauseChanged)==null||i.call(e)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(i){for(const e of this.playableAsset.tracks)if(!e.muted)switch(e.type){case Nn.Activation:for(let t=0;t<e.outputs.length;t++){const s=e.outputs[t];if(typeof s=="object"){let r=!1;for(const o of e.clips)o.start<=i&&i<=o.end&&(r=!0);const n=s;n.visible!==void 0&&(n.visible=r)}}break}for(const e of this._animationTracks)e.evaluate(i);for(const e of this._audioTracks)e.evaluate(i);for(const e of this._signalTracks)e.evaluate(i);for(const e of this._controlTracks)e.evaluate(i);for(const e of this._customTracks)e.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=VA(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let s=e.outputs[t];if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const r=ee.findByGuid(s,i);r===null||typeof r!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",s,e.name,e.type)):(gv&&console.log("Resolved binding",s,"to",r),e.outputs[t]=r)}else if(s===null){if(e.outputs.splice(t,1),RT.createTrackFunctions[e.type])continue;e.type!==Nn.Audio&&e.type!==Nn.Control&&e.type!==Nn.Marker&&e.type!==Nn.Signal&&console.warn("Missing binding",s,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===Nn.Control)for(let t=0;t<e.clips.length;t++){const s=e.clips[t];let r=s.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const n=ee.findByGuid(r,i);n===null||typeof n!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,s):(gv&&console.log("Resolved binding",r,"to",n),s.asset.sourceObject=n)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){for(const e of i.clips)e.end>this._duration&&(this._duration=e.end);for(const e of i.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var i,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=ee.findObjectOfType(hf,this.context);for(const s of this.playableAsset.tracks){const r=s.type,n=RT.createTrackFunctions[r];if(n!=null){const o=n(this,s);if(typeof o.evaluate=="function"){o.director=this,o.track=s,this._customTracks.push(o);continue}}if(s.type===Nn.Animation){if(s.clips.length<=0){gv&&console.warn("Animation track has no clips",s);continue}for(let o=s.outputs.length-1;o>=0;o--){let a=s.outputs[o];if(a instanceof De){const c=ee.getOrAddComponent(a,Vr);c&&(a=c)}const l=(i=a?.gameObject)==null?void 0:i.animations;if(l){const c=new Ux;c.trackOffset=s.trackOffset,c.director=this,c.track=s;for(let h=0;h<s.clips.length;h++){const d=s.clips[h],p=d.asset;if(!p){console.error("MISSING anim model?","clip#"+h,d,s,this.playableAsset,this.name);continue}const f=p.clip;let m=f;if((typeof m=="string"||typeof m=="number")&&(m=l.find(A=>A.name===f)),!m){console.warn("Could not find animationClip for model",d,s.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}c.mixer||(c.mixer=new yy(a.gameObject)),c.clips.push(m),c.mixer.uncacheAction(m),c.createHooks(d.asset,m);const v=c.mixer.clipAction(m);c.actions.push(v),c.models.push(d)}this._animationTracks.push(c)}}}else if(s.type===Nn.Audio){if(s.clips.length<=0)continue;const o=new yv;if(o.director=this,o.track=s,this._audioTracks.push(o),!t)continue;o.listener=t.listener;for(let a=0;a<s.clips.length;a++){const l=s.clips[a];o.addModel(l)}}else if(s.type===Nn.Marker){const o=new bv;o.director=this,o.track=s;for(const a of s.markers)switch(a.type){case IT.Signal:o.models.push(a),o.didTrigger.push(!1);break}if(o!==null&&o.models.length>0){const a=ee.getComponent(this.gameObject,df);a&&(o.receivers.push(a),this._signalTracks.push(o))}}else if(s.type===Nn.Signal){const o=new bv;o.director=this,o.track=s;for(const a of s.markers)o.models.push(a),o.didTrigger.push(!1);for(const a of s.outputs)o.receivers.push(a);this._signalTracks.push(o)}else if(s.type===Nn.Control){const o=new Fx;o.director=this,o.track=s;for(const a of s.clips)o.models.push(a);o.resolveSourceObjects(this.context),this._controlTracks.push(o)}}}setAudioTracksAllowPlaying(i){for(const e of this._audioTracks)e.onAllowAudioChanged(i)}};let Qu=RT;u(Qu,"createTrackFunctions",{});const ju=re("debugtimeline");class vv{constructor(){u(this,"director"),u(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let s=this.track.clips.length-1;s>=0;s--)yield this.track.clips[s];else for(const s of this.track.clips)yield s}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,s,r=!0){if(t<0||t>=s.length)return 0;const n=s[t];if(r||e>=n.start&&e<=n.end){let o=1,a=!1;if(n.easeInDuration>0){const l=Math.min((e-n.start)/n.easeInDuration,1);o*=l}if(n.easeOutDuration>0&&!a){const l=Math.min((n.end-e)/n.easeOutDuration,1);o*=l}return o}return 0}}class pse{constructor(e){u(this,"clip"),u(this,"rootPositionOffset"),u(this,"rootQuaternionOffset"),u(this,"rootStartPosition"),u(this,"rootEndPosition"),u(this,"rootStartQuaternion"),u(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const s=e.getRoot(),r=s.name+".position",n=s.name+".quaternion";ju&&console.log(t.name,t.tracks,r);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(r))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),ju&&console.log(this.rootPositionOffset);else if(o.name.endsWith(n)&&(this.rootStartQuaternion=new Ue().fromArray(o.values,0),this.rootEndQuaternion=new Ue().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),ju)){const a=new Ys().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Ux extends vv{constructor(){super(...arguments),u(this,"models",[]),u(this,"trackOffset"),u(this,"target"),u(this,"mixer"),u(this,"clips",[]),u(this,"actions",[]),u(this,"_actionOffsets",[]),u(this,"_didBind",!1),u(this,"_animator",null),u(this,"_animatorWasEnabled",!1),u(this,"_useclipOffsets",!0),u(this,"_totalOffsetPosition",new S),u(this,"_totalOffsetRotation",new Ue),u(this,"_totalOffsetPosition2",new S),u(this,"_totalOffsetRotation2",new Ue),u(this,"_summedPos",new S),u(this,"_tempPos",new S),u(this,"_summedRot",new Ue),u(this,"_tempRot",new Ue),u(this,"_clipRotQuat",new Ue)}onPauseChanged(){this._animator&&this._animatorWasEnabled!==void 0&&(this._animator.enabled=this.director.isPlaying===!1?this._animatorWasEnabled:!1)}createHooks(e,t){var s,r;if(((s=t.tracks)==null?void 0:s.length)<=0){console.warn("No tracks in AnimationClip",t);return}const n=t.tracks[0].name.split("."),o=n[n.length-2],a=o+".position",l=o+".quaternion";let c=!1,h=!1;for(const d of t.tracks)d.name.endsWith(a)?(c=!0,this.createPositionInterpolant(t,e,d)):d.name.endsWith(l)&&(h=!0,this.createRotationInterpolant(t,e,d));if(!c||!h){const d=(r=this.mixer)==null?void 0:r.getRoot(),p=t.tracks[0],f=p.name.lastIndexOf("."),m=p.name.substring(0,f),v=m.substring(m.lastIndexOf(".")+1),A=d.getObjectByName(v);if(A)if(c){if(!h){const g=t.tracks[0].name.substring(0,f)+".quaternion";ju&&console.warn("Create quaternion track",v,A);const b=A.quaternion,y=new wa(g,[0,t.duration],[b.x,b.y,b.z,b.w,b.x,b.y,b.z,b.w]);t.tracks.push(y),this.createRotationInterpolant(t,e,y)}}else{const g=m+".position";ju&&console.warn("Create position track",v,A);const b=A.position,y=new Qc(g,[0,t.duration],[b.x,b.y,b.z,b.x,b.y,b.z]);t.tracks.push(y),this.createPositionInterpolant(t,e,y)}}}bind(){if(!this._didBind){this._didBind=!0,ju&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new pse(e);this._actionOffsets.push(t)}this.target&&(this._animator=ee.getComponent(this.target,Vr)??null,this._animator?(this._animatorWasEnabled=this._animator.enabled,this._animator.enabled=!1):this._animatorWasEnabled=!1);for(const e of this.models){const t=e.asset,s=t.position,r=t.rotation;s&&s.x!==void 0&&(s.isVector3||(t.position=new S(s.x,s.y,s.z)),r.isQuaternion||(t.rotation=new Ue(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new S(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Ue(t.x,t.y,t.z,t.w)))}}evaluate(e){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 t=0,s=0,r=!1,n=!1;for(let o=0;o<this.clips.length;o++){const a=this.models[o],l=this.actions[o],c=a.asset;l.weight=0;const h=e>=a.start&&e<=a.end,d=a.preExtrapolationMode,p=a.postExtrapolationMode,f=o<this.clips.length-1?this.models[o+1]:null;let m=h,v=!1;if(!m&&!r&&a.end<e&&p!==Qa.None?(!f||f.start>e)&&(m=!0,r=!0):o==0&&!m&&!n&&a.start>e&&d!==Qa.None&&(!f||f.start<e)&&(m=!0,v=!0,n=!0),m){let A=1;A*=this.evaluateWeight(e,o,this.models,m),A*=this.director.weight;let g=h;if(v)switch(d){case Qa.Hold:break;case Qa.Loop:e+=a.start,g=!0;break;default:e+=a.start,g=!0;break}let b=this.getClipTime(e,a),y=0;const x=c.duration;if(v&&d===Qa.Hold&&(b=0),g){if(c.loop)for(y+=Math.floor(b/(x+1e-6));b>x;)b-=x}else if(!h&&r)switch(p){case Qa.Hold:b=this.getClipTime(a.end,a);break;case Qa.Loop:b%=x;break;case Qa.PingPong:const E=Math.floor(b/x)%2!==0;b%=x,E&&(b=x-b);break}a.reversed===!0?l.time=l.getClip().duration-b:l.time=b,l.timeScale=0;const _=A;if(l.weight=_,l.clampWhenFinished=!0,l.isRunning()||l.play(),this._useclipOffsets){const E=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,I=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(s=1-A),t+=1;const P=this._summedPos.set(0,0,0),M=this._tempPos.set(0,0,0),C=this._summedRot.identity(),U=this._tempRot.identity(),G=c.rotation;G&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(G,A));const F=this._actionOffsets[o];if(F.hasOffsets)for(let z=0;z<y;z++)F.rootPositionOffset?M.copy(F.rootPositionOffset):M.set(0,0,0),M.applyQuaternion(C),this._clipRotQuat&&M.applyQuaternion(this._clipRotQuat),F.rootQuaternionOffset&&(U.copy(F.rootQuaternionOffset),C.multiply(U)),P.add(M);this._clipRotQuat&&I.multiply(this._clipRotQuat),I.multiply(C),c.position&&P.add(c.position),E.add(P)}}}this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.mixer.update(e)}createRotationInterpolant(e,t,s){var r;const n=s.createInterpolant.bind(s),o=new Ue;this.ensureTrackOffsets();const a=(r=this.trackOffset)==null?void 0:r.rotation;s.createInterpolant=()=>{const l=n(),c=l.evaluate.bind(l);return l.evaluate=h=>{const d=c(h);return o.set(d[0],d[1],d[2],d[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),d[0]=o.x,d[1]=o.y,d[2]=o.z,d[3]=o.w,d},l}}createPositionInterpolant(e,t,s){var r,n;const o=s.createInterpolant.bind(s),a=new S;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation,c=(n=this.trackOffset)==null?void 0:n.position;let h;s.createInterpolant=()=>{const d=o(),p=d.evaluate.bind(d);return d.evaluate=f=>{var m,v;const A=p(f);return a.set(A[0],A[1],A[2]),t.removeStartOffset&&(h===void 0?(h=null,h=(v=(m=this._actionOffsets.find(g=>g.clip===e))==null?void 0:m.rootStartPosition)==null?void 0:v.clone()):h!=null&&h.isVector3&&a.sub(h)),a.applyQuaternion(this._totalOffsetRotation),a.add(this._totalOffsetPosition),l&&a.applyQuaternion(l),c&&(a.x-=c.x,a.y+=c.y,a.z+=c.z),A[0]=a.x,A[1]=a.y,A[2]=a.z,A},d}}}const fse=re("mutetimeline"),Av=class extends vv{constructor(){super(...arguments),u(this,"models",[]),u(this,"listener"),u(this,"audio",[]),u(this,"audioContextTimeOffset",[]),u(this,"lastTime",0),u(this,"_audioLoader",null)}getAudioFilePath(i){const e=this.director.sourceId;return Sc(e,i)}onAllowAudioChanged(i){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(i?t.asset.volume:0)}}addModel(i){const e=new Ay(this.listener);this.audio.push(e),this.models.push(i)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop()}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}evaluate(i){if(fse||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=e?.1:0;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=this.audio[s];if((!n||!n.buffer)&&this.isInTimeRange(r,i-1,i+1)&&this.handleAudioLoading(r,n),fs.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale,n.loop=r.asset.loop,i>=r.start&&i<=r.end&&i<this.director.duration){if(this.director.isPlaying==!1){if(n.isPlaying&&n.stop(),this.lastTime===i)continue}else if(!n.isPlaying)n.offset=r.clipIn+(i-r.start)*r.timeScale,n.play(t);else{const a=r.clipIn+(i-r.start)*r.timeScale,l=n.context.currentTime-n._startedAt+n.offset;Math.abs(a-l)>.3&&(n.offset=a,n.stop(),n.play(t))}let o=r.asset.volume;if(e&&(o=0),r.easeInDuration>0){const a=Math.min((i-r.start)/r.easeInDuration,1);o*=a}if(r.easeOutDuration>0){const a=Math.min((r.end-i)/r.easeOutDuration,1);o*=a}n.setVolume(o*this.director.weight)}else n.isPlaying&&n.stop()}this.lastTime=i}loadAudio(i,e=0,t=0){let s=null;const r=i-t,n=i+e;for(const o of this.models)if(this.isInTimeRange(o,r,n)){const a=this.audio[this.models.indexOf(o)],l=this.handleAudioLoading(o,a);l!==null&&(s===null&&(s=[]),s.push(l))}return s!==null?Promise.all(s):null}isInTimeRange(i,e,t){return e<=i.start&&t>=i.end||e>=i.start&&e<=i.end||t>=i.start&&t<=i.end}static dispose(){Av._audioBuffers.clear()}handleAudioLoading(i,e){this._audioLoader||(this._audioLoader=new gy);const t=this.getAudioFilePath(i.asset.clip);if(Av._audioBuffers.get(t)){const r=Av._audioBuffers.get(t);return r.then(n=>{n&&e.setBuffer(n)}),r}ju&&console.warn("LOAD audio track",t,this.director.sourceId);const s=new Promise((r,n)=>{this._audioLoader.load(t,o=>{e.setBuffer(o),r(o)},void 0,o=>{console.error("Error loading audio",o),r(null)})});return Av._audioBuffers.set(t,s),s}};let yv=Av;u(yv,"_audioBuffers",new Map);class bv extends vv{constructor(){super(...arguments),u(this,"models",[]),u(this,"didTrigger",[]),u(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const s=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const n=this.models[r],o=this.didTrigger[r],a=n.time-e;let l=!1;if(n.retroActive)l=a<=1e-6;else{const c=Math.abs(a);c>=1e-5&&c<s&&(l=!0)}if(l){if(!o)if(this.didTrigger[r]=!0,((t=this.receivers)==null?void 0:t.length)<=0)df.invoke(n.asset);else for(const c of this.receivers)c&&c.invoke(n.asset)}else n.emitOnce||(this.didTrigger[r]=!1)}}}class Fx extends vv{constructor(){super(...arguments),u(this,"models",[]),u(this,"timelines",[]),u(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const s=this.models[t].asset;if(!s.sourceObject||typeof s.sourceObject!="object"){console.log("no source object, removing model",t,s),this.models.splice(t,1);continue}else{const r=ee.getComponent(s.sourceObject,Qu);this.timelines.push(r),r&&s.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const o=this.getClipTime(e,r);if(n.controlActivation){const a=n.sourceObject;a.visible=!0}if(n.updateDirector){const a=this.timelines[s];a&&(a.isPlaying&&a.pause(),a.time=o,a.evaluate())}}else{const o=(t=this._previousActiveModel)==null?void 0:t.asset;if(n.controlActivation){const a=n.sourceObject;o?.sourceObject!==a&&(a.visible=!1)}}}}}var mse=Object.defineProperty,gse=Object.getOwnPropertyDescriptor,X3=(i,e,t,s)=>{for(var r=s>1?void 0:s?gse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&mse(e,t,r),r};class Et{constructor(e){u(this,"_active",!0),u(this,"_value"),u(this,"_valueRaw"),u(this,"_defaultValue"),u(this,"valueProcessor"),u(this,"onValueChanged"),this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const s=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,s,this)}testIfValueChanged(e){return this._valueRaw!==e}}X3([w()],Et.prototype,"overrideState",1),X3([w()],Et.prototype,"value",1);var vse=Object.defineProperty,Ase=Object.getOwnPropertyDescriptor,yse=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ase(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&vse(e,t,r),r};const bse=re("debugpost");class Er extends Zc{constructor(e=void 0){if(super(),u(this,"active",!0),u(this,"_result"),u(this,"_didCreateVolumeParameters",!1),e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const s=e[t],r=this[t];r instanceof Et&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){bse&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const s=this[t];s instanceof Et&&s.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Et){const n=e[r];if(n!==void 0){const o=this[r];o.value=n}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Et){const s=e.value;return this[t].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Et&&(this[t]||(this[t]=new Et))}}yse([w()],Er.prototype,"active",2);var xse=Object.defineProperty,_se=Object.getOwnPropertyDescriptor,wse=(i,e,t,s)=>{for(var r=s>1?void 0:s?_se(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&xse(e,t,r),r};const Sse=re("debugpost"),PT={};function wo(i,e){PT[i]=e}function Cse(i){return i.__type in PT?PT[i.__type]:(Sse&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),Er)}class xv{constructor(){u(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}wse([Np([i=>Cse(i),Er])],xv.prototype,"components",2);var Ese=Object.defineProperty,Mse=Object.getOwnPropertyDescriptor,Tse=(i,e,t,s)=>{for(var r=s>1?void 0:s?Mse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Ese(e,t,r),r};class _v extends Er{constructor(){super(...arguments),u(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new N7({preset:Mp.HIGH,edgeDetectionMode:nE.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}Tse([w(Et)],_v.prototype,"preset",2),wo("Antialiasing",_v);class Nx{constructor(){u(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,s){const r=ee.getComponents(e,fs);if(r.length)for(const n of r){if(!n.clip||!n.playOnAwake)continue;const o=n.clip.split("/").pop();this.files.includes(n.clip)||this.files.push(n.clip),t.addEventListener("serialize",(a,l)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${n.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${n.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${n.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const s=t.split("/").pop(),r=await(await(await fetch(t)).blob()).arrayBuffer(),n=new Uint8Array(r);e.files["audio/"+s]=n}}}var Ise=Object.defineProperty,Rse=Object.getOwnPropertyDescriptor,Y3=(i,e,t,s)=>{for(var r=s>1?void 0:s?Rse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Ise(e,t,r),r};const Pse=re("debugmouth");class wv extends Me{constructor(){super(...arguments),u(this,"idle",[]),u(this,"talking",[]),u(this,"marker",null),u(this,"voip",null),u(this,"lastMouthChangeTime",0),u(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=ee.findObjectOfType(yc,this.context),this.marker||(this.marker=ee.getComponentInParent(this.gameObject,Cr))},3e3)}update(){var e;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((e=this.marker)==null?void 0:e.connectionId)??null;if(!t){Pse&&(t=null);return}const s=this.voip.getFrequency(t)??0;this.updateLips(s)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<e.length;s++){const r=e[s];r&&(r.visible=s===t)}}}}Y3([w(De)],wv.prototype,"idle",2),Y3([w(De)],wv.prototype,"talking",2);class BT extends Me{constructor(){super(...arguments),u(this,"voip",null),u(this,"marker",null),u(this,"_startPosition",null)}awake(){this.voip=ee.findObjectOfType(yc,this.context),this.marker=ee.getComponentInParent(this.gameObject,Cr)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());let s=t/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var Bse=Object.defineProperty,kse=Object.getOwnPropertyDescriptor,zx=(i,e,t,s)=>{for(var r=s>1?void 0:s?kse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Bse(e,t,r),r};class Gu extends Me{constructor(){super(...arguments),u(this,"eyes",[]),u(this,"lastBlinkTime",0),u(this,"blinkLength",0),u(this,"eyesOpen",!0),u(this,"state",null)}awake(){this.state=ee.getComponentInParent(this.gameObject,Wr)}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 e of this.eyes)e&&(e.visible=this.eyesOpen)}}}zx([w(De)],Gu.prototype,"eyes",2),zx([w()],Gu.prototype,"lastBlinkTime",2),zx([w()],Gu.prototype,"blinkLength",2),zx([w()],Gu.prototype,"eyesOpen",2);var Dse=Object.defineProperty,Ose=Object.getOwnPropertyDescriptor,kT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ose(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Dse(e,t,r),r},DT;const J3=(DT=class extends Me{constructor(){super(...arguments),u(this,"head",null),u(this,"eyes",null),u(this,"target",null),u(this,"brain",null),u(this,"vec",new S),u(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=ee.getComponentInParent(this.gameObject,qg)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=ee.addNewComponent(this.gameObject,qg)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const i=this.target;if(i&&this.head){const e=this.eyes;if(e){const t=yt(i);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const s=yt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const n=J3.forward;if(n.set(0,0,1),n.applyQuaternion(Rs(this.head)),n.dot(r)>.45)for(let o=0;o<e.length;o++)e[o].lookAt(this.currentTargetPoint)}}}},u(DT,"forward",new S(0,0,1)),DT);let pf=J3;kT([w(De)],pf.prototype,"head",2),kT([w(De)],pf.prototype,"eyes",2),kT([w(De)],pf.prototype,"target",2);var Lse=Object.defineProperty,Use=Object.getOwnPropertyDescriptor,OT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Use(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Lse(e,t,r),r};class ff extends Me{constructor(){super(...arguments),u(this,"length",1),u(this,"depthTest",!0),u(this,"isGizmo",!0),u(this,"_axes",null)}onEnable(){if(this.isGizmo&&!Zm)return;this._axes||(this._axes=new gp(this.length)),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}OT([w()],ff.prototype,"length",2),OT([w()],ff.prototype,"depthTest",2),OT([w()],ff.prototype,"isGizmo",2);class LT extends Me{constructor(){super(...arguments),u(this,"from"),u(this,"to"),u(this,"hint"),u(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;let e=yt(this.to).clone(),t=yt(this.from).clone(),s=e.distanceTo(t),r=e.clone();r.sub(t);let n=t.clone();n.add(e),n.multiplyScalar(.5);let o=yt(this.hint).clone();o.sub(n);let a=new S;a.crossVectors(o,r),a.crossVectors(r,a),a.normalize();let l=s*.5,c=Math.max(this.desiredDistance,l),h=Math.sqrt(c*c-l*l),d=a.clone();d.multiplyScalar(h),d.add(n),is(this.gameObject,d);let p=n.clone();p.sub(a),this.gameObject.lookAt(p)}}class Qx{constructor(){u(this,"behaviours",[]),u(this,"behaviourComponents",[]),u(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(s=>{ee.foreachComponent(s,r=>{var n;const o=r;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const a=(n=o.beforeCreateDocument)==null?void 0:n.call(o,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,s){var r;for(const n of this.behaviourComponents)(r=n.createBehaviours)==null||r.call(n,this,t,s)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var s;if((s=this.behaviours)!=null&&s.length){t.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){console.log("onAfterSerialize",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)console.log("behaviour",t),typeof t.afterSerialize=="function"&&(console.log("beh has afterSerialize",t),t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e))}}var Fse=Object.defineProperty,Nse=Object.getOwnPropertyDescriptor,UT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Nse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Fse(e,t,r),r};class Hu extends Er{constructor(){super(...arguments),u(this,"threshold"),u(this,"intensity"),u(this,"scatter"),u(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=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new QL(this.context.scene,this.context.mainCamera,{blendFunction:Dt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new uE;return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}}UT([w(Et)],Hu.prototype,"threshold",2),UT([w(Et)],Hu.prototype,"intensity",2),UT([w(Et)],Hu.prototype,"scatter",2),wo("Bloom",Hu);var zse=Object.defineProperty,Qse=Object.getOwnPropertyDescriptor,sa=(i,e,t,s)=>{for(var r=s>1?void 0:s?Qse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&zse(e,t,r),r};class ja extends Me{constructor(){super(...arguments),u(this,"attachedRigidbody",null),u(this,"isTrigger",!1),u(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ji))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ji))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(ji))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}}sa([w(ji)],ja.prototype,"attachedRigidbody",2),sa([w()],ja.prototype,"isTrigger",2),sa([w()],ja.prototype,"sharedMaterial",2);class Sv extends ja{constructor(){super(...arguments),u(this,"radius",.5),u(this,"center",new S(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this,this.center,this.radius)}}sa([w()],Sv.prototype,"radius",2),sa([w(S)],Sv.prototype,"center",2);class Cv extends ja{constructor(){super(...arguments),u(this,"size",new S(1,1,1)),u(this,"center",new S(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.center,this.size)}}sa([w(S)],Cv.prototype,"size",2),sa([w(S)],Cv.prototype,"center",2);class Ev extends ja{constructor(){super(...arguments),u(this,"sharedMesh"),u(this,"convex",!1)}onEnable(){var e,t,s,r,n;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof xe&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,Ks(this.gameObject));else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${(r=this.sharedMesh)==null?void 0:r.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const a in o.children){const l=o.children[a];l.isMesh&&((n=this.context.physics.engine)==null||n.addMeshCollider(this,l,this.convex,Ks(this.gameObject)))}}}}}sa([w()],Ev.prototype,"convex",2);class Ah extends ja{constructor(){super(...arguments),u(this,"center",new S(0,0,0)),u(this,"radius",.5),u(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.center,this.height,this.radius)}}sa([w(S)],Ah.prototype,"center",2),sa([w()],Ah.prototype,"radius",2),sa([w()],Ah.prototype,"height",2);function FT(i){return i[Na]||(i.parent?FT(i.parent):null)}function jx(i,e){if(!i)return;const t=i.material;if(t?.isMaterial===!0){const s=i.parent;s&&s.isText,t.side=e.doubleSided??!0?Si:gr,t.shadowSide=e.doubleSided?Si:gr,i.castShadow=e.castShadows?e.castShadows:!1,i.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const s of i.children)jx(s,e)}function mf(i,e,t){i[e]===void 0&&console.warn("Field",e,"is undefined on",i);const s=Proxy.revocable(i[e],{set(o,a,l,c){const h=o[a],d=Reflect.set(o,a,l,c);return t(l,h),d}}),r=s.revoke,n=i[e];return s.revoke=()=>{i[e]=n,r()},i[e]=s.proxy,s}const K3=Symbol("Scheduled action");function jse(i,e,t=On.OnBeforeRender){let s=i[K3];s||(s=i[K3]={});const r=e.name;s[t]||(s[t]={});const n=s[t];if(n[r])return;function*o(){e?.call(i),n[r]=null}const a=i.startCoroutine(o(),t);n[r]=a}var Gse=Object.defineProperty,Hse=Object.getOwnPropertyDescriptor,Vu=(i,e,t,s)=>{for(var r=s>1?void 0:s?Hse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Gse(e,t,r),r};const NT=re("debugui"),zT=re("debuguilayout");class QT{constructor(){u(this,"width"),u(this,"height")}}class jT{constructor(){u(this,"x"),u(this,"y"),u(this,"width"),u(this,"height")}}const ra=new S,Mv=new Be,Gx=new Ue,Z3=class extends fa{constructor(){super(...arguments),u(this,"_anchoredPosition"),u(this,"sizeDelta",new Y(100,100)),u(this,"pivot",new Y(.5,.5)),u(this,"anchorMin",new Y(0,0)),u(this,"anchorMax",new Y(1,1)),u(this,"offsetMin",new Y(0,0)),u(this,"offsetMax",new Y(0,0)),u(this,"lastMatrix"),u(this,"rectBlock"),u(this,"_transformNeedsUpdate",!1),u(this,"_initialPosition"),u(this,"_parentRectTransform"),u(this,"_lastUpdateFrame",-1),u(this,"_lastAnchoring"),u(this,"_createdBlocks",[]),u(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 Y),this._anchoredPosition}set anchoredPosition(i){this._anchoredPosition=i}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const i=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;let t=i*e;return t+=this.sizeDelta.x,t}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const i=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;let t=i*e;return t+=this.sizeDelta.y,t}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new Y),this.lastMatrix=new Be,this.rectBlock=new De,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,mf(this,"_anchoredPosition",()=>{this.markDirty()}),mf(this,"sizeDelta",()=>{this.markDirty()}),mf(this,"pivot",()=>{this.markDirty()}),mf(this,"anchorMin",()=>{this.markDirty()}),mf(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var i;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(i=this.Canvas)==null||i.registerTransform(this)}onDisable(){var i;super.onDisable(),this.removeShadowComponent(),(i=this.Canvas)==null||i.unregisterTransform(this)}onParentRectTransformChanged(i){this._transformNeedsUpdate||this.onApplyTransform(zT?`${i.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(zT&&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(i){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=ee.getComponentInParent(this.gameObject.parent,Z3):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,zT&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+i),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,ra.set(0,0,0),this.applyPivot(ra),t.matrix.setPosition(ra.x,ra.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Gx.copy(this.gameObject.quaternion),Gx.x*=-1,Gx.z*=-1,Mv.makeRotationFromQuaternion(Gx),t.matrix.premultiply(Mv)),ra.set(0,0,0),this.applyAnchoring(ra),(e=this.Canvas)!=null&&e.screenspace?ra.z+=.1:ra.z+=.01,Mv.identity(),Mv.setPosition(ra.x,ra.y,ra.z),t.matrix.premultiply(Mv),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const s=!0;for(const r of $C(this.gameObject,fa,s,1)){if(r===this||!r.activeAndEnabled)continue;const n=r;n.onParentRectTransformChanged&&n.onParentRectTransformChanged(this)}}applyAnchoring(i){this._lastAnchoring||(this._lastAnchoring=new Y);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),i.x+=this._initialPosition.x-this.gameObject.position.x,i.y+=this._initialPosition.y-this.gameObject.position.y,i.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=t.height*.5*r,i.y+=s;let n=0;const o=1-this.anchorMax.x-this.anchorMin.x;n-=t.width*.5*o,i.x+=n}}applyPivot(i){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;i.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;i.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const i={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(i),i}ensureValidSize(i,e=1e-4){return i.width<=0&&(i.width=e),i.height<=0&&(i.height=1e-4),i}createNewBlock(i){i={...this.getBasicOptions(),...i},NT&&console.log(this.name,i);const e=new vT(i);return this._createdBlocks.push(e),e}createNewText(i){NT&&console.log(i),i={...this.getBasicOptions(),...i},NT&&console.log(this.name,i);const e=new z3(i);return this._createdTextBlocks.push(e),e}};let rr=Z3;Vu([w(Y)],rr.prototype,"anchoredPosition",1),Vu([w(Y)],rr.prototype,"sizeDelta",2),Vu([w(Y)],rr.prototype,"pivot",2),Vu([w(Y)],rr.prototype,"anchorMin",2),Vu([w(Y)],rr.prototype,"anchorMax",2),Vu([w(Y)],rr.prototype,"offsetMin",2),Vu([w(Y)],rr.prototype,"offsetMax",2);class Vse extends N3{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const s in t)for(const r in t[s])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(s);for(const s of e._components)e._simpleState__statesProperties[s.id]&&(e._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const s=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],s.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)s.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const s in e)this._simpleState__statesProperties[s]&&(this._simpleState__normalStyles[s]=e[s]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var Wse=Object.defineProperty,qse=Object.getOwnPropertyDescriptor,$3=(i,e,t,s)=>{for(var r=s>1?void 0:s?qse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Wse(e,t,r),r};class gf extends Me{constructor(){super(...arguments),u(this,"effectColor"),u(this,"effectDistance")}}$3([w(Ai)],gf.prototype,"effectColor",2),$3([w(Y)],gf.prototype,"effectDistance",2);var Xse=Object.defineProperty,Yse=Object.getOwnPropertyDescriptor,ez=(i,e,t,s)=>{for(var r=s>1?void 0:s?Yse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Xse(e,t,r),r};const Hx={backgroundColor:new Ae(1,1,1),backgroundOpacity:1,borderColor:new Ae(1,1,1),borderOpacity:1};var GT;const Vx=(GT=class extends fa{constructor(){super(...arguments),u(this,"_alphaFactor",1),u(this,"raycastTarget",!0),u(this,"uiObject",null),u(this,"_color",null),u(this,"_rect",null),u(this,"_stateManager",null),u(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Ai(1,1,1,1)),this._color}set color(i){(!this._color||this._color.r!==i.r||this._color.g!==i.g||this._color.b!==i.b||this._color.alpha!==i.alpha)&&(this._color||(this._color=new Ai(1,1,1,1)),this._color.copy(i))}setAlphaFactor(i){this._alphaFactor=i,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(Hx.backgroundColor=this._color,Hx.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Hx,this._alphaFactor),this.uiObject.set(Hx),this.markDirty())}get m_Color(){return this._color}get rectTransform(){return this._rect||(this._rect=ee.getComponent(this.gameObject,rr)),this._rect}onParentRectTransformChanged(){var i;(i=this.uiObject)==null||i.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(i){this.makePanel(),this.uiObject&&(this.uiObject.setState(i),this==null||this.markDirty())}setupState(i){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Vse(this.uiObject)),this.uiObject.setupState(i.state,i.attributes))}setOptions(i){this.makePanel(),this.uiObject&&this.uiObject.set(i)}awake(){super.awake(),this.makePanel(),mf(this,"_color",()=>jse(this,this.onColorChanged))}onEnable(){var i;super.onEnable(),this.uiObject&&((i=this.rectTransform.shadowComponent)==null||i.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 i=.015;const e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:i};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(i){}onCreate(i){this.uiObject=this.rectTransform.createNewBlock(i),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(i,e=1){var t;const s=(t=this.gameObject)==null?void 0:t.getComponent(gf);s&&(s.effectDistance&&(i.borderWidth=Math.max(Math.abs(s.effectDistance.x),Math.abs(s.effectDistance.y))),s.effectColor&&(i.borderColor=s.effectColor,i.borderOpacity=s.effectColor.alpha*e))}async setTexture(i){if(this.setOptions({backgroundOpacity:0}),i){if(i.colorSpace===st)if(Vx.textureCache.has(i))i=Vx.textureCache.get(i);else{const e=i.clone();e.colorSpace=Fs,Vx.textureCache.set(i,e),i=e}this.setOptions({backgroundImage:i,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)}},u(GT,"textureCache",new Map),GT);let Wu=Vx;ez([w(Ai)],Wu.prototype,"color",1),ez([w()],Wu.prototype,"raycastTarget",2);class Tv extends Wu{constructor(){super(...arguments),u(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var Jse=Object.defineProperty,Kse=Object.getOwnPropertyDescriptor,Wx=(i,e,t,s)=>{for(var r=s>1?void 0:s?Kse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Jse(e,t,r),r};let HT=class{constructor(){u(this,"texture",null),u(this,"rect")}};Wx([w(Gt)],HT.prototype,"texture",2);let vf=class extends Tv{constructor(){super(...arguments),u(this,"_sprite"),u(this,"pixelsPerUnitMultiplier",1)}set image(i){this.sprite||(this.sprite=new HT),this.sprite.texture=i,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(i){this._sprite!==i&&(this._sprite=i,this.onAfterCreated())}isBuiltinSprite(){var i,e,t,s,r,n,o,a;switch((e=(i=this.sprite)==null?void 0:i.texture)==null?void 0:e.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((r=(s=(t=this.sprite)==null?void 0:t.texture)==null?void 0:s.image)==null?void 0:r.width)===32&&((a=(o=(n=this.sprite)==null?void 0:n.texture)==null?void 0:o.image)==null?void 0:a.height)===32}onBeforeCreate(i){var e,t;super.onBeforeCreate(i),this.isBuiltinSprite()&&(i.borderRadius=5/this.pixelsPerUnitMultiplier,((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name)==="Knob"&&(i.borderRadius=999))}onAfterCreated(){var i;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((i=this.sprite)==null?void 0:i.texture))}};Wx([w(HT)],vf.prototype,"sprite",1),Wx([w()],vf.prototype,"pixelsPerUnitMultiplier",2);class qx extends Tv{constructor(){super(...arguments),u(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Wx([w(Gt)],qx.prototype,"mainTexture",1);var Zse=Object.defineProperty,$se=Object.getOwnPropertyDescriptor,zn=(i,e,t,s)=>{for(var r=s>1?void 0:s?$se(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Zse(e,t,r),r};const Af=re("debugbutton");class qu{constructor(){u(this,"colorMultiplier"),u(this,"disabledColor"),u(this,"fadeDuration"),u(this,"highlightedColor"),u(this,"normalColor"),u(this,"pressedColor"),u(this,"selectedColor")}}zn([w()],qu.prototype,"colorMultiplier",2),zn([w(Ai)],qu.prototype,"disabledColor",2),zn([w()],qu.prototype,"fadeDuration",2),zn([w(Ai)],qu.prototype,"highlightedColor",2),zn([w(Ai)],qu.prototype,"normalColor",2),zn([w(Ai)],qu.prototype,"pressedColor",2),zn([w(Ai)],qu.prototype,"selectedColor",2);class ec extends Me{constructor(){super(...arguments),u(this,"onClick"),u(this,"_isHovered",!1),u(this,"colors"),u(this,"transition"),u(this,"animationTriggers"),u(this,"animator"),u(this,"_interactable",!0),u(this,"_requestedAnimatorTrigger"),u(this,"_isInit",!1),u(this,"_image")}onPointerEnter(e){var t,s;Af&&console.log("Button Enter",(t=this.animationTriggers)==null?void 0:t.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&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;Af&&console.log("Button Exit",(e=this.animationTriggers)==null?void 0:e.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&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(e){var t,s;Af&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(e){var t,s;Af&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.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&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){var t;this.interactable&&e.pointerId===0&&(Af&&(console.warn("Button Click",this.onClick),hs("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(t=this.onClick)==null||t.invoke())}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Af&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=ee.getComponent(this.gameObject,vf),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var t,s,r,n,o;e.setInteractable(this.interactable);const a=this.getFinalColor(e.color,(t=this.colors)==null?void 0:t.normalColor),l={state:"normal",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};e.setupState(l);const c=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.highlightedColor),h={state:"hovered",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};e.setupState(h);const d=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),p={state:"pressed",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(p);const f=this.getFinalColor(e.color,(n=this.colors)==null?void 0:n.selectedColor),m={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(m);const v=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.disabledColor),A={state:"disabled",attributes:{backgroundColor:v,backgroundOpacity:v.alpha}};e.setupState(A)}getFinalColor(e,t){return t?e.clone().multiply(t):e.clone()}}zn([w(pn)],ec.prototype,"onClick",2),zn([w()],ec.prototype,"colors",2),zn([w()],ec.prototype,"transition",2),zn([w()],ec.prototype,"animationTriggers",2),zn([w(Vr)],ec.prototype,"animator",2),zn([w()],ec.prototype,"interactable",1);var ere=Object.defineProperty,tre=Object.getOwnPropertyDescriptor,As=(i,e,t,s)=>{for(var r=s>1?void 0:s?tre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ere(e,t,r),r};const tz=re("debuguilayout");class yh{constructor(){u(this,"left",0),u(this,"right",0),u(this,"top",0),u(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}As([w()],yh.prototype,"left",2),As([w()],yh.prototype,"right",2),As([w()],yh.prototype,"top",2),As([w()],yh.prototype,"bottom",2);class Qn extends Me{constructor(){super(...arguments),u(this,"_rectTransform",null),u(this,"_needsUpdate",!1),u(this,"childAlignment",0),u(this,"reverseArrangement",!1),u(this,"spacing",0),u(this,"padding"),u(this,"minWidth",0),u(this,"minHeight",0),u(this,"flexibleHeight",0),u(this,"flexibleWidth",0),u(this,"preferredHeight",0),u(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(tz&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){tz&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(rr);const e=this.gameObject.getComponentInParent(nr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(nr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}As([w()],Qn.prototype,"childAlignment",2),As([w()],Qn.prototype,"reverseArrangement",2),As([w()],Qn.prototype,"spacing",2),As([w(yh)],Qn.prototype,"padding",2),As([w()],Qn.prototype,"minWidth",2),As([w()],Qn.prototype,"minHeight",2),As([w()],Qn.prototype,"flexibleHeight",2),As([w()],Qn.prototype,"flexibleWidth",2),As([w()],Qn.prototype,"preferredHeight",2),As([w()],Qn.prototype,"preferredWidth",2);class bh extends Qn{constructor(){super(...arguments),u(this,"childControlHeight",!0),u(this,"childControlWidth",!0),u(this,"childForceExpandHeight",!1),u(this,"childForceExpandWidth",!1),u(this,"childScaleHeight",!1),u(this,"childScaleWidth",!1)}onCalculateLayout(e){var t;const s=this.primaryAxis,r=e.width;let n=r;const o=e.height;let a=o;n-=this.padding.horizontal,a-=this.padding.vertical,s==="x"?this.padding.horizontal:this.padding.vertical;const l=s==="x",c=l?"y":"x",h=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,p=l?this.childForceExpandWidth:this.childForceExpandHeight,f=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:n,v=l?r:o,A=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let g=0;l?g+=this.padding.left:g+=this.padding.top;let b=0,y=0;for(let P=0;P<this.gameObject.children.length;P++){const M=this.gameObject.children[P],C=ee.getComponent(M,rr);C!=null&&C.activeAndEnabled&&(y+=1,l?b+=C.width:b+=C.height)}let x=0;const _=this.spacing*(y-1);if(p||h){let P=0;l?P=n-=_:P=a-=_,y>0&&(x=P/y)}let E=0;E+=this.padding.left,E-=this.padding.right,A!==0&&(g=v-b,g*=A,g-=_*A,l?(g-=this.padding.right*A,g+=this.padding.left*(1-A),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*A,g+=this.padding.top*(1-A),g<this.padding.top&&(g=this.padding.top)));let I=1;for(let P=0;P<this.gameObject.children.length;P++){const M=this.gameObject.children[P],C=ee.getComponent(M,rr);if(C!=null&&C.activeAndEnabled){(t=C.pivot)==null||t.set(.5,.5),C.anchorMin.set(0,1),C.anchorMax.set(0,1);const U=r*.5+E*.5;C.anchoredPosition.x!==U&&(C.anchoredPosition.x=U);const G=o*-.5;C.anchoredPosition.y!==G&&(C.anchoredPosition.y=G),f&&d&&C.sizeDelta[c]!==m&&(C.sizeDelta[c]=m),p&&h&&C.sizeDelta[s]!==x&&(C.sizeDelta[s]=x);const F=l?C.width:C.height;let z=F*.5;if(g+=z,p){let te=x*I-x*.5;te>g&&(g=te-x*.5+F+this.padding.left,g-=z)}let q=g;s==="y"&&(q=-q),C.anchoredPosition[s]!==q&&(C.anchoredPosition[s]=q),g+=z,g+=this.spacing,I+=1}}}}As([w()],bh.prototype,"childControlHeight",2),As([w()],bh.prototype,"childControlWidth",2),As([w()],bh.prototype,"childForceExpandHeight",2),As([w()],bh.prototype,"childForceExpandWidth",2),As([w()],bh.prototype,"childScaleHeight",2),As([w()],bh.prototype,"childScaleWidth",2);class VT extends bh{get primaryAxis(){return"y"}}class WT extends bh{get primaryAxis(){return"x"}}class qT extends Qn{onCalculateLayout(){}}var ire=Object.defineProperty,sre=Object.getOwnPropertyDescriptor,Ga=(i,e,t,s)=>{for(var r=s>1?void 0:s?sre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ire(e,t,r),r},iz=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(iz||{});const XT=re("debuguilayout"),sz=class extends rv{constructor(){super(...arguments),u(this,"_renderOnTop"),u(this,"_depthWrite",!1),u(this,"_doubleSided",!0),u(this,"_castShadows",!1),u(this,"_receiveShadows",!1),u(this,"_renderMode",-1),u(this,"_rootCanvas"),u(this,"_scaleFactor",1),u(this,"worldCamera"),u(this,"planeDistance",-1),u(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),u(this,"previousParent",null),u(this,"_lastMatrixWorld",null),u(this,"_rectTransforms",[]),u(this,"_layoutGroups",new Map),u(this,"onBeforeRenderRoutine",()=>{var i,e,t,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(e=this.shadowComponent)==null||e.updateWorldMatrix(!0,!0),Fn.ensureUpdateMeshUI(yT,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),Fn.ensureUpdateMeshUI(yT,this.context))}),u(this,"onAfterRenderRoutine",()=>{var i,e;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const t=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),Fn.ensureUpdateMeshUI(yT,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=t,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(e=this._lastMatrixWorld)==null||e.copy(this.gameObject.matrixWorld)}}),u(this,"_updateRenderSettingsRoutine"),u(this,"_activeRenderMode",-1),u(this,"_lastWidth",-1),u(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(i){i!==this._renderOnTop&&(this._renderOnTop=i,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(i){this._depthWrite!==i&&(this._depthWrite=i,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(i){this._doubleSided!==i&&(this._doubleSided=i,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(i){this._castShadows!==i&&(this._castShadows=i,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(i){this._receiveShadows!==i&&(this._receiveShadows=i,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(i){this._renderMode!==i&&(this._renderMode=i,this.onRenderSettingsChanged())}set rootCanvas(i){this._rootCanvas instanceof sz||(this._rootCanvas=i)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(i){this._scaleFactor=i}awake(){var i;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,XT&&console.log("Canvas.Awake()",((i=this.previousParent)==null?void 0:i.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Be,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 i=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);i!==-1&&this.context.pre_render_callbacks.splice(i,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(i){this._rectTransforms.push(i)}unregisterTransform(i){const e=this._rectTransforms.indexOf(i);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(i){const e=i.gameObject;this._layoutGroups.set(e,i)}unregisterLayoutGroup(i){const e=i.gameObject;this._layoutGroups.delete(e)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Be);const i=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);XT&&i&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);let e=!1;for(const t of this._rectTransforms){i&&t.markDirty();let s=this._layoutGroups.get(t.gameObject);t.isDirty&&!s&&(s=t.gameObject.getComponentInParent(Qn)),(t.isDirty||s!=null&&s.isDirty)&&(XT&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),s?.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),On.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),jx(this.shadowComponent,this);for(const i of ee.getComponentsInChildren(this.gameObject,fa))jx(i.shadowComponent,this)}}onUpdateRenderMode(i=!1){if(!i&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=et.lerp(e.nearClipPlane,e.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const s=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(rr);let n=!1;r.sizeDelta.x!==this.context.domWidth&&(n=!0),r.sizeDelta.y!==this.context.domHeight&&(n=!0);const o=e.fieldOfView*Math.PI/180,a=2*Math.tan(o/2)*Math.abs(s);this.gameObject.scale.x=a/this.context.domHeight,this.gameObject.scale.y=a/this.context.domHeight,this.gameObject.scale.z=.01,n&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let nr=sz;Ga([w()],nr.prototype,"renderOnTop",1),Ga([w()],nr.prototype,"depthWrite",1),Ga([w()],nr.prototype,"doubleSided",1),Ga([w()],nr.prototype,"castShadows",1),Ga([w()],nr.prototype,"receiveShadows",1),Ga([w()],nr.prototype,"renderMode",1),Ga([w(nr)],nr.prototype,"rootCanvas",1),Ga([w()],nr.prototype,"scaleFactor",1),Ga([w(Di)],nr.prototype,"worldCamera",2),Ga([w()],nr.prototype,"planeDistance",2);var rre=Object.defineProperty,nre=Object.getOwnPropertyDescriptor,YT=(i,e,t,s)=>{for(var r=s>1?void 0:s?nre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&rre(e,t,r),r};class xh extends Me{constructor(){super(...arguments),u(this,"_alpha",1),u(this,"interactable",!0),u(this,"blocksRaycasts",!0),u(this,"_isDirty",!1),u(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),On.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of ee.getComponentsInChildren(this.gameObject,fa,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}YT([w()],xh.prototype,"alpha",1),YT([w()],xh.prototype,"interactable",2),YT([w()],xh.prototype,"blocksRaycasts",2);var ore=Object.defineProperty,are=Object.getOwnPropertyDescriptor,Ei=(i,e,t,s)=>{for(var r=s>1?void 0:s?are(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ore(e,t,r),r};class Xu extends Me{constructor(){super(...arguments),u(this,"object"),u(this,"target"),u(this,"duration",1),u(this,"relativeMotion",!1),u(this,"coroutine",null),u(this,"targetPos",new S),u(this,"targetRot",new Ue),u(this,"targetScale",new S)}*moveToTarget(){if(!this.target||!this.object)return;const e=yt(this.object).clone(),t=yt(this.target).clone(),s=Rs(this.object).clone(),r=Rs(this.target).clone(),n=Ks(this.object).clone(),o=Ks(this.target).clone(),a=e.distanceTo(t),l=s.angleTo(r),c=n.distanceTo(o);if(a<.01&&l<.01&&c<.01){is(this.object,t),cn(this.object,r),SC(this.object,o),this.coroutine=null;return}let h=0,d=0;for(;h<1;)h+=this.context.time.deltaTime/this.duration,h>1&&(h=1),d=h<.5?4*h*h*h:1-Math.pow(-2*h+2,3)/2,this.targetPos.lerpVectors(e,t,d),this.targetRot.slerpQuaternions(s,r,d),this.targetScale.lerpVectors(n,o,d),is(this.object,this.targetPos),cn(this.object,this.targetRot),SC(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),n=this.target.quaternion.clone(),o=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(n),this.targetScale.copy(this.object.scale).multiply(o);let a=0,l=0;for(;a<1;)a+=this.context.time.deltaTime/this.duration,a>1&&(a=1),l=a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,l),this.object.quaternion.slerpQuaternions(t,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),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(e){var t;if(this.target&&this.object&&this.gameObject){const s=new Hr("Move to "+((t=this.target)==null?void 0:t.name),fn.tapTrigger(this.gameObject),li.transformAction(this.object,this.target,this.duration,this.relativeMotion?gM.Relative:gM.Absolute));e.addBehavior(s)}}}Ei([w(De)],Xu.prototype,"object",2),Ei([w(De)],Xu.prototype,"target",2),Ei([w()],Xu.prototype,"duration",2),Ei([w()],Xu.prototype,"relativeMotion",2);var JT;const Yu=(JT=class extends Me{constructor(){super(...arguments),u(this,"materialToSwitch"),u(this,"variantMaterial"),u(this,"fadeDuration",0),u(this,"_objectsWithThisMaterial",[]),u(this,"selfModel"),u(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const i=ee.findObjectsOfType(Pi);for(const e of i)e.sharedMaterial===this.materialToSwitch&&this._objectsWithThisMaterial.push(e)}}onPointerClick(){if(this.variantMaterial)for(const i of this._objectsWithThisMaterial)i.sharedMaterial=this.variantMaterial}async beforeCreateDocument(i,e){this.targetModels=[],Yu._materialTriggersPerId={},this.materialToSwitch&&await Jo.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Jo.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(i,e,t){this._objectsWithThisMaterial.find(s=>s.gameObject.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(Yu._materialTriggersPerId[this.materialToSwitch.uuid]||(Yu._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Yu._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(i,e){if(!this.materialToSwitch)return;const t=Yu._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const s={};for(const n of t){const o=n.createVariants();o&&o.length>0&&(s[n.selfModel.uuid]=o)}const r=[];for(const n of t){for(const o in s)o!==n.selfModel.uuid&&r.push(s[o]);n.createAndAttachBehaviors(i,s[n.selfModel.uuid],r)}}delete Yu._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(i,e,t){const s=[],r=[],n=Math.max(0,this.fadeDuration);for(const o of this.targetModels){const a=li.fadeAction(o,n,!1);r.push(a)}for(const o of t)r.push(li.fadeAction(o,n,!1));for(const o of e)s.push(li.fadeAction(o,n,!1)),r.push(li.fadeAction(o,n,!0));i.addBehavior(new Hr("Select "+this.selfModel.name,fn.tapTrigger(this.selfModel),li.parallel(...r))),i.addBehavior(new Hr("Start hidden "+this.selfModel.name,fn.sceneStartTrigger(),li.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const i=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&fo.createEmptyParent(e),e.parent&&e.parent.add(t),i.push(t)}return i}},u(JT,"_materialTriggersPerId",{}),JT);let yf=Yu;Ei([w(It)],yf.prototype,"materialToSwitch",2),Ei([w(It)],yf.prototype,"variantMaterial",2),Ei([w()],yf.prototype,"fadeDuration",2);class bf extends Me{constructor(){super(...arguments),u(this,"target"),u(this,"toggleOnClick",!1),u(this,"targetState",!0),u(this,"hideSelf",!0),u(this,"selfModel"),u(this,"otherModel"),u(this,"toggleModel"),u(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(e,t,s){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(e,t){if(this.target){if(this.otherModel=t.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&PF.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(li.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(li.fadeAction(this.toggleModel,0,!0)),r.push(li.fadeAction(this.otherModel,0,this.targetState)),e.addBehavior(new Hr("Toggle_"+this.selfModel.name+"_hideSelf",fn.tapTrigger(this.selfModel),li.sequence(...r))),this.toggleOnClick&&this.toggleModel){const n=[];n.push(li.fadeAction(this.toggleModel,0,!1)),n.push(li.fadeAction(this.selfModel,0,!0)),n.push(li.fadeAction(this.otherModel,0,!this.targetState)),e.addBehavior(new Hr("Toggle_"+this.selfModel.name+"_toggleSelf",fn.tapTrigger(this.toggleModel),li.sequence(...n))),e.addBehavior(new Hr("HideOnStart_"+this.gameObject.name,fn.sceneStartTrigger(),li.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Ei([w(De)],bf.prototype,"target",2),Ei([w()],bf.prototype,"targetState",2),Ei([w()],bf.prototype,"hideSelf",2);class KT extends Me{start(){this.gameObject.visible=!1}createBehaviours(e,t,s){t.uuid===this.gameObject.uuid&&e.addBehavior(new Hr("HideOnStart_"+this.gameObject.name,fn.sceneStartTrigger(),li.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class xf extends Me{constructor(){super(...arguments),u(this,"target"),u(this,"duration",.5),u(this,"motionType",mM.bounce)}beforeCreateDocument(){}createBehaviours(e,t,s){if(this.target&&t.uuid===this.gameObject.uuid){const r=new Hr("emphasize "+this.name,fn.tapTrigger(this.gameObject),li.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,t){}}Ei([w()],xf.prototype,"target",2),Ei([w()],xf.prototype,"duration",2),Ei([w()],xf.prototype,"motionType",2);class _f extends Me{constructor(){super(...arguments),u(this,"target"),u(this,"clip",""),u(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const e=this.gameObject.addNewComponent(fs);e&&(e.spatialBlend=1,e.volume=1,e.loop=!1,this.target=e)}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(e,t,s){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const n=this.target?this.target.gameObject:this.gameObject,o=r.split("/").pop(),a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?AM.NonSpatial:AM.Spatial,c=new Hr("playAudio "+this.name,fn.tapTrigger(this.gameObject),li.playAudioAction(n,"audio/"+o,HF.Play,a,l));e.addBehavior(c)}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s)return;const r=s.split("/").pop(),n=await(await(await fetch(this.clip)).blob()).arrayBuffer(),o=new Uint8Array(n);t.files["audio/"+r]=o}}Ei([w(fs)],_f.prototype,"target",2),Ei([w(URL)],_f.prototype,"clip",2),Ei([w()],_f.prototype,"toggleOnClick",2);var ZT;const wf=(ZT=class extends Me{constructor(){super(...arguments),u(this,"target"),u(this,"animator"),u(this,"stateName"),u(this,"stateNameAfterPlaying"),u(this,"loopAfterPlaying",!1),u(this,"selfModel"),u(this,"stateAnimationModel"),u(this,"stateAnimation"),u(this,"stateAfterPlayingAnimationModel"),u(this,"stateAfterPlayingAnimation")}onPointerClick(){var i;this.target&&this.stateName&&((i=this.animator)==null||i.play(this.stateName,0,0,.1))}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}onAfterHierarchy(){wf.animationActions=[]}afterCreateDocument(i,e){!this.stateAnimation||!this.stateAnimationModel||e.document.traverse(t=>{var s,r;if(t.uuid===((s=this.target)==null?void 0:s.uuid)&&this.stateAnimation){const n=[];let o=wf.animationActions.find(l=>l.affectedObjects==t&&l.start==this.stateAnimation.start&&l.duration==this.stateAnimation.duration);if(o||(o=li.startAnimationAction(t,this.stateAnimation.start,this.stateAnimation.duration),wf.animationActions.push(o)),n.push(o),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let l=wf.animationActions.find(h=>h.affectedObjects==t&&h.start==this.stateAfterPlayingAnimation.start&&h.duration==this.stateAfterPlayingAnimation.duration);l||(l=li.startAnimationAction(t,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),wf.animationActions.push(l));const c=li.sequence(l);this.loopAfterPlaying&&c.makeLooping(),n.push(c)}const a=new Hr("tap "+this.name+" for "+this.stateName+" on "+((r=this.target)==null?void 0:r.name),fn.tapTrigger(this.selfModel),li.sequence(...n));i.addBehavior(a)}})}createAnimation(i,e,t){var s,r,n,o;if(this.target&&this.animator){const a=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);this.stateAnimationModel=e,this.stateAnimation=i.registerAnimation(this.target,a?.motion.clip);const l=(o=(n=this.animator)==null?void 0:n.runtimeAnimatorController)==null?void 0:o.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=e,this.stateAfterPlayingAnimation=i.registerAnimation(this.target,l?.motion.clip)}}},u(ZT,"animationActions",[]),ZT);let _h=wf;Ei([w(De)],_h.prototype,"target",2),Ei([w(Vr)],_h.prototype,"animator",2),Ei([w()],_h.prototype,"stateName",2),Ei([w()],_h.prototype,"stateNameAfterPlaying",2),Ei([w()],_h.prototype,"loopAfterPlaying",2);class Sf extends Me{constructor(){super(...arguments),u(this,"target")}getType(){}getDuration(){}}Ei([w(De)],Sf.prototype,"target",2);class Iv extends Me{constructor(){super(...arguments),u(this,"target")}}Ei([w(Sf)],Iv.prototype,"target",2);class Rv extends Sf{constructor(){super(...arguments),u(this,"type",1),u(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Ei([w()],Rv.prototype,"type",2),Ei([w()],Rv.prototype,"duration",2);class $T extends Iv{}var lre=Object.defineProperty,cre=Object.getOwnPropertyDescriptor,tc=(i,e,t,s)=>{for(var r=s>1?void 0:s?cre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&lre(e,t,r),r};class Ju extends Me{constructor(){super(...arguments),u(this,"center",new S(0,0,0)),u(this,"radius",.5),u(this,"height",2),u(this,"_rigidbody",null),u(this,"_activeGroundCollisions",new Set)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(ji),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(ji)),this.rigidbody)}onEnable(){let e=this.rigidbody,t=this.gameObject.getComponent(Ah);t||(t=this.gameObject.addNewComponent(Ah)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){for(const t of e.contacts)if(t.normal.y>.1){this._activeGroundCollisions.add(e);break}}onCollisionExit(e){this._activeGroundCollisions.delete(e)}get isGrounded(){return this._activeGroundCollisions.size>0}}tc([w(S)],Ju.prototype,"center",2),tc([w()],Ju.prototype,"radius",2),tc([w()],Ju.prototype,"height",2);class ic extends Me{constructor(){super(...arguments),u(this,"controller"),u(this,"movementSpeed",2),u(this,"rotationSpeed",2),u(this,"jumpForce",1),u(this,"doubleJumpForce",2),u(this,"animator"),u(this,"lookForward",!0),u(this,"_currentSpeed",new S(0,0,0)),u(this,"_currentAngularSpeed",new S(0,0,0)),u(this,"_temp",new S(0,0,0)),u(this,"_jumpCount",0),u(this,"_currentRotation"),u(this,"_raycastOptions",new Go)}awake(){this._currentRotation=new Ue}update(){var e,t,s,r,n,o,a,l,c,h,d;(e=this.controller)!=null&&e.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((t=this.animator)==null||t.setBool("doubleJump",!1)));const p=this.context.input.isKeyPressed("w"),f=this.context.input.isKeyPressed("s"),m=this.context.input.isKeyPressed("a"),v=this.context.input.isKeyPressed("d"),A=this.context.input.isKeyDown(" "),g=(p?1:0)+(f?-1:0);this._currentSpeed.z+=g*this.movementSpeed*this.context.time.deltaTime,(s=this.animator)==null||s.setBool("running",g!=0),(n=this.animator)==null||n.setBool("jumping",((r=this.controller)==null?void 0:r.isGrounded)===!0&&A),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 b=(m?1:0)+(v?-1:0);if(this._currentAngularSpeed.y+=et.toRadians(b*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const y=this.context.mainCameraComponent.forward;y.y=0,y.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),y),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&&A&&this.jumpForce>0){let y=(o=this.controller)==null?void 0:o.isGrounded;if(this.doubleJumpForce>0&&!((a=this.controller)!=null&&a.isGrounded)&&this._jumpCount===1&&(y=!0,(l=this.animator)==null||l.setBool("doubleJump",!0)),y){this._jumpCount+=1;const x=this.controller.rigidbody,_=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;x.applyImpulse(new S(0,1,0).multiplyScalar(_))}}if(this.controller){const y=(c=this.controller)==null?void 0:c.rigidbody.getVelocity().y;if(y<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new _a),this._raycastOptions.ray.origin.copy(yt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const x=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const _=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(x),(_.length&&_[0].distance>2||y<-10)&&((h=this.animator)==null||h.setBool("falling",!0))}else(d=this.animator)==null||d.setBool("falling",!1)}}}tc([w(Ju)],ic.prototype,"controller",2),tc([w()],ic.prototype,"movementSpeed",2),tc([w()],ic.prototype,"rotationSpeed",2),tc([w()],ic.prototype,"jumpForce",2),tc([w()],ic.prototype,"doubleJumpForce",2),tc([w(Vr)],ic.prototype,"animator",2);var hre=Object.defineProperty,ure=Object.getOwnPropertyDescriptor,dre=(i,e,t,s)=>{for(var r=s>1?void 0:s?ure(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&hre(e,t,r),r};class Pv extends Er{constructor(){super(...arguments),u(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new UL;return e.offset=new Y(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}dre([w(Et)],Pv.prototype,"intensity",2),wo("ChromaticAberration",Pv);var pre=Object.defineProperty,fre=Object.getOwnPropertyDescriptor,Xx=(i,e,t,s)=>{for(var r=s>1?void 0:s?fre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&pre(e,t,r),r};class wh extends Er{constructor(){super(...arguments),u(this,"postExposure"),u(this,"contrast"),u(this,"hueShift"),u(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Br&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=vm);const e=new LL;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Br&&(this.context.renderer.toneMapping=vm),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{e.contrast=s};const t=new NL;return this.hueShift.onValueChanged=s=>t.hue=s,this.saturation.onValueChanged=s=>t.saturation=s,[t,e]}}Xx([w(Et)],wh.prototype,"postExposure",2),Xx([w(Et)],wh.prototype,"contrast",2),Xx([w(Et)],wh.prototype,"hueShift",2),Xx([w(Et)],wh.prototype,"saturation",2),wo("ColorAdjustments",wh);const mre=(Math.sqrt(5)-1)/4,or=(5-Math.sqrt(5))/20,Yx=i=>Math.floor(i)|0,Jx=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 gre(i=Math.random){const e=vre(i),t=new Float64Array(e).map(o=>Jx[o%32*4]),s=new Float64Array(e).map(o=>Jx[o%32*4+1]),r=new Float64Array(e).map(o=>Jx[o%32*4+2]),n=new Float64Array(e).map(o=>Jx[o%32*4+3]);return function(o,a,l,c){let h,d,p,f,m;const v=(o+a+l+c)*mre,A=Yx(o+v),g=Yx(a+v),b=Yx(l+v),y=Yx(c+v),x=(A+g+b+y)*or,_=A-x,E=g-x,I=b-x,P=y-x,M=o-_,C=a-E,U=l-I,G=c-P;let F=0,z=0,q=0,te=0;M>C?F++:z++,M>U?F++:q++,M>G?F++:te++,C>U?z++:q++,C>G?z++:te++,U>G?q++:te++;const Z=F>=3?1:0,$=z>=3?1:0,he=q>=3?1:0,le=te>=3?1:0,X=F>=2?1:0,ne=z>=2?1:0,_e=q>=2?1:0,Ee=te>=2?1:0,Oe=F>=1?1:0,ze=z>=1?1:0,$e=q>=1?1:0,Je=te>=1?1:0,qe=M-Z+or,xt=C-$+or,pe=U-he+or,H=G-le+or,Le=M-X+2*or,ye=C-ne+2*or,ge=U-_e+2*or,Qe=G-Ee+2*or,me=M-Oe+3*or,Ye=C-ze+3*or,it=U-$e+3*or,ht=G-Je+3*or,qt=M-1+4*or,ti=C-1+4*or,L=U-1+4*or,D=G-1+4*or,ce=A&255,Re=g&255,Pe=b&255,Q=y&255;let ve=.6-M*M-C*C-U*U-G*G;if(ve<0)h=0;else{const be=ce+e[Re+e[Pe+e[Q]]];ve*=ve,h=ve*ve*(t[be]*M+s[be]*C+r[be]*U+n[be]*G)}let Se=.6-qe*qe-xt*xt-pe*pe-H*H;if(Se<0)d=0;else{const be=ce+Z+e[Re+$+e[Pe+he+e[Q+le]]];Se*=Se,d=Se*Se*(t[be]*qe+s[be]*xt+r[be]*pe+n[be]*H)}let ue=.6-Le*Le-ye*ye-ge*ge-Qe*Qe;if(ue<0)p=0;else{const be=ce+X+e[Re+ne+e[Pe+_e+e[Q+Ee]]];ue*=ue,p=ue*ue*(t[be]*Le+s[be]*ye+r[be]*ge+n[be]*Qe)}let Ve=.6-me*me-Ye*Ye-it*it-ht*ht;if(Ve<0)f=0;else{const be=ce+Oe+e[Re+ze+e[Pe+$e+e[Q+Je]]];Ve*=Ve,f=Ve*Ve*(t[be]*me+s[be]*Ye+r[be]*it+n[be]*ht)}let Xe=.6-qt*qt-ti*ti-L*L-D*D;if(Xe<0)m=0;else{const be=ce+1+e[Re+1+e[Pe+1+e[Q+1]]];Xe*=Xe,m=Xe*Xe*(t[be]*qt+s[be]*ti+r[be]*L+n[be]*D)}return 27*(h+d+p+f+m)}}function vre(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const s=t+~~(i()*(256-t)),r=e[t];e[t]=e[s],e[s]=r}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var Are=Object.defineProperty,yre=Object.getOwnPropertyDescriptor,K=(i,e,t,s)=>{for(var r=s>1?void 0:s?yre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Are(e,t,r),r};const Kx=re("debugparticles");var sc=(i=>(i[i.Billboard=0]="Billboard",i[i.Stretch=1]="Stretch",i[i.HorizontalBillboard=2]="HorizontalBillboard",i[i.VerticalBillboard=3]="VerticalBillboard",i[i.Mesh=4]="Mesh",i))(sc||{});class Sh{constructor(){u(this,"alphaKeys"),u(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let s,r=0,n=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const l=this.alphaKeys[a];(l.time<e||!s)&&(s=l,r=a)}for(let a=0;a<this.colorKeys.length;a++){const l=this.colorKeys[a];(l.time<e||!n)&&(n=l,o=a)}if(n)if(o+1<this.colorKeys.length){const a=this.colorKeys[o+1],l=et.remap(e,n.time,a.time,0,1);t.r=et.lerp(n.color.r,a.color.r,l),t.g=et.lerp(n.color.g,a.color.g,l),t.b=et.lerp(n.color.b,a.color.b,l)}else t.r=n.color.r,t.g=n.color.g,t.b=n.color.b;if(s)if(r+1<this.alphaKeys.length){const a=this.alphaKeys[r+1],l=et.remap(e,s.time,a.time,0,1);t.alpha=et.lerp(s.alpha,a.alpha,l)}else t.alpha=s.alpha;return t}}K([w()],Sh.prototype,"alphaKeys",2),K([w()],Sh.prototype,"colorKeys",2);var Zx=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(Zx||{}),rz=(i=>(i[i.Sphere=0]="Sphere",i[i.SphereShell=1]="SphereShell",i[i.Hemisphere=2]="Hemisphere",i[i.HemisphereShell=3]="HemisphereShell",i[i.Cone=4]="Cone",i[i.Box=5]="Box",i[i.Mesh=6]="Mesh",i[i.ConeShell=7]="ConeShell",i[i.ConeVolume=8]="ConeVolume",i[i.ConeVolumeShell=9]="ConeVolumeShell",i[i.Circle=10]="Circle",i[i.CircleEdge=11]="CircleEdge",i[i.SingleSidedEdge=12]="SingleSidedEdge",i[i.MeshRenderer=13]="MeshRenderer",i[i.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",i[i.BoxShell=15]="BoxShell",i[i.BoxEdge=16]="BoxEdge",i[i.Donut=17]="Donut",i[i.Rectangle=18]="Rectangle",i[i.Sprite=19]="Sprite",i[i.SpriteRenderer=20]="SpriteRenderer",i))(rz||{});class at{constructor(){u(this,"mode"),u(this,"constant"),u(this,"constantMin"),u(this,"constantMax"),u(this,"curve"),u(this,"curveMin"),u(this,"curveMax"),u(this,"curveMultiplier")}evaluate(e,t){const s=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=et.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const r=e*this.curveMin.duration,n=e*this.curveMax.duration;return et.lerp(this.curveMin.evaluate(r),this.curveMax.evaluate(n),s%1)*this.curveMultiplier;case 3:return et.lerp(this.constantMin,this.constantMax,s%1);default:this.curveMax.evaluate(e)*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(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let s=0;s<e.keys.length;s++){const r=e.keys[s];r.value>t&&(t=r.value)}return t}}K([w()],at.prototype,"mode",2),K([w()],at.prototype,"constant",2),K([w()],at.prototype,"constantMin",2),K([w()],at.prototype,"constantMax",2),K([w(Lu)],at.prototype,"curve",2),K([w(Lu)],at.prototype,"curveMin",2),K([w(Lu)],at.prototype,"curveMax",2),K([w()],at.prototype,"curveMultiplier",2);var $x;const na=($x=class{constructor(){u(this,"mode"),u(this,"color"),u(this,"colorMin"),u(this,"colorMax"),u(this,"gradient"),u(this,"gradientMin"),u(this,"gradientMax")}evaluate(i,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,na._temp),na._temp;case 2:return na._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(i,na._temp),this.gradientMax.evaluate(i,na._temp2),na._temp.lerp(na._temp2,t)}return na._temp.set(16711935),na._temp.alpha=1,na._temp}},u($x,"_temp",new Ai(0,0,0,1)),u($x,"_temp2",new Ai(0,0,0,1)),$x);let An=na;K([w(Ai)],An.prototype,"color",2),K([w(Ai)],An.prototype,"colorMin",2),K([w(Ai)],An.prototype,"colorMax",2),K([w(Sh)],An.prototype,"gradient",2),K([w(Sh)],An.prototype,"gradientMin",2),K([w(Sh)],An.prototype,"gradientMax",2);class ar{constructor(){u(this,"cullingMode"),u(this,"duration"),u(this,"emitterVelocityMode"),u(this,"flipRotation"),u(this,"gravityModifier"),u(this,"gravityModifierMultiplier"),u(this,"loop"),u(this,"maxParticles"),u(this,"playOnAwake"),u(this,"prewarm"),u(this,"ringBufferLoopRange"),u(this,"ringBufferMode"),u(this,"scalingMode"),u(this,"simulationSpace"),u(this,"simulationSpeed"),u(this,"startColor"),u(this,"startDelay"),u(this,"startDelayMultiplier"),u(this,"startLifetime"),u(this,"startLifetimeMultiplier"),u(this,"startRotation"),u(this,"startRotationMultiplier"),u(this,"startRotation3D"),u(this,"startRotationX"),u(this,"startRotationXMultiplier"),u(this,"startRotationY"),u(this,"startRotationYMultiplier"),u(this,"startRotationZ"),u(this,"startRotationZMultiplier"),u(this,"startSize"),u(this,"startSize3D"),u(this,"startSizeMultiplier"),u(this,"startSizeX"),u(this,"startSizeXMultiplier"),u(this,"startSizeY"),u(this,"startSizeYMultiplier"),u(this,"startSizeZ"),u(this,"startSizeZMultiplier"),u(this,"startSpeed"),u(this,"startSpeedMultiplier"),u(this,"stopAction"),u(this,"useUnscaledTime")}}K([w(at)],ar.prototype,"gravityModifier",2),K([w(An)],ar.prototype,"startColor",2),K([w(at)],ar.prototype,"startDelay",2),K([w(at)],ar.prototype,"startLifetime",2),K([w(at)],ar.prototype,"startRotation",2),K([w(at)],ar.prototype,"startRotationX",2),K([w(at)],ar.prototype,"startRotationY",2),K([w(at)],ar.prototype,"startRotationZ",2),K([w(at)],ar.prototype,"startSize",2),K([w(at)],ar.prototype,"startSizeX",2),K([w(at)],ar.prototype,"startSizeY",2),K([w(at)],ar.prototype,"startSizeZ",2),K([w(at)],ar.prototype,"startSpeed",2);class Bv{constructor(){u(this,"cycleCount"),u(this,"maxCount"),u(this,"minCount"),u(this,"probability"),u(this,"repeatInterval"),u(this,"time"),u(this,"count"),u(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const s=this.time+this.repeatInterval*this._performed;if(e>=s&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=et.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const r=Math.random();t=et.lerp(this.count.curveMin.evaluate(r),this.count.curveMax.evaluate(r),Math.random());break}}return t}}class Ha{constructor(){u(this,"enabled"),u(this,"bursts"),u(this,"rateOverTime"),u(this,"rateOverTimeMultiplier"),u(this,"rateOverDistance"),u(this,"rateOverDistanceMultiplier"),u(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const s=this.bursts[t];this.system.main.loop&&s.time>=this.system.time&&s.reset(),e+=Math.round(s.run(this.system.time))}return e}}K([w()],Ha.prototype,"enabled",2),K([w()],Ha.prototype,"bursts",2),K([w(at)],Ha.prototype,"rateOverTime",2),K([w()],Ha.prototype,"rateOverTimeMultiplier",2),K([w(at)],Ha.prototype,"rateOverDistance",2),K([w()],Ha.prototype,"rateOverDistanceMultiplier",2);class kv{constructor(){u(this,"enabled"),u(this,"color")}}K([w(An)],kv.prototype,"color",2);class Ch{constructor(){u(this,"enabled"),u(this,"separateAxes"),u(this,"size"),u(this,"sizeMultiplier"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier"),u(this,"_time",0),u(this,"_temp",new S)}evaluate(e,t,s){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,s)*this.xMultiplier,t.y=this.y.evaluate(e,s)*this.yMultiplier,t.z=this.z.evaluate(e,s)*this.zMultiplier;else{const r=this.size.evaluate(e,s)*this.sizeMultiplier;t.x=r}return t}}K([w(at)],Ch.prototype,"size",2),K([w(at)],Ch.prototype,"x",2),K([w(at)],Ch.prototype,"y",2),K([w(at)],Ch.prototype,"z",2);var e_;const Dv=(e_=class{constructor(){u(this,"shapeType",5),u(this,"enabled",!0),u(this,"alignToDirection",!1),u(this,"angle",0),u(this,"arc",360),u(this,"arcSpread"),u(this,"arcSpeedMultiplier"),u(this,"arcMode"),u(this,"boxThickness"),u(this,"position"),u(this,"rotation"),u(this,"_rotation",new Ys),u(this,"scale"),u(this,"radius"),u(this,"radiusThickness"),u(this,"sphericalDirectionAmount"),u(this,"randomDirectionAmount"),u(this,"randomPositionAmount"),u(this,"system"),u(this,"_space"),u(this,"_worldSpaceMatrix",new Be),u(this,"_worldSpaceMatrixInverse",new Be),u(this,"_vector",new S(0,0,0)),u(this,"_temp",new S(0,0,0)),u(this,"_dir",new S),u(this,"_loopTime",0),u(this,"_loopDirection",1),Kx&&console.log(this)}get type(){return rz[this.shapeType]}initialize(i){this.getPosition(),i.position.copy(this._vector)}toJSON(){return this}clone(){return new Dv}update(i,e,t,s){this.system=i,this._space=t,t===1&&(this._worldSpaceMatrix.copy(s.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=et.toRadians(this.rotation.x),this._rotation.y=et.toRadians(this.rotation.y),this._rotation.z=et.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const i=this._temp.copy(this.position),e=this._space===1;e&&i.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Kx&&Ll.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(i);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,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),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Kx&&Ll.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i){var e;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 t=i.x,s=i.y,r=i.z;this._dir.set(t,s,r),(e=this.system)!=null&&e.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),Kx&&(Ll.DrawSphere(i,.01,8925952,.5,!0),Ll.DrawDirection(i,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,e){if(e<=0)return;const t=Dv._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,i.add(t)}randomizeDirection(i,e){if(e===0)return;const t=Dv._randomQuat,s=Dv._tempVec;s.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(s,e*Math.random()*Math.PI),i.applyQuaternion(t)}spherizeDirection(i,e){if(e===0)return;const t=Math.random()*Math.PI*2,s=Math.acos(1-Math.random()*2),r=Math.sin(s)*Math.cos(t),n=Math.sin(s)*Math.sin(t),o=Math.cos(s),a=new S(r,n,o);i.lerp(a,e)}randomSpherePoint(i,e,t,s,r){const n=Math.random(),o=Math.random(),a=2*Math.PI*n*(s/360),l=Math.acos(2*o-1),c=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,h=i.x+this.scale.x*(-c*Math.sin(l)*Math.cos(a)),d=i.y+this.scale.y*(c*Math.sin(l)*Math.sin(a)),p=i.z+this.scale.z*(c*Math.cos(l));r.x=h,r.y=d,r.z=p}randomCirclePoint(i,e,t,s,r){const n=Math.random(),o=2*Math.PI*n*(s/360),a=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,l=i.x+this.scale.x*a*Math.cos(o),c=i.y+this.scale.y*a*Math.sin(o),h=i.z;r.x=l,r.y=c,r.z=h}randomConePoint(i,e,t,s,r,n,o){let a=0,l=0;switch(n){case 0:a=Math.random(),l=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,l=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let c=2*Math.PI*a*(r/360);switch(n){case 2:case 1:c+=Math.PI+.5,c+=this._loopTime*Math.PI*2,c%=et.toRadians(r);break}const h=Math.acos(2*l-1),d=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),s)*t,p=i.x+-d*Math.sin(h)*Math.cos(c),f=i.y+d*Math.sin(h)*Math.sin(c),m=i.z;o.x=p*this.scale.x,o.y=f*this.scale.y,o.z=m*this.scale.z}},u(e_,"_randomQuat",new Ue),u(e_,"_tempVec",new S),e_);let ns=Dv;K([w()],ns.prototype,"shapeType",2),K([w()],ns.prototype,"enabled",2),K([w()],ns.prototype,"alignToDirection",2),K([w()],ns.prototype,"angle",2),K([w()],ns.prototype,"arc",2),K([w()],ns.prototype,"arcSpread",2),K([w()],ns.prototype,"arcSpeedMultiplier",2),K([w()],ns.prototype,"arcMode",2),K([w(S)],ns.prototype,"boxThickness",2),K([w(S)],ns.prototype,"position",2),K([w(S)],ns.prototype,"rotation",2),K([w(S)],ns.prototype,"scale",2),K([w()],ns.prototype,"radius",2),K([w()],ns.prototype,"radiusThickness",2),K([w()],ns.prototype,"sphericalDirectionAmount",2),K([w()],ns.prototype,"randomDirectionAmount",2),K([w()],ns.prototype,"randomPositionAmount",2);class fi{constructor(){u(this,"damping"),u(this,"enabled"),u(this,"frequency"),u(this,"octaveCount"),u(this,"octaveMultiplier"),u(this,"octaveScale"),u(this,"positionAmount"),u(this,"quality"),u(this,"remap"),u(this,"remapEnabled"),u(this,"remapMultiplier"),u(this,"remapX"),u(this,"remapXMultiplier"),u(this,"remapY"),u(this,"remapYMultiplier"),u(this,"remapZ"),u(this,"remapZMultiplier"),u(this,"scrollSpeedMultiplier"),u(this,"separateAxes"),u(this,"strengthMultiplier"),u(this,"strengthX"),u(this,"strengthXMultiplier"),u(this,"strengthY"),u(this,"strengthYMultiplier"),u(this,"strengthZ"),u(this,"strengthZMultiplier"),u(this,"_noise"),u(this,"_time",0),u(this,"_temp",new S)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,s,r,n,o){if(!this.enabled)return;this._noise||(this._noise=gre(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),l=this._noise(a.x,a.y,a.z,this._time),c=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),h=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(l,c,h).normalize();const d=n/o;let p=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=p*this.strengthXMultiplier,this._temp.y*=p*this.strengthYMultiplier,this._temp.z*=p*this.strengthZMultiplier):(this.strengthX&&(p*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(p)),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}K([w()],fi.prototype,"damping",2),K([w()],fi.prototype,"enabled",2),K([w()],fi.prototype,"frequency",2),K([w()],fi.prototype,"octaveCount",2),K([w()],fi.prototype,"octaveMultiplier",2),K([w()],fi.prototype,"octaveScale",2),K([w(at)],fi.prototype,"positionAmount",2),K([w()],fi.prototype,"quality",2),K([w(at)],fi.prototype,"remap",2),K([w()],fi.prototype,"remapEnabled",2),K([w()],fi.prototype,"remapMultiplier",2),K([w(at)],fi.prototype,"remapX",2),K([w()],fi.prototype,"remapXMultiplier",2),K([w(at)],fi.prototype,"remapY",2),K([w()],fi.prototype,"remapYMultiplier",2),K([w(at)],fi.prototype,"remapZ",2),K([w()],fi.prototype,"remapZMultiplier",2),K([w()],fi.prototype,"scrollSpeedMultiplier",2),K([w()],fi.prototype,"separateAxes",2),K([w()],fi.prototype,"strengthMultiplier",2),K([w(at)],fi.prototype,"strengthX",2),K([w()],fi.prototype,"strengthXMultiplier",2),K([w(at)],fi.prototype,"strengthY",2),K([w()],fi.prototype,"strengthYMultiplier",2),K([w(at)],fi.prototype,"strengthZ",2),K([w()],fi.prototype,"strengthZMultiplier",2);class Oi{constructor(){u(this,"enabled"),u(this,"attachRibbonToTransform",!1),u(this,"colorOverLifetime"),u(this,"colorOverTrail"),u(this,"dieWithParticles",!0),u(this,"inheritParticleColor",!0),u(this,"lifetime"),u(this,"lifetimeMultiplier"),u(this,"minVertexDistance",.2),u(this,"mode",0),u(this,"ratio",1),u(this,"ribbonCount",1),u(this,"shadowBias",0),u(this,"sizeAffectsLifetime",!1),u(this,"sizeAffectsWidth",!1),u(this,"splitSubEmitterRibbons",!1),u(this,"textureMode",0),u(this,"widthOverTrail"),u(this,"widthOverTrailMultiplier"),u(this,"worldSpace",!1)}getWidth(e,t,s,r){let n=this.widthOverTrail.evaluate(s,r);return e*=n,e}getColor(e,t,s){const r=this.colorOverTrail.evaluate(s),n=this.colorOverLifetime.evaluate(t);e.x*=r.r*n.r,e.y*=r.g*n.g,e.z*=r.b*n.b,e.w*=r.alpha*n.alpha}}K([w()],Oi.prototype,"enabled",2),K([w()],Oi.prototype,"attachRibbonToTransform",2),K([w(An)],Oi.prototype,"colorOverLifetime",2),K([w(An)],Oi.prototype,"colorOverTrail",2),K([w()],Oi.prototype,"dieWithParticles",2),K([w()],Oi.prototype,"inheritParticleColor",2),K([w(at)],Oi.prototype,"lifetime",2),K([w()],Oi.prototype,"lifetimeMultiplier",2),K([w()],Oi.prototype,"minVertexDistance",2),K([w()],Oi.prototype,"mode",2),K([w()],Oi.prototype,"ratio",2),K([w()],Oi.prototype,"ribbonCount",2),K([w()],Oi.prototype,"shadowBias",2),K([w()],Oi.prototype,"sizeAffectsLifetime",2),K([w()],Oi.prototype,"sizeAffectsWidth",2),K([w()],Oi.prototype,"splitSubEmitterRibbons",2),K([w()],Oi.prototype,"textureMode",2),K([w(at)],Oi.prototype,"widthOverTrail",2),K([w()],Oi.prototype,"widthOverTrailMultiplier",2),K([w()],Oi.prototype,"worldSpace",2);class Gi{constructor(){u(this,"enabled"),u(this,"space",0),u(this,"orbitalX"),u(this,"orbitalY"),u(this,"orbitalZ"),u(this,"orbitalXMultiplier"),u(this,"orbitalYMultiplier"),u(this,"orbitalZMultiplier"),u(this,"orbitalOffsetX"),u(this,"orbitalOffsetY"),u(this,"orbitalOffsetZ"),u(this,"speedModifier"),u(this,"speedModifierMultiplier"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier"),u(this,"_system"),u(this,"_temp",new S),u(this,"_temp2",new S),u(this,"_temp3",new S),u(this,"_hasOrbital",!1),u(this,"_index",0),u(this,"_orbitalMatrix",new Be)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,s,r,n,o,a){var l;if(!this.enabled)return;const c=o/a,h=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,d=this.x.evaluate(c),p=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-d,p,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((l=this._system)==null?void 0:l.worldPos)){const m=this._temp2.set(s.x,s.y,s.z),v=this.orbitalXMultiplier,A=this.orbitalYMultiplier,g=this.orbitalZMultiplier,b=h*Math.PI*2*10,y=Math.cos(b*v),x=Math.sin(b*v),_=Math.cos(b*A),E=Math.sin(b*A),I=Math.cos(b*g),P=Math.sin(b*g),M=m.x*(_*I)+m.y*(_*P)+m.z*-E,C=m.x*(x*E*I-y*P)+m.y*(x*E*P+y*I)+m.z*(x*_),U=m.x*(y*E*I+x*P)+m.y*(y*E*P-x*I)+m.z*(y*_),G=this._temp3.set(m.x-M,m.y-C,m.z-U);G.normalize(),G.multiplyScalar(.2/n*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),r.x+=G.x,r.y+=G.y,r.z+=G.z}r.x+=this._temp.x,r.y+=this._temp.y,r.z+=this._temp.z,r.x*=h,r.y*=h,r.z*=h}}K([w()],Gi.prototype,"enabled",2),K([w()],Gi.prototype,"space",2),K([w(at)],Gi.prototype,"orbitalX",2),K([w(at)],Gi.prototype,"orbitalY",2),K([w(at)],Gi.prototype,"orbitalZ",2),K([w()],Gi.prototype,"orbitalXMultiplier",2),K([w()],Gi.prototype,"orbitalYMultiplier",2),K([w()],Gi.prototype,"orbitalZMultiplier",2),K([w()],Gi.prototype,"orbitalOffsetX",2),K([w()],Gi.prototype,"orbitalOffsetY",2),K([w()],Gi.prototype,"orbitalOffsetZ",2),K([w(at)],Gi.prototype,"speedModifier",2),K([w()],Gi.prototype,"speedModifierMultiplier",2),K([w(at)],Gi.prototype,"x",2),K([w()],Gi.prototype,"xMultiplier",2),K([w(at)],Gi.prototype,"y",2),K([w()],Gi.prototype,"yMultiplier",2),K([w(at)],Gi.prototype,"z",2),K([w()],Gi.prototype,"zMultiplier",2);class lr{constructor(){u(this,"animation"),u(this,"enabled"),u(this,"cycleCount"),u(this,"frameOverTime"),u(this,"frameOverTimeMultiplier"),u(this,"numTilesX"),u(this,"numTilesY"),u(this,"startFrame"),u(this,"startFrameMultiplier"),u(this,"rowMode"),u(this,"rowIndex"),u(this,"spriteCount"),u(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(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let s=this.frameOverTime.evaluate(e%1);return s*=this.frameOverTimeMultiplier,s*=t,s=s%t,s=Math.floor(s),s}}K([w()],lr.prototype,"animation",2),K([w()],lr.prototype,"enabled",2),K([w()],lr.prototype,"cycleCount",2),K([w(at)],lr.prototype,"frameOverTime",2),K([w()],lr.prototype,"frameOverTimeMultiplier",2),K([w()],lr.prototype,"numTilesX",2),K([w()],lr.prototype,"numTilesY",2),K([w(at)],lr.prototype,"startFrame",2),K([w()],lr.prototype,"startFrameMultiplier",2),K([w()],lr.prototype,"rowMode",2),K([w()],lr.prototype,"rowIndex",2),K([w()],lr.prototype,"spriteCount",2),K([w()],lr.prototype,"timeMode",2);class So{constructor(){u(this,"enabled"),u(this,"separateAxes"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}K([w()],So.prototype,"enabled",2),K([w()],So.prototype,"separateAxes",2),K([w(at)],So.prototype,"x",2),K([w()],So.prototype,"xMultiplier",2),K([w(at)],So.prototype,"y",2),K([w()],So.prototype,"yMultiplier",2),K([w(at)],So.prototype,"z",2),K([w()],So.prototype,"zMultiplier",2);class jn{constructor(){u(this,"enabled"),u(this,"range"),u(this,"separateAxes"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const s=et.lerp(this.range.x,this.range.y,t);return this.z.evaluate(s)*-1}return 0}}K([w()],jn.prototype,"enabled",2),K([w()],jn.prototype,"range",2),K([w()],jn.prototype,"separateAxes",2),K([w(at)],jn.prototype,"x",2),K([w()],jn.prototype,"xMultiplier",2),K([w(at)],jn.prototype,"y",2),K([w()],jn.prototype,"yMultiplier",2),K([w(at)],jn.prototype,"z",2),K([w()],jn.prototype,"zMultiplier",2);class ys{constructor(){u(this,"enabled"),u(this,"dampen"),u(this,"drag"),u(this,"dragMultiplier"),u(this,"limit"),u(this,"limitMultiplier"),u(this,"separateAxes"),u(this,"limitX"),u(this,"limitXMultiplier"),u(this,"limitY"),u(this,"limitYMultiplier"),u(this,"limitZ"),u(this,"limitZMultiplier"),u(this,"multiplyDragByParticleSize",!1),u(this,"multiplyDragByParticleVelocity",!1),u(this,"space"),u(this,"_temp",new S),u(this,"_temp2",new S)}apply(e,t,s,r,n,o,a){if(this.enabled){const l=this.limit.evaluate(n)*this.limitMultiplier;if(t.length()>l){this._temp.copy(t).normalize().multiplyScalar(l);let c=this.dampen*.5;t.x=et.lerp(t.x,this._temp.x,c),t.y=et.lerp(t.y,this._temp.y,c),t.z=et.lerp(t.z,this._temp.z,c),s.x=et.lerp(s.x,this._temp.x,c),s.y=et.lerp(s.y,this._temp.y,c),s.z=et.lerp(s.z,this._temp.z,c)}}}}K([w()],ys.prototype,"enabled",2),K([w()],ys.prototype,"dampen",2),K([w(at)],ys.prototype,"drag",2),K([w()],ys.prototype,"dragMultiplier",2),K([w(at)],ys.prototype,"limit",2),K([w()],ys.prototype,"limitMultiplier",2),K([w()],ys.prototype,"separateAxes",2),K([w(at)],ys.prototype,"limitX",2),K([w()],ys.prototype,"limitXMultiplier",2),K([w(at)],ys.prototype,"limitY",2),K([w()],ys.prototype,"limitYMultiplier",2),K([w(at)],ys.prototype,"limitZ",2),K([w()],ys.prototype,"limitZMultiplier",2),K([w()],ys.prototype,"multiplyDragByParticleSize",2),K([w()],ys.prototype,"multiplyDragByParticleVelocity",2),K([w()],ys.prototype,"space",2);class Eh{constructor(){u(this,"enabled"),u(this,"curve"),u(this,"curveMultiplier"),u(this,"mode"),u(this,"system"),u(this,"_lastWorldPosition"),u(this,"_velocity",new S),u(this,"_temp",new S)}update(e){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(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,s){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const r=this.curve.evaluate(t,s);this._temp.copy(this._velocity).multiplyScalar(r),e.add(this._temp)}}}K([w()],Eh.prototype,"enabled",2),K([w(at)],Eh.prototype,"curve",2),K([w()],Eh.prototype,"curveMultiplier",2),K([w()],Eh.prototype,"mode",2);class Yr{constructor(){u(this,"enabled"),u(this,"range"),u(this,"separateAxes"),u(this,"size"),u(this,"sizeMultiplier"),u(this,"x"),u(this,"xMultiplier"),u(this,"y"),u(this,"yMultiplier"),u(this,"z"),u(this,"zMultiplier")}evaluate(e,t,s,r){const n=e.length(),o=et.remap(n,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,s);return r*a}}K([w()],Yr.prototype,"enabled",2),K([w(Y)],Yr.prototype,"range",2),K([w()],Yr.prototype,"separateAxes",2),K([w(at)],Yr.prototype,"size",2),K([w()],Yr.prototype,"sizeMultiplier",2),K([w(at)],Yr.prototype,"x",2),K([w()],Yr.prototype,"xMultiplier",2),K([w(at)],Yr.prototype,"y",2),K([w()],Yr.prototype,"yMultiplier",2),K([w(at)],Yr.prototype,"z",2),K([w()],Yr.prototype,"zMultiplier",2);class Ku{constructor(){u(this,"enabled"),u(this,"range"),u(this,"color")}evaluate(e,t,s){const r=e.length(),n=et.remap(r,this.range.x,this.range.y,0,1),o=this.color.evaluate(n,t);s.x*=o.r,s.y*=o.g,s.z*=o.b,s.w*=o.alpha}}K([w()],Ku.prototype,"enabled",2),K([w(Y)],Ku.prototype,"range",2),K([w(An)],Ku.prototype,"color",2);function bre(i){const e=i.domElement.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const s=document.createElement("button");s.id="open-in-ar",s.innerText="Open in QuickLook",t.appendChild(s);const r=document.createElement("a");r.id="needle-usdz-link",r.style.display="none",r.rel="ar",r.href="",t.appendChild(r);const n=document.createElement("img");return n.id="button",r.appendChild(n),i.domElement.appendChild(t),r}function xre(){var i=new Date;const e=i.getMonth()+1,t=i.getDate(),s=i.getHours(),r=i.getMinutes(),n=i.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,l=(s<10?"0":"")+s,c=(r<10?"0":"")+r,h=(n<10?"0":"")+n;return i.getFullYear()+o+a+"-"+l+c+h}const t_=re("debugusdz");function _re(i,e){const t=[],s=ee.getComponentsInChildren(i,Vr);let r=!1;t_&&console.log(s);for(const n of s){if(!n||!n.runtimeAnimatorController)continue;t_&&console.log(n);const o=[];for(const a of n.runtimeAnimatorController.enumerateActions()){t_&&console.log(a);const l=a.getClip();if(!r&&l.tracks.length>0){r=!0;const c=l.tracks[0],h=c.name.substring(0,c.name.lastIndexOf(".")),d=new kn(h+".position",[0,.01],[0,0,0,0,0,0]),p=new kn(h+".quaternion",[0,.01],[0,0,0,1,0,0,0,1]);o.push(new Lr("rest",.01,[d,p]))}o.includes(l)||o.push(l)}t.push({root:n.gameObject,clips:o})}t_&&console.log(t);for(const n of t)for(const o of n.clips)e.registerAnimation(n.root,o)}var wre=Object.defineProperty,Sre=Object.getOwnPropertyDescriptor,rc=(i,e,t,s)=>{for(var r=s>1?void 0:s?Sre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&wre(e,t,r),r};const Zu=re("debugtext");var Ds=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Ds||{}),nz=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(nz||{});class Jr extends Wu{constructor(){super(...arguments),u(this,"alignment",0),u(this,"verticalOverflow",0),u(this,"horizontalOverflow",0),u(this,"lineSpacing",1),u(this,"supportRichText",!1),u(this,"font"),u(this,"fontStyle",0),u(this,"_text",""),u(this,"_fontSize",12),u(this,"_textMeshUi",null),u(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;(e=this.uiObject)==null||e.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var e;this.uiObject&&((e=this.Canvas)!=null&&e.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var e;const t=(e=this.uiObject)==null?void 0:e._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(e){Zu&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,Zu&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),Zu&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let e=this.fontSize;const t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var s,r,n;if(Zu&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let o=this.getNextTag(e);if(o){if(o.startIndex>0){for(let c=this.uiObject.children.length-1;c>=0;c--){const h=this.uiObject.children[c];h.isUI&&(this.uiObject.remove(h),h.clear())}const l=new Tx({textContent:e.substring(0,o.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const a=[];for(;o;){const l=this.getNextTag(e,o.endIndex),c={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(l){c.textContent=this.getText(e,o,l),this.handleTag(o,c,a);const h=new Tx(c);(r=this.uiObject)==null||r.add(h)}else{c.textContent=e.substring(o.endIndex),this.handleTag(o,c,a);const h=new Tx(c);(n=this.uiObject)==null||n.add(h)}o=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,s={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let n=0;n<this._textMeshUi.length;n++){if(e[n]===!0)continue;r=!0;const o=this._textMeshUi[n];o.textContent&&(jx(o,s),e[n]=!0)}if(!r)break;yield}}handleTag(e,t,s){if(!e.isEndTag){if(e.type.includes("color")){const r=new eI(e,{color:t.color});if(s.push(r),e.type.length>6){const n=parseInt("0x"+e.type.substring(7));t.color=n}else t.color=new Ae(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const r=new eI(e,{fontWeight:700});s.push(r)}else if(e.type=="i"){this.setFont(t,2);const r=new eI(e,{fontStyle:"italic"});s.push(r)}}}getText(e,t,s){return e.substring(t.endIndex,s.startIndex)}getNextTag(e,t=0){const s=e.indexOf("<",t),r=e.indexOf(">",s);if(s>=0&&r>=0){const n=e.substring(s+1,r);return{type:n,startIndex:s,endIndex:r+1,isEndTag:n.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;let s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,t);Zu&&console.log("Selected font family:"+r);let n=AT.getFontFamily(r);switch(n||(n=AT.addFontFamily(r)),e.fontFamily=n,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let o=n.getVariant(e.fontWeight,e.fontStyle);if(!o){let a=r;a!=null&&a.endsWith("-msdf.json")||(a+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),o=n.addVariant(e.fontWeight,e.fontStyle,a,l),o?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var s;const r=e.lastIndexOf("-");if(r<0)return e;const n=(s=e.substring(r+1))==null?void 0:s.toLowerCase();if(Cre.includes(n))return Zu&&console.warn("Unsupported font style: "+n),e;const o=e.lastIndexOf("/");let a=e;o>=0&&(a=a.substring(o+1));let l=a[0]===a[0].toUpperCase();const c=e.substring(0,r);switch(Zu&&console.log("Select font: ",e,nz[t],a,l,c),t){case 0:return l?c+"-Regular":c+"-regular";case 1:return l?c+"-Bold":c+"-bold";case 2:return l?c+"-Italic":c+"-italic";case 3:return l?c+"-BoldItalic":c+"-bolditalic";default:return e}}}rc([w()],Jr.prototype,"alignment",2),rc([w()],Jr.prototype,"verticalOverflow",2),rc([w()],Jr.prototype,"horizontalOverflow",2),rc([w()],Jr.prototype,"lineSpacing",2),rc([w()],Jr.prototype,"supportRichText",2),rc([w(URL)],Jr.prototype,"font",2),rc([w()],Jr.prototype,"fontStyle",2),rc([w()],Jr.prototype,"text",1),rc([w()],Jr.prototype,"fontSize",1);class eI{constructor(e,t){u(this,"tag"),u(this,"previousValues"),this.tag=e,this.previousValues=t}}const Cre=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Mh{constructor(e){u(this,"id"),u(this,"content",""),u(this,"font",[]),u(this,"pointSize",144),u(this,"width"),u(this,"height"),u(this,"depth"),u(this,"wrapMode"),u(this,"horizontalAlignment"),u(this,"verticalAlignment"),u(this,"material"),this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var s;t.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(s=this.font)==null||s.push("sans-serif"));const r=this.font.map(n=>`"${n}"`).join(", ");t.appendLine(`string[] font = [ ${r} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),t.closeBlock()}}u(Mh,"global_id",0);class i_{static singleLine(e,t,s){const r=new Mh("text_"+Mh.getId());return r.content=e,t&&(r.pointSize=t),s&&(r.depth=s),r}static multiLine(e,t,s,r,n,o){const a=new Mh("text_"+Mh.getId());return a.content=e,a.width=t,a.height=s,a.horizontalAlignment=r,a.verticalAlignment=n,o!==void 0&&(a.wrapMode=o),a}}const Ere=new Be().makeRotationY(Math.PI),Mre=new Be().makeScale(-1,1,-1);class Ov{get extensionName(){return"text"}onExportObject(e,t,s){}exportText(e,t,s){const r=ee.getComponent(e,Jr);if(!r)return;const n=ee.getComponent(e,rr);let o=100,a=100;n&&(o=n.width,a=n.height),t.matrix=Ere.clone(),n&&t.matrix.premultiply(Mre);const l=new Ae().copySRGBToLinear(r.color);t.material=new zo({color:l,emissive:l}),t.addEventListener("serialize",(c,h)=>{let d=r.text;d=d.replace(/\n/g,"\\n");const p=i_.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(p,r.alignment),this.setOverflow(p,r),t.material&&(p.material=t.material),p.pointSize=this.convertToTextSize(r.fontSize),p.depth=.001,p.writeTo(void 0,c)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case Ds.LowerLeft:case Ds.MiddleLeft:case Ds.UpperLeft:e.horizontalAlignment="left";break;case Ds.LowerCenter:case Ds.MiddleCenter:case Ds.UpperCenter:e.horizontalAlignment="center";break;case Ds.LowerRight:case Ds.MiddleRight:case Ds.UpperRight:e.horizontalAlignment="right";break}switch(t){case Ds.LowerLeft:case Ds.LowerCenter:case Ds.LowerRight:e.verticalAlignment="bottom";break;case Ds.MiddleLeft:case Ds.MiddleCenter:case Ds.MiddleRight:e.verticalAlignment="middle";break;case Ds.UpperLeft:case Ds.UpperCenter:case Ds.UpperRight:e.verticalAlignment="top";break}}}class s_{get extensionName(){return"tmui"}onExportObject(e,t,s){const r=ee.getComponent(e,nr);if(r&&r.activeAndEnabled&&r.renderMode===iz.WorldSpace){const n=new Ov,o=ee.getComponent(e,rr),a=ee.getComponent(e,xh);if(o){o.width,o.height;const l=fo.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const h=c.matrix;l.matrix.copy(h);const d=new Map,p=new Map;d.set(c,l),p.set(c,a?a.alpha:1),c.traverse(f=>{if(f===c)return;const m=fo.createEmpty();m.matrix.copy(f.matrix);const v=f.parent,A=v&&typeof v.textContent=="string"&&v.textContent.length;let g=p.get(v)||1;const b=ee.getComponent(f,xh);if(b&&(g*=b.alpha),f instanceof xe&&A){const x=f[Na].gameObject;n.exportText(x,m,s)}if(f instanceof xe&&!A){const x=f.geometry.clone();x.scale(1,1,-1),this.flipWindingOrder(x),m.geometry=x;const _=new Ae,E=f.material.opacity;_.copy(f.material.color),m.material=new hi({color:_,opacity:E*g,map:f.material.map,transparent:!0})}d.set(f,m),p.set(f,g);const y=d.get(v);if(!y){console.error("Error when exporting UI: shadow component parent not found!",f,f.parent);return}y.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let s=0,r=t.length/3;s<r;s++){let n=t[s*3];t[s*3]=t[s*3+2],t[s*3+2]=n}e.index.needsUpdate=!0}}var Tre=Object.defineProperty,Ire=Object.getOwnPropertyDescriptor,Gn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ire(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Tre(e,t,r),r};const js=re("debugusdz");class Th{constructor(){u(this,"callToAction"),u(this,"checkoutTitle"),u(this,"checkoutSubtitle"),u(this,"callToActionURL")}}Gn([w()],Th.prototype,"callToAction",2),Gn([w()],Th.prototype,"checkoutTitle",2),Gn([w()],Th.prototype,"checkoutSubtitle",2),Gn([w()],Th.prototype,"callToActionURL",2);class Hn extends Me{constructor(){super(...arguments),u(this,"objectToExport"),u(this,"autoExportAnimations",!1),u(this,"exportFileName"),u(this,"customUsdzFile"),u(this,"customBranding"),u(this,"anchoringType","plane"),u(this,"planeAnchoringAlignment","horizontal"),u(this,"interactive",!0),u(this,"extensions",[]),u(this,"allowCreateQuicklookButton",!0),u(this,"link"),u(this,"webxr"),u(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAsync()}),u(this,"lastCallback"),u(this,"_quicklookButton"),u(this,"_quicklookButtonContainer",null)}start(){var e,t,s;js&&(console.log(this),console.log("Debug USDZ, press 't' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),Cc()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((s=this.objectToExport)!=null&&s.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Qx),this.extensions.push(new Nx),this.extensions.push(new Ov),this.extensions.push(new s_))}onEnable(){var e;const t=pm(),s=ll();(js||t&&s)&&((js||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=bre(this.context),this.link.addEventListener("message",this.lastCallback)),js&&hs("USDZ Exporter enabled: "+this.name),(e=document.getElementById("open-in-ar"))==null||e.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var e,t;(e=this.link)==null||e.removeEventListener("message",this.lastCallback);const s=pm(),r=ll();(js||s&&r)&&this.removeQuicklookButton(),js&&hs("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var e;let t=this.exportFileName??((e=this.objectToExport)==null?void 0:e.name)??this.name;if(Rp()||(t+="-MadeWithNeedle"),t+="-"+xre(),this.customUsdzFile){js&&console.log("Exporting custom usdz",this.customUsdzFile);const v=this.buildQuicklookOverlay();js&&console.log(v);const A=v.callToAction?encodeURIComponent(v.callToAction):"",g=v.checkoutTitle?encodeURIComponent(v.checkoutTitle):"",b=v.checkoutSubtitle?encodeURIComponent(v.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${A}&checkoutTitle=${g}&checkoutSubtitle=${b}&callToActionURL=${v.callToActionURL}`,js&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click();return}if(!this.objectToExport)return;const s=ee.getComponentsInChildren(this.objectToExport,Pi),r=new Array;for(const v of s)for(const A of v.sharedMaterials)if(A){const g=v.loadProgressiveTextures(A);g instanceof Promise&&r.push(g)}js&&hs("Load textures: "+r.length),await Promise.all(r),js&&hs("Load textures: done"),this.applyWebARSessionRoot();const n=new MK,o=[...this.extensions],a=new $b;o.push(a),this.autoExportAnimations&&_re(this.objectToExport,a);const l={self:this,exporter:n,extensions:o,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:l})),n.debug=js,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 c=await n.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:o,quickLookCompatible:!0}),h=new Blob([c],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:l}));const d=this.buildQuicklookOverlay();js&&console.log(d);const p=d.callToAction?encodeURIComponent(d.callToAction):"",f=d.checkoutTitle?encodeURIComponent(d.checkoutTitle):"",m=d.checkoutSubtitle?encodeURIComponent(d.checkoutSubtitle):"";this.link.href=URL.createObjectURL(h)+`#callToAction=${p}&checkoutTitle=${f}&checkoutSubtitle=${m}&callToActionURL=${d.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click()}quicklookCallback(e){if(e?.data=="_apple_ar_quicklook_button_tapped"){js&&lo("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const s=new URLSearchParams(this.link.href);if(s){const r=s.get("callToActionURL");js&&hs("Quicklook url: "+r),r&&(Rp()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var e,t,s,r,n,o;const a={};return this.customBranding&&Object.assign(a,this.customBranding),Rp()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),a.callToAction="Close",a.checkoutTitle="\u{1F335} Made with Needle",a.checkoutSubtitle="_"),(((e=a.callToAction)==null?void 0:e.length)||((t=a.checkoutTitle)==null?void 0:t.length)||((s=a.checkoutSubtitle)==null?void 0:s.length))&&((r=a.callToAction)!=null&&r.length||(a.callToAction="\0"),(n=a.checkoutTitle)!=null&&n.length||(a.checkoutTitle="\0"),(o=a.checkoutSubtitle)!=null&&o.length||(a.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:a})),a}async createQuicklookButton(){var e,t;if(!this.webxr)if(await dm(1),this.webxr=ee.findObjectOfType(wt)??void 0,this.webxr)if(this.webxr.VRButton&&((e=this.webxr.VRButton.parentElement)==null||e.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const s=(t=this.webxr.ARButton.parentElement)==null?void 0:t.querySelector("a");s&&(s.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",r=>{r.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 s=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");s||(s=document.createElement("div"),s.classList.add("webxr-buttons"));const r=document.createElement("button");r.innerText="Open in Quicklook",r.addEventListener("click",()=>{this.exportAsync()}),r.classList.add("webxr-ar-button"),r.classList.add("webxr-button"),r.classList.add("quicklook-ar-button"),this._quicklookButton=r,s.appendChild(r),this._quicklookButtonContainer=s,this.dispatchEvent(new CustomEvent("created-button",{detail:r}))}else console.warn("Could not find WebXR component: will not create Quicklook button",Lt.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var e;(e=this._quicklookButton)==null||e.remove()}applyWebARSessionRoot(){if(js&&console.log("applyWebARSessionRoot"),!this.objectToExport)return;let e=ee.getComponentInParent(this.objectToExport,ka);const t=e!=null;if(e||(e=ee.getComponentInChildren(this.objectToExport,ka)),!e){js&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const s=t?this.objectToExport:e.gameObject,r=1/e.arScale;js&&console.log("Scale",r,s),s.matrix.makeScale(r,r,r),e.invertForward&&s.matrix.multiply(new Be().makeRotationY(Math.PI))}}Gn([w(De)],Hn.prototype,"objectToExport",2),Gn([w()],Hn.prototype,"autoExportAnimations",2),Gn([w()],Hn.prototype,"exportFileName",2),Gn([w(URL)],Hn.prototype,"customUsdzFile",2),Gn([w(Th)],Hn.prototype,"customBranding",2),Gn([w()],Hn.prototype,"anchoringType",2),Gn([w()],Hn.prototype,"planeAnchoringAlignment",2),Gn([w()],Hn.prototype,"interactive",2),Gn([w()],Hn.prototype,"allowCreateQuicklookButton",2);const oz=re("debugdeletable");class r_ extends Ba{}class tI extends Me{constructor(){super(...arguments),u(this,"deleteBoxes",[])}awake(){this.deleteBoxes=ee.findObjectsOfType(r_,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const s=ee.getComponentInParent(this.gameObject,Jp);s?oz&&console.warn("Can not delete object with usage marker",this.guid,s):(oz&&console.log("DESTROY",this.gameObject),ab(this.gameObject,this.context.connection))}}}}var Rre=Object.defineProperty,Pre=Object.getOwnPropertyDescriptor,$u=(i,e,t,s)=>{for(var r=s>1?void 0:s?Pre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Rre(e,t,r),r};class oa extends Er{constructor(){super(...arguments),u(this,"mode"),u(this,"focusDistance"),u(this,"focalLength"),u(this,"aperture"),u(this,"gaussianMaxRadius"),u(this,"resolutionScale"),u(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=t=>{const s=t/300,r=2;return et.lerp(r,.01,s)};const e=20;this.aperture.valueProcessor=t=>{const s=1-t/32;return et.lerp(1,e,s)}}onCreateEffect(){if(this.mode===0)return;const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;Cc()&&(s=.6),this.resolutionScale=new Et(s*e)}const t=new FL(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{t.circleOfConfusionMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>t.circleOfConfusionMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>t.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>t.resolution.scale=s),[t]}unapply(){}}$u([w()],oa.prototype,"mode",2),$u([w(Et)],oa.prototype,"focusDistance",2),$u([w(Et)],oa.prototype,"focalLength",2),$u([w(Et)],oa.prototype,"aperture",2),$u([w(Et)],oa.prototype,"gaussianMaxRadius",2),$u([w(Et)],oa.prototype,"resolutionScale",2),$u([w(Et)],oa.prototype,"bokehScale",2),wo("DepthOfField",oa);var Bre=Object.defineProperty,kre=Object.getOwnPropertyDescriptor,Dre=(i,e,t,s)=>{for(var r=s>1?void 0:s?kre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Bre(e,t,r),r};class n_ extends Me{constructor(){super(...arguments),u(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||ee.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Ore()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}Dre([w()],n_.prototype,"visibleOn",2);let o_;function Ore(){if(o_===!0||o_===!1)return o_;let i=!1;return function(e){(/(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(e)||/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(e.substr(0,4)))&&(i=!0)}(navigator.userAgent||navigator.vendor||window.opera),o_=i,i}class iI{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var Lre=Object.defineProperty,Ure=Object.getOwnPropertyDescriptor,az=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ure(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Lre(e,t,r),r},lz=(i=>(i.SelectStart="selectstart",i.SelectEnd="selectend",i))(lz||{}),a_;const Ih=(a_=class extends Yp{constructor(){super(),u(this,"showGizmo",!0),u(this,"useViewAngle",!0),u(this,"transformSelf",!0),u(this,"orbit",null),u(this,"selectStartEventListener",[]),u(this,"selectEndEventListener",[]),u(this,"_dragHelper",null),u(this,"_draggingRigidbodies",[]),u(this,"_waitingForDragStart",null),u(this,"_isDragging",!1),u(this,"_marker",null),u(this,"_dragDelta"),u(this,"_didDrag",!1),u(this,"_activePointerId"),this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new Y}static get HasAnySelected(){return this._active>0}addDragEventListener(i,e){switch(i){case"selectstart":this.selectStartEventListener.push(e);break;case"selectend":this.selectEndEventListener.push(e);break}}start(){this.orbit=ee.findObjectOfType(Zl,this.context),this.gameObject.getComponentInParent(Yl)||this.gameObject.addNewComponent(Yl)}allowEdit(i=null){return this.context.connection.allowEditing}onPointerEnter(i){if(!this.allowEdit(this.gameObject)||wt.IsInWebXR)return;const e=ee.getComponentInParent(i.object,Ih);!e||e!==this||(Ih.lastHovered=i.object,this.context.domElement.style.cursor="pointer")}onPointerExit(i){this.allowEdit(this.gameObject)&&(wt.IsInWebXR||Ih.lastHovered===i.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(i){this.allowEdit(this.gameObject)&&(wt.IsInWebXR||(Ih._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=i.clone(),i.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(i){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(Ih._active>0&&(Ih._active-=1),!wt.IsInWebXR&&(this.onDragEnd(i),i.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var i;if(!wt.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const t=this.context.input.getPointerPositionDelta(0);if(t&&this._dragDelta.add(t),this._dragDelta.length()>2)this._didDrag=!0;else return}const e=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(e)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((i=this._dragHelper)==null?void 0:i.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(i){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new hz(this.context.mainCamera);else return;if(!i||!i.object)return;const e=ee.getComponentInParent(i.object,Ih);if(!e||e!==this)return;let t=i.object;this.transformSelf&&(t=this.gameObject);const s={selected:t,attached:t};for(const a of this.selectStartEventListener)a(this,s);if(this._activePointerId=i.pointerId,!s.attached)return;s.attached,t=s.attached,this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const r=ee.getComponentInChildren(t,mh);r&&(r.fastMode=!0,r?.requestOwnership()),this._marker=ee.addNewComponent(t,Jp),this._draggingRigidbodies.length=0;const n=ee.getComponentsInChildren(t,ji);n&&this._draggingRigidbodies.push(...n);const o=HA();ee.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 i of this._draggingRigidbodies)i.wakeUp(),i.resetVelocities()}}onDragEnd(i){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const s of this._draggingRigidbodies)s.setVelocity(s.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),i!=null&&i.object){const s=ee.getComponentInChildren(i.object,mh);s&&(s.fastMode=!1)}this._marker&&this._marker.destroy();for(const s of this.selectEndEventListener)s(this);const t=HA();ee.invokeOnChildren(e,t("onDragEnd"))}},u(a_,"_active",0),u(a_,"lastHovered"),a_);let Cf=Ih;az([w()],Cf.prototype,"showGizmo",2),az([w()],Cf.prototype,"useViewAngle",2);const cz=class{constructor(i){u(this,"showGizmo",!0),u(this,"useViewAngle",!0),u(this,"_selected",null),u(this,"_context",null),u(this,"_camera"),u(this,"_cameraPlane",new so),u(this,"_hasGroundPlane",!1),u(this,"_groundPlane",new so),u(this,"_groundOffset",new S),u(this,"_groundOffsetFactor",0),u(this,"_groundDistance",0),u(this,"_groundPlanePoint",new S),u(this,"_raycaster",new mp),u(this,"_cameraPlaneOffset",new S),u(this,"_intersection",new S),u(this,"_worldPosition",new S),u(this,"_inverseMatrix",new Be),u(this,"_rbs",[]),u(this,"_groundLine"),u(this,"_groundMarker"),u(this,"_groundOffsetVector",new S(0,1,0)),u(this,"_requireUpdateGroundPlane",!0),u(this,"_didDragOnGroundPlaneLastFrame",!1),this._camera=i;const e=new es(cz.geometry),t=e.material;t.color=new Ae(.4,.4,.4),e.layers.set(2),e.name="line",e.scale.y=1,this._groundLine=e;const s=new Po(.5,22,22),r=new hi({color:t.color}),n=new xe(s,r);n.visible=!1,n.layers.set(2),this._groundMarker=n}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(i,e){if(this._selected&&e)for(const t of this._rbs)t.wakeUp(),t.setVelocity(0,0,0);if(this._selected&&qr.Remove(e,this._selected),this._selected=i,this._context=e,this._rbs.length=0,i?(e.scene.add(this._groundLine),e.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!e){console.error("DragHelper: no context");return}qr.Add(e,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(i){var e,t,s,r,n;if(!this._context)return;const o="Space",a="KeyD",l=((e=this._context)==null?void 0:e.input.isKeyPressed(o))||((t=this._context)==null?void 0:t.input.isKeyPressed(a)),c=this._context.input.getTouchesPressedCount()>=2||l;if(c){const d=this._context.input.getPointerPositionDelta(0);d&&(this._groundOffsetVector.set(0,1,0),(s=this._selected)==null||s.rotateOnWorldAxis(this._groundOffsetVector,d.x*this._context.time.deltaTime))}const h=this._context.input.getPointerPositionRC(0);if(h&&(this._raycaster.setFromCamera(h,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const d=yt(this._camera).clone().sub(yt(this._selected)).normalize(),p=Math.abs(d.dot(this._groundOffsetVector)),f=((r=this._context)==null?void 0:r.input.isKeyPressed(o))||((n=this._context)==null?void 0:n.input.isKeyPressed(a));let m=!this.useViewAngle||p>.2;(c||f||this._context.input.getPointerPressedCount()>1)&&(m=!1);const v=this._didDragOnGroundPlaneLastFrame!==m;if(this._didDragOnGroundPlaneLastFrame=m,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!m||v)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const A=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=A,m){this._groundOffsetVector.set(0,1,0);const g=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(g,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);v&&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(i,e,t){if(this._selected){if(t){const s=yt(this._selected);s.y=i.y,i=s}if(is(this._selected,i),is(this._groundLine,i),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=e!==null&&this.showGizmo,e){const s=yt(this._camera).distanceTo(e)*.01;this._groundMarker.scale.set(s,s,s),is(this._groundMarker,e)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const i=this._context.input.getPointerPositionRC(0);i&&(this._raycaster.setFromCamera(i,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 i=yt(this._selected),e=new _a(new S(0,.1,0).add(i),new S(0,-1,0)),t=new Go;t.ignore=[this._selected];const s=this._context.physics.raycastFromRay(e,t);for(let r=0;r<s.length;r++){const n=s[r];if(!n.face||this.contains(this._selected,n.object))continue;const o=new S(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(o,n.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(e.direction.multiplyScalar(-1),e.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(i),this._groundOffset.copy(this._intersection).sub(i)}onDidUpdate(){wn.markDirty(this._selected);for(const i of this._rbs)i.wakeUp(),i.resetForcesAndTorques(),i.setAngularVelocity(0,0,0)}contains(i,e){if(i===e)return!0;if(i.children){for(const t of i.children)if(this.contains(t,e))return!0}return!1}};let hz=cz;u(hz,"geometry",new At().setFromPoints([new S(0,0,0),new S(0,-1,0)]));function sI(i,e,t){console.warn("Adding components on object has been temporarily disabled")}var uz=(i=>(i.File_Spawned="file-spawned",i))(uz||{});class dz{constructor(e,t,s,r,n,o,a,l){u(this,"guid"),u(this,"file_name"),u(this,"file_hash"),u(this,"file_size"),u(this,"position"),u(this,"seed"),u(this,"sender"),u(this,"serverUrl"),u(this,"parentGuid"),u(this,"boundsSize"),this.seed=t,this.guid=s,this.file_name=r,this.file_hash=n,this.file_size=o,this.position=a,this.sender=e,this.serverUrl=l}}async function pz(i,e,t){const s=i.name;return s.endsWith(".gltf")||s.endsWith(".glb")?new Promise((r,n)=>{const o=new FileReader;o.readAsArrayBuffer(i),o.onloadend=async a=>{const l=o.result,c=lb(),h=new sn(c),d=await Wo().parseSync(e,l,i.name,h);if(d&&d.scene){const p=d.scene;if(!p.guid){const f=new sn(c);p.guid=f.generateUUID()}t&&Fre(e.connection,i,c,p,t),sI(),r(d)}}}):(console.warn("Unsupported file type: "+s,i),null)}async function fz(i,e){return new Promise(async(t,s)=>{const r=lb(),n=new sn(r),o=i.toString(),a=await Wo().loadSync(e,o,o,n);a&&a.scene?(a.scene,sI(),t(a)):console.warn("Unsupported file type: "+i.toString())})}Ii.registerCallback(Pr.ContextCreated,i=>{mz(i.context)});function mz(i){i.connection.beginListen("file-spawned",async e=>{if(e.sender!==i.connection.connectionId){console.log("received file event",e),Nre(e,i);let t=null;try{t=await gE(e.file_name,e.file_hash,e.file_size,e.serverUrl)}finally{zre(e)}if(t){const s=new sn(e.seed),r=await Wo().parseSync(i,t,e.file_name,s);if(r&&r.scene){const n=r.scene;if(sI(),e.parentGuid){const o=bg(e.parentGuid,i.scene);o&&"add"in o&&o.add(n)}n.parent||i.scene.add(n),e.position!==null&&n.position.copy(e.position)}}else console.error("download didnt return file")}})}async function Fre(i,e,t,s,r){if(!i.connectionId){console.error("Can not upload file - no connection id");return}if(!s.guid){console.error("Can not upload file - no guid",s,s.guid);return}const n=await iU(e,r);if(!n)return;if(!n.filename){console.error("Can not send upload event - no filename",e.name);return}if(!n.hash){console.error("Can not send upload event - no hash",e.name);return}const o=new dz(i.connectionId,t,s.guid,n.filename,n.hash,e.size,s.position,n.url??r);s.parent&&(o.parentGuid=s.parent.guid),i.send("file-spawned",o)}const rI={};function Nre(i,e){const t=new gi,s=new xe(t,new hi({color:65280})),r=new Cy(s,5592405);if(rI[i.guid]=r,e.scene.add(r),i.parentGuid){const n=bg(i.parentGuid,e.scene);n&&n.add(r)}i.position&&r.position.copy(i.position)}function zre(i,e){const t=i.guid,s=rI[t];s&&(delete rI[t],s.removeFromParent())}var Qre=Object.defineProperty,jre=Object.getOwnPropertyDescriptor,nI=(i,e,t,s)=>{for(var r=s>1?void 0:s?jre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Qre(e,t,r),r};const Gre=re("debugnet"),oI=class extends Me{constructor(){super(...arguments),u(this,"url",null),u(this,"urlParameterName",null),u(this,"localhost",null)}awake(){Gre&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let i=this.url?oI.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const t=re(this.urlParameterName);t&&typeof t=="string"&&(i=t)}if(!i)return null;const e=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(i);return e!=null&&e.groups?e?.groups.socket_prefix?i:"wss://"+e?.groups.url:null}static GetUrl(i,e){let t=i;const s=oI.IsLocalNetwork()&&e;return s&&(t=e),i!=null&&i.startsWith("/")&&(t=(s?t:window.location.origin)+i),t}static IsLocalNetwork(i=window.location.hostname){return Rr(i)}};let ed=oI;nI([w()],ed.prototype,"url",2),nI([w()],ed.prototype,"urlParameterName",2),nI([w()],ed.prototype,"localhost",2);var Hre=Object.defineProperty,Vre=Object.getOwnPropertyDescriptor,gz=(i,e,t,s)=>{for(var r=s>1?void 0:s?Vre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Hre(e,t,r),r};const Ef=re("debugdroplistener");class Lv extends Me{constructor(){super(...arguments),u(this,"filesBackendUrl"),u(this,"localhost"),u(this,"onDrag",e=>{e.preventDefault()}),u(this,"onDrop",async e=>{if(Ef&&console.log(e),!e.dataTransfer)return;e.preventDefault();const t=e.dataTransfer.items;if(t)for(const s in t){const r=t[s];if(r.kind==="file"){const n=r.getAsFile();if(!n)continue;await this.addFiles(n)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(async n=>{Ef&&console.log("dropped url",n);try{const o=new URL(n);if(!o)return;const a=await fz(o,this.context);a&&this.addObject(e,a)}catch{console.log("dropped string is not a valid URL!",n)}})}})}onEnable(){this.filesBackendUrl=ed.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,Ef&&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(...e){if(Ef&&console.log("Add files",e),!!Array.isArray(e)&&e.length)for(const t of e){if(!t)continue;Ef&&console.log("Register file "+t.name+" to",this.filesBackendUrl,t);const s=await pz(t,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:t})),s&&this.addObject(void 0,s)}}async addObject(e,t){Ef&&console.log("Dropped",t);const s=t.scene;if(e!==void 0){const r=new Go;r.setMask(16777215),r.screenPointFromOffset(e.offsetX,e.offsetY);const n=this.context.physics.raycast(r);if(n&&n.length>0)for(const o of n){s.position.copy(o.point);break}}this.gameObject.add(s),this.dispatchEvent(new CustomEvent("object-added",{detail:t}))}}gz([w()],Lv.prototype,"filesBackendUrl",2),gz([w()],Lv.prototype,"localhost",2);var Wre=Object.defineProperty,qre=Object.getOwnPropertyDescriptor,l_=(i,e,t,s)=>{for(var r=s>1?void 0:s?qre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Wre(e,t,r),r};class td extends Yp{constructor(){super(...arguments),u(this,"parent",null),u(this,"object",null),u(this,"limitCount",10),u(this,"limitInterval",60),u(this,"_currentCount",0),u(this,"_startPosition",null),u(this,"_startQuaternion",null)}awake(){var e,t;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((e=this.object.position)==null?void 0:e.clone())??new S(0,0,0),this._startQuaternion=((t=this.object.quaternion)==null?void 0:t.clone())??new Ue(0,0,0,1)}const s=ee.getComponentInParent(this.gameObject,Cf);s?s.addDragEventListener(lz.SelectStart,(r,n)=>{if(this._currentCount>=this.limitCount){n.attached=null;return}const o=this.handleDuplication(n.selected);o&&(console.assert(o!==n.selected,"Duplicated object is original"),n.attached=o)}):console.warn("Could no find drag controls in parent",this.name),vs.addEventListener(ql.SelectStart,(r,n)=>{if(this._currentCount>=this.limitCount){n.grab=null;return}const o=this.handleDuplication(n.selected);o&&(n.grab=o)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(e){var t;if(this._currentCount>=this.limitCount||!this.object)return null;if(e===this.gameObject||this.handleMultiObject(e)){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 s=new Ta;this.parent||(this.parent=this.gameObject.parent),this.parent&&(s.parent=this.parent.guid??((t=this.parent.userData)==null?void 0:t.guid),s.keepWorldPosition=!0),s.position=this.worldPosition,s.rotation=this.worldQuaternion,s.context=this.context,this._currentCount+=1;const r=ee.instantiateSynced(this.object,s);return console.assert(r!==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),r}return null}handleMultiObject(e){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,e):!1}isInChildren(e,t){if(!e)return!1;if(e===t)return!0;if(e.children){for(let s of e.children)if(this.isInChildren(s,t))return!0}return!1}}l_([w(De)],td.prototype,"parent",2),l_([w(De)],td.prototype,"object",2),l_([w()],td.prototype,"limitCount",2),l_([w()],td.prototype,"limitInterval",2);var Mf=(i=>(i[i.PointerEnter=0]="PointerEnter",i[i.PointerExit=1]="PointerExit",i[i.PointerDown=2]="PointerDown",i[i.PointerUp=3]="PointerUp",i[i.PointerClick=4]="PointerClick",i[i.Drag=5]="Drag",i[i.Drop=6]="Drop",i[i.Scroll=7]="Scroll",i[i.UpdateSelected=8]="UpdateSelected",i[i.Select=9]="Select",i[i.Deselect=10]="Deselect",i[i.Move=11]="Move",i[i.InitializePotentialDrag=12]="InitializePotentialDrag",i[i.BeginDrag=13]="BeginDrag",i[i.EndDrag=14]="EndDrag",i[i.Submit=15]="Submit",i[i.Cancel=16]="Cancel",i))(Mf||{}),Xre=Object.defineProperty,Yre=Object.getOwnPropertyDescriptor,aI=(i,e,t,s)=>{for(var r=s>1?void 0:s?Yre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Xre(e,t,r),r};class lI{constructor(){u(this,"eventID"),u(this,"callback")}}aI([w()],lI.prototype,"eventID",2),aI([w(pn)],lI.prototype,"callback",2);class c_ extends Me{constructor(){super(...arguments),u(this,"triggers")}invoke(e){if(this.triggers)for(const t of this.triggers)t.eventID===e&&t.callback.invoke()}onPointerClick(e){this.invoke(Mf.PointerClick)}onPointerEnter(e){this.invoke(Mf.PointerEnter)}onPointerExit(e){this.invoke(Mf.PointerExit)}onPointerDown(e){this.invoke(Mf.PointerDown)}onPointerUp(e){this.invoke(Mf.PointerUp)}}aI([w(lI)],c_.prototype,"triggers",2);var Jre=Object.defineProperty,Kre=Object.getOwnPropertyDescriptor,cI=(i,e,t,s)=>{for(var r=s>1?void 0:s?Kre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Jre(e,t,r),r};class hI extends Me{constructor(){super(...arguments),u(this,"connectedBody"),u(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(ji)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}cI([w(ji)],hI.prototype,"connectedBody",2);class uI extends hI{createJoint(e,t){var s;(s=this.context.physics.engine)==null||s.addFixedJoint(e,t)}}class Uv extends hI{constructor(){super(...arguments),u(this,"anchor"),u(this,"axis")}createJoint(e,t){var s;this.axis&&this.anchor&&((s=this.context.physics.engine)==null||s.addHingeJoint(e,t,this.anchor,this.axis))}}cI([w(S)],Uv.prototype,"anchor",2),cI([w(S)],Uv.prototype,"axis",2);const Zre={type:"change"};let $re=class extends Cs{constructor(i,e){super(),this.object=i,this.domElement=e,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const t=this,s=1e-6,r=new Ue,n=new S;this.tmpQuaternion=new Ue,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(p){if(!(p.altKey||this.enabled===!1)){switch(p.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(p){if(this.enabled!==!1){switch(p.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(p){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(p.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(p){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const f=this.getContainerDimensions(),m=f.size[0]/2,v=f.size[1]/2;this.moveState.yawLeft=-(p.pageX-f.offset[0]-m)/m,this.moveState.pitchDown=(p.pageY-f.offset[1]-v)/v,this.updateRotationVector()}},this.pointerup=function(p){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(p.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(p){this.enabled!==!1&&p.preventDefault()},this.update=function(p){if(this.enabled===!1)return;const f=p*t.movementSpeed,m=p*t.rollSpeed;t.object.translateX(t.moveVector.x*f),t.object.translateY(t.moveVector.y*f),t.object.translateZ(t.moveVector.z*f),t.tmpQuaternion.set(t.rotationVector.x*m,t.rotationVector.y*m,t.rotationVector.z*m,1).normalize(),t.object.quaternion.multiply(t.tmpQuaternion),(n.distanceToSquared(t.object.position)>s||8*(1-r.dot(t.object.quaternion))>s)&&(t.dispatchEvent(Zre),r.copy(t.object.quaternion),n.copy(t.object.position))},this.updateMovementVector=function(){const p=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=-p+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",l),this.domElement.removeEventListener("pointermove",a),this.domElement.removeEventListener("pointerup",c),window.removeEventListener("keydown",h),window.removeEventListener("keyup",d)};const o=this.contextMenu.bind(this),a=this.pointermove.bind(this),l=this.pointerdown.bind(this),c=this.pointerup.bind(this),h=this.keydown.bind(this),d=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",o),this.domElement.addEventListener("pointerdown",l),this.domElement.addEventListener("pointermove",a),this.domElement.addEventListener("pointerup",c),window.addEventListener("keydown",h),window.addEventListener("keyup",d),this.updateMovementVector(),this.updateRotationVector()}};class dI extends Me{constructor(){super(...arguments),u(this,"_controls",null)}onEnable(){var e;const t=(e=ee.getComponent(this.gameObject,Di))==null?void 0:e.cam;this._controls=new $re(t,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var e;(e=this._controls)==null||e.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var ene=Object.defineProperty,tne=Object.getOwnPropertyDescriptor,pI=(i,e,t,s)=>{for(var r=s>1?void 0:s?tne(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ene(e,t,r),r};class Tf extends Me{constructor(){super(...arguments),u(this,"_fog")}get fog(){return this._fog||(this._fog=new xS(0,0,50)),this._fog}get mode(){return 1}set near(e){this.fog.near=e}get near(){return this.fog.near}set far(e){this.fog.far=e}get far(){return this.fog.far}set color(e){this.fog.color.copy(e)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}pI([w()],Tf.prototype,"near",1),pI([w()],Tf.prototype,"far",1),pI([w(Ae)],Tf.prototype,"color",1);let h_,fI,If,u_;function mI(i,e=1/0,t=null){fI||(fI=new Rn(2,2,1,1)),If||(If=new kt({uniforms:{blitTexture:new Te(i)},vertexShader:`
5022
5022
  varying vec2 vUv;
5023
5023
  void main(){
5024
5024
  vUv = uv;