@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(i);const s=FC;FC&&console.log("ARSupported?",Ag,"VRSupported?",vg),(s||this.createARButton&&this.enableAR&&Ag)&&(e=Pn.createARButton(this),this._arButton=e,i.appendChild(e)),(s||this.createVRButton&&this.enableVR&&vg)&&(t=Pn.createVRButton(this),this._vrButton=t,i.appendChild(t)),setTimeout(()=>{Pn.resetButtonStyles(t),Pn.resetButtonStyles(e)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(e){var i;if(!e)return;const t=this.context.renderer.xr.getSession();if(t){const s=e.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!s)return;this._currentHeadPose=s;const r=s==null?void 0:s.transform;r&&this._transformOrientation.set(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w),Pn._isInXr===!1&&t&&this.onEnterXR(t,e);for(const o of this.controllers)o.onUpdate(t);this._isInAR&&((i=this.webAR)==null||i.onUpdate(t,e))}Pn.events.dispatchEvent({type:"xrUpdate",frame:e,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 e=0;e<2;e++)Ji.Create(this,e,this.gameObject,rp.PhysicalDevice);Pn.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(xt(this.context.mainCamera)),this._originalCameraRotation.copy(On(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 e=$.findObjectOfType(ww,this.context);e?(this.rig=e.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new Io,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(e,t){var o,a;console.log("[XR] session begin",e,t),Pn._isInXr=!0,this.ensureRig();const i=this.context.renderer.xr.getReferenceSpace();if(i&&this.rig){const l=t.getViewerPose(i),c=l==null?void 0:l.transform.orientation;if(c){const h=new Le(c.x,c.y,c.z,c.w),d=new cs().setFromQuaternion(h);this.rig.rotateY(d.y)}}const s=this.context.renderer.xr;if(this.context.mainCamera){const l=s.getCamera();FC&&console.log("WebXRCamera",l);const c=(o=this.context.mainCameraComponent)==null?void 0:o.cullingMask;if(l&&c!==void 0){for(const h of l.cameras)h.layers.mask=c;l.layers.mask=c}else if(l){for(const h of l.cameras)h.layers.enableAll();l.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const r=this._requestedAR?vn.AR:vn.VR;switch(Ro.Global.Set(r),r){case vn.AR:this.context.xrSessionMode=MA.ImmersiveAR,this._isInAR=!0,(a=this.webAR)==null||a.onBegin(e);break;case vn.VR:this.context.xrSessionMode=MA.ImmersiveVR,this._isInVR=!0,this.onEnterVR(e);break}e.addEventListener("end",()=>{console.log("[XR] session end"),Pn._isInXr=!1,this.onExitXR(e)}),this.onEnterXR_HandleMirrorWindow(e),Pn.events.dispatchEvent({type:"xrStarted",session:e})}onExitXR(e){var i,s,r,o;const t=this._isInAR;e&&(this._isInAR?(i=this.webAR)==null||i.onEnd(e):(s=this.context.mainCameraComponent)==null||s.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&&((r=this._originalCameraParent)==null||r.add(this.context.mainCamera),hn(this.context.mainCamera,this._originalCameraPosition),wr(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),t&&((o=this._originalXRRigParent)==null||o.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Ro.Global.Set(vn.Browser|vn.ThirdPerson),Pn.events.dispatchEvent({type:"xrStopped",session:e})}onEnterVR(e){}destroyControllers(){var e;for(let t=this.controllers.length-1;t>=0;t-=1)(e=this.controllers[t])==null||e.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(e){se("mirror")&&setTimeout(()=>{if(!Pn.IsInWebXR)return;const t=new URL(window.location.href);cA(t.searchParams,S_,1),cA(t.searchParams,"isMirror",1);const i=t.toString();this.xrMirrorWindow=window.open(i,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Pn.IsInWebXR&&e.end()})})},1e3)}},u(Tf,"_isInXr",!1),u(Tf,"events",new Un),u(Tf,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),u(Tf,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),Tf);let St=Pn;$p([w()],St.prototype,"enableVR",2);$p([w()],St.prototype,"enableAR",2);$p([w(Kn)],St.prototype,"defaultAvatar",2);$p([w()],St.prototype,"handModelPath",2);$p([w()],St.prototype,"createVRButton",2);$p([w()],St.prototype,"createARButton",2);const Yf=class{constructor(e){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=e}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const e=this.arDomOverlay;return e.getAROverlayContainer?this.arOverlayElement=e.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(e){this.reticleActive=e}async onBegin(e){var o,a,l,c;const t=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const i=(o=navigator.userAgent)!=null&&o.includes("OculusBrowser")?rp.PhysicalDevice:rp.Touch,s=i===rp.Touch?4:2;for(let h=0;h<s;h++)Ji.Create(this.webxr,h,this.webxr.gameObject,i);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=$.findObjectOfType(rl,t)),!this.sessionRoot){const h=this.webxr.gameObject;this.sessionRoot=$.addNewComponent(h,rl),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=t.scene.background,this.previousEnvironment=t.scene.environment,t.scene.background=null,e.requestReferenceSpace("viewer").then(h=>{var d,f;(f=(d=e.requestHitTestSource)==null?void 0:d.call(e,{space:h}))==null||f.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 ye(new av(.07,.09,32).rotateX(-Math.PI/2),new fi),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new ke,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,Yf.tempWebXRObject||(Yf.tempWebXRObject=new ke),this.context.scene.add(Yf.tempWebXRObject),$.addComponent(Yf.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(a=this.sessionRoot)==null||a.onBegin(e)):console.warn("No WebARSessionRoot found in scene");const r=this.context.domElement;(l=r==null?void 0:r.onEnterAR)==null||l.call(r,e,this.arOverlayElement),(c=this.context.mainCameraComponent)==null||c.applyClearFlagsIfIsActiveCamera()}onEnd(e){var s,r;this._previousParent&&($.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const t=this.webxr.context;t.scene.background=this.previousBackground,t.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,e);const i=this.context.domElement;(s=i.onExitAR)==null||s.call(i,e),(r=this.context.mainCameraComponent)==null||r.applyClearFlagsIfIsActiveCamera()}onUpdate(e,t){var s,r;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const o=this.webxr.Rig,a=$ie.clone();(s=this.sessionRoot)==null||s.placeAt(o,a)}return}if(!this.hitTestSource)return;const i=t.getHitTestResults(this.hitTestSource);if(i.length){const o=i[0],a=this.webxr.context.renderer.xr.getReferenceSpace();if(a){const l=o.getPose(a);if(this.sessionRoot){const c=this.sessionRoot.onUpdate(this.webxr.Rig,e,l);this.didPlaceARSessionRoot=c}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&l)){const c=l.transform.matrix;this.reticle.matrix.fromArray(c),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(r=this.sessionRoot)==null||r.onUpdate(this.webxr.Rig,e,null),this.reticle&&(this.reticle.visible=!1)}};let Ku=Yf;u(Ku,"tempWebXRObject");const $ie=new De().identity().makeTranslation(0,0,0);class ic{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 ic(this.input,this.event);return Object.assign(e,this),e}}class em extends we{awake(){qs.createIfNoneExists(this.context)}onEnable(){var e;(e=qs.get(this.context))==null||e.register(this)}onDisable(){var e;(e=qs.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class mc extends em{constructor(){super(...arguments);u(this,"targets",null);u(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(t=null){return this.targets?(t??(t=new va),t.targets=this.targets,t.results=this.raycastHits,this.context.physics.raycast(t)):null}}class hR extends mc{}const yg=se("debugeventsystem");var gM=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(gM||{});const Oa=class extends we{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",[]);Oa.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Oa.systems.length<=0&&Oa.systems.push(...$.findObjectsOfType(Oa,t)));for(const s of Oa.systems)if(s.context===t)return;const i=new ke;$.addNewComponent(i,Oa),t.scene.add(i)}static get systems(){const t=Dt.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i){zl.update(t,i)}static markUIDirty(t){zl.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){Oa.systems.splice(Oa.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!$.findObjectOfType(em,this.context)){const i=$.addNewComponent(this.context.scene,mc);this.raycaster.push(i),tn()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var s,r;const i=(s=this.raycaster)==null?void 0:s.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){const t=new Map;this._selectStartFn??(this._selectStartFn=(s,r)=>{if(!r.grab)return;zl.resetLastSelected();const o=new ic(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=!1,t.set(s,r.grab),r.grab&&!this.handleEvents(r.grab,o)&&(r.grab=null)}),this._selectEndFn??(this._selectEndFn=(s,r)=>{var l;if(!r.grab)return;const o=new ic(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=s.selectionClick,this.handleEvents(r.grab,o);const a=t.get(s);if(t.set(s,null),a)for(let c=0;c<this.raisedPointerDownEvents.length;c++){const h=this.raisedPointerDownEvents[c];this.raisedPointerDownObjects[c]===a&&h&&((l=h.onPointerUp)==null||l.call(h,o),this.raisedPointerDownEvents.splice(c,1),this.raisedPointerDownObjects.splice(c,1),c--)}});const i=new va;this._selectUpdateFn??(this._selectUpdateFn=s=>{i.ray=s.getRay();const r=this.performRaycast(i);if(!r)return;const o=new ic(this.context.input);o.inputSource=s,this.handleIntersections(r,o)}),Ji.addEventListener(Nl.SelectStart,this._selectStartFn),Ji.addEventListener(Nl.SelectEnd,this._selectEndFn),Ji.addEventListener(Nl.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){Ji.removeEventListener(Nl.SelectStart,this._selectStartFn),Ji.removeEventListener(Nl.SelectEnd,this._selectEndFn),Ji.removeEventListener(Nl.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(),St.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const a=this.context.input.getPointerPositionRC(0);if(a&&a.x===0&&a.y===0)return;this._didMove=!0}let t=0;for(const a of this.context.input.foreachPointerId()){const l=this.context.input.getPointerDown(a),c=this.context.input.getPointerUp(a);if(l||c){t=a;break}}const i=this.context.input.getPointerEvent(t),s=new ic(this.context.input,i);s.inputSource=this.context.input,s.pointerId=t,s.isClicked=this.context.input.getPointerClicked(t),s.isDown=this.context.input.getPointerDown(t),s.isUp=this.context.input.getPointerUp(t),s.isPressed=this.context.input.getPointerPressed(t),yg&&s.isClicked&&console.log("CLICK",t);const r=this.performRaycast(null);if(!r)return;this.lastPointerEvent=s;const o={sender:this,args:s,hasActiveUI:this.currentActiveMeshUIComponents.length>0};yg&&s.isClicked&&yn("EventSystem: "+s.pointerId+" - "+this.context.time.frame+" - Up:"+s.isUp+", Down:"+s.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(r,s),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const i of this.raisedPointerDownEvents)i.onPointerUp&&i.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const i of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(i)<0){this._tempComponentsArray.length=0;const s=$.getComponentsInParent(i,we,this._tempComponentsArray);this.lastPointerEvent.object=i;for(let r=0;r<s.length;r++){const o=s[r];if(!o.gameObject||o.destroyed)continue;const a=o;a.onPointerExit&&a.onPointerExit(this.lastPointerEvent)}}const t=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=t}performRaycast(t){if(!this.raycaster)return null;this._sortedHits.length=0;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;const s=i.performRaycast(t);s&&s.length>0&&this._sortedHits.push(...s)}return this._sortedHits.sort((i,s)=>i.distance-s.distance),this._sortedHits}handleIntersections(t,i){if(!t||t.length<=0)return!1;t=this.sortCandidates(t);for(const s of t){const{object:r}=s;if(this.handleEvents(r,i))return!0}return!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const s=t[i],r=s.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(s);continue}this._sortingBuffer.push(s)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEvents(t,i){if(!this.testIsVisible(t))return i.isClicked&&yg&&console.log("not allowed",t),!1;const s=t;i.object=t,this.lastPointerEvent=i;const r=t.parent;let o=!1;const a=i.isClicked??!1;let l=null;if(r&&r.isUI){const c=(i.isPressed||i.isClicked)??!1;if(r[Ga]){const h=r[Ga].gameObject;if(h){if(!Tp.isInteractable(h,this.out))return!1;l=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,c),t=h,o=!0}}if(!o&&this.handleMeshUiObjectWithoutShadowDom(r,c))return!0}if(a&&yg&&console.log(this.context.time.frame,t),this.objectsHoveredThisFrame.push(t),l===null||l.interactable){const c=this.objectsHoveredLastFrame.indexOf(t)>=0;this.handleEventsArray.length=0;const h=$.getComponentsInParent(t,we,this.handleEventsArray);for(let d=0;d<h.length;d++){if(i.used)return!0;if(h[d].destroyed)continue;const f=h[d];if(f.interactable!==!1){if(f.onPointerEnter&&(c||f.onPointerEnter(i)),f.onPointerMove&&f.onPointerMove(i),i.isDown&&f.onPointerDown&&!this.raisedPointerDownEvents.includes(f)&&(f.onPointerDown(i),this.raisedPointerDownEvents.push(f),this.raisedPointerDownObjects.push(s)),i.isUp&&f.onPointerUp){const p=this.raisedPointerDownEvents.indexOf(f);p!==-1&&this.raisedPointerDownEvents.splice(p,1),f.onPointerUp(i)}i.isClicked&&f.onPointerClick&&f.onPointerClick(i)}}}return!0}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const s=zl.updateState(t,i);return s&&this.currentActiveMeshUIComponents.push(s),s!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&zl.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];zl.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?$.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let qs=Oa;u(qs,"_eventSystemMap",new Map),u(qs,"didSearchEventSystem",!1);class zl{static markDirty(){this.needsUpdate=!0}static update(e,t){const i=t.time.frameCount;for(const s of this.lastUpdateFrame)if(s.context===t){if(i===s.frame)return;s.frame=i;let r=this.needsUpdate||i<1;s.nextUpdate===t.time.frameCount&&(r=!0),r&&(yg&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:i,nextUpdate:i}],e.update()}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}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(zl,"lastSelected",null),u(zl,"lastUpdateFrame",[]),u(zl,"needsUpdate",!1);const Db=Symbol("cameraController");function ene(n){return n[Db]}function rk(n,e,t){t?n[Db]=e:n[Db]===e&&(n[Db]=null)}var tne=Object.defineProperty,ine=Object.getOwnPropertyDescriptor,nne=(n,e,t,i)=>{for(var s=i>1?void 0:i?ine(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&tne(e,t,s),s};const g0=se("freecam"),UC=se("debugcamerafit"),sne={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let NC;class xc extends we{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(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}awake(){this._lookTargetPosition=new M,this._startedListeningToKeyEvents=!1}start(){if(this._controls){const t=$.getComponent(this.gameObject,Ni);if(t&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const s=xt(t.cam).length(),r=new M(0,0,-s).applyMatrix4(t.cam.matrixWorld);this.setTarget(r,!0)}}this.startCoroutine(this.startRaycastDelayed()),this._eventSystem=qs.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(gM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(gM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=$.getComponent(this.gameObject,Ni);this._camera=t;const i=t==null?void 0:t.cam;if(i&&rk(i,this,!0),!this._controls){console.assert(i!=null,"Missing camera",this),i&&(this._cameraObject=i);const s=this.targetElement??this.context.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new nZ(i,s),i==null||i.quaternion.copy(r),NC===void 0&&(NC={...this._controls.keys})}this._controls&&(g0&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Dh()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?g0||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):g0||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=$.getComponent(this.gameObject,Th)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&rk(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,!this.setFromTargetPosition()){const t=new va;t.screenPoint=new K(0,0),t.lineThreshold=.1;const i=this.context.physics.raycast(t);i.length>0&&this.setTarget(i[0].point,!0)}}onBeforeRender(){var i,s,r;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 t=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(t||(t=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),t?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const o=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const a=(i=this._cameraObject)==null?void 0:i.position;nU(a,this._cameraTargetPosition,o)}else(s=this._cameraObject)==null||s.position.lerp(this._cameraTargetPosition,o);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,o),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!g0&&((r=this.lookAtConstraint)!=null&&r.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?NC:sne,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(t,i=!1){var s;t?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=t.clone(),i&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(t=0,i=1){var r;if(!this._controls)return!1;const s=(r=this.lookAtConstraint)==null?void 0:r.sources;if(s&&s.length>0){const o=s[t];if(o)return o.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,i),!0}return!1}setTarget(t=null,i=!1){this._controls&&(t!==null&&this._lookTargetPosition.copy(t),i?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(t,i){this._controls&&this._controls.target.lerp(t,i)}distanceToTarget(t){return this._controls?this._controls.target.distanceTo(t):-1}setTargetFromRaycast(){var i,s;if(!this.controls)return;const t=this.context.physics.raycast();for(const r of t)if(r.distance>0&&$.isActiveInHierarchy(r.object)){if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const o=xt(this.context.mainCamera);this._cameraTargetPosition=o.clone().sub(this.controls.target).add(this._lookTargetPosition),(s=(i=this._cameraObject)==null?void 0:i.parent)==null||s.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(t,i=1.1){const s=this._cameraObject,r=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0||!s||!r)return;const o=new M,a=new M,l=new Dn;l.makeEmpty();for(const v of t)v instanceof C1||v instanceof HT||l.expandByObject(v,!0);if(s.updateMatrixWorld(),s.updateProjectionMatrix(),l.getCenter(a),l.applyMatrix4(s.matrixWorldInverse),l.getSize(o),l.setFromCenterAndSize(a,o),o.length()<=1e-10){UC&&console.warn("Camera fit size is zero",l,[...t]);return}const c=s.fov,h=2*Math.atan(Math.tan(c*Math.PI/360/2)*s.aspect)/Math.PI*360,d=o.y/(2*Math.atan(Math.PI*c/360)),f=o.x/(2*Math.atan(Math.PI*h/360)),p=i*Math.max(d,f)+o.z/2;UC&&console.log("Fit camera to objects",d,f,"distance",p);const m=xt(s),A=r.target.clone().sub(m).normalize().multiplyScalar(p);if(r.maxDistance=p*10,r.minDistance=p*.01,r.target.copy(a),s.near=p/100,s.far=p*100,s.updateMatrixWorld(),s.updateProjectionMatrix(),hn(s,r.target.clone().sub(A)),UC){const v=new C1(l);this.context.scene.add(v),aU(v,Dx(s)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",g=>{g.code==="KeyF"&&this.fitCamera(t)}))}r.update()}}nne([w(_v)],xc.prototype,"lookAtConstraint",2);var rne=Object.defineProperty,one=Object.getOwnPropertyDescriptor,Go=(n,e,t,i)=>{for(var s=i>1?void 0:i?one(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rne(e,t,s),s},zG=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(zG||{});const bg=se("debugcam"),ok=se("debugscreenpointtoray");var tb;const _g=(tb=class extends we{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(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&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(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&t&&(this._cam.near=e,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&t&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){let s=this.cam;const r=_g._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),ok&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const o=_g._direction.set(r.x,r.y,r.z),a=xt(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new ol(a.clone(),o.clone())}awake(){ok&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const s=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);tc.DrawRay(s.origin,s.direction,r,10)})}onEnable(){bg&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),lne(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 e=this.context.renderer;e&&this._targetTexture.render(this.context.scene,this._cam,e)}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof Xt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof Xt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new Xt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new cd(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){bg&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,bg&&yn("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(_g.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 e=this._backgroundColor.alpha;_g.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new ane(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,l;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;const i=t.environmentBlendMode;bg&&yn("Environment blend mode: "+i+" on "+navigator.userAgent);const s=i==="additive"||i==="alpha-blend";if(e.xrSessionMode===MA.ImmersiveAR&&i==="opaque"){if((o=navigator.userAgent)!=null&&o.includes("OculusBrowser"))return!0;if((a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((l=navigator.userAgent)!=null&&l.includes("Mobile WebXRViewer/v2")))return!0}return s}},u(tb,"_origin",new M),u(tb,"_direction",new M),tb);let Ni=_g;Go([w()],Ni.prototype,"fieldOfView",1);Go([w()],Ni.prototype,"nearClipPlane",1);Go([w()],Ni.prototype,"farClipPlane",1);Go([w()],Ni.prototype,"clearFlags",1);Go([w()],Ni.prototype,"orthographic",2);Go([w()],Ni.prototype,"orthographicSize",2);Go([w()],Ni.prototype,"ARBackgroundAlpha",2);Go([w()],Ni.prototype,"cullingMask",1);Go([w()],Ni.prototype,"backgroundBlurriness",1);Go([w()],Ni.prototype,"backgroundIntensity",1);Go([w(_i)],Ni.prototype,"backgroundColor",1);Go([w(yh)],Ni.prototype,"targetTexture",1);class ane{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&&(bg&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=nt,this._skybox.mapping=Bo,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function lne(n){se("freecam")&&n.context.mainCameraComponent===n&&$.getOrAddComponent(n.gameObject,xc)}class Ip extends we{constructor(){super(...arguments);u(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new NT),this._listener}awake(){wn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=$.getComponentInParent(this.gameObject,Ni);i?i.cam.add(t):this.gameObject.add(t)})}}var cne=Object.defineProperty,hne=Object.getOwnPropertyDescriptor,Sw=(n,e,t,i)=>{for(var s=i>1?void 0:i?hne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&cne(e,t,s),s};const une=se("debugsignals");class Tv{constructor(){u(this,"guid")}}Sw([w()],Tv.prototype,"guid",2);class tm{constructor(){u(this,"signal");u(this,"reaction")}}Sw([w(Tv)],tm.prototype,"signal",2);Sw([w(yr)],tm.prototype,"reaction",2);var DE;const kl=(DE=class extends we{constructor(){super(...arguments);u(this,"events")}static invoke(e){if(kl.receivers[e]){const t=kl.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){une&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)kl.receivers[e.signal.guid]||(kl.receivers[e.signal.guid]=[]),kl.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(kl.receivers[e.signal.guid]){const t=kl.receivers[e.signal.guid].indexOf(this);t>=0&&kl.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;let t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(s){console.error(s)}}},u(DE,"receivers",{}),DE);let im=kl;Sw([w(tm)],im.prototype,"events",2);var kr=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(kr||{}),Ba=(n=>(n[n.None=0]="None",n[n.Hold=1]="Hold",n[n.Loop=2]="Loop",n[n.PingPong=3]="PingPong",n[n.Continue=4]="Continue",n))(Ba||{}),uR=(n=>(n.Signal="SignalEmitter",n))(uR||{});const Xm=se("debugtimeline"),Q_=class extends we{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(t,i){this.createTrackFunctions[t]=i}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(Xm||$s())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,i,s;Xm&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(i=this.playableAsset)==null?void 0:i.tracks,Array.isArray((s=this.playableAsset)==null?void 0:s.tracks),this)}onEnable(){var t,i;for(const s of this._audioTracks)(t=s.onEnable)==null||t.call(s);for(const s of this._customTracks)(i=s.onEnable)==null||i.call(s);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,i;this.stop();for(const s of this._audioTracks)(t=s.onDisable)==null||t.call(s);for(const s of this._customTracks)(i=s.onDisable)==null||i.call(s);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const i of this._allTracks)for(const s of i)(t=s.onDestroy)==null||t.call(s)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const i=[];for(const s of this._audioTracks){const r=s.loadAudio(this._time,1,0);r&&i.push(r)}if(i.length>0&&(await Promise.all(i),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!wn.userInteractionRegistered&&this.waitForAudio;)await ZA(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 s of this._audioTracks)s.stop();const t=this._isPaused==!0,i=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null}evaluate(){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}this.internalEvaluate(t)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const i of t)yield i}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onPauseChanged)==null||t.call(i)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(t){for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case kr.Activation:for(let s=0;s<i.outputs.length;s++){const r=i.outputs[s];if(typeof r=="object"){let o=!1;for(const l of i.clips)l.start<=t&&t<=l.end&&(o=!0);const a=r;a.visible!==void 0&&(a.visible=o)}}break}for(const i of this._animationTracks)i.evaluate(t);for(const i of this._audioTracks)i.evaluate(t);for(const i of this._signalTracks)i.evaluate(t);for(const i of this._controlTracks)i.evaluate(t);for(const i of this._customTracks)i.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=W_(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const i of this.playableAsset.tracks){for(let s=i.outputs.length-1;s>=0;s--){let r=i.outputs[s];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=$.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(s,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Xm&&console.log("Resolved binding",r,"to",o),i.outputs[s]=o)}else if(r===null){if(i.outputs.splice(s,1),Q_.createTrackFunctions[i.type])continue;i.type!==kr.Audio&&i.type!==kr.Control&&i.type!==kr.Marker&&i.type!==kr.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===kr.Control)for(let s=0;s<i.clips.length;s++){const r=i.clips[s];let o=r.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const a=$.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Xm&&console.log("Resolved binding",o,"to",a),r.asset.sourceObject=a)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,s;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=$.findObjectOfType(Ip,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=Q_.createTrackFunctions[o];if(a!=null){const l=a(this,r);if(typeof l.evaluate=="function"){l.director=this,l.track=r,this._customTracks.push(l);continue}}if(r.type===kr.Animation){if(r.clips.length<=0){Xm&&console.warn("Animation track has no clips",r);continue}for(let l=r.outputs.length-1;l>=0;l--){let c=r.outputs[l];if(c instanceof ke){const d=$.getOrAddComponent(c,ir);d&&(c=d)}const h=(i=c==null?void 0:c.gameObject)==null?void 0:i.animations;if(h){const d=new Cw;d.trackOffset=r.trackOffset,d.director=this,d.track=r;for(let f=0;f<r.clips.length;f++){const p=r.clips[f],m=p.asset;if(!m){console.error("MISSING anim model?","clip#"+f,p,r,this.playableAsset,this.name);continue}const A=m.clip;let v=A;if((typeof v=="string"||typeof v=="number")&&(v=h.find(b=>b.name===A)),!v){console.warn("Could not find animationClip for model",p,r.name,this.name,(s=this.playableAsset)==null?void 0:s.name);continue}d.mixer||(d.mixer=new Px(c.gameObject)),d.clips.push(v),d.mixer.uncacheAction(v),d.createHooks(p.asset,v);const g=d.mixer.clipAction(v);d.actions.push(g),d.models.push(p)}this._animationTracks.push(d)}}}else if(r.type===kr.Audio){if(r.clips.length<=0)continue;const l=new Zu;if(l.director=this,l.track=r,this._audioTracks.push(l),!t)continue;l.listener=t.listener;for(let c=0;c<r.clips.length;c++){const h=r.clips[c];l.addModel(h)}}else if(r.type===kr.Marker){const l=new GA;l.director=this,l.track=r;for(const c of r.markers)switch(c.type){case uR.Signal:l.models.push(c),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const c=$.getComponent(this.gameObject,im);c&&(l.receivers.push(c),this._signalTracks.push(l))}}else if(r.type===kr.Signal){const l=new GA;l.director=this,l.track=r;for(const c of r.markers)l.models.push(c),l.didTrigger.push(!1);for(const c of r.outputs)l.receivers.push(c);this._signalTracks.push(l)}else if(r.type===kr.Control){const l=new Ew;l.director=this,l.track=r;for(const c of r.clips)l.models.push(c);l.resolveSourceObjects(this.context),this._controlTracks.push(l)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}};let lc=Q_;u(lc,"createTrackFunctions",{});const Ju=se("debugtimeline");class Iv{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 i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,s=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(s||e>=r.start&&e<=r.end){let o=1,a=!1;if(r.easeInDuration>0){const l=Math.min((e-r.start)/r.easeInDuration,1);o*=l}if(r.easeOutDuration>0&&!a){const l=Math.min((r.end-e)/r.easeOutDuration,1);o*=l}return o}return 0}}class dne{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 i=e.getRoot(),s=i.name+".position",r=i.name+".quaternion";Ju&&console.log(t.name,t.tracks,s);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(s))this.rootStartPosition=new M().fromArray(o.values,0),this.rootEndPosition=new M().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(r)&&(this.rootStartQuaternion=new Le().fromArray(o.values,0),this.rootEndQuaternion=new Le().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Ju)){const a=new cs().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Cw extends Iv{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 M);u(this,"_totalOffsetRotation",new Le);u(this,"_totalOffsetPosition2",new M);u(this,"_totalOffsetRotation2",new Le);u(this,"_summedPos",new M);u(this,"_tempPos",new M);u(this,"_summedRot",new Le);u(this,"_tempRot",new Le);u(this,"_clipRotQuat",new Le)}onPauseChanged(){this._animator&&this._animatorWasEnabled!==void 0&&(this._animator.enabled=this.director.isPlaying===!1?this._animatorWasEnabled:!1)}createHooks(t,i){var h,d;if(((h=i.tracks)==null?void 0:h.length)<=0){console.warn("No tracks in AnimationClip",i);return}const s=i.tracks[0].name.split("."),r=s[s.length-2],o=r+".position",a=r+".quaternion";let l=!1,c=!1;for(const f of i.tracks)f.name.endsWith(o)?(l=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(c=!0,this.createRotationInterpolant(i,t,f));if(!l||!c){const f=(d=this.mixer)==null?void 0:d.getRoot(),p=i.tracks[0],m=p.name.lastIndexOf("."),A=p.name.substring(0,m),v=A.substring(A.lastIndexOf(".")+1),g=f.getObjectByName(v);if(g)if(l){if(!c){const b=i.tracks[0].name.substring(0,m)+".quaternion";Ju&&console.warn("Create quaternion track",v,g);const y=g.quaternion,_=new nl(b,[0,i.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);i.tracks.push(_),this.createRotationInterpolant(i,t,_)}}else{const b=A+".position";Ju&&console.warn("Create position track",v,g);const y=g.position,_=new Eh(b,[0,i.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);i.tracks.push(_),this.createPositionInterpolant(i,t,_)}}}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 t of this.actions){const i=new dne(t);this._actionOffsets.push(i)}this.target&&(this._animator=$.getComponent(this.target,ir)??null,this._animator?(this._animatorWasEnabled=this._animator.enabled,this._animator.enabled=!1):this._animatorWasEnabled=!1);for(const t of this.models){const i=t.asset,s=i.position,r=i.rotation;s&&s.x!==void 0&&(s.isVector3||(i.position=new M(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new Le(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new M(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Le(i.x,i.y,i.z,i.w)))}}evaluate(t){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 i=0,s=0,r=!1,o=!1;for(let a=0;a<this.clips.length;a++){const l=this.models[a],c=this.actions[a],h=l.asset;c.weight=0;const d=t>=l.start&&t<=l.end,f=l.preExtrapolationMode,p=l.postExtrapolationMode,m=a<this.clips.length-1?this.models[a+1]:null;let A=d,v=!1;if(!A&&!r&&l.end<t&&p!==Ba.None?(!m||m.start>t)&&(A=!0,r=!0):a==0&&!A&&!o&&l.start>t&&f!==Ba.None&&(!m||m.start<t)&&(A=!0,v=!0,o=!0),A){let g=1;g*=this.evaluateWeight(t,a,this.models,A),g*=this.director.weight;let b=d;if(v)switch(f){case Ba.Hold:break;case Ba.Loop:t+=l.start,b=!0;break;default:t+=l.start,b=!0;break}let y=this.getClipTime(t,l),_=0;const x=h.duration;if(v&&f===Ba.Hold&&(y=0),b){if(h.loop)for(_+=Math.floor(y/(x+1e-6));y>x;)y-=x}else if(!d&&r)switch(p){case Ba.Hold:y=this.getClipTime(l.end,l);break;case Ba.Loop:y%=x;break;case Ba.PingPong:const R=Math.floor(y/x)%2!==0;y%=x,R&&(y=x-y);break}l.reversed===!0?c.time=c.getClip().duration-y:c.time=y,c.timeScale=0;const S=g;if(c.weight=S,c.clampWhenFinished=!0,c.isRunning()||c.play(),this._useclipOffsets){const I=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,R=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(s=1-g),i+=1;const E=this._summedPos.set(0,0,0),T=this._tempPos.set(0,0,0),k=this._summedRot.identity(),W=this._tempRot.identity(),U=h.rotation;U&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(U,g));const z=this._actionOffsets[a];if(z.hasOffsets)for(let Q=0;Q<_;Q++)z.rootPositionOffset?T.copy(z.rootPositionOffset):T.set(0,0,0),T.applyQuaternion(k),this._clipRotQuat&&T.applyQuaternion(this._clipRotQuat),z.rootQuaternionOffset&&(W.copy(z.rootQuaternionOffset),k.multiply(W)),E.add(T);this._clipRotQuat&&R.multiply(this._clipRotQuat),R.multiply(k),h.position&&E.add(h.position),I.add(E)}}}this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.mixer.update(t)}createRotationInterpolant(t,i,s){var l;const r=s.createInterpolant.bind(s),o=new Le;this.ensureTrackOffsets();const a=(l=this.trackOffset)==null?void 0:l.rotation;s.createInterpolant=()=>{const c=r(),h=c.evaluate.bind(c);return c.evaluate=d=>{const f=h(d);return o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},c}}createPositionInterpolant(t,i,s){var h,d;const r=s.createInterpolant.bind(s),o=new M;this.ensureTrackOffsets();const a=(h=this.trackOffset)==null?void 0:h.rotation,l=(d=this.trackOffset)==null?void 0:d.position;let c;s.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=m=>{var v,g;const A=p(m);return o.set(A[0],A[1],A[2]),i.removeStartOffset&&(c===void 0?(c=null,c=(g=(v=this._actionOffsets.find(b=>b.clip===t))==null?void 0:v.rootStartPosition)==null?void 0:g.clone()):c!=null&&c.isVector3&&o.sub(c)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),l&&(o.x-=l.x,o.y+=l.y,o.z+=l.z),A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const fne=se("mutetimeline"),Kf=class extends Iv{constructor(){super(...arguments);u(this,"models",[]);u(this,"listener");u(this,"audio",[]);u(this,"audioContextTimeOffset",[]);u(this,"lastTime",0);u(this,"_audioLoader",null)}getAudioFilePath(t){const i=this.director.sourceId;return Bh(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const s=this.models[i];this.audio[i].setVolume(t?s.asset.volume:0)}}addModel(t){const i=new Rx(this.listener);this.audio.push(i),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}evaluate(t){if(fne||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,s=i?.1:0;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.audio[r];if((!a||!a.buffer)&&this.isInTimeRange(o,t-1,t+1)&&this.handleAudioLoading(o,a),wn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale,a.loop=o.asset.loop,t>=o.start&&t<=o.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(a.isPlaying&&a.stop(),this.lastTime===t)continue}else if(!a.isPlaying)a.offset=o.clipIn+(t-o.start)*o.timeScale,a.play(s);else{const c=o.clipIn+(t-o.start)*o.timeScale,h=a.context.currentTime-a._startedAt+a.offset;Math.abs(c-h)>.3&&(a.offset=c,a.stop(),a.play(s))}let l=o.asset.volume;if(i&&(l=0),o.easeInDuration>0){const c=Math.min((t-o.start)/o.easeInDuration,1);l*=c}if(o.easeOutDuration>0){const c=Math.min((o.end-t)/o.easeOutDuration,1);l*=c}a.setVolume(l*this.director.weight)}else a.isPlaying&&a.stop()}this.lastTime=t}loadAudio(t,i=0,s=0){let r=null;const o=t-s,a=t+i;for(const l of this.models)if(this.isInTimeRange(l,o,a)){const c=this.audio[this.models.indexOf(l)],h=this.handleAudioLoading(l,c);h!==null&&(r===null&&(r=[]),r.push(h))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,s){return i<=t.start&&s>=t.end||i>=t.start&&i<=t.end||s>=t.start&&s<=t.end}static dispose(){Kf._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new a_);const s=this.getAudioFilePath(t.asset.clip);if(Kf._audioBuffers.get(s)){const o=Kf._audioBuffers.get(s);return o.then(a=>{a&&i.setBuffer(a)}),o}Ju&&console.warn("LOAD audio track",s,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(s,l=>{i.setBuffer(l),o(l)},void 0,l=>{console.error("Error loading audio",l),o(null)})});return Kf._audioBuffers.set(s,r),r}};let Zu=Kf;u(Zu,"_audioBuffers",new Map);class GA extends Iv{constructor(){super(...arguments);u(this,"models",[]);u(this,"didTrigger",[]);u(this,"receivers",[])}evaluate(t){var s;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],l=o.time-t;let c=!1;if(o.retroActive)c=l<=1e-6;else{const h=Math.abs(l);h>=1e-5&&h<i&&(c=!0)}if(c){if(!a)if(this.didTrigger[r]=!0,((s=this.receivers)==null?void 0:s.length)<=0)im.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class Ew extends Iv{constructor(){super(...arguments);u(this,"models",[]);u(this,"timelines",[]);u(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=$.getComponent(r.sourceObject,lc);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[s];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const l=o.sourceObject;(a==null?void 0:a.sourceObject)!==l&&(l.visible=!1)}}}}}var pne=Object.defineProperty,mne=Object.getOwnPropertyDescriptor,GG=(n,e,t,i)=>{for(var s=i>1?void 0:i?mne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&pne(e,t,s),s};class Tt{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 i=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,i,this)}testIfValueChanged(e){return this._valueRaw!==e}}GG([w()],Tt.prototype,"overrideState",1);GG([w()],Tt.prototype,"value",1);var gne=Object.defineProperty,Ane=Object.getOwnPropertyDescriptor,vne=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ane(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&gne(e,t,s),s};const yne=se("debugpost");class Ds extends Nh{constructor(t=void 0){super();u(this,"active",!0);u(this,"_result");u(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const s=t[i],r=this[i];r instanceof Tt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){yne&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const s=this[i];s instanceof Tt&&s.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Tt){const a=t[r];if(a!==void 0){const l=this[r];l.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof Tt){const s=t.value;return this[i].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===Tt&&(this[i]||(this[i]=new Tt))}}vne([w()],Ds.prototype,"active",2);var bne=Object.defineProperty,_ne=Object.getOwnPropertyDescriptor,xne=(n,e,t,i)=>{for(var s=i>1?void 0:i?_ne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&bne(e,t,s),s};const wne=se("debugpost"),AM={};function Ho(n,e){AM[n]=e}function Sne(n){return n.__type in AM?AM[n.__type]:(wne&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Ds)}class Rv{constructor(){u(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}xne([jp([n=>Sne(n),Ds])],Rv.prototype,"components",2);var Cne=Object.defineProperty,Ene=Object.getOwnPropertyDescriptor,Mne=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ene(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Cne(e,t,s),s};class Pv extends Ds{constructor(){super(...arguments);u(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new U7({preset:If.HIGH,edgeDetectionMode:aI.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}Mne([w(Tt)],Pv.prototype,"preset",2);Ho("Antialiasing",Pv);class Mw{constructor(){u(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,i){const s=$.getComponents(e,wn);if(s.length)for(const r of s){if(!r.clip||!r.playOnAwake)continue;const o=r.clip.split("/").pop();this.files.includes(r.clip)||this.files.push(r.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 = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${r.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i=t.split("/").pop(),o=await(await(await fetch(t)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files["audio/"+i]=a}}}var Tne=Object.defineProperty,Ine=Object.getOwnPropertyDescriptor,HG=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ine(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Tne(e,t,s),s};const Rne=se("debugmouth");class Bv extends we{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=$.findObjectOfType(yc,this.context),this.marker||(this.marker=$.getComponentInParent(this.gameObject,Yn))},3e3)}update(){var s;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((s=this.marker)==null?void 0:s.connectionId)??null;if(!t){Rne&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<t.length;s++){const r=t[s];r&&(r.visible=s===i)}}}}HG([w(ke)],Bv.prototype,"idle",2);HG([w(ke)],Bv.prototype,"talking",2);class dR extends we{constructor(){super(...arguments);u(this,"voip",null);u(this,"marker",null);u(this,"_startPosition",null)}awake(){this.voip=$.findObjectOfType(yc,this.context),this.marker=$.getComponentInParent(this.gameObject,Yn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());let s=i/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var Pne=Object.defineProperty,Bne=Object.getOwnPropertyDescriptor,Tw=(n,e,t,i)=>{for(var s=i>1?void 0:i?Bne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Pne(e,t,s),s};class gd extends we{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=$.getComponentInParent(this.gameObject,ls)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(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 i of this.eyes)i&&(i.visible=this.eyesOpen)}}}Tw([w(ke)],gd.prototype,"eyes",2);Tw([w()],gd.prototype,"lastBlinkTime",2);Tw([w()],gd.prototype,"blinkLength",2);Tw([w()],gd.prototype,"eyesOpen",2);var Dne=Object.defineProperty,kne=Object.getOwnPropertyDescriptor,fR=(n,e,t,i)=>{for(var s=i>1?void 0:i?kne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Dne(e,t,s),s},kE;const QG=(kE=class extends we{constructor(){super(...arguments);u(this,"head",null);u(this,"eyes",null);u(this,"target",null);u(this,"brain",null);u(this,"vec",new M);u(this,"currentTargetPoint",new M)}awake(){this.brain||(this.brain=$.getComponentInParent(this.gameObject,PA)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=$.addNewComponent(this.gameObject,PA)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=xt(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const s=xt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const o=QG.forward;if(o.set(0,0,1),o.applyQuaternion(On(this.head)),o.dot(r)>.45)for(let l=0;l<t.length;l++)t[l].lookAt(this.currentTargetPoint)}}}},u(kE,"forward",new M(0,0,1)),kE);let nm=QG;fR([w(ke)],nm.prototype,"head",2);fR([w(ke)],nm.prototype,"eyes",2);fR([w(ke)],nm.prototype,"target",2);var One=Object.defineProperty,Lne=Object.getOwnPropertyDescriptor,pR=(n,e,t,i)=>{for(var s=i>1?void 0:i?Lne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&One(e,t,s),s};class sm extends we{constructor(){super(...arguments);u(this,"length",1);u(this,"depthTest",!0);u(this,"isGizmo",!0);u(this,"_axes",null)}onEnable(){if(this.isGizmo&&!lv)return;this._axes||(this._axes=new Up(this.length)),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}pR([w()],sm.prototype,"length",2);pR([w()],sm.prototype,"depthTest",2);pR([w()],sm.prototype,"isGizmo",2);class mR extends we{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 t=xt(this.to).clone(),i=xt(this.from).clone(),s=t.distanceTo(i),r=t.clone();r.sub(i);let o=i.clone();o.add(t),o.multiplyScalar(.5);let a=xt(this.hint).clone();a.sub(o);let l=new M;l.crossVectors(a,r),l.crossVectors(r,l),l.normalize();let c=s*.5,h=Math.max(this.desiredDistance,c),d=Math.sqrt(h*h-c*c),f=l.clone();f.multiplyScalar(d),f.add(o),hn(this.gameObject,f);let p=o.clone();p.sub(l),this.gameObject.lookAt(p)}}class Iw{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(i=>{$.foreachComponent(i,s=>{var o;const r=s;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,i){var s;for(const r of this.behaviourComponents)(s=r.createBehaviours)==null||s.call(r,this,t,i)}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 i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const s of this.behaviours)s.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 Fne=Object.defineProperty,Une=Object.getOwnPropertyDescriptor,gR=(n,e,t,i)=>{for(var s=i>1?void 0:i?Une(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Fne(e,t,s),s};class Ad extends Ds{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=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom){const i=t=new n3(this.context.scene,this.context.mainCamera,{blendFunction:kt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});i.inverted=!0}else t=new uI;return this.intensity.onValueChanged=i=>{t.intensity=i},this.threshold.onValueChanged=i=>{t.luminanceMaterial.threshold=i},this.scatter.onValueChanged=i=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=i},t}}gR([w(Tt)],Ad.prototype,"threshold",2);gR([w(Tt)],Ad.prototype,"intensity",2);gR([w(Tt)],Ad.prototype,"scatter",2);Ho("Bloom",Ad);var Nne=Object.defineProperty,zne=Object.getOwnPropertyDescriptor,_a=(n,e,t,i)=>{for(var s=i>1?void 0:i?zne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Nne(e,t,s),s};class cl extends we{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 t;(t=this.context.physics.engine)==null||t.removeBody(this)}}_a([w(ji)],cl.prototype,"attachedRigidbody",2);_a([w()],cl.prototype,"isTrigger",2);_a([w()],cl.prototype,"sharedMaterial",2);class Dv extends cl{constructor(){super(...arguments);u(this,"radius",.5);u(this,"center",new M(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this,this.center,this.radius)}}_a([w()],Dv.prototype,"radius",2);_a([w(M)],Dv.prototype,"center",2);class kv extends cl{constructor(){super(...arguments);u(this,"size",new M(1,1,1));u(this,"center",new M(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.center,this.size)}}_a([w(M)],kv.prototype,"size",2);_a([w(M)],kv.prototype,"center",2);class Ov extends cl{constructor(){super(...arguments);u(this,"sharedMesh");u(this,"convex",!1)}onEnable(){var t,i,s,r,o;if(super.onEnable(),(t=this.sharedMesh)!=null&&t.isMesh||this.gameObject instanceof ye&&(this.sharedMesh=this.gameObject),(i=this.sharedMesh)!=null&&i.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,as(this.gameObject));else{const a=this.sharedMesh;if(a!=null&&a.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 l in a.children){const c=a.children[l];c.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,c,this.convex,as(this.gameObject)))}}}}}_a([w()],Ov.prototype,"convex",2);class Rh extends cl{constructor(){super(...arguments);u(this,"center",new M(0,0,0));u(this,"radius",.5);u(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.center,this.height,this.radius)}}_a([w(M)],Rh.prototype,"center",2);_a([w()],Rh.prototype,"radius",2);_a([w()],Rh.prototype,"height",2);function AR(n){const e=n[Ga];return e||(n.parent?AR(n.parent):null)}function D_(n,e){if(!n)return;const t=n.material;if((t==null?void 0:t.isMaterial)===!0){const i=n.parent;i&&i.isText,t.side=e.doubleSided??!0?Mi:Rs,t.shadowSide=e.doubleSided?Mi:Rs,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of n.children)D_(i,e)}function Bf(n,e,t){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const i=Proxy.revocable(n[e],{set(o,a,l,c){const h=o[a],d=Reflect.set(o,a,l,c);return t(l,h),d}}),s=i.revoke,r=n[e];return i.revoke=()=>{n[e]=r,s()},n[e]=i.proxy,i}const ak=Symbol("Scheduled action");function Gne(n,e,t=Yr.OnBeforeRender){let i=n[ak];i||(i=n[ak]={});const s=e.name;i[t]||(i[t]={});const r=i[t];if(r[s])return;function*a(){e==null||e.call(n),r[s]=null}const l=n.startCoroutine(a(),t);r[s]=l}var Hne=Object.defineProperty,Qne=Object.getOwnPropertyDescriptor,vd=(n,e,t,i)=>{for(var s=i>1?void 0:i?Qne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Hne(e,t,s),s};const zC=se("debugui"),GC=se("debuguilayout");class vR{constructor(){u(this,"width");u(this,"height")}}class yR{constructor(){u(this,"x");u(this,"y");u(this,"width");u(this,"height")}}const Ko=new M,qm=new De,A0=new Le,VG=class extends ma{constructor(){super(...arguments);u(this,"_anchoredPosition");u(this,"sizeDelta",new K(100,100));u(this,"pivot",new K(.5,.5));u(this,"anchorMin",new K(0,0));u(this,"anchorMax",new K(1,1));u(this,"offsetMin",new K(0,0));u(this,"offsetMax",new K(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 K),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;let i=e*t;return i+=this.sizeDelta.x,i}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;let i=e*t;return i+=this.sizeDelta.y,i}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new K),this.lastMatrix=new De,this.rectBlock=new ke,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Bf(this,"_anchoredPosition",()=>{this.markDirty()}),Bf(this,"sizeDelta",()=>{this.markDirty()}),Bf(this,"pivot",()=>{this.markDirty()}),Bf(this,"anchorMin",()=>{this.markDirty()}),Bf(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var e;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(e=this.Canvas)==null||e.registerTransform(this)}onDisable(){var e;super.onDisable(),this.removeShadowComponent(),(e=this.Canvas)==null||e.unregisterTransform(this)}onParentRectTransformChanged(e){this._transformNeedsUpdate||this.onApplyTransform(GC?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(GC&&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(e){var s;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=$.getComponentInParent(this.gameObject.parent,VG):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,GC&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,Ko.set(0,0,0),this.applyPivot(Ko),t.matrix.setPosition(Ko.x,Ko.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(A0.copy(this.gameObject.quaternion),A0.x*=-1,A0.z*=-1,qm.makeRotationFromQuaternion(A0),t.matrix.premultiply(qm)),Ko.set(0,0,0),this.applyAnchoring(Ko),(s=this.Canvas)!=null&&s.screenspace?Ko.z+=.1:Ko.z+=.01,qm.identity(),qm.setPosition(Ko.x,Ko.y,Ko.z),t.matrix.premultiply(qm),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of rI(this.gameObject,ma,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new K);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),e.x+=this._initialPosition.x-this.gameObject.position.x,e.y+=this._initialPosition.y-this.gameObject.position.y,e.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=i.height*.5*r,e.y+=s;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,e.x+=o}}applyPivot(e){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;e.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;e.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const e={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(e),e}ensureValidSize(e,t=1e-4){return e.width<=0&&(e.width=t),e.height<=0&&(e.height=1e-4),e}createNewBlock(e){e={...this.getBasicOptions(),...e},zC&&console.log(this.name,e);const t=new aR(e);return this._createdBlocks.push(t),t}createNewText(e){zC&&console.log(e),e={...this.getBasicOptions(),...e},zC&&console.log(this.name,e);const t=new LG(e);return this._createdTextBlocks.push(t),t}};let fs=VG;vd([w(K)],fs.prototype,"anchoredPosition",1);vd([w(K)],fs.prototype,"sizeDelta",2);vd([w(K)],fs.prototype,"pivot",2);vd([w(K)],fs.prototype,"anchorMin",2);vd([w(K)],fs.prototype,"anchorMax",2);vd([w(K)],fs.prototype,"offsetMin",2);vd([w(K)],fs.prototype,"offsetMax",2);class Vne extends OG{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const s in t[i])e._simpleState__statesProperties[s]||(e._simpleState__statesProperties[s]=[]),e._simpleState__statesProperties[s].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._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 i=[];for(const s in t)this._simpleState__statesProperties[s]||(this._simpleState__statesProperties[s]=[],i.push(s)),this._simpleState__statesProperties[s].push(e);for(const s of this._components)i.indexOf(s.id)>-1&&(this._simpleState__normalStyles[s.id]=s.inline?s.inline:s._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 i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);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 Wne=Object.defineProperty,jne=Object.getOwnPropertyDescriptor,WG=(n,e,t,i)=>{for(var s=i>1?void 0:i?jne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Wne(e,t,s),s};class rm extends we{constructor(){super(...arguments);u(this,"effectColor");u(this,"effectDistance")}}WG([w(_i)],rm.prototype,"effectColor",2);WG([w(K)],rm.prototype,"effectDistance",2);var Xne=Object.defineProperty,qne=Object.getOwnPropertyDescriptor,jG=(n,e,t,i)=>{for(var s=i>1?void 0:i?qne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Xne(e,t,s),s};const v0={backgroundColor:new ve(1,1,1),backgroundOpacity:1,borderColor:new ve(1,1,1),borderOpacity:1};var OE;const kb=(OE=class extends ma{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 _i(1,1,1,1)),this._color}set color(e){(!this._color||this._color.r!==e.r||this._color.g!==e.g||this._color.b!==e.b||this._color.alpha!==e.alpha)&&(this._color||(this._color=new _i(1,1,1,1)),this._color.copy(e))}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(v0.backgroundColor=this._color,v0.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(v0,this._alphaFactor),this.uiObject.set(v0),this.markDirty())}get m_Color(){return this._color}get rectTransform(){return this._rect||(this._rect=$.getComponent(this.gameObject,fs)),this._rect}onParentRectTransformChanged(){var e;(e=this.uiObject)==null||e.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(e){this.makePanel(),this.uiObject&&(this.uiObject.setState(e),this==null||this.markDirty())}setupState(e){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Vne(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),Bf(this,"_color",()=>Gne(this,this.onColorChanged))}onEnable(){var e;super.onEnable(),this.uiObject&&((e=this.rectTransform.shadowComponent)==null||e.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 e=.015;const t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:e};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(e){}onCreate(e){this.uiObject=this.rectTransform.createNewBlock(e),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(e,t=1){var s;const i=(s=this.gameObject)==null?void 0:s.getComponent(rm);i&&(i.effectDistance&&(e.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(e.borderColor=i.effectColor,e.borderOpacity=i.effectColor.alpha*t))}async setTexture(e){if(this.setOptions({backgroundOpacity:0}),e){if(e.colorSpace===nt)if(kb.textureCache.has(e))e=kb.textureCache.get(e);else{const t=e.clone();t.colorSpace=Jn,kb.textureCache.set(e,t),e=t}this.setOptions({backgroundImage:e,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(OE,"textureCache",new Map),OE);let yd=kb;jG([w(_i)],yd.prototype,"color",1);jG([w()],yd.prototype,"raycastTarget",2);class Lv extends yd{constructor(){super(...arguments);u(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var Yne=Object.defineProperty,Kne=Object.getOwnPropertyDescriptor,Rw=(n,e,t,i)=>{for(var s=i>1?void 0:i?Kne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yne(e,t,s),s};let bR=class{constructor(){u(this,"texture",null);u(this,"rect")}};Rw([w(Gt)],bR.prototype,"texture",2);let om=class extends Lv{constructor(){super(...arguments);u(this,"_sprite");u(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new bR),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,i,s,r,o,a,l,c;switch((i=(t=this.sprite)==null?void 0:t.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(r=(s=this.sprite)==null?void 0:s.texture)==null?void 0:r.image)==null?void 0:o.width)===32&&((c=(l=(a=this.sprite)==null?void 0:a.texture)==null?void 0:l.image)==null?void 0:c.height)===32}onBeforeCreate(t){var i,s;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((s=(i=this.sprite)==null?void 0:i.texture)==null?void 0:s.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};Rw([w(bR)],om.prototype,"sprite",1);Rw([w()],om.prototype,"pixelsPerUnitMultiplier",2);class Pw extends Lv{constructor(){super(...arguments);u(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(t){this._mainTexture!==t&&(this._mainTexture=t,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Rw([w(Gt)],Pw.prototype,"mainTexture",1);var Jne=Object.defineProperty,Zne=Object.getOwnPropertyDescriptor,$r=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jne(e,t,s),s};const df=se("debugbutton");class bd{constructor(){u(this,"colorMultiplier");u(this,"disabledColor");u(this,"fadeDuration");u(this,"highlightedColor");u(this,"normalColor");u(this,"pressedColor");u(this,"selectedColor")}}$r([w()],bd.prototype,"colorMultiplier",2);$r([w(_i)],bd.prototype,"disabledColor",2);$r([w()],bd.prototype,"fadeDuration",2);$r([w(_i)],bd.prototype,"highlightedColor",2);$r([w(_i)],bd.prototype,"normalColor",2);$r([w(_i)],bd.prototype,"pressedColor",2);$r([w(_i)],bd.prototype,"selectedColor",2);class wc extends we{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(t){var i,s;df&&console.log("Button Enter",(i=this.animationTriggers)==null?void 0:i.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 t,i;df&&console.log("Button Exit",(t=this.animationTriggers)==null?void 0:t.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&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(t){var i,s;df&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.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(t){var i,s;df&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.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(t){var i;this.interactable&&t.pointerId===0&&(df&&(console.warn("Button Click",this.onClick),yn("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(i=this.onClick)==null||i.invoke())}set interactable(t){this._interactable=t,this._image&&(this._image.setInteractable(t),t?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(t){this.interactable=t}awake(){super.awake(),df&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(t){var i;this._requestedAnimatorTrigger=t,yield,yield,this._requestedAnimatorTrigger==t&&((i=this.animator)==null||i.SetTrigger(t))}init(){this._isInit||(this._isInit=!0,this._image=$.getComponent(this.gameObject,om),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(t){var p,m,A,v,g;t.setInteractable(this.interactable);const i=this.getFinalColor(t.color,(p=this.colors)==null?void 0:p.normalColor),s={state:"normal",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};t.setupState(s);const r=this.getFinalColor(t.color,(m=this.colors)==null?void 0:m.highlightedColor),o={state:"hovered",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};t.setupState(o);const a=this.getFinalColor(t.color,(A=this.colors)==null?void 0:A.pressedColor),l={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(l);const c=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.selectedColor),h={state:"selected",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};t.setupState(h);const d=this.getFinalColor(t.color,(g=this.colors)==null?void 0:g.disabledColor),f={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};t.setupState(f)}getFinalColor(t,i){return i?t.clone().multiply(i):t.clone()}}$r([w(yr)],wc.prototype,"onClick",2);$r([w()],wc.prototype,"colors",2);$r([w()],wc.prototype,"transition",2);$r([w()],wc.prototype,"animationTriggers",2);$r([w(ir)],wc.prototype,"animator",2);$r([w()],wc.prototype,"interactable",1);var $ne=Object.defineProperty,ese=Object.getOwnPropertyDescriptor,En=(n,e,t,i)=>{for(var s=i>1?void 0:i?ese(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$ne(e,t,s),s};const lk=se("debuguilayout");class Vh{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}}En([w()],Vh.prototype,"left",2);En([w()],Vh.prototype,"right",2);En([w()],Vh.prototype,"top",2);En([w()],Vh.prototype,"bottom",2);class eo extends we{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(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(lk&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){lk&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(fs);const t=this.gameObject.getComponentInParent(ps);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(ps);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}En([w()],eo.prototype,"childAlignment",2);En([w()],eo.prototype,"reverseArrangement",2);En([w()],eo.prototype,"spacing",2);En([w(Vh)],eo.prototype,"padding",2);En([w()],eo.prototype,"minWidth",2);En([w()],eo.prototype,"minHeight",2);En([w()],eo.prototype,"flexibleHeight",2);En([w()],eo.prototype,"flexibleWidth",2);En([w()],eo.prototype,"preferredHeight",2);En([w()],eo.prototype,"preferredWidth",2);class Wh extends eo{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(t){var R;const i=this.primaryAxis,s=t.width;let r=s;const o=t.height;let a=o;r-=this.padding.horizontal,a-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const l=i==="x",c=l?"y":"x",h=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,f=l?this.childForceExpandWidth:this.childForceExpandHeight,p=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:r,A=l?s:o,v=.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 E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],k=$.getComponent(T,fs);k!=null&&k.activeAndEnabled&&(y+=1,l?b+=k.width:b+=k.height)}let _=0;const x=this.spacing*(y-1);if(f||h){let E=0;l?E=r-=x:E=a-=x,y>0&&(_=E/y)}let S=0;S+=this.padding.left,S-=this.padding.right,v!==0&&(g=A-b,g*=v,g-=x*v,l?(g-=this.padding.right*v,g+=this.padding.left*(1-v),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*v,g+=this.padding.top*(1-v),g<this.padding.top&&(g=this.padding.top)));let I=1;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],k=$.getComponent(T,fs);if(k!=null&&k.activeAndEnabled){(R=k.pivot)==null||R.set(.5,.5),k.anchorMin.set(0,1),k.anchorMax.set(0,1);const W=s*.5+S*.5;k.anchoredPosition.x!==W&&(k.anchoredPosition.x=W);const U=o*-.5;k.anchoredPosition.y!==U&&(k.anchoredPosition.y=U),p&&d&&k.sizeDelta[c]!==m&&(k.sizeDelta[c]=m),f&&h&&k.sizeDelta[i]!==_&&(k.sizeDelta[i]=_);const z=l?k.width:k.height;let Q=z*.5;if(g+=Q,f){let X=_*I-_*.5;X>g&&(g=X-_*.5+z+this.padding.left,g-=Q)}let ee=g;i==="y"&&(ee=-ee),k.anchoredPosition[i]!==ee&&(k.anchoredPosition[i]=ee),g+=Q,g+=this.spacing,I+=1}}}}En([w()],Wh.prototype,"childControlHeight",2);En([w()],Wh.prototype,"childControlWidth",2);En([w()],Wh.prototype,"childForceExpandHeight",2);En([w()],Wh.prototype,"childForceExpandWidth",2);En([w()],Wh.prototype,"childScaleHeight",2);En([w()],Wh.prototype,"childScaleWidth",2);class _R extends Wh{get primaryAxis(){return"y"}}class xR extends Wh{get primaryAxis(){return"x"}}class wR extends eo{onCalculateLayout(){}}var tse=Object.defineProperty,ise=Object.getOwnPropertyDescriptor,hl=(n,e,t,i)=>{for(var s=i>1?void 0:i?ise(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&tse(e,t,s),s},XG=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(XG||{});const HC=se("debuguilayout"),qG=class extends Mv{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 e,t,i,s;if(this.context.isInVR){(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(t=this.shadowComponent)==null||t.updateWorldMatrix(!0,!0),qs.ensureUpdateMeshUI(LC,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),qs.ensureUpdateMeshUI(LC,this.context))});u(this,"onAfterRenderRoutine",()=>{var e,t;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r==null||r.add(this.gameObject)}else this.previousParent.add(this.gameObject);const i=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(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),qs.ensureUpdateMeshUI(LC,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=i,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(t=this._lastMatrixWorld)==null||t.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(e){e!==this._renderOnTop&&(this._renderOnTop=e,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(e){this._depthWrite!==e&&(this._depthWrite=e,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(e){this._doubleSided!==e&&(this._doubleSided=e,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(e){this._castShadows!==e&&(this._castShadows=e,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(e){this._renderMode!==e&&(this._renderMode=e,this.onRenderSettingsChanged())}set rootCanvas(e){this._rootCanvas instanceof qG||(this._rootCanvas=e)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(e){this._scaleFactor=e}awake(){var e;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,HC&&console.log("Canvas.Awake()",((e=this.previousParent)==null?void 0:e.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new De,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 e=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);e!==-1&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(e){this._rectTransforms.push(e)}unregisterTransform(e){const t=this._rectTransforms.indexOf(e);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(e){const t=e.gameObject;this._layoutGroups.set(t,e)}unregisterLayoutGroup(e){const t=e.gameObject;this._layoutGroups.delete(t)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new De);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);HC&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);let t=!1;for(const i of this._rectTransforms){e&&i.markDirty();let s=this._layoutGroups.get(i.gameObject);i.isDirty&&!s&&(s=i.gameObject.getComponentInParent(eo)),(i.isDirty||s!=null&&s.isDirty)&&(HC&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),s==null||s.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Yr.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),D_(this.shadowComponent,this);for(const e of $.getComponentsInChildren(this.gameObject,ma))D_(e.shadowComponent,this)}}onUpdateRenderMode(e=!1){if(!e&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=et.lerp(t.nearClipPlane,t.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const s=i+.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(fs);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=t.fieldOfView*Math.PI/180,l=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=l/this.context.domHeight,this.gameObject.scale.y=l/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r==null||r.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let ps=qG;hl([w()],ps.prototype,"renderOnTop",1);hl([w()],ps.prototype,"depthWrite",1);hl([w()],ps.prototype,"doubleSided",1);hl([w()],ps.prototype,"castShadows",1);hl([w()],ps.prototype,"receiveShadows",1);hl([w()],ps.prototype,"renderMode",1);hl([w(ps)],ps.prototype,"rootCanvas",1);hl([w()],ps.prototype,"scaleFactor",1);hl([w(Ni)],ps.prototype,"worldCamera",2);hl([w()],ps.prototype,"planeDistance",2);var nse=Object.defineProperty,sse=Object.getOwnPropertyDescriptor,SR=(n,e,t,i)=>{for(var s=i>1?void 0:i?sse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&nse(e,t,s),s};class Ph extends we{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(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Yr.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const t of $.getComponentsInChildren(this.gameObject,ma,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}SR([w()],Ph.prototype,"alpha",1);SR([w()],Ph.prototype,"interactable",2);SR([w()],Ph.prototype,"blocksRaycasts",2);var rse=Object.defineProperty,ose=Object.getOwnPropertyDescriptor,Ri=(n,e,t,i)=>{for(var s=i>1?void 0:i?ose(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rse(e,t,s),s};class _d extends we{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 M);u(this,"targetRot",new Le);u(this,"targetScale",new M)}*moveToTarget(){if(!this.target||!this.object)return;const t=xt(this.object).clone(),i=xt(this.target).clone(),s=On(this.object).clone(),r=On(this.target).clone(),o=as(this.object).clone(),a=as(this.target).clone(),l=t.distanceTo(i),c=s.angleTo(r),h=o.distanceTo(a);if(l<.01&&c<.01&&h<.01){hn(this.object,i),wr(this.object,r),B1(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(s,r,f),this.targetScale.lerpVectors(o,a,f),hn(this.object,this.targetPos),wr(this.object,this.targetRot),B1(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let l=0,c=0;for(;l<1;)l+=this.context.time.deltaTime/this.duration,l>1&&(l=1),c=l<.5?4*l*l*l:1-Math.pow(-2*l+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,c),this.object.quaternion.slerpQuaternions(i,this.targetRot,c),this.object.scale.lerpVectors(s,this.targetScale,c),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new hs("Move to "+((i=this.target)==null?void 0:i.name),br.tapTrigger(this.gameObject),ci.transformAction(this.object,this.target,this.duration,this.relativeMotion?oM.Relative:oM.Absolute));t.addBehavior(s)}}}Ri([w(ke)],_d.prototype,"object",2);Ri([w(ke)],_d.prototype,"target",2);Ri([w()],_d.prototype,"duration",2);Ri([w()],_d.prototype,"relativeMotion",2);var LE;const Mu=(LE=class extends we{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 e=$.findObjectsOfType(Ui);for(const t of e)t.sharedMaterial===this.materialToSwitch&&this._objectsWithThisMaterial.push(t)}}onPointerClick(){if(this.variantMaterial)for(const e of this._objectsWithThisMaterial)e.sharedMaterial=this.variantMaterial}async beforeCreateDocument(e,t){this.targetModels=[],Mu._materialTriggersPerId={},this.materialToSwitch&&await Ur.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Ur.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.gameObject.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(Mu._materialTriggersPerId[this.materialToSwitch.uuid]||(Mu._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Mu._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=Mu._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const o of i){const a=o.createVariants();a&&a.length>0&&(s[o.selfModel.uuid]=a)}const r=[];for(const o of i){for(const a in s)a!==o.selfModel.uuid&&r.push(s[a]);o.createAndAttachBehaviors(e,s[o.selfModel.uuid],r)}}delete Mu._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);for(const a of this.targetModels){const l=ci.fadeAction(a,o,!1);r.push(l)}for(const a of i)r.push(ci.fadeAction(a,o,!1));for(const a of t)s.push(ci.fadeAction(a,o,!1)),r.push(ci.fadeAction(a,o,!0));e.addBehavior(new hs("Select "+this.selfModel.name,br.tapTrigger(this.selfModel),ci.parallel(...r))),e.addBehavior(new hs("Start hidden "+this.selfModel.name,br.sceneStartTrigger(),ci.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&mr.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},u(LE,"_materialTriggersPerId",{}),LE);let am=Mu;Ri([w(Bt)],am.prototype,"materialToSwitch",2);Ri([w(Bt)],am.prototype,"variantMaterial",2);Ri([w()],am.prototype,"fadeDuration",2);class lm extends we{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(t,i,s){i.uuid===this.gameObject.uuid&&(this.selfModel=i)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(t,i){if(this.target){if(this.otherModel=i.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())&&tz.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(ci.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(ci.fadeAction(this.toggleModel,0,!0)),r.push(ci.fadeAction(this.otherModel,0,this.targetState)),t.addBehavior(new hs("Toggle_"+this.selfModel.name+"_hideSelf",br.tapTrigger(this.selfModel),ci.sequence(...r))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(ci.fadeAction(this.toggleModel,0,!1)),o.push(ci.fadeAction(this.selfModel,0,!0)),o.push(ci.fadeAction(this.otherModel,0,!this.targetState)),t.addBehavior(new hs("Toggle_"+this.selfModel.name+"_toggleSelf",br.tapTrigger(this.toggleModel),ci.sequence(...o))),t.addBehavior(new hs("HideOnStart_"+this.gameObject.name,br.sceneStartTrigger(),ci.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Ri([w(ke)],lm.prototype,"target",2);Ri([w()],lm.prototype,"targetState",2);Ri([w()],lm.prototype,"hideSelf",2);class CR extends we{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new hs("HideOnStart_"+this.gameObject.name,br.sceneStartTrigger(),ci.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class cm extends we{constructor(){super(...arguments);u(this,"target");u(this,"duration",.5);u(this,"motionType",MI.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new hs("emphasize "+this.name,br.tapTrigger(this.gameObject),ci.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}Ri([w()],cm.prototype,"target",2);Ri([w()],cm.prototype,"duration",2);Ri([w()],cm.prototype,"motionType",2);class hm extends we{constructor(){super(...arguments);u(this,"target");u(this,"clip","");u(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const t=this.gameObject.addNewComponent(wn);t&&(t.spatialBlend=1,t.volume=1,t.loop=!1,this.target=t)}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(t,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const o=this.target?this.target.gameObject:this.gameObject,a=r.split("/").pop(),l=this.target?this.target.volume:1,c=this.target&&this.target.spatialBlend==0?aM.NonSpatial:aM.Spatial,h=new hs("playAudio "+this.name,br.tapTrigger(this.gameObject),ci.playAudioAction(o,"audio/"+a,az.Play,l,c));t.addBehavior(h)}}async afterSerialize(t,i){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(),l=await(await(await fetch(this.clip)).blob()).arrayBuffer(),c=new Uint8Array(l);i.files["audio/"+r]=c}}Ri([w(wn)],hm.prototype,"target",2);Ri([w(URL)],hm.prototype,"clip",2);Ri([w()],hm.prototype,"toggleOnClick",2);var FE;const Df=(FE=class extends we{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 e;this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}onAfterHierarchy(){Df.animationActions=[]}afterCreateDocument(e,t){if(!this.stateAnimation||!this.stateAnimationModel)return;t.document.traverse(s=>{var r,o;if(s.uuid===((r=this.target)==null?void 0:r.uuid)&&this.stateAnimation){const a=[];let l=Df.animationActions.find(h=>h.affectedObjects==s&&h.start==this.stateAnimation.start&&h.duration==this.stateAnimation.duration);if(l||(l=ci.startAnimationAction(s,this.stateAnimation.start,this.stateAnimation.duration),Df.animationActions.push(l)),a.push(l),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let h=Df.animationActions.find(f=>f.affectedObjects==s&&f.start==this.stateAfterPlayingAnimation.start&&f.duration==this.stateAfterPlayingAnimation.duration);h||(h=ci.startAnimationAction(s,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),Df.animationActions.push(h));const d=ci.sequence(h);this.loopAfterPlaying&&d.makeLooping(),a.push(d)}const c=new hs("tap "+this.name+" for "+this.stateName+" on "+((o=this.target)==null?void 0:o.name),br.tapTrigger(this.selfModel),ci.sequence(...a));e.addBehavior(c)}})}createAnimation(e,t,i){var s,r,o,a;if(this.target&&this.animator){const l=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);this.stateAnimationModel=t,this.stateAnimation=e.registerAnimation(this.target,l==null?void 0:l.motion.clip);const c=(a=(o=this.animator)==null?void 0:o.runtimeAnimatorController)==null?void 0:a.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=t,this.stateAfterPlayingAnimation=e.registerAnimation(this.target,c==null?void 0:c.motion.clip)}}},u(FE,"animationActions",[]),FE);let jh=Df;Ri([w(ke)],jh.prototype,"target",2);Ri([w(ir)],jh.prototype,"animator",2);Ri([w()],jh.prototype,"stateName",2);Ri([w()],jh.prototype,"stateNameAfterPlaying",2);Ri([w()],jh.prototype,"loopAfterPlaying",2);class um extends we{constructor(){super(...arguments);u(this,"target")}getType(){}getDuration(){}}Ri([w(ke)],um.prototype,"target",2);class Fv extends we{constructor(){super(...arguments);u(this,"target")}}Ri([w(um)],Fv.prototype,"target",2);class Uv extends um{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}}Ri([w()],Uv.prototype,"type",2);Ri([w()],Uv.prototype,"duration",2);class ER extends Fv{}var ase=Object.defineProperty,lse=Object.getOwnPropertyDescriptor,Sc=(n,e,t,i)=>{for(var s=i>1?void 0:i?lse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ase(e,t,s),s};class xd extends we{constructor(){super(...arguments);u(this,"center",new M(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 t=this.rigidbody,i=this.gameObject.getComponent(Rh);i||(i=this.gameObject.addNewComponent(Rh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){for(const i of t.contacts)if(i.normal.y>.1){this._activeGroundCollisions.add(t);break}}onCollisionExit(t){this._activeGroundCollisions.delete(t)}get isGrounded(){return this._activeGroundCollisions.size>0}}Sc([w(M)],xd.prototype,"center",2);Sc([w()],xd.prototype,"radius",2);Sc([w()],xd.prototype,"height",2);class Cc extends we{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 M(0,0,0));u(this,"_currentAngularSpeed",new M(0,0,0));u(this,"_temp",new M(0,0,0));u(this,"_jumpCount",0);u(this,"_currentRotation");u(this,"_raycastOptions",new va)}awake(){this._currentRotation=new Le}update(){var c,h,d,f,p,m,A,v,g,b,y;(c=this.controller)!=null&&c.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((h=this.animator)==null||h.setBool("doubleJump",!1)));const t=this.context.input.isKeyPressed("w"),i=this.context.input.isKeyPressed("s"),s=this.context.input.isKeyPressed("a"),r=this.context.input.isKeyPressed("d"),o=this.context.input.isKeyDown(" "),a=(t?1:0)+(i?-1:0);this._currentSpeed.z+=a*this.movementSpeed*this.context.time.deltaTime,(d=this.animator)==null||d.setBool("running",a!=0),(p=this.animator)==null||p.setBool("jumping",((f=this.controller)==null?void 0:f.isGrounded)===!0&&o),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 l=(s?1:0)+(r?-1:0);if(this._currentAngularSpeed.y+=et.toRadians(l*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const _=this.context.mainCameraComponent.forward;_.y=0,_.normalize(),this._currentRotation.setFromUnitVectors(new M(0,0,1),_),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&&o&&this.jumpForce>0){let _=(m=this.controller)==null?void 0:m.isGrounded;if(this.doubleJumpForce>0&&!((A=this.controller)!=null&&A.isGrounded)&&this._jumpCount===1&&(_=!0,(v=this.animator)==null||v.setBool("doubleJump",!0)),_){this._jumpCount+=1;const x=this.controller.rigidbody,S=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;x.applyImpulse(new M(0,1,0).multiplyScalar(S))}}if(this.controller){const _=(g=this.controller)==null?void 0:g.rigidbody.getVelocity().y;if(_<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new ol),this._raycastOptions.ray.origin.copy(xt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const x=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const S=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(x),(S.length&&S[0].distance>2||_<-10)&&((b=this.animator)==null||b.setBool("falling",!0))}else(y=this.animator)==null||y.setBool("falling",!1)}}}Sc([w(xd)],Cc.prototype,"controller",2);Sc([w()],Cc.prototype,"movementSpeed",2);Sc([w()],Cc.prototype,"rotationSpeed",2);Sc([w()],Cc.prototype,"jumpForce",2);Sc([w()],Cc.prototype,"doubleJumpForce",2);Sc([w(ir)],Cc.prototype,"animator",2);var cse=Object.defineProperty,hse=Object.getOwnPropertyDescriptor,use=(n,e,t,i)=>{for(var s=i>1?void 0:i?hse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&cse(e,t,s),s};class Nv extends Ds{constructor(){super(...arguments);u(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new $N;return t.offset=new K(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}use([w(Tt)],Nv.prototype,"intensity",2);Ho("ChromaticAberration",Nv);var dse=Object.defineProperty,fse=Object.getOwnPropertyDescriptor,Bw=(n,e,t,i)=>{for(var s=i>1?void 0:i?fse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&dse(e,t,s),s};class Xh extends Ds{constructor(){super(...arguments);u(this,"postExposure");u(this,"contrast");u(this,"hueShift");u(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=t=>(t=Math.pow(2,t),t),this.postExposure.defaultValue=0,this.contrast.valueProcessor=t=>{let i=1;return t>0?i=200:t<0&&(i=100),t/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=t=>Math.PI*t/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=t=>t<0?t/100:t/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Ys&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=dA);const t=new ZN;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Ys&&(this.context.renderer.toneMapping=dA),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{t.contrast=s};const i=new t3;return this.hueShift.onValueChanged=s=>i.hue=s,this.saturation.onValueChanged=s=>i.saturation=s,[i,t]}}Bw([w(Tt)],Xh.prototype,"postExposure",2);Bw([w(Tt)],Xh.prototype,"contrast",2);Bw([w(Tt)],Xh.prototype,"hueShift",2);Bw([w(Tt)],Xh.prototype,"saturation",2);Ho("ColorAdjustments",Xh);const pse=(Math.sqrt(5)-1)/4,es=(5-Math.sqrt(5))/20,y0=n=>Math.floor(n)|0,b0=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 mse(n=Math.random){const e=gse(n),t=new Float64Array(e).map(o=>b0[o%32*4]),i=new Float64Array(e).map(o=>b0[o%32*4+1]),s=new Float64Array(e).map(o=>b0[o%32*4+2]),r=new Float64Array(e).map(o=>b0[o%32*4+3]);return function(a,l,c,h){let d,f,p,m,A;const v=(a+l+c+h)*pse,g=y0(a+v),b=y0(l+v),y=y0(c+v),_=y0(h+v),x=(g+b+y+_)*es,S=g-x,I=b-x,R=y-x,E=_-x,T=a-S,k=l-I,W=c-R,U=h-E;let z=0,Q=0,ee=0,X=0;T>k?z++:Q++,T>W?z++:ee++,T>U?z++:X++,k>W?Q++:ee++,k>U?Q++:X++,W>U?ee++:X++;const J=z>=3?1:0,ie=Q>=3?1:0,oe=ee>=3?1:0,Y=X>=3?1:0,te=z>=2?1:0,xe=Q>=2?1:0,be=ee>=2?1:0,Se=X>=2?1:0,Ce=z>=1?1:0,We=Q>=1?1:0,He=ee>=1?1:0,lt=X>=1?1:0,Ct=T-J+es,tt=k-ie+es,H=W-oe+es,Fe=U-Y+es,me=T-te+2*es,Oe=k-xe+2*es,_e=W-be+2*es,Ze=U-Se+2*es,Xe=T-Ce+3*es,Ye=k-We+3*es,ft=W-He+3*es,Et=U-lt+3*es,qt=T-1+4*es,N=k-1+4*es,O=W-1+4*es,he=U-1+4*es,Te=g&255,Ie=b&255,Ue=y&255,V=_&255;let de=.6-T*T-k*k-W*W-U*U;if(de<0)d=0;else{const Be=Te+e[Ie+e[Ue+e[V]]];de*=de,d=de*de*(t[Be]*T+i[Be]*k+s[Be]*W+r[Be]*U)}let ae=.6-Ct*Ct-tt*tt-H*H-Fe*Fe;if(ae<0)f=0;else{const Be=Te+J+e[Ie+ie+e[Ue+oe+e[V+Y]]];ae*=ae,f=ae*ae*(t[Be]*Ct+i[Be]*tt+s[Be]*H+r[Be]*Fe)}let Ve=.6-me*me-Oe*Oe-_e*_e-Ze*Ze;if(Ve<0)p=0;else{const Be=Te+te+e[Ie+xe+e[Ue+be+e[V+Se]]];Ve*=Ve,p=Ve*Ve*(t[Be]*me+i[Be]*Oe+s[Be]*_e+r[Be]*Ze)}let qe=.6-Xe*Xe-Ye*Ye-ft*ft-Et*Et;if(qe<0)m=0;else{const Be=Te+Ce+e[Ie+We+e[Ue+He+e[V+lt]]];qe*=qe,m=qe*qe*(t[Be]*Xe+i[Be]*Ye+s[Be]*ft+r[Be]*Et)}let Ge=.6-qt*qt-N*N-O*O-he*he;if(Ge<0)A=0;else{const Be=Te+1+e[Ie+1+e[Ue+1+e[V+1]]];Ge*=Ge,A=Ge*Ge*(t[Be]*qt+i[Be]*N+s[Be]*O+r[Be]*he)}return 27*(d+f+p+m+A)}}function gse(n){const t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){const s=i+~~(n()*(256-i)),r=t[i];t[i]=t[s],t[s]=r}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Ase=Object.defineProperty,vse=Object.getOwnPropertyDescriptor,Z=(n,e,t,i)=>{for(var s=i>1?void 0:i?vse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ase(e,t,s),s};const _0=se("debugparticles");var Xl=(n=>(n[n.Billboard=0]="Billboard",n[n.Stretch=1]="Stretch",n[n.HorizontalBillboard=2]="HorizontalBillboard",n[n.VerticalBillboard=3]="VerticalBillboard",n[n.Mesh=4]="Mesh",n))(Xl||{});class qh{constructor(){u(this,"alphaKeys");u(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let i,s=0,r=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const l=this.alphaKeys[a];(l.time<e||!i)&&(i=l,s=a)}for(let a=0;a<this.colorKeys.length;a++){const l=this.colorKeys[a];(l.time<e||!r)&&(r=l,o=a)}if(r)if(o+1<this.colorKeys.length){const l=this.colorKeys[o+1],c=et.remap(e,r.time,l.time,0,1);t.r=et.lerp(r.color.r,l.color.r,c),t.g=et.lerp(r.color.g,l.color.g,c),t.b=et.lerp(r.color.b,l.color.b,c)}else t.r=r.color.r,t.g=r.color.g,t.b=r.color.b;if(i)if(s+1<this.alphaKeys.length){const l=this.alphaKeys[s+1],c=et.remap(e,i.time,l.time,0,1);t.alpha=et.lerp(i.alpha,l.alpha,c)}else t.alpha=i.alpha;return t}}Z([w()],qh.prototype,"alphaKeys",2);Z([w()],qh.prototype,"colorKeys",2);var Dw=(n=>(n[n.Local=0]="Local",n[n.World=1]="World",n[n.Custom=2]="Custom",n))(Dw||{}),YG=(n=>(n[n.Sphere=0]="Sphere",n[n.SphereShell=1]="SphereShell",n[n.Hemisphere=2]="Hemisphere",n[n.HemisphereShell=3]="HemisphereShell",n[n.Cone=4]="Cone",n[n.Box=5]="Box",n[n.Mesh=6]="Mesh",n[n.ConeShell=7]="ConeShell",n[n.ConeVolume=8]="ConeVolume",n[n.ConeVolumeShell=9]="ConeVolumeShell",n[n.Circle=10]="Circle",n[n.CircleEdge=11]="CircleEdge",n[n.SingleSidedEdge=12]="SingleSidedEdge",n[n.MeshRenderer=13]="MeshRenderer",n[n.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",n[n.BoxShell=15]="BoxShell",n[n.BoxEdge=16]="BoxEdge",n[n.Donut=17]="Donut",n[n.Rectangle=18]="Rectangle",n[n.Sprite=19]="Sprite",n[n.SpriteRenderer=20]="SpriteRenderer",n))(YG||{});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 i=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 s=e*this.curveMin.duration,r=e*this.curveMax.duration;return et.lerp(this.curveMin.evaluate(s),this.curveMax.evaluate(r),i%1)*this.curveMultiplier;case 3:return et.lerp(this.constantMin,this.constantMax,i%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 i=0;i<e.keys.length;i++){const s=e.keys[i];s.value>t&&(t=s.value)}return t}}Z([w()],at.prototype,"mode",2);Z([w()],at.prototype,"constant",2);Z([w()],at.prototype,"constantMin",2);Z([w()],at.prototype,"constantMax",2);Z([w(fd)],at.prototype,"curve",2);Z([w(fd)],at.prototype,"curveMin",2);Z([w(fd)],at.prototype,"curveMax",2);Z([w()],at.prototype,"curveMultiplier",2);var ib;const na=(ib=class{constructor(){u(this,"mode");u(this,"color");u(this,"colorMin");u(this,"colorMax");u(this,"gradient");u(this,"gradientMin");u(this,"gradientMax")}evaluate(n,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(n,na._temp),na._temp;case 2:return na._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(n,na._temp),this.gradientMax.evaluate(n,na._temp2),na._temp.lerp(na._temp2,t)}return na._temp.set(16711935),na._temp.alpha=1,na._temp}},u(ib,"_temp",new _i(0,0,0,1)),u(ib,"_temp2",new _i(0,0,0,1)),ib);let Sr=na;Z([w(_i)],Sr.prototype,"color",2);Z([w(_i)],Sr.prototype,"colorMin",2);Z([w(_i)],Sr.prototype,"colorMax",2);Z([w(qh)],Sr.prototype,"gradient",2);Z([w(qh)],Sr.prototype,"gradientMin",2);Z([w(qh)],Sr.prototype,"gradientMax",2);class vs{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")}}Z([w(at)],vs.prototype,"gravityModifier",2);Z([w(Sr)],vs.prototype,"startColor",2);Z([w(at)],vs.prototype,"startDelay",2);Z([w(at)],vs.prototype,"startLifetime",2);Z([w(at)],vs.prototype,"startRotation",2);Z([w(at)],vs.prototype,"startRotationX",2);Z([w(at)],vs.prototype,"startRotationY",2);Z([w(at)],vs.prototype,"startRotationZ",2);Z([w(at)],vs.prototype,"startSize",2);Z([w(at)],vs.prototype,"startSizeX",2);Z([w(at)],vs.prototype,"startSizeY",2);Z([w(at)],vs.prototype,"startSizeZ",2);Z([w(at)],vs.prototype,"startSpeed",2);class HA{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 i=this.time+this.repeatInterval*this._performed;if(e>=i&&(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 s=Math.random();t=et.lerp(this.count.curveMin.evaluate(s),this.count.curveMax.evaluate(s),Math.random());break}}return t}}class ul{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 i=this.bursts[t];this.system.main.loop&&i.time>=this.system.time&&i.reset(),e+=Math.round(i.run(this.system.time))}return e}}Z([w()],ul.prototype,"enabled",2);Z([w()],ul.prototype,"bursts",2);Z([w(at)],ul.prototype,"rateOverTime",2);Z([w()],ul.prototype,"rateOverTimeMultiplier",2);Z([w(at)],ul.prototype,"rateOverDistance",2);Z([w()],ul.prototype,"rateOverDistanceMultiplier",2);class zv{constructor(){u(this,"enabled");u(this,"color")}}Z([w(Sr)],zv.prototype,"color",2);class Yh{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 M)}evaluate(e,t,i){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,i)*this.xMultiplier,t.y=this.y.evaluate(e,i)*this.yMultiplier,t.z=this.z.evaluate(e,i)*this.zMultiplier;else{const s=this.size.evaluate(e,i)*this.sizeMultiplier;t.x=s}return t}}Z([w(at)],Yh.prototype,"size",2);Z([w(at)],Yh.prototype,"x",2);Z([w(at)],Yh.prototype,"y",2);Z([w(at)],Yh.prototype,"z",2);var nb;const xg=(nb=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 cs);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 De);u(this,"_worldSpaceMatrixInverse",new De);u(this,"_vector",new M(0,0,0));u(this,"_temp",new M(0,0,0));u(this,"_dir",new M);u(this,"_loopTime",0);u(this,"_loopDirection",1);_0&&console.log(this)}get type(){return YG[this.shapeType]}initialize(n){this.getPosition(),n.position.copy(this._vector)}toJSON(){return this}clone(){return new xg}update(n,e,t,i){this.system=n,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(n){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",n.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const n=this._temp.copy(this.position),e=this._space===1;e&&n.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:_0&&tc.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(n);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)),_0&&tc.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(n){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=n.x,i=n.y,s=n.z;this._dir.set(t,i,s),(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),_0&&(tc.DrawSphere(n,.01,8925952,.5,!0),tc.DrawDirection(n,this._dir,8925952,.5,!0)),this._dir}randomizePosition(n,e){if(e<=0)return;const t=xg._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,n.add(t)}randomizeDirection(n,e){if(e===0)return;const t=xg._randomQuat,i=xg._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),n.applyQuaternion(t)}spherizeDirection(n,e){if(e===0)return;const t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),s=Math.sin(i)*Math.cos(t),r=Math.sin(i)*Math.sin(t),o=Math.cos(i),a=new M(s,r,o);n.lerp(a,e)}randomSpherePoint(n,e,t,i,s){const r=Math.random(),o=Math.random(),a=2*Math.PI*r*(i/360),l=Math.acos(2*o-1),c=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,h=n.x+this.scale.x*(-c*Math.sin(l)*Math.cos(a)),d=n.y+this.scale.y*(c*Math.sin(l)*Math.sin(a)),f=n.z+this.scale.z*(c*Math.cos(l));s.x=h,s.y=d,s.z=f}randomCirclePoint(n,e,t,i,s){const r=Math.random(),o=2*Math.PI*r*(i/360),a=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,l=n.x+this.scale.x*a*Math.cos(o),c=n.y+this.scale.y*a*Math.sin(o),h=n.z;s.x=l,s.y=c,s.z=h}randomConePoint(n,e,t,i,s,r,o){let a=0,l=0;switch(r){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*(s/360);switch(r){case 2:case 1:c+=Math.PI+.5,c+=this._loopTime*Math.PI*2,c%=et.toRadians(s);break}const h=Math.acos(2*l-1),d=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,f=n.x+-d*Math.sin(h)*Math.cos(c),p=n.y+d*Math.sin(h)*Math.sin(c),m=n.z;o.x=f*this.scale.x,o.y=p*this.scale.y,o.z=m*this.scale.z}},u(nb,"_randomQuat",new Le),u(nb,"_tempVec",new M),nb);let dn=xg;Z([w()],dn.prototype,"shapeType",2);Z([w()],dn.prototype,"enabled",2);Z([w()],dn.prototype,"alignToDirection",2);Z([w()],dn.prototype,"angle",2);Z([w()],dn.prototype,"arc",2);Z([w()],dn.prototype,"arcSpread",2);Z([w()],dn.prototype,"arcSpeedMultiplier",2);Z([w()],dn.prototype,"arcMode",2);Z([w(M)],dn.prototype,"boxThickness",2);Z([w(M)],dn.prototype,"position",2);Z([w(M)],dn.prototype,"rotation",2);Z([w(M)],dn.prototype,"scale",2);Z([w()],dn.prototype,"radius",2);Z([w()],dn.prototype,"radiusThickness",2);Z([w()],dn.prototype,"sphericalDirectionAmount",2);Z([w()],dn.prototype,"randomDirectionAmount",2);Z([w()],dn.prototype,"randomPositionAmount",2);class gi{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 M)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,i,s,r,o){if(!this.enabled)return;this._noise||(this._noise=mse(()=>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=r/o;let f=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=f*this.strengthXMultiplier,this._temp.y*=f*this.strengthYMultiplier,this._temp.z*=f*this.strengthZMultiplier):(this.strengthX&&(f*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(f)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}Z([w()],gi.prototype,"damping",2);Z([w()],gi.prototype,"enabled",2);Z([w()],gi.prototype,"frequency",2);Z([w()],gi.prototype,"octaveCount",2);Z([w()],gi.prototype,"octaveMultiplier",2);Z([w()],gi.prototype,"octaveScale",2);Z([w(at)],gi.prototype,"positionAmount",2);Z([w()],gi.prototype,"quality",2);Z([w(at)],gi.prototype,"remap",2);Z([w()],gi.prototype,"remapEnabled",2);Z([w()],gi.prototype,"remapMultiplier",2);Z([w(at)],gi.prototype,"remapX",2);Z([w()],gi.prototype,"remapXMultiplier",2);Z([w(at)],gi.prototype,"remapY",2);Z([w()],gi.prototype,"remapYMultiplier",2);Z([w(at)],gi.prototype,"remapZ",2);Z([w()],gi.prototype,"remapZMultiplier",2);Z([w()],gi.prototype,"scrollSpeedMultiplier",2);Z([w()],gi.prototype,"separateAxes",2);Z([w()],gi.prototype,"strengthMultiplier",2);Z([w(at)],gi.prototype,"strengthX",2);Z([w()],gi.prototype,"strengthXMultiplier",2);Z([w(at)],gi.prototype,"strengthY",2);Z([w()],gi.prototype,"strengthYMultiplier",2);Z([w(at)],gi.prototype,"strengthZ",2);Z([w()],gi.prototype,"strengthZMultiplier",2);class Gi{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,i,s){let r=this.widthOverTrail.evaluate(i,s);return e*=r,e}getColor(e,t,i){const s=this.colorOverTrail.evaluate(i),r=this.colorOverLifetime.evaluate(t);e.x*=s.r*r.r,e.y*=s.g*r.g,e.z*=s.b*r.b,e.w*=s.alpha*r.alpha}}Z([w()],Gi.prototype,"enabled",2);Z([w()],Gi.prototype,"attachRibbonToTransform",2);Z([w(Sr)],Gi.prototype,"colorOverLifetime",2);Z([w(Sr)],Gi.prototype,"colorOverTrail",2);Z([w()],Gi.prototype,"dieWithParticles",2);Z([w()],Gi.prototype,"inheritParticleColor",2);Z([w(at)],Gi.prototype,"lifetime",2);Z([w()],Gi.prototype,"lifetimeMultiplier",2);Z([w()],Gi.prototype,"minVertexDistance",2);Z([w()],Gi.prototype,"mode",2);Z([w()],Gi.prototype,"ratio",2);Z([w()],Gi.prototype,"ribbonCount",2);Z([w()],Gi.prototype,"shadowBias",2);Z([w()],Gi.prototype,"sizeAffectsLifetime",2);Z([w()],Gi.prototype,"sizeAffectsWidth",2);Z([w()],Gi.prototype,"splitSubEmitterRibbons",2);Z([w()],Gi.prototype,"textureMode",2);Z([w(at)],Gi.prototype,"widthOverTrail",2);Z([w()],Gi.prototype,"widthOverTrailMultiplier",2);Z([w()],Gi.prototype,"worldSpace",2);class Xi{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 M);u(this,"_temp2",new M);u(this,"_temp3",new M);u(this,"_hasOrbital",!1);u(this,"_index",0);u(this,"_orbitalMatrix",new De)}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,i,s,r,o,a){var p;if(!this.enabled)return;const l=o/a,c=this.speedModifier.evaluate(l)*this.speedModifierMultiplier,h=this.x.evaluate(l),d=this.y.evaluate(l),f=this.z.evaluate(l);if(this._temp.set(-h,d,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((p=this._system)==null?void 0:p.worldPos)){const A=this._temp2.set(i.x,i.y,i.z),v=this.orbitalXMultiplier,g=this.orbitalYMultiplier,b=this.orbitalZMultiplier,y=c*Math.PI*2*10,_=Math.cos(y*v),x=Math.sin(y*v),S=Math.cos(y*g),I=Math.sin(y*g),R=Math.cos(y*b),E=Math.sin(y*b),T=A.x*(S*R)+A.y*(S*E)+A.z*-I,k=A.x*(x*I*R-_*E)+A.y*(x*I*E+_*R)+A.z*(x*S),W=A.x*(_*I*R+x*E)+A.y*(_*I*E-x*R)+A.z*(_*S),U=this._temp3.set(A.x-T,A.y-k,A.z-W);U.normalize(),U.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),s.x+=U.x,s.y+=U.y,s.z+=U.z}s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z,s.x*=c,s.y*=c,s.z*=c}}Z([w()],Xi.prototype,"enabled",2);Z([w()],Xi.prototype,"space",2);Z([w(at)],Xi.prototype,"orbitalX",2);Z([w(at)],Xi.prototype,"orbitalY",2);Z([w(at)],Xi.prototype,"orbitalZ",2);Z([w()],Xi.prototype,"orbitalXMultiplier",2);Z([w()],Xi.prototype,"orbitalYMultiplier",2);Z([w()],Xi.prototype,"orbitalZMultiplier",2);Z([w()],Xi.prototype,"orbitalOffsetX",2);Z([w()],Xi.prototype,"orbitalOffsetY",2);Z([w()],Xi.prototype,"orbitalOffsetZ",2);Z([w(at)],Xi.prototype,"speedModifier",2);Z([w()],Xi.prototype,"speedModifierMultiplier",2);Z([w(at)],Xi.prototype,"x",2);Z([w()],Xi.prototype,"xMultiplier",2);Z([w(at)],Xi.prototype,"y",2);Z([w()],Xi.prototype,"yMultiplier",2);Z([w(at)],Xi.prototype,"z",2);Z([w()],Xi.prototype,"zMultiplier",2);class ys{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 i=this.frameOverTime.evaluate(e%1);return i*=this.frameOverTimeMultiplier,i*=t,i=i%t,i=Math.floor(i),i}}Z([w()],ys.prototype,"animation",2);Z([w()],ys.prototype,"enabled",2);Z([w()],ys.prototype,"cycleCount",2);Z([w(at)],ys.prototype,"frameOverTime",2);Z([w()],ys.prototype,"frameOverTimeMultiplier",2);Z([w()],ys.prototype,"numTilesX",2);Z([w()],ys.prototype,"numTilesY",2);Z([w(at)],ys.prototype,"startFrame",2);Z([w()],ys.prototype,"startFrameMultiplier",2);Z([w()],ys.prototype,"rowMode",2);Z([w()],ys.prototype,"rowIndex",2);Z([w()],ys.prototype,"spriteCount",2);Z([w()],ys.prototype,"timeMode",2);class Qo{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}}Z([w()],Qo.prototype,"enabled",2);Z([w()],Qo.prototype,"separateAxes",2);Z([w(at)],Qo.prototype,"x",2);Z([w()],Qo.prototype,"xMultiplier",2);Z([w(at)],Qo.prototype,"y",2);Z([w()],Qo.prototype,"yMultiplier",2);Z([w(at)],Qo.prototype,"z",2);Z([w()],Qo.prototype,"zMultiplier",2);class to{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 i=et.lerp(this.range.x,this.range.y,t);return this.z.evaluate(i)*-1}return 0}}Z([w()],to.prototype,"enabled",2);Z([w()],to.prototype,"range",2);Z([w()],to.prototype,"separateAxes",2);Z([w(at)],to.prototype,"x",2);Z([w()],to.prototype,"xMultiplier",2);Z([w(at)],to.prototype,"y",2);Z([w()],to.prototype,"yMultiplier",2);Z([w(at)],to.prototype,"z",2);Z([w()],to.prototype,"zMultiplier",2);class Mn{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 M);u(this,"_temp2",new M)}apply(e,t,i,s,r,o,a){if(this.enabled){const l=this.limit.evaluate(r)*this.limitMultiplier;if(t.length()>l){this._temp.copy(t).normalize().multiplyScalar(l);let h=this.dampen*.5;t.x=et.lerp(t.x,this._temp.x,h),t.y=et.lerp(t.y,this._temp.y,h),t.z=et.lerp(t.z,this._temp.z,h),i.x=et.lerp(i.x,this._temp.x,h),i.y=et.lerp(i.y,this._temp.y,h),i.z=et.lerp(i.z,this._temp.z,h)}}}}Z([w()],Mn.prototype,"enabled",2);Z([w()],Mn.prototype,"dampen",2);Z([w(at)],Mn.prototype,"drag",2);Z([w()],Mn.prototype,"dragMultiplier",2);Z([w(at)],Mn.prototype,"limit",2);Z([w()],Mn.prototype,"limitMultiplier",2);Z([w()],Mn.prototype,"separateAxes",2);Z([w(at)],Mn.prototype,"limitX",2);Z([w()],Mn.prototype,"limitXMultiplier",2);Z([w(at)],Mn.prototype,"limitY",2);Z([w()],Mn.prototype,"limitYMultiplier",2);Z([w(at)],Mn.prototype,"limitZ",2);Z([w()],Mn.prototype,"limitZMultiplier",2);Z([w()],Mn.prototype,"multiplyDragByParticleSize",2);Z([w()],Mn.prototype,"multiplyDragByParticleVelocity",2);Z([w()],Mn.prototype,"space",2);class Kh{constructor(){u(this,"enabled");u(this,"curve");u(this,"curveMultiplier");u(this,"mode");u(this,"system");u(this,"_lastWorldPosition");u(this,"_velocity",new M);u(this,"_temp",new M)}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,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const s=this.curve.evaluate(t,i);this._temp.copy(this._velocity).multiplyScalar(s),e.add(this._temp)}}}Z([w()],Kh.prototype,"enabled",2);Z([w(at)],Kh.prototype,"curve",2);Z([w()],Kh.prototype,"curveMultiplier",2);Z([w()],Kh.prototype,"mode",2);class sr{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,i,s){const r=e.length(),o=et.remap(r,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,i);return s*a}}Z([w()],sr.prototype,"enabled",2);Z([w(K)],sr.prototype,"range",2);Z([w()],sr.prototype,"separateAxes",2);Z([w(at)],sr.prototype,"size",2);Z([w()],sr.prototype,"sizeMultiplier",2);Z([w(at)],sr.prototype,"x",2);Z([w()],sr.prototype,"xMultiplier",2);Z([w(at)],sr.prototype,"y",2);Z([w()],sr.prototype,"yMultiplier",2);Z([w(at)],sr.prototype,"z",2);Z([w()],sr.prototype,"zMultiplier",2);class wd{constructor(){u(this,"enabled");u(this,"range");u(this,"color")}evaluate(e,t,i){const s=e.length(),r=et.remap(s,this.range.x,this.range.y,0,1),o=this.color.evaluate(r,t);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}Z([w()],wd.prototype,"enabled",2);Z([w(K)],wd.prototype,"range",2);Z([w(Sr)],wd.prototype,"color",2);function yse(n){const e=n.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 i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const r=document.createElement("img");return r.id="button",s.appendChild(r),n.domElement.appendChild(t),s}function bse(){var n=new Date;const e=n.getMonth()+1,t=n.getDate(),i=n.getHours(),s=n.getMinutes(),r=n.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,l=(i<10?"0":"")+i,c=(s<10?"0":"")+s,h=(r<10?"0":"")+r;return n.getFullYear()+o+a+"-"+l+c+h}const x0=se("debugusdz");function _se(n,e){const t=[],i=$.getComponentsInChildren(n,ir);let s=!1;x0&&console.log(i);for(const r of i){if(!r||!r.runtimeAnimatorController)continue;x0&&console.log(r);const o=[];for(const a of r.runtimeAnimatorController.enumerateActions()){x0&&console.log(a);const l=a.getClip();if(!s&&l.tracks.length>0){s=!0;const c=l.tracks[0],h=c.name.substring(0,c.name.lastIndexOf(".")),d=new qr(h+".position",[0,.01],[0,0,0,0,0,0]),f=new qr(h+".quaternion",[0,.01],[0,0,0,1,0,0,0,1]);o.push(new Ks("rest",.01,[d,f]))}o.includes(l)||o.push(l)}t.push({root:r.gameObject,clips:o})}x0&&console.log(t);for(const r of t)for(const o of r.clips)e.registerAnimation(r.root,o)}var xse=Object.defineProperty,wse=Object.getOwnPropertyDescriptor,Ec=(n,e,t,i)=>{for(var s=i>1?void 0:i?wse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&xse(e,t,s),s};const fu=se("debugtext");var Bn=(n=>(n[n.UpperLeft=0]="UpperLeft",n[n.UpperCenter=1]="UpperCenter",n[n.UpperRight=2]="UpperRight",n[n.MiddleLeft=3]="MiddleLeft",n[n.MiddleCenter=4]="MiddleCenter",n[n.MiddleRight=5]="MiddleRight",n[n.LowerLeft=6]="LowerLeft",n[n.LowerCenter=7]="LowerCenter",n[n.LowerRight=8]="LowerRight",n))(Bn||{}),KG=(n=>(n[n.Normal=0]="Normal",n[n.Bold=1]="Bold",n[n.Italic=2]="Italic",n[n.BoldAndItalic=3]="BoldAndItalic",n))(KG||{});class rr extends yd{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(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;(t=this.uiObject)==null||t.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var t;this.uiObject&&((t=this.Canvas)!=null&&t.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var i;const t=(i=this.uiObject)==null?void 0:i._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(t){fu&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,fu&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),fu&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let t=this.fontSize;const i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var s,r,o;if(fu&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let a=this.getNextTag(t);if(a){if(a.startIndex>0){for(let h=this.uiObject.children.length-1;h>=0;h--){const d=this.uiObject.children[h];d.isUI&&(this.uiObject.remove(d),d.clear())}const c=new Bb({textContent:t.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(c)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const l=[];for(;a;){const c=this.getNextTag(t,a.endIndex),h={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(c){h.textContent=this.getText(t,a,c),this.handleTag(a,h,l);const d=new Bb(h);(r=this.uiObject)==null||r.add(d)}else{h.textContent=t.substring(a.endIndex),this.handleTag(a,h,l);const d=new Bb(h);(o=this.uiObject)==null||o.add(d)}a=c}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,s={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(t[o]===!0)continue;r=!0;const a=this._textMeshUi[o];a.textContent&&(D_(a,s),t[o]=!0)}if(!r)break;yield}}handleTag(t,i,s){if(!t.isEndTag){if(t.type.includes("color")){const r=new QC(t,{color:i.color});if(s.push(r),t.type.length>6){const o=parseInt("0x"+t.type.substring(7));i.color=o}else i.color=new ve(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const r=new QC(t,{fontWeight:700});s.push(r)}else if(t.type=="i"){this.setFont(i,2);const r=new QC(t,{fontStyle:"italic"});s.push(r)}}}getText(t,i,s){return t.substring(i.endIndex,s.startIndex)}getNextTag(t,i=0){const s=t.indexOf("<",i),r=t.indexOf(">",s);if(s>=0&&r>=0){const o=t.substring(s+1,r);return{type:o,startIndex:s,endIndex:r+1,isEndTag:o.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;let s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,i);fu&&console.log("Selected font family:"+r);let o=pM.getFontFamily(r);switch(o||(o=pM.addFontFamily(r)),t.fontFamily=o,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let a=o.getVariant(t.fontWeight,t.fontStyle);if(!a){let l=r;l!=null&&l.endsWith("-msdf.json")||(l+="-msdf.json");let c=r;c!=null&&c.endsWith(".png")||(c+=".png"),a=o.addVariant(t.fontWeight,t.fontStyle,l,c),a==null||a.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var h;const s=t.lastIndexOf("-");if(s<0)return t;const r=(h=t.substring(s+1))==null?void 0:h.toLowerCase();if(Sse.includes(r))return fu&&console.warn("Unsupported font style: "+r),t;const o=t.lastIndexOf("/");let a=t;o>=0&&(a=a.substring(o+1));let l=a[0]===a[0].toUpperCase();const c=t.substring(0,s);switch(fu&&console.log("Select font: ",t,KG[i],a,l,c),i){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 t}}}Ec([w()],rr.prototype,"alignment",2);Ec([w()],rr.prototype,"verticalOverflow",2);Ec([w()],rr.prototype,"horizontalOverflow",2);Ec([w()],rr.prototype,"lineSpacing",2);Ec([w()],rr.prototype,"supportRichText",2);Ec([w(URL)],rr.prototype,"font",2);Ec([w()],rr.prototype,"fontStyle",2);Ec([w()],rr.prototype,"text",1);Ec([w()],rr.prototype,"fontSize",1);class QC{constructor(e,t){u(this,"tag");u(this,"previousValues");this.tag=e,this.previousValues=t}}const Sse=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class dh{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 i=this.font.map(r=>`"${r}"`).join(", ");t.appendLine(`string[] font = [ ${i} ]`),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(dh,"global_id",0);class kw{static singleLine(e,t,i){const s=new dh("text_"+dh.getId());return s.content=e,t&&(s.pointSize=t),i&&(s.depth=i),s}static multiLine(e,t,i,s,r,o){const a=new dh("text_"+dh.getId());return a.content=e,a.width=t,a.height=i,a.horizontalAlignment=s,a.verticalAlignment=r,o!==void 0&&(a.wrapMode=o),a}}const Cse=new De().makeRotationY(Math.PI),Ese=new De().makeScale(-1,1,-1);class Gv{get extensionName(){return"text"}onExportObject(e,t,i){}exportText(e,t,i){const s=$.getComponent(e,rr);if(!s)return;const r=$.getComponent(e,fs);let o=100,a=100;r&&(o=r.width,a=r.height),t.matrix=Cse.clone(),r&&t.matrix.premultiply(Ese);const l=new ve().copySRGBToLinear(s.color);t.material=new fa({color:l,emissive:l}),t.addEventListener("serialize",(c,h)=>{let d=s.text;d=d.replace(/\n/g,"\\n");const f=kw.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(f,s.alignment),this.setOverflow(f,s),t.material&&(f.material=t.material),f.pointSize=this.convertToTextSize(s.fontSize),f.depth=.001,f.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 Bn.LowerLeft:case Bn.MiddleLeft:case Bn.UpperLeft:e.horizontalAlignment="left";break;case Bn.LowerCenter:case Bn.MiddleCenter:case Bn.UpperCenter:e.horizontalAlignment="center";break;case Bn.LowerRight:case Bn.MiddleRight:case Bn.UpperRight:e.horizontalAlignment="right";break}switch(t){case Bn.LowerLeft:case Bn.LowerCenter:case Bn.LowerRight:e.verticalAlignment="bottom";break;case Bn.MiddleLeft:case Bn.MiddleCenter:case Bn.MiddleRight:e.verticalAlignment="middle";break;case Bn.UpperLeft:case Bn.UpperCenter:case Bn.UpperRight:e.verticalAlignment="top";break}}}class Ow{get extensionName(){return"tmui"}onExportObject(e,t,i){const s=$.getComponent(e,ps);if(s&&s.activeAndEnabled&&s.renderMode===XG.WorldSpace){const r=new Gv,o=$.getComponent(e,fs),a=$.getComponent(e,Ph);if(o){o.width,o.height;const l=mr.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const h=c.matrix;l.matrix.copy(h);const d=new Map,f=new Map;d.set(c,l),f.set(c,a?a.alpha:1),c.traverse(p=>{if(p===c)return;const m=mr.createEmpty();m.matrix.copy(p.matrix);const A=p.parent,v=A&&typeof A.textContent=="string"&&A.textContent.length;let g=f.get(A)||1;const b=$.getComponent(p,Ph);if(b&&(g*=b.alpha),p instanceof ye&&v){const _=p[Ga].gameObject;r.exportText(_,m,i)}if(p instanceof ye&&!v){const _=p.geometry.clone();_.scale(1,1,-1),this.flipWindingOrder(_),m.geometry=_;const x=new ve,S=p.material.opacity;x.copy(p.material.color),m.material=new fi({color:x,opacity:S*g,map:p.material.map,transparent:!0})}d.set(p,m),f.set(p,g);const y=d.get(A);if(!y){console.error("Error when exporting UI: shadow component parent not found!",p,p.parent);return}y.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let i=0,s=t.length/3;i<s;i++){let r=t[i*3];t[i*3]=t[i*3+2],t[i*3+2]=r}e.index.needsUpdate=!0}}var Mse=Object.defineProperty,Tse=Object.getOwnPropertyDescriptor,io=(n,e,t,i)=>{for(var s=i>1?void 0:i?Tse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Mse(e,t,s),s};const zn=se("debugusdz");class Jh{constructor(){u(this,"callToAction");u(this,"checkoutTitle");u(this,"checkoutSubtitle");u(this,"callToActionURL")}}io([w()],Jh.prototype,"callToAction",2);io([w()],Jh.prototype,"checkoutTitle",2);io([w()],Jh.prototype,"checkoutSubtitle",2);io([w()],Jh.prototype,"callToActionURL",2);class no extends we{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",t=>{t.preventDefault(),this.exportAsync()});u(this,"lastCallback");u(this,"_quicklookButton");u(this,"_quicklookButtonContainer",null)}start(){var t,i,s;zn&&(console.log(this),console.log("Debug USDZ, press 't' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),Dh()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((i=(t=this.objectToExport)==null?void 0:t.children)!=null&&i.length)&&!((s=this.objectToExport)!=null&&s.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Iw),this.extensions.push(new Mw),this.extensions.push(new Gv),this.extensions.push(new Ow))}onEnable(){var s;const t=hA(),i=Gl();(zn||t&&i)&&((zn||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=yse(this.context),this.link.addEventListener("message",this.lastCallback)),zn&&yn("USDZ Exporter enabled: "+this.name),(s=document.getElementById("open-in-ar"))==null||s.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var s,r;(s=this.link)==null||s.removeEventListener("message",this.lastCallback);const t=hA(),i=Gl();(zn||t&&i)&&this.removeQuicklookButton(),zn&&yn("USDZ Exporter disabled: "+this.name),(r=document.getElementById("open-in-ar"))==null||r.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var A;let t=this.exportFileName??((A=this.objectToExport)==null?void 0:A.name)??this.name;if(ip()||(t+="-MadeWithNeedle"),t+="-"+bse(),this.customUsdzFile){zn&&console.log("Exporting custom usdz",this.customUsdzFile);const v=this.buildQuicklookOverlay();zn&&console.log(v);const g=v.callToAction?encodeURIComponent(v.callToAction):"",b=v.checkoutTitle?encodeURIComponent(v.checkoutTitle):"",y=v.checkoutSubtitle?encodeURIComponent(v.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${g}&checkoutTitle=${b}&checkoutSubtitle=${y}&callToActionURL=${v.callToActionURL}`,zn&&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 i=$.getComponentsInChildren(this.objectToExport,Ui),s=new Array;for(const v of i)for(const g of v.sharedMaterials)if(g){const b=v.loadProgressiveTextures(g);b instanceof Promise&&s.push(b)}zn&&yn("Load textures: "+s.length),await Promise.all(s),zn&&yn("Load textures: done"),this.applyWebARSessionRoot();const r=new EJ,o=[...this.extensions],a=new cw;o.push(a),this.autoExportAnimations&&_se(this.objectToExport,a);const l={self:this,exporter:r,extensions:o,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:l})),r.debug=zn,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 r.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();zn&&console.log(d);const f=d.callToAction?encodeURIComponent(d.callToAction):"",p=d.checkoutTitle?encodeURIComponent(d.checkoutTitle):"",m=d.checkoutSubtitle?encodeURIComponent(d.checkoutSubtitle):"";this.link.href=URL.createObjectURL(h)+`#callToAction=${f}&checkoutTitle=${p}&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(t){if((t==null?void 0:t.data)=="_apple_ar_quicklook_button_tapped"){zn&&Fo("Quicklook closed via call to action button");var i=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(i),!i.defaultPrevented){const s=new URLSearchParams(this.link.href);if(s){const r=s.get("callToActionURL");zn&&yn("Quicklook url: "+r),r&&(ip()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var s,r,o,a,l,c;const t={};return this.customBranding&&Object.assign(t,this.customBranding),ip()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),t.callToAction="Close",t.checkoutTitle="🌵 Made with Needle",t.checkoutSubtitle="_"),(((s=t.callToAction)==null?void 0:s.length)||((r=t.checkoutTitle)==null?void 0:r.length)||((o=t.checkoutSubtitle)==null?void 0:o.length))&&((a=t.callToAction)!=null&&a.length||(t.callToAction="\0"),(l=t.checkoutTitle)!=null&&l.length||(t.checkoutTitle="\0"),(c=t.checkoutSubtitle)!=null&&c.length||(t.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:t})),t}async createQuicklookButton(){var t,i;if(!this.webxr)if(await ZA(1),this.webxr=$.findObjectOfType(St)??void 0,this.webxr)if(this.webxr.VRButton&&((t=this.webxr.VRButton.parentElement)==null||t.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const s=(i=this.webxr.ARButton.parentElement)==null?void 0:i.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",Dt.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var t;(t=this._quicklookButton)==null||t.remove()}applyWebARSessionRoot(){if(zn&&console.log("applyWebARSessionRoot"),!this.objectToExport)return;let t=$.getComponentInParent(this.objectToExport,rl);const i=t!=null;if(t||(t=$.getComponentInChildren(this.objectToExport,rl)),!t){zn&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const s=i?this.objectToExport:t.gameObject,r=1/t.arScale;zn&&console.log("Scale",r,s),s.matrix.makeScale(r,r,r),t.invertForward&&s.matrix.multiply(new De().makeRotationY(Math.PI))}}io([w(ke)],no.prototype,"objectToExport",2);io([w()],no.prototype,"autoExportAnimations",2);io([w()],no.prototype,"exportFileName",2);io([w(URL)],no.prototype,"customUsdzFile",2);io([w(Jh)],no.prototype,"customBranding",2);io([w()],no.prototype,"anchoringType",2);io([w()],no.prototype,"planeAnchoringAlignment",2);io([w()],no.prototype,"interactive",2);io([w()],no.prototype,"allowCreateQuicklookButton",2);const ck=se("debugdeletable");class Lw extends To{}class MR extends we{constructor(){super(...arguments);u(this,"deleteBoxes",[])}awake(){this.deleteBoxes=$.findObjectsOfType(Lw,this.context)}update(){for(const t of this.deleteBoxes){const i=this.gameObject;if(t.isInBox(i)===!0){const r=$.getComponentInParent(this.gameObject,Yp);r?ck&&console.warn("Can not delete object with usage marker",this.guid,r):(ck&&console.log("DESTROY",this.gameObject),Xx(this.gameObject,this.context.connection))}}}}var Ise=Object.defineProperty,Rse=Object.getOwnPropertyDescriptor,Sd=(n,e,t,i)=>{for(var s=i>1?void 0:i?Rse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ise(e,t,s),s};class xa extends Ds{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=i=>{const s=i/300,r=2;return et.lerp(r,.01,s)};const t=20;this.aperture.valueProcessor=i=>{const s=1-i/32;return et.lerp(1,t,s)}}onCreateEffect(){if(this.mode===0)return;const t=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;Dh()&&(s=.6),this.resolutionScale=new Tt(s*t)}const i=new e3(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{i.circleOfConfusionMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>i.circleOfConfusionMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>i.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>i.resolution.scale=s),[i]}unapply(){}}Sd([w()],xa.prototype,"mode",2);Sd([w(Tt)],xa.prototype,"focusDistance",2);Sd([w(Tt)],xa.prototype,"focalLength",2);Sd([w(Tt)],xa.prototype,"aperture",2);Sd([w(Tt)],xa.prototype,"gaussianMaxRadius",2);Sd([w(Tt)],xa.prototype,"resolutionScale",2);Sd([w(Tt)],xa.prototype,"bokehScale",2);Ho("DepthOfField",xa);var Pse=Object.defineProperty,Bse=Object.getOwnPropertyDescriptor,Dse=(n,e,t,i)=>{for(var s=i>1?void 0:i?Bse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Pse(e,t,s),s};class Fw extends we{constructor(){super(...arguments);u(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||$.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:kse()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}Dse([w()],Fw.prototype,"visibleOn",2);let w0;function kse(){if(w0===!0||w0===!1)return w0;let n=!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)))&&(n=!0)}(navigator.userAgent||navigator.vendor||window.opera),w0=n,n}class TR{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var Ose=Object.defineProperty,Lse=Object.getOwnPropertyDescriptor,JG=(n,e,t,i)=>{for(var s=i>1?void 0:i?Lse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ose(e,t,s),s},ZG=(n=>(n.SelectStart="selectstart",n.SelectEnd="selectend",n))(ZG||{}),sb;const sh=(sb=class extends qp{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 K}static get HasAnySelected(){return this._active>0}addDragEventListener(e,t){switch(e){case"selectstart":this.selectStartEventListener.push(t);break;case"selectend":this.selectEndEventListener.push(t);break}}start(){this.orbit=$.findObjectOfType(xc,this.context),this.gameObject.getComponentInParent(mc)||this.gameObject.addNewComponent(mc)}allowEdit(e=null){return this.context.connection.allowEditing}onPointerEnter(e){if(!this.allowEdit(this.gameObject)||St.IsInWebXR)return;const t=$.getComponentInParent(e.object,sh);!t||t!==this||(sh.lastHovered=e.object,this.context.domElement.style.cursor="pointer")}onPointerExit(e){this.allowEdit(this.gameObject)&&(St.IsInWebXR||sh.lastHovered===e.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(e){this.allowEdit(this.gameObject)&&(St.IsInWebXR||(sh._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=e.clone(),e.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(e){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(sh._active>0&&(sh._active-=1),!St.IsInWebXR&&(this.onDragEnd(e),e.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var e;if(!St.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const i=this.context.input.getPointerPositionDelta(0);if(i&&this._dragDelta.add(i),this._dragDelta.length()>2)this._didDrag=!0;else return}const t=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(t)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((e=this._dragHelper)==null?void 0:e.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(e){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new Ob(this.context.mainCamera);else return;if(!e||!e.object)return;const t=$.getComponentInParent(e.object,sh);if(!t||t!==this)return;let i=e.object;this.transformSelf&&(i=this.gameObject);const s={selected:i,attached:i};for(const l of this.selectStartEventListener)l(this,s);if(this._activePointerId=e.pointerId,!s.attached)return;s.attached,i=s.attached,this._isDragging=!0,this._dragHelper.setSelected(i,this.context),this.orbit&&(this.orbit.enabled=!1);const r=$.getComponentInChildren(i,Th);r&&(r.fastMode=!0,r==null||r.requestOwnership()),this._marker=$.addNewComponent(i,Yp),this._draggingRigidbodies.length=0;const o=$.getComponentsInChildren(i,ji);o&&this._draggingRigidbodies.push(...o);const a=qb();$.invokeOnChildren(this._dragHelper.selected,a("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities()}}onDragEnd(e){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 t=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),e!=null&&e.object){const s=$.getComponentInChildren(e.object,Th);s&&(s.fastMode=!1)}this._marker&&this._marker.destroy();for(const s of this.selectEndEventListener)s(this);const i=qb();$.invokeOnChildren(t,i("onDragEnd"))}},u(sb,"_active",0),u(sb,"lastHovered"),sb);let dm=sh;JG([w()],dm.prototype,"showGizmo",2);JG([w()],dm.prototype,"useViewAngle",2);const AP=class{constructor(e){u(this,"showGizmo",!0);u(this,"useViewAngle",!0);u(this,"_selected",null);u(this,"_context",null);u(this,"_camera");u(this,"_cameraPlane",new Co);u(this,"_hasGroundPlane",!1);u(this,"_groundPlane",new Co);u(this,"_groundOffset",new M);u(this,"_groundOffsetFactor",0);u(this,"_groundDistance",0);u(this,"_groundPlanePoint",new M);u(this,"_raycaster",new Fp);u(this,"_cameraPlaneOffset",new M);u(this,"_intersection",new M);u(this,"_worldPosition",new M);u(this,"_inverseMatrix",new De);u(this,"_rbs",[]);u(this,"_groundLine");u(this,"_groundMarker");u(this,"_groundOffsetVector",new M(0,1,0));u(this,"_requireUpdateGroundPlane",!0);u(this,"_didDragOnGroundPlaneLastFrame",!1);this._camera=e;const t=new ln(AP.geometry),i=t.material;i.color=new ve(.4,.4,.4),t.layers.set(2),t.name="line",t.scale.y=1,this._groundLine=t;const s=new No(.5,22,22),r=new fi({color:i.color}),o=new ye(s,r);o.visible=!1,o.layers.set(2),this._groundMarker=o}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(e,t){if(this._selected&&t)for(const i of this._rbs)i.wakeUp(),i.setVelocity(0,0,0);if(this._selected&&Zs.Remove(t,this._selected),this._selected=e,this._context=t,this._rbs.length=0,e?(t.scene.add(this._groundLine),t.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!t){console.error("DragHelper: no context");return}Zs.Add(t,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(e){var a,l,c,h,d;if(!this._context)return;const t="Space",i="KeyD",s=((a=this._context)==null?void 0:a.input.isKeyPressed(t))||((l=this._context)==null?void 0:l.input.isKeyPressed(i)),r=this._context.input.getTouchesPressedCount()>=2||s;if(r){const f=this._context.input.getPointerPositionDelta(0);f&&(this._groundOffsetVector.set(0,1,0),(c=this._selected)==null||c.rotateOnWorldAxis(this._groundOffsetVector,f.x*this._context.time.deltaTime))}const o=this._context.input.getPointerPositionRC(0);if(o&&(this._raycaster.setFromCamera(o,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const f=xt(this._camera).clone().sub(xt(this._selected)).normalize(),p=Math.abs(f.dot(this._groundOffsetVector)),m=((h=this._context)==null?void 0:h.input.isKeyPressed(t))||((d=this._context)==null?void 0:d.input.isKeyPressed(i));let A=!this.useViewAngle||p>.2;(r||m||this._context.input.getPointerPressedCount()>1)&&(A=!1);const v=this._didDragOnGroundPlaneLastFrame!==A;if(this._didDragOnGroundPlaneLastFrame=A,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!A||v)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const g=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=g,A){this._groundOffsetVector.set(0,1,0);const b=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(b,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(e,t,i){if(this._selected){if(i){const s=xt(this._selected);s.y=e.y,e=s}if(hn(this._selected,e),hn(this._groundLine,e),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=t!==null&&this.showGizmo,t){const s=xt(this._camera).distanceTo(t)*.01;this._groundMarker.scale.set(s,s,s),hn(this._groundMarker,t)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const e=this._context.input.getPointerPositionRC(0);e&&(this._raycaster.setFromCamera(e,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 e=xt(this._selected),t=new ol(new M(0,.1,0).add(e),new M(0,-1,0)),i=new va;i.ignore=[this._selected];const s=this._context.physics.raycastFromRay(t,i);for(let r=0;r<s.length;r++){const o=s[r];if(!o.face||this.contains(this._selected,o.object))continue;const a=new M(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(a,o.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(t.direction.multiplyScalar(-1),t.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(e),this._groundOffset.copy(this._intersection).sub(e)}onDidUpdate(){vr.markDirty(this._selected);for(const e of this._rbs)e.wakeUp(),e.resetForcesAndTorques(),e.setAngularVelocity(0,0,0)}contains(e,t){if(e===t)return!0;if(e.children){for(const i of e.children)if(this.contains(i,t))return!0}return!1}};let Ob=AP;u(Ob,"geometry",new wt().setFromPoints([new M(0,0,0),new M(0,-1,0)]));function IR(n,e,t){console.warn("Adding components on object has been temporarily disabled")}var $G=(n=>(n.File_Spawned="file-spawned",n))($G||{});class e4{constructor(e,t,i,s,r,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=i,this.file_name=s,this.file_hash=r,this.file_size=o,this.position=a,this.sender=e,this.serverUrl=l}}async function t4(n,e,t){const i=n.name;return i.endsWith(".gltf")||i.endsWith(".glb")?new Promise((s,r)=>{const o=new FileReader;o.readAsArrayBuffer(n),o.onloadend=async a=>{const l=o.result,c=qx(),h=new Js(c),d=await pa().parseSync(e,l,n.name,h);if(d&&d.scene){const f=d.scene;if(!f.guid){const p=new Js(c);f.guid=p.generateUUID()}t&&Fse(e.connection,n,c,f,t),IR(),s(d)}}}):(console.warn("Unsupported file type: "+i,n),null)}async function i4(n,e){return new Promise(async(t,i)=>{const s=qx(),r=new Js(s),o=n.toString(),a=await pa().loadSync(e,o,o,r);a&&a.scene?(a.scene,IR(),t(a)):console.warn("Unsupported file type: "+n.toString())})}Li.registerCallback(Ws.ContextCreated,n=>{n4(n.context)});function n4(n){n.connection.beginListen("file-spawned",async e=>{if(e.sender!==n.connection.connectionId){console.log("received file event",e),Use(e,n);let t=null;try{t=await fI(e.file_name,e.file_hash,e.file_size,e.serverUrl)}finally{Nse(e)}if(t){const i=new Js(e.seed),s=await pa().parseSync(n,t,e.file_name,i);if(s&&s.scene){const r=s.scene;if(IR(),e.parentGuid){const o=mv(e.parentGuid,n.scene);o&&"add"in o&&o.add(r)}r.parent||n.scene.add(r),e.position!==null&&r.position.copy(e.position)}}else console.error("download didnt return file")}})}async function Fse(n,e,t,i,s){if(!n.connectionId){console.error("Can not upload file - no connection id");return}if(!i.guid){console.error("Can not upload file - no guid",i,i.guid);return}const r=await u3(e,s);if(!r)return;if(!r.filename){console.error("Can not send upload event - no filename",e.name);return}if(!r.hash){console.error("Can not send upload event - no hash",e.name);return}const o=new e4(n.connectionId,t,i.guid,r.filename,r.hash,e.size,i.position,r.url??s);i.parent&&(o.parentGuid=i.parent.guid),n.send("file-spawned",o)}const vM={};function Use(n,e){const t=new Ai,i=new ye(t,new fi({color:65280})),s=new Bx(i,5592405);if(vM[n.guid]=s,e.scene.add(s),n.parentGuid){const r=mv(n.parentGuid,e.scene);r&&r.add(s)}n.position&&s.position.copy(n.position)}function Nse(n,e){const t=n.guid,i=vM[t];i&&(delete vM[t],i.removeFromParent())}var zse=Object.defineProperty,Gse=Object.getOwnPropertyDescriptor,RR=(n,e,t,i)=>{for(var s=i>1?void 0:i?Gse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&zse(e,t,s),s};const Hse=se("debugnet"),yM=class extends we{constructor(){super(...arguments);u(this,"url",null);u(this,"urlParameterName",null);u(this,"localhost",null)}awake(){Hse&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let e=this.url?yM.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const r=se(this.urlParameterName);r&&typeof r=="string"&&(e=r)}if(!e)return null;const i=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(e);return i!=null&&i.groups?(i==null?void 0:i.groups.socket_prefix)?e:"wss://"+(i==null?void 0:i.groups.url):null}static GetUrl(e,t){let i=e;const s=yM.IsLocalNetwork()&&t;return s&&(i=t),e!=null&&e.startsWith("/")&&(i=(s?i:window.location.origin)+e),i}static IsLocalNetwork(e=window.location.hostname){return $s(e)}};let Cd=yM;RR([w()],Cd.prototype,"url",2);RR([w()],Cd.prototype,"urlParameterName",2);RR([w()],Cd.prototype,"localhost",2);var Qse=Object.defineProperty,Vse=Object.getOwnPropertyDescriptor,s4=(n,e,t,i)=>{for(var s=i>1?void 0:i?Vse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qse(e,t,s),s};const ff=se("debugdroplistener");class Hv extends we{constructor(){super(...arguments);u(this,"filesBackendUrl");u(this,"localhost");u(this,"onDrag",t=>{t.preventDefault()});u(this,"onDrop",async t=>{if(ff&&console.log(t),!t.dataTransfer)return;t.preventDefault();const i=t.dataTransfer.items;if(i)for(const s in i){const r=i[s];if(r.kind==="file"){const o=r.getAsFile();if(!o)continue;await this.addFiles(o)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(async o=>{ff&&console.log("dropped url",o);try{const a=new URL(o);if(!a)return;const l=await i4(a,this.context);l&&this.addObject(t,l)}catch{console.log("dropped string is not a valid URL!",o)}})}})}onEnable(){this.filesBackendUrl=Cd.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,ff&&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(...t){if(ff&&console.log("Add files",t),!!Array.isArray(t)&&t.length)for(const i of t){if(!i)continue;ff&&console.log("Register file "+i.name+" to",this.filesBackendUrl,i);const s=await t4(i,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:i})),s&&this.addObject(void 0,s)}}async addObject(t,i){ff&&console.log("Dropped",i);const s=i.scene;if(t!==void 0){const r=new va;r.setMask(16777215),r.screenPointFromOffset(t.offsetX,t.offsetY);const o=this.context.physics.raycast(r);if(o&&o.length>0)for(const a of o){s.position.copy(a.point);break}}this.gameObject.add(s),this.dispatchEvent(new CustomEvent("object-added",{detail:i}))}}s4([w()],Hv.prototype,"filesBackendUrl",2);s4([w()],Hv.prototype,"localhost",2);var Wse=Object.defineProperty,jse=Object.getOwnPropertyDescriptor,Uw=(n,e,t,i)=>{for(var s=i>1?void 0:i?jse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Wse(e,t,s),s};class Ed extends qp{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 i,s;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((i=this.object.position)==null?void 0:i.clone())??new M(0,0,0),this._startQuaternion=((s=this.object.quaternion)==null?void 0:s.clone())??new Le(0,0,0,1)}const t=$.getComponentInParent(this.gameObject,dm);t?t.addDragEventListener(ZG.SelectStart,(r,o)=>{if(this._currentCount>=this.limitCount){o.attached=null;return}const a=this.handleDuplication(o.selected);a&&(console.assert(a!==o.selected,"Duplicated object is original"),o.attached=a)}):console.warn("Could no find drag controls in parent",this.name),Ji.addEventListener(Nl.SelectStart,(r,o)=>{if(this._currentCount>=this.limitCount){o.grab=null;return}const a=this.handleDuplication(o.selected);a&&(o.grab=a)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(t){var i;if(this._currentCount>=this.limitCount||!this.object)return null;if(t===this.gameObject||this.handleMultiObject(t)){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 sl;this.parent||(this.parent=this.gameObject.parent),this.parent&&(s.parent=this.parent.guid??((i=this.parent.userData)==null?void 0:i.guid),s.keepWorldPosition=!0),s.position=this.worldPosition,s.rotation=this.worldQuaternion,s.context=this.context,this._currentCount+=1;const r=$.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(t){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,t):!1}isInChildren(t,i){if(!t)return!1;if(t===i)return!0;if(t.children){for(let s of t.children)if(this.isInChildren(s,i))return!0}return!1}}Uw([w(ke)],Ed.prototype,"parent",2);Uw([w(ke)],Ed.prototype,"object",2);Uw([w()],Ed.prototype,"limitCount",2);Uw([w()],Ed.prototype,"limitInterval",2);var kf=(n=>(n[n.PointerEnter=0]="PointerEnter",n[n.PointerExit=1]="PointerExit",n[n.PointerDown=2]="PointerDown",n[n.PointerUp=3]="PointerUp",n[n.PointerClick=4]="PointerClick",n[n.Drag=5]="Drag",n[n.Drop=6]="Drop",n[n.Scroll=7]="Scroll",n[n.UpdateSelected=8]="UpdateSelected",n[n.Select=9]="Select",n[n.Deselect=10]="Deselect",n[n.Move=11]="Move",n[n.InitializePotentialDrag=12]="InitializePotentialDrag",n[n.BeginDrag=13]="BeginDrag",n[n.EndDrag=14]="EndDrag",n[n.Submit=15]="Submit",n[n.Cancel=16]="Cancel",n))(kf||{}),Xse=Object.defineProperty,qse=Object.getOwnPropertyDescriptor,PR=(n,e,t,i)=>{for(var s=i>1?void 0:i?qse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Xse(e,t,s),s};class BR{constructor(){u(this,"eventID");u(this,"callback")}}PR([w()],BR.prototype,"eventID",2);PR([w(yr)],BR.prototype,"callback",2);class Nw extends we{constructor(){super(...arguments);u(this,"triggers")}invoke(t){if(this.triggers)for(const i of this.triggers)i.eventID===t&&i.callback.invoke()}onPointerClick(t){this.invoke(kf.PointerClick)}onPointerEnter(t){this.invoke(kf.PointerEnter)}onPointerExit(t){this.invoke(kf.PointerExit)}onPointerDown(t){this.invoke(kf.PointerDown)}onPointerUp(t){this.invoke(kf.PointerUp)}}PR([w(BR)],Nw.prototype,"triggers",2);var Yse=Object.defineProperty,Kse=Object.getOwnPropertyDescriptor,DR=(n,e,t,i)=>{for(var s=i>1?void 0:i?Kse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yse(e,t,s),s};class kR extends we{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)}}DR([w(ji)],kR.prototype,"connectedBody",2);class OR extends kR{createJoint(e,t){var i;(i=this.context.physics.engine)==null||i.addFixedJoint(e,t)}}class Qv extends kR{constructor(){super(...arguments);u(this,"anchor");u(this,"axis")}createJoint(t,i){var s;this.axis&&this.anchor&&((s=this.context.physics.engine)==null||s.addHingeJoint(t,i,this.anchor,this.axis))}}DR([w(M)],Qv.prototype,"anchor",2);DR([w(M)],Qv.prototype,"axis",2);const Jse={type:"change"};let Zse=class extends Un{constructor(e,t){super(),this.object=e,this.domElement=t,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const i=this,s=1e-6,r=new Le,o=new M;this.tmpQuaternion=new Le,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 M(0,0,0),this.rotationVector=new M(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 m=this.getContainerDimensions(),A=m.size[0]/2,v=m.size[1]/2;this.moveState.yawLeft=-(p.pageX-m.offset[0]-A)/A,this.moveState.pitchDown=(p.pageY-m.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 m=p*i.movementSpeed,A=p*i.rollSpeed;i.object.translateX(i.moveVector.x*m),i.object.translateY(i.moveVector.y*m),i.object.translateZ(i.moveVector.z*m),i.tmpQuaternion.set(i.rotationVector.x*A,i.rotationVector.y*A,i.rotationVector.z*A,1).normalize(),i.object.quaternion.multiply(i.tmpQuaternion),(o.distanceToSquared(i.object.position)>s||8*(1-r.dot(i.object.quaternion))>s)&&(i.dispatchEvent(Jse),r.copy(i.object.quaternion),o.copy(i.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",a),this.domElement.removeEventListener("pointerdown",c),this.domElement.removeEventListener("pointermove",l),this.domElement.removeEventListener("pointerup",h),window.removeEventListener("keydown",d),window.removeEventListener("keyup",f)};const a=this.contextMenu.bind(this),l=this.pointermove.bind(this),c=this.pointerdown.bind(this),h=this.pointerup.bind(this),d=this.keydown.bind(this),f=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",a),this.domElement.addEventListener("pointerdown",c),this.domElement.addEventListener("pointermove",l),this.domElement.addEventListener("pointerup",h),window.addEventListener("keydown",d),window.addEventListener("keyup",f),this.updateMovementVector(),this.updateRotationVector()}};class LR extends we{constructor(){super(...arguments);u(this,"_controls",null)}onEnable(){var i;const t=(i=$.getComponent(this.gameObject,Ni))==null?void 0:i.cam;this._controls=new Zse(t,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var t;(t=this._controls)==null||t.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var $se=Object.defineProperty,ere=Object.getOwnPropertyDescriptor,FR=(n,e,t,i)=>{for(var s=i>1?void 0:i?ere(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$se(e,t,s),s};class fm extends we{constructor(){super(...arguments);u(this,"_fog")}get fog(){return this._fog||(this._fog=new AT(0,0,50)),this._fog}get mode(){return 1}set near(t){this.fog.near=t}get near(){return this.fog.near}set far(t){this.fog.far=t}get far(){return this.fog.far}set color(t){this.fog.color.copy(t)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}FR([w()],fm.prototype,"near",1);FR([w()],fm.prototype,"far",1);FR([w(ve)],fm.prototype,"color",1);let S0,VC,pf,C0;function WC(n,e=1/0,t=null){VC||(VC=new Kr(2,2,1,1)),pf||(pf=new Ot({uniforms:{blitTexture:new Ee(n)},vertexShader:`
5021
+ `,this.context.appendHTMLElement(i);const s=FC;FC&&console.log("ARSupported?",Ag,"VRSupported?",vg),(s||this.createARButton&&this.enableAR&&Ag)&&(e=Pn.createARButton(this),this._arButton=e,i.appendChild(e)),(s||this.createVRButton&&this.enableVR&&vg)&&(t=Pn.createVRButton(this),this._vrButton=t,i.appendChild(t)),setTimeout(()=>{Pn.resetButtonStyles(t),Pn.resetButtonStyles(e)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(e){var i;if(!e)return;const t=this.context.renderer.xr.getSession();if(t){const s=e.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!s)return;this._currentHeadPose=s;const r=s==null?void 0:s.transform;r&&this._transformOrientation.set(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w),Pn._isInXr===!1&&t&&this.onEnterXR(t,e);for(const o of this.controllers)o.onUpdate(t);this._isInAR&&((i=this.webAR)==null||i.onUpdate(t,e))}Pn.events.dispatchEvent({type:"xrUpdate",frame:e,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 e=0;e<2;e++)Ji.Create(this,e,this.gameObject,rp.PhysicalDevice);Pn.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(xt(this.context.mainCamera)),this._originalCameraRotation.copy(On(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 e=$.findObjectOfType(ww,this.context);e?(this.rig=e.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new Io,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(e,t){var o,a;console.log("[XR] session begin",e,t),Pn._isInXr=!0,this.ensureRig();const i=this.context.renderer.xr.getReferenceSpace();if(i&&this.rig){const l=t.getViewerPose(i),c=l==null?void 0:l.transform.orientation;if(c){const h=new Le(c.x,c.y,c.z,c.w),d=new cs().setFromQuaternion(h);this.rig.rotateY(d.y)}}const s=this.context.renderer.xr;if(this.context.mainCamera){const l=s.getCamera();FC&&console.log("WebXRCamera",l);const c=(o=this.context.mainCameraComponent)==null?void 0:o.cullingMask;if(l&&c!==void 0){for(const h of l.cameras)h.layers.mask=c;l.layers.mask=c}else if(l){for(const h of l.cameras)h.layers.enableAll();l.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const r=this._requestedAR?vn.AR:vn.VR;switch(Ro.Global.Set(r),r){case vn.AR:this.context.xrSessionMode=MA.ImmersiveAR,this._isInAR=!0,(a=this.webAR)==null||a.onBegin(e);break;case vn.VR:this.context.xrSessionMode=MA.ImmersiveVR,this._isInVR=!0,this.onEnterVR(e);break}e.addEventListener("end",()=>{console.log("[XR] session end"),Pn._isInXr=!1,this.onExitXR(e)}),this.onEnterXR_HandleMirrorWindow(e),Pn.events.dispatchEvent({type:"xrStarted",session:e})}onExitXR(e){var i,s,r,o;const t=this._isInAR;e&&(this._isInAR?(i=this.webAR)==null||i.onEnd(e):(s=this.context.mainCameraComponent)==null||s.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&&((r=this._originalCameraParent)==null||r.add(this.context.mainCamera),hn(this.context.mainCamera,this._originalCameraPosition),wr(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),t&&((o=this._originalXRRigParent)==null||o.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Ro.Global.Set(vn.Browser|vn.ThirdPerson),Pn.events.dispatchEvent({type:"xrStopped",session:e})}onEnterVR(e){}destroyControllers(){var e;for(let t=this.controllers.length-1;t>=0;t-=1)(e=this.controllers[t])==null||e.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(e){se("mirror")&&setTimeout(()=>{if(!Pn.IsInWebXR)return;const t=new URL(window.location.href);cA(t.searchParams,S_,1),cA(t.searchParams,"isMirror",1);const i=t.toString();this.xrMirrorWindow=window.open(i,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Pn.IsInWebXR&&e.end()})})},1e3)}},u(Tf,"_isInXr",!1),u(Tf,"events",new Un),u(Tf,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),u(Tf,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),Tf);let St=Pn;$p([w()],St.prototype,"enableVR",2);$p([w()],St.prototype,"enableAR",2);$p([w(Kn)],St.prototype,"defaultAvatar",2);$p([w()],St.prototype,"handModelPath",2);$p([w()],St.prototype,"createVRButton",2);$p([w()],St.prototype,"createARButton",2);const Yf=class{constructor(e){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=e}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const e=this.arDomOverlay;return e.getAROverlayContainer?this.arOverlayElement=e.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(e){this.reticleActive=e}async onBegin(e){var o,a,l,c;const t=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const i=(o=navigator.userAgent)!=null&&o.includes("OculusBrowser")?rp.PhysicalDevice:rp.Touch,s=i===rp.Touch?4:2;for(let h=0;h<s;h++)Ji.Create(this.webxr,h,this.webxr.gameObject,i);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=$.findObjectOfType(rl,t)),!this.sessionRoot){const h=this.webxr.gameObject;this.sessionRoot=$.addNewComponent(h,rl),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=t.scene.background,this.previousEnvironment=t.scene.environment,t.scene.background=null,e.requestReferenceSpace("viewer").then(h=>{var d,f;(f=(d=e.requestHitTestSource)==null?void 0:d.call(e,{space:h}))==null||f.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 ye(new av(.07,.09,32).rotateX(-Math.PI/2),new fi),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new ke,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,Yf.tempWebXRObject||(Yf.tempWebXRObject=new ke),this.context.scene.add(Yf.tempWebXRObject),$.addComponent(Yf.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(a=this.sessionRoot)==null||a.onBegin(e)):console.warn("No WebARSessionRoot found in scene");const r=this.context.domElement;(l=r==null?void 0:r.onEnterAR)==null||l.call(r,e,this.arOverlayElement),(c=this.context.mainCameraComponent)==null||c.applyClearFlagsIfIsActiveCamera()}onEnd(e){var s,r;this._previousParent&&($.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const t=this.webxr.context;t.scene.background=this.previousBackground,t.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,e);const i=this.context.domElement;(s=i.onExitAR)==null||s.call(i,e),(r=this.context.mainCameraComponent)==null||r.applyClearFlagsIfIsActiveCamera()}onUpdate(e,t){var s,r;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const o=this.webxr.Rig,a=$ie.clone();(s=this.sessionRoot)==null||s.placeAt(o,a)}return}if(!this.hitTestSource)return;const i=t.getHitTestResults(this.hitTestSource);if(i.length){const o=i[0],a=this.webxr.context.renderer.xr.getReferenceSpace();if(a){const l=o.getPose(a);if(this.sessionRoot){const c=this.sessionRoot.onUpdate(this.webxr.Rig,e,l);this.didPlaceARSessionRoot=c}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&l)){const c=l.transform.matrix;this.reticle.matrix.fromArray(c),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(r=this.sessionRoot)==null||r.onUpdate(this.webxr.Rig,e,null),this.reticle&&(this.reticle.visible=!1)}};let Ku=Yf;u(Ku,"tempWebXRObject");const $ie=new De().identity().makeTranslation(0,0,0);class ic{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 ic(this.input,this.event);return Object.assign(e,this),e}}class em extends we{awake(){qs.createIfNoneExists(this.context)}onEnable(){var e;(e=qs.get(this.context))==null||e.register(this)}onDisable(){var e;(e=qs.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class mc extends em{constructor(){super(...arguments);u(this,"targets",null);u(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(t=null){return this.targets?(t??(t=new va),t.targets=this.targets,t.results=this.raycastHits,this.context.physics.raycast(t)):null}}class hR extends mc{}const yg=se("debugeventsystem");var gM=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(gM||{});const Oa=class extends we{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",[]);Oa.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Oa.systems.length<=0&&Oa.systems.push(...$.findObjectsOfType(Oa,t)));for(const s of Oa.systems)if(s.context===t)return;const i=new ke;$.addNewComponent(i,Oa),t.scene.add(i)}static get systems(){const t=Dt.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i){zl.update(t,i)}static markUIDirty(t){zl.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){Oa.systems.splice(Oa.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!$.findObjectOfType(em,this.context)){const i=$.addNewComponent(this.context.scene,mc);this.raycaster.push(i),tn()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var s,r;const i=(s=this.raycaster)==null?void 0:s.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){const t=new Map;this._selectStartFn??(this._selectStartFn=(s,r)=>{if(!r.grab)return;zl.resetLastSelected();const o=new ic(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=!1,t.set(s,r.grab),r.grab&&!this.handleEvents(r.grab,o)&&(r.grab=null)}),this._selectEndFn??(this._selectEndFn=(s,r)=>{var l;if(!r.grab)return;const o=new ic(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=s.selectionClick,this.handleEvents(r.grab,o);const a=t.get(s);if(t.set(s,null),a)for(let c=0;c<this.raisedPointerDownEvents.length;c++){const h=this.raisedPointerDownEvents[c];this.raisedPointerDownObjects[c]===a&&h&&((l=h.onPointerUp)==null||l.call(h,o),this.raisedPointerDownEvents.splice(c,1),this.raisedPointerDownObjects.splice(c,1),c--)}});const i=new va;this._selectUpdateFn??(this._selectUpdateFn=s=>{i.ray=s.getRay();const r=this.performRaycast(i);if(!r)return;const o=new ic(this.context.input);o.inputSource=s,this.handleIntersections(r,o)}),Ji.addEventListener(Nl.SelectStart,this._selectStartFn),Ji.addEventListener(Nl.SelectEnd,this._selectEndFn),Ji.addEventListener(Nl.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){Ji.removeEventListener(Nl.SelectStart,this._selectStartFn),Ji.removeEventListener(Nl.SelectEnd,this._selectEndFn),Ji.removeEventListener(Nl.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(),St.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const a=this.context.input.getPointerPositionRC(0);if(a&&a.x===0&&a.y===0)return;this._didMove=!0}let t=0;for(const a of this.context.input.foreachPointerId()){const l=this.context.input.getPointerDown(a),c=this.context.input.getPointerUp(a);if(l||c){t=a;break}}const i=this.context.input.getPointerEvent(t),s=new ic(this.context.input,i);s.inputSource=this.context.input,s.pointerId=t,s.isClicked=this.context.input.getPointerClicked(t),s.isDown=this.context.input.getPointerDown(t),s.isUp=this.context.input.getPointerUp(t),s.isPressed=this.context.input.getPointerPressed(t),yg&&s.isClicked&&console.log("CLICK",t);const r=this.performRaycast(null);if(!r)return;this.lastPointerEvent=s;const o={sender:this,args:s,hasActiveUI:this.currentActiveMeshUIComponents.length>0};yg&&s.isClicked&&yn("EventSystem: "+s.pointerId+" - "+this.context.time.frame+" - Up:"+s.isUp+", Down:"+s.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(r,s),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const i of this.raisedPointerDownEvents)i.onPointerUp&&i.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const i of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(i)<0){this._tempComponentsArray.length=0;const s=$.getComponentsInParent(i,we,this._tempComponentsArray);this.lastPointerEvent.object=i;for(let r=0;r<s.length;r++){const o=s[r];if(!o.gameObject||o.destroyed)continue;const a=o;a.onPointerExit&&a.onPointerExit(this.lastPointerEvent)}}const t=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=t}performRaycast(t){if(!this.raycaster)return null;this._sortedHits.length=0;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;const s=i.performRaycast(t);s&&s.length>0&&this._sortedHits.push(...s)}return this._sortedHits.sort((i,s)=>i.distance-s.distance),this._sortedHits}handleIntersections(t,i){if(!t||t.length<=0)return!1;t=this.sortCandidates(t);for(const s of t){const{object:r}=s;if(this.handleEvents(r,i))return!0}return!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const s=t[i],r=s.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(s);continue}this._sortingBuffer.push(s)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEvents(t,i){if(!this.testIsVisible(t))return i.isClicked&&yg&&console.log("not allowed",t),!1;const s=t;i.object=t,this.lastPointerEvent=i;const r=t.parent;let o=!1;const a=i.isClicked??!1;let l=null;if(r&&r.isUI){const c=(i.isPressed||i.isClicked)??!1;if(r[Ga]){const h=r[Ga].gameObject;if(h){if(!Tp.isInteractable(h,this.out))return!1;l=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,c),t=h,o=!0}}if(!o&&this.handleMeshUiObjectWithoutShadowDom(r,c))return!0}if(a&&yg&&console.log(this.context.time.frame,t),this.objectsHoveredThisFrame.push(t),l===null||l.interactable){const c=this.objectsHoveredLastFrame.indexOf(t)>=0;this.handleEventsArray.length=0;const h=$.getComponentsInParent(t,we,this.handleEventsArray);for(let d=0;d<h.length;d++){if(i.used)return!0;if(h[d].destroyed)continue;const f=h[d];if(f.interactable!==!1){if(f.onPointerEnter&&(c||f.onPointerEnter(i)),f.onPointerMove&&f.onPointerMove(i),i.isDown&&f.onPointerDown&&!this.raisedPointerDownEvents.includes(f)&&(f.onPointerDown(i),this.raisedPointerDownEvents.push(f),this.raisedPointerDownObjects.push(s)),i.isUp&&f.onPointerUp){const p=this.raisedPointerDownEvents.indexOf(f);p!==-1&&this.raisedPointerDownEvents.splice(p,1),f.onPointerUp(i)}i.isClicked&&f.onPointerClick&&f.onPointerClick(i)}}}return!0}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const s=zl.updateState(t,i);return s&&this.currentActiveMeshUIComponents.push(s),s!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&zl.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];zl.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?$.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let qs=Oa;u(qs,"_eventSystemMap",new Map),u(qs,"didSearchEventSystem",!1);class zl{static markDirty(){this.needsUpdate=!0}static update(e,t){const i=t.time.frameCount;for(const s of this.lastUpdateFrame)if(s.context===t){if(i===s.frame)return;s.frame=i;let r=this.needsUpdate||i<1;s.nextUpdate===t.time.frameCount&&(r=!0),r&&(yg&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:i,nextUpdate:i}],e.update()}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}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(zl,"lastSelected",null),u(zl,"lastUpdateFrame",[]),u(zl,"needsUpdate",!1);const Db=Symbol("cameraController");function ene(n){return n[Db]}function rk(n,e,t){t?n[Db]=e:n[Db]===e&&(n[Db]=null)}var tne=Object.defineProperty,ine=Object.getOwnPropertyDescriptor,nne=(n,e,t,i)=>{for(var s=i>1?void 0:i?ine(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&tne(e,t,s),s};const g0=se("freecam"),UC=se("debugcamerafit"),sne={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let NC;class xc extends we{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(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}awake(){this._lookTargetPosition=new M,this._startedListeningToKeyEvents=!1}start(){if(this._controls){const t=$.getComponent(this.gameObject,Ni);if(t&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const s=xt(t.cam).length(),r=new M(0,0,-s).applyMatrix4(t.cam.matrixWorld);this.setTarget(r,!0)}}this.startCoroutine(this.startRaycastDelayed()),this._eventSystem=qs.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(gM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(gM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=$.getComponent(this.gameObject,Ni);this._camera=t;const i=t==null?void 0:t.cam;if(i&&rk(i,this,!0),!this._controls){console.assert(i!=null,"Missing camera",this),i&&(this._cameraObject=i);const s=this.targetElement??this.context.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new nZ(i,s),i==null||i.quaternion.copy(r),NC===void 0&&(NC={...this._controls.keys})}this._controls&&(g0&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Dh()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?g0||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):g0||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=$.getComponent(this.gameObject,Th)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&rk(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,!this.setFromTargetPosition()){const t=new va;t.screenPoint=new K(0,0),t.lineThreshold=.1;const i=this.context.physics.raycast(t);i.length>0&&this.setTarget(i[0].point,!0)}}onBeforeRender(){var i,s,r;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 t=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(t||(t=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),t?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const o=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const a=(i=this._cameraObject)==null?void 0:i.position;nU(a,this._cameraTargetPosition,o)}else(s=this._cameraObject)==null||s.position.lerp(this._cameraTargetPosition,o);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,o),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!g0&&((r=this.lookAtConstraint)!=null&&r.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?NC:sne,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(t,i=!1){var s;t?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=t.clone(),i&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(t=0,i=1){var r;if(!this._controls)return!1;const s=(r=this.lookAtConstraint)==null?void 0:r.sources;if(s&&s.length>0){const o=s[t];if(o)return o.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,i),!0}return!1}setTarget(t=null,i=!1){this._controls&&(t!==null&&this._lookTargetPosition.copy(t),i?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(t,i){this._controls&&this._controls.target.lerp(t,i)}distanceToTarget(t){return this._controls?this._controls.target.distanceTo(t):-1}setTargetFromRaycast(){var i,s;if(!this.controls)return;const t=this.context.physics.raycast();for(const r of t)if(r.distance>0&&$.isActiveInHierarchy(r.object)){if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const o=xt(this.context.mainCamera);this._cameraTargetPosition=o.clone().sub(this.controls.target).add(this._lookTargetPosition),(s=(i=this._cameraObject)==null?void 0:i.parent)==null||s.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(t,i=1.1){const s=this._cameraObject,r=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0||!s||!r)return;const o=new M,a=new M,l=new Dn;l.makeEmpty();for(const v of t)v instanceof C1||v instanceof HT||l.expandByObject(v,!0);if(s.updateMatrixWorld(),s.updateProjectionMatrix(),l.getCenter(a),l.applyMatrix4(s.matrixWorldInverse),l.getSize(o),l.setFromCenterAndSize(a,o),o.length()<=1e-10){UC&&console.warn("Camera fit size is zero",l,[...t]);return}const c=s.fov,h=2*Math.atan(Math.tan(c*Math.PI/360/2)*s.aspect)/Math.PI*360,d=o.y/(2*Math.atan(Math.PI*c/360)),f=o.x/(2*Math.atan(Math.PI*h/360)),p=i*Math.max(d,f)+o.z/2;UC&&console.log("Fit camera to objects",d,f,"distance",p);const m=xt(s),A=r.target.clone().sub(m).normalize().multiplyScalar(p);if(r.maxDistance=p*10,r.minDistance=p*.01,r.target.copy(a),s.near=p/100,s.far=p*100,s.updateMatrixWorld(),s.updateProjectionMatrix(),hn(s,r.target.clone().sub(A)),UC){const v=new C1(l);this.context.scene.add(v),aU(v,Dx(s)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",g=>{g.code==="KeyF"&&this.fitCamera(t)}))}r.update()}}nne([w(_v)],xc.prototype,"lookAtConstraint",2);var rne=Object.defineProperty,one=Object.getOwnPropertyDescriptor,Go=(n,e,t,i)=>{for(var s=i>1?void 0:i?one(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rne(e,t,s),s},zG=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(zG||{});const bg=se("debugcam"),ok=se("debugscreenpointtoray");var tb;const _g=(tb=class extends we{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(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&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(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&t&&(this._cam.near=e,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&t&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){let s=this.cam;const r=_g._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),ok&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const o=_g._direction.set(r.x,r.y,r.z),a=xt(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new ol(a.clone(),o.clone())}awake(){ok&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const s=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);tc.DrawRay(s.origin,s.direction,r,10)})}onEnable(){bg&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),lne(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 e=this.context.renderer;e&&this._targetTexture.render(this.context.scene,this._cam,e)}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof Xt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof Xt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new Xt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new cd(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){bg&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,bg&&yn("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(_g.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 e=this._backgroundColor.alpha;_g.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new ane(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,l;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;const i=t.environmentBlendMode;bg&&yn("Environment blend mode: "+i+" on "+navigator.userAgent);const s=i==="additive"||i==="alpha-blend";if(e.xrSessionMode===MA.ImmersiveAR&&i==="opaque"){if((o=navigator.userAgent)!=null&&o.includes("OculusBrowser"))return!0;if((a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((l=navigator.userAgent)!=null&&l.includes("Mobile WebXRViewer/v2")))return!0}return s}},u(tb,"_origin",new M),u(tb,"_direction",new M),tb);let Ni=_g;Go([w()],Ni.prototype,"fieldOfView",1);Go([w()],Ni.prototype,"nearClipPlane",1);Go([w()],Ni.prototype,"farClipPlane",1);Go([w()],Ni.prototype,"clearFlags",1);Go([w()],Ni.prototype,"orthographic",2);Go([w()],Ni.prototype,"orthographicSize",2);Go([w()],Ni.prototype,"ARBackgroundAlpha",2);Go([w()],Ni.prototype,"cullingMask",1);Go([w()],Ni.prototype,"backgroundBlurriness",1);Go([w()],Ni.prototype,"backgroundIntensity",1);Go([w(_i)],Ni.prototype,"backgroundColor",1);Go([w(yh)],Ni.prototype,"targetTexture",1);class ane{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&&(bg&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=nt,this._skybox.mapping=Bo,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function lne(n){se("freecam")&&n.context.mainCameraComponent===n&&$.getOrAddComponent(n.gameObject,xc)}class Ip extends we{constructor(){super(...arguments);u(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new NT),this._listener}awake(){wn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=$.getComponentInParent(this.gameObject,Ni);i?i.cam.add(t):this.gameObject.add(t)})}}var cne=Object.defineProperty,hne=Object.getOwnPropertyDescriptor,Sw=(n,e,t,i)=>{for(var s=i>1?void 0:i?hne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&cne(e,t,s),s};const une=se("debugsignals");class Tv{constructor(){u(this,"guid")}}Sw([w()],Tv.prototype,"guid",2);class tm{constructor(){u(this,"signal");u(this,"reaction")}}Sw([w(Tv)],tm.prototype,"signal",2);Sw([w(yr)],tm.prototype,"reaction",2);var DE;const kl=(DE=class extends we{constructor(){super(...arguments);u(this,"events")}static invoke(e){if(kl.receivers[e]){const t=kl.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){une&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)kl.receivers[e.signal.guid]||(kl.receivers[e.signal.guid]=[]),kl.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(kl.receivers[e.signal.guid]){const t=kl.receivers[e.signal.guid].indexOf(this);t>=0&&kl.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;let t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(s){console.error(s)}}},u(DE,"receivers",{}),DE);let im=kl;Sw([w(tm)],im.prototype,"events",2);var kr=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(kr||{}),Ba=(n=>(n[n.None=0]="None",n[n.Hold=1]="Hold",n[n.Loop=2]="Loop",n[n.PingPong=3]="PingPong",n[n.Continue=4]="Continue",n))(Ba||{}),uR=(n=>(n.Signal="SignalEmitter",n))(uR||{});const Xm=se("debugtimeline"),Q_=class extends we{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(t,i){this.createTrackFunctions[t]=i}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(Xm||$s())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,i,s;Xm&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(i=this.playableAsset)==null?void 0:i.tracks,Array.isArray((s=this.playableAsset)==null?void 0:s.tracks),this)}onEnable(){var t,i;for(const s of this._audioTracks)(t=s.onEnable)==null||t.call(s);for(const s of this._customTracks)(i=s.onEnable)==null||i.call(s);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,i;this.stop();for(const s of this._audioTracks)(t=s.onDisable)==null||t.call(s);for(const s of this._customTracks)(i=s.onDisable)==null||i.call(s);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const i of this._allTracks)for(const s of i)(t=s.onDestroy)==null||t.call(s)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const i=[];for(const s of this._audioTracks){const r=s.loadAudio(this._time,1,0);r&&i.push(r)}if(i.length>0&&(await Promise.all(i),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!wn.userInteractionRegistered&&this.waitForAudio;)await ZA(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 s of this._audioTracks)s.stop();const t=this._isPaused==!0,i=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null}evaluate(){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}this.internalEvaluate(t)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const i of t)yield i}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onPauseChanged)==null||t.call(i)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(t){for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case kr.Activation:for(let s=0;s<i.outputs.length;s++){const r=i.outputs[s];if(typeof r=="object"){let o=!1;for(const l of i.clips)l.start<=t&&t<=l.end&&(o=!0);const a=r;a.visible!==void 0&&(a.visible=o)}}break}for(const i of this._animationTracks)i.evaluate(t);for(const i of this._audioTracks)i.evaluate(t);for(const i of this._signalTracks)i.evaluate(t);for(const i of this._controlTracks)i.evaluate(t);for(const i of this._customTracks)i.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=W_(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const i of this.playableAsset.tracks){for(let s=i.outputs.length-1;s>=0;s--){let r=i.outputs[s];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=$.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(s,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Xm&&console.log("Resolved binding",r,"to",o),i.outputs[s]=o)}else if(r===null){if(i.outputs.splice(s,1),Q_.createTrackFunctions[i.type])continue;i.type!==kr.Audio&&i.type!==kr.Control&&i.type!==kr.Marker&&i.type!==kr.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===kr.Control)for(let s=0;s<i.clips.length;s++){const r=i.clips[s];let o=r.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const a=$.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Xm&&console.log("Resolved binding",o,"to",a),r.asset.sourceObject=a)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,s;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=$.findObjectOfType(Ip,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=Q_.createTrackFunctions[o];if(a!=null){const l=a(this,r);if(typeof l.evaluate=="function"){l.director=this,l.track=r,this._customTracks.push(l);continue}}if(r.type===kr.Animation){if(r.clips.length<=0){Xm&&console.warn("Animation track has no clips",r);continue}for(let l=r.outputs.length-1;l>=0;l--){let c=r.outputs[l];if(c instanceof ke){const d=$.getOrAddComponent(c,ir);d&&(c=d)}const h=(i=c==null?void 0:c.gameObject)==null?void 0:i.animations;if(h){const d=new Cw;d.trackOffset=r.trackOffset,d.director=this,d.track=r;for(let f=0;f<r.clips.length;f++){const p=r.clips[f],m=p.asset;if(!m){console.error("MISSING anim model?","clip#"+f,p,r,this.playableAsset,this.name);continue}const A=m.clip;let v=A;if((typeof v=="string"||typeof v=="number")&&(v=h.find(b=>b.name===A)),!v){console.warn("Could not find animationClip for model",p,r.name,this.name,(s=this.playableAsset)==null?void 0:s.name);continue}d.mixer||(d.mixer=new Px(c.gameObject)),d.clips.push(v),d.mixer.uncacheAction(v),d.createHooks(p.asset,v);const g=d.mixer.clipAction(v);d.actions.push(g),d.models.push(p)}this._animationTracks.push(d)}}}else if(r.type===kr.Audio){if(r.clips.length<=0)continue;const l=new Zu;if(l.director=this,l.track=r,this._audioTracks.push(l),!t)continue;l.listener=t.listener;for(let c=0;c<r.clips.length;c++){const h=r.clips[c];l.addModel(h)}}else if(r.type===kr.Marker){const l=new GA;l.director=this,l.track=r;for(const c of r.markers)switch(c.type){case uR.Signal:l.models.push(c),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const c=$.getComponent(this.gameObject,im);c&&(l.receivers.push(c),this._signalTracks.push(l))}}else if(r.type===kr.Signal){const l=new GA;l.director=this,l.track=r;for(const c of r.markers)l.models.push(c),l.didTrigger.push(!1);for(const c of r.outputs)l.receivers.push(c);this._signalTracks.push(l)}else if(r.type===kr.Control){const l=new Ew;l.director=this,l.track=r;for(const c of r.clips)l.models.push(c);l.resolveSourceObjects(this.context),this._controlTracks.push(l)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}};let lc=Q_;u(lc,"createTrackFunctions",{});const Ju=se("debugtimeline");class Iv{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 i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,s=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(s||e>=r.start&&e<=r.end){let o=1,a=!1;if(r.easeInDuration>0){const l=Math.min((e-r.start)/r.easeInDuration,1);o*=l}if(r.easeOutDuration>0&&!a){const l=Math.min((r.end-e)/r.easeOutDuration,1);o*=l}return o}return 0}}class dne{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 i=e.getRoot(),s=i.name+".position",r=i.name+".quaternion";Ju&&console.log(t.name,t.tracks,s);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(s))this.rootStartPosition=new M().fromArray(o.values,0),this.rootEndPosition=new M().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(r)&&(this.rootStartQuaternion=new Le().fromArray(o.values,0),this.rootEndQuaternion=new Le().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Ju)){const a=new cs().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Cw extends Iv{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 M);u(this,"_totalOffsetRotation",new Le);u(this,"_totalOffsetPosition2",new M);u(this,"_totalOffsetRotation2",new Le);u(this,"_summedPos",new M);u(this,"_tempPos",new M);u(this,"_summedRot",new Le);u(this,"_tempRot",new Le);u(this,"_clipRotQuat",new Le)}onPauseChanged(){this._animator&&this._animatorWasEnabled!==void 0&&(this._animator.enabled=this.director.isPlaying===!1?this._animatorWasEnabled:!1)}createHooks(t,i){var h,d;if(((h=i.tracks)==null?void 0:h.length)<=0){console.warn("No tracks in AnimationClip",i);return}const s=i.tracks[0].name.split("."),r=s[s.length-2],o=r+".position",a=r+".quaternion";let l=!1,c=!1;for(const f of i.tracks)f.name.endsWith(o)?(l=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(c=!0,this.createRotationInterpolant(i,t,f));if(!l||!c){const f=(d=this.mixer)==null?void 0:d.getRoot(),p=i.tracks[0],m=p.name.lastIndexOf("."),A=p.name.substring(0,m),v=A.substring(A.lastIndexOf(".")+1),g=f.getObjectByName(v);if(g)if(l){if(!c){const b=i.tracks[0].name.substring(0,m)+".quaternion";Ju&&console.warn("Create quaternion track",v,g);const y=g.quaternion,_=new nl(b,[0,i.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);i.tracks.push(_),this.createRotationInterpolant(i,t,_)}}else{const b=A+".position";Ju&&console.warn("Create position track",v,g);const y=g.position,_=new Eh(b,[0,i.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);i.tracks.push(_),this.createPositionInterpolant(i,t,_)}}}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 t of this.actions){const i=new dne(t);this._actionOffsets.push(i)}this.target&&(this._animator=$.getComponent(this.target,ir)??null,this._animator?(this._animatorWasEnabled=this._animator.enabled,this._animator.enabled=!1):this._animatorWasEnabled=!1);for(const t of this.models){const i=t.asset,s=i.position,r=i.rotation;s&&s.x!==void 0&&(s.isVector3||(i.position=new M(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new Le(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new M(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Le(i.x,i.y,i.z,i.w)))}}evaluate(t){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 i=0,s=0,r=!1,o=!1;for(let a=0;a<this.clips.length;a++){const l=this.models[a],c=this.actions[a],h=l.asset;c.weight=0;const d=t>=l.start&&t<=l.end,f=l.preExtrapolationMode,p=l.postExtrapolationMode,m=a<this.clips.length-1?this.models[a+1]:null;let A=d,v=!1;if(!A&&!r&&l.end<t&&p!==Ba.None?(!m||m.start>t)&&(A=!0,r=!0):a==0&&!A&&!o&&l.start>t&&f!==Ba.None&&(!m||m.start<t)&&(A=!0,v=!0,o=!0),A){let g=1;g*=this.evaluateWeight(t,a,this.models,A),g*=this.director.weight;let b=d;if(v)switch(f){case Ba.Hold:break;case Ba.Loop:t+=l.start,b=!0;break;default:t+=l.start,b=!0;break}let y=this.getClipTime(t,l),_=0;const x=h.duration;if(v&&f===Ba.Hold&&(y=0),b){if(h.loop)for(_+=Math.floor(y/(x+1e-6));y>x;)y-=x}else if(!d&&r)switch(p){case Ba.Hold:y=this.getClipTime(l.end,l);break;case Ba.Loop:y%=x;break;case Ba.PingPong:const R=Math.floor(y/x)%2!==0;y%=x,R&&(y=x-y);break}l.reversed===!0?c.time=c.getClip().duration-y:c.time=y,c.timeScale=0;const S=g;if(c.weight=S,c.clampWhenFinished=!0,c.isRunning()||c.play(),this._useclipOffsets){const I=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,R=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(s=1-g),i+=1;const E=this._summedPos.set(0,0,0),T=this._tempPos.set(0,0,0),k=this._summedRot.identity(),W=this._tempRot.identity(),U=h.rotation;U&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(U,g));const z=this._actionOffsets[a];if(z.hasOffsets)for(let Q=0;Q<_;Q++)z.rootPositionOffset?T.copy(z.rootPositionOffset):T.set(0,0,0),T.applyQuaternion(k),this._clipRotQuat&&T.applyQuaternion(this._clipRotQuat),z.rootQuaternionOffset&&(W.copy(z.rootQuaternionOffset),k.multiply(W)),E.add(T);this._clipRotQuat&&R.multiply(this._clipRotQuat),R.multiply(k),h.position&&E.add(h.position),I.add(E)}}}this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.mixer.update(t)}createRotationInterpolant(t,i,s){var l;const r=s.createInterpolant.bind(s),o=new Le;this.ensureTrackOffsets();const a=(l=this.trackOffset)==null?void 0:l.rotation;s.createInterpolant=()=>{const c=r(),h=c.evaluate.bind(c);return c.evaluate=d=>{const f=h(d);return o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},c}}createPositionInterpolant(t,i,s){var h,d;const r=s.createInterpolant.bind(s),o=new M;this.ensureTrackOffsets();const a=(h=this.trackOffset)==null?void 0:h.rotation,l=(d=this.trackOffset)==null?void 0:d.position;let c;s.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=m=>{var v,g;const A=p(m);return o.set(A[0],A[1],A[2]),i.removeStartOffset&&(c===void 0?(c=null,c=(g=(v=this._actionOffsets.find(b=>b.clip===t))==null?void 0:v.rootStartPosition)==null?void 0:g.clone()):c!=null&&c.isVector3&&o.sub(c)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),l&&(o.x-=l.x,o.y+=l.y,o.z+=l.z),A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const fne=se("mutetimeline"),Kf=class extends Iv{constructor(){super(...arguments);u(this,"models",[]);u(this,"listener");u(this,"audio",[]);u(this,"audioContextTimeOffset",[]);u(this,"lastTime",0);u(this,"_audioLoader",null)}getAudioFilePath(t){const i=this.director.sourceId;return Bh(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const s=this.models[i];this.audio[i].setVolume(t?s.asset.volume:0)}}addModel(t){const i=new Rx(this.listener);this.audio.push(i),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}evaluate(t){if(fne||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,s=i?.1:0;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.audio[r];if((!a||!a.buffer)&&this.isInTimeRange(o,t-1,t+1)&&this.handleAudioLoading(o,a),wn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale,a.loop=o.asset.loop,t>=o.start&&t<=o.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(a.isPlaying&&a.stop(),this.lastTime===t)continue}else if(!a.isPlaying)a.offset=o.clipIn+(t-o.start)*o.timeScale,a.play(s);else{const c=o.clipIn+(t-o.start)*o.timeScale,h=a.context.currentTime-a._startedAt+a.offset;Math.abs(c-h)>.3&&(a.offset=c,a.stop(),a.play(s))}let l=o.asset.volume;if(i&&(l=0),o.easeInDuration>0){const c=Math.min((t-o.start)/o.easeInDuration,1);l*=c}if(o.easeOutDuration>0){const c=Math.min((o.end-t)/o.easeOutDuration,1);l*=c}a.setVolume(l*this.director.weight)}else a.isPlaying&&a.stop()}this.lastTime=t}loadAudio(t,i=0,s=0){let r=null;const o=t-s,a=t+i;for(const l of this.models)if(this.isInTimeRange(l,o,a)){const c=this.audio[this.models.indexOf(l)],h=this.handleAudioLoading(l,c);h!==null&&(r===null&&(r=[]),r.push(h))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,s){return i<=t.start&&s>=t.end||i>=t.start&&i<=t.end||s>=t.start&&s<=t.end}static dispose(){Kf._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new a_);const s=this.getAudioFilePath(t.asset.clip);if(Kf._audioBuffers.get(s)){const o=Kf._audioBuffers.get(s);return o.then(a=>{a&&i.setBuffer(a)}),o}Ju&&console.warn("LOAD audio track",s,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(s,l=>{i.setBuffer(l),o(l)},void 0,l=>{console.error("Error loading audio",l),o(null)})});return Kf._audioBuffers.set(s,r),r}};let Zu=Kf;u(Zu,"_audioBuffers",new Map);class GA extends Iv{constructor(){super(...arguments);u(this,"models",[]);u(this,"didTrigger",[]);u(this,"receivers",[])}evaluate(t){var s;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],l=o.time-t;let c=!1;if(o.retroActive)c=l<=1e-6;else{const h=Math.abs(l);h>=1e-5&&h<i&&(c=!0)}if(c){if(!a)if(this.didTrigger[r]=!0,((s=this.receivers)==null?void 0:s.length)<=0)im.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class Ew extends Iv{constructor(){super(...arguments);u(this,"models",[]);u(this,"timelines",[]);u(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=$.getComponent(r.sourceObject,lc);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[s];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const l=o.sourceObject;(a==null?void 0:a.sourceObject)!==l&&(l.visible=!1)}}}}}var pne=Object.defineProperty,mne=Object.getOwnPropertyDescriptor,GG=(n,e,t,i)=>{for(var s=i>1?void 0:i?mne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&pne(e,t,s),s};class Tt{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 i=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,i,this)}testIfValueChanged(e){return this._valueRaw!==e}}GG([w()],Tt.prototype,"overrideState",1);GG([w()],Tt.prototype,"value",1);var gne=Object.defineProperty,Ane=Object.getOwnPropertyDescriptor,vne=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ane(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&gne(e,t,s),s};const yne=se("debugpost");class Ds extends Nh{constructor(t=void 0){super();u(this,"active",!0);u(this,"_result");u(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const s=t[i],r=this[i];r instanceof Tt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){yne&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const s=this[i];s instanceof Tt&&s.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Tt){const a=t[r];if(a!==void 0){const l=this[r];l.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof Tt){const s=t.value;return this[i].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===Tt&&(this[i]||(this[i]=new Tt))}}vne([w()],Ds.prototype,"active",2);var bne=Object.defineProperty,_ne=Object.getOwnPropertyDescriptor,xne=(n,e,t,i)=>{for(var s=i>1?void 0:i?_ne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&bne(e,t,s),s};const wne=se("debugpost"),AM={};function Ho(n,e){AM[n]=e}function Sne(n){return n.__type in AM?AM[n.__type]:(wne&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Ds)}class Rv{constructor(){u(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}xne([jp([n=>Sne(n),Ds])],Rv.prototype,"components",2);var Cne=Object.defineProperty,Ene=Object.getOwnPropertyDescriptor,Mne=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ene(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Cne(e,t,s),s};class Pv extends Ds{constructor(){super(...arguments);u(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new U7({preset:If.HIGH,edgeDetectionMode:aI.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}Mne([w(Tt)],Pv.prototype,"preset",2);Ho("Antialiasing",Pv);class Mw{constructor(){u(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,i){const s=$.getComponents(e,wn);if(s.length)for(const r of s){if(!r.clip||!r.playOnAwake)continue;const o=r.clip.split("/").pop();this.files.includes(r.clip)||this.files.push(r.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 = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${r.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i=t.split("/").pop(),o=await(await(await fetch(t)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files["audio/"+i]=a}}}var Tne=Object.defineProperty,Ine=Object.getOwnPropertyDescriptor,HG=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ine(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Tne(e,t,s),s};const Rne=se("debugmouth");class Bv extends we{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=$.findObjectOfType(yc,this.context),this.marker||(this.marker=$.getComponentInParent(this.gameObject,Yn))},3e3)}update(){var s;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((s=this.marker)==null?void 0:s.connectionId)??null;if(!t){Rne&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<t.length;s++){const r=t[s];r&&(r.visible=s===i)}}}}HG([w(ke)],Bv.prototype,"idle",2);HG([w(ke)],Bv.prototype,"talking",2);class dR extends we{constructor(){super(...arguments);u(this,"voip",null);u(this,"marker",null);u(this,"_startPosition",null)}awake(){this.voip=$.findObjectOfType(yc,this.context),this.marker=$.getComponentInParent(this.gameObject,Yn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());let s=i/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var Pne=Object.defineProperty,Bne=Object.getOwnPropertyDescriptor,Tw=(n,e,t,i)=>{for(var s=i>1?void 0:i?Bne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Pne(e,t,s),s};class gd extends we{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=$.getComponentInParent(this.gameObject,ls)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(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 i of this.eyes)i&&(i.visible=this.eyesOpen)}}}Tw([w(ke)],gd.prototype,"eyes",2);Tw([w()],gd.prototype,"lastBlinkTime",2);Tw([w()],gd.prototype,"blinkLength",2);Tw([w()],gd.prototype,"eyesOpen",2);var Dne=Object.defineProperty,kne=Object.getOwnPropertyDescriptor,fR=(n,e,t,i)=>{for(var s=i>1?void 0:i?kne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Dne(e,t,s),s},kE;const QG=(kE=class extends we{constructor(){super(...arguments);u(this,"head",null);u(this,"eyes",null);u(this,"target",null);u(this,"brain",null);u(this,"vec",new M);u(this,"currentTargetPoint",new M)}awake(){this.brain||(this.brain=$.getComponentInParent(this.gameObject,PA)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=$.addNewComponent(this.gameObject,PA)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=xt(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const s=xt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const o=QG.forward;if(o.set(0,0,1),o.applyQuaternion(On(this.head)),o.dot(r)>.45)for(let l=0;l<t.length;l++)t[l].lookAt(this.currentTargetPoint)}}}},u(kE,"forward",new M(0,0,1)),kE);let nm=QG;fR([w(ke)],nm.prototype,"head",2);fR([w(ke)],nm.prototype,"eyes",2);fR([w(ke)],nm.prototype,"target",2);var One=Object.defineProperty,Lne=Object.getOwnPropertyDescriptor,pR=(n,e,t,i)=>{for(var s=i>1?void 0:i?Lne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&One(e,t,s),s};class sm extends we{constructor(){super(...arguments);u(this,"length",1);u(this,"depthTest",!0);u(this,"isGizmo",!0);u(this,"_axes",null)}onEnable(){if(this.isGizmo&&!lv)return;this._axes||(this._axes=new Up(this.length)),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}pR([w()],sm.prototype,"length",2);pR([w()],sm.prototype,"depthTest",2);pR([w()],sm.prototype,"isGizmo",2);class mR extends we{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 t=xt(this.to).clone(),i=xt(this.from).clone(),s=t.distanceTo(i),r=t.clone();r.sub(i);let o=i.clone();o.add(t),o.multiplyScalar(.5);let a=xt(this.hint).clone();a.sub(o);let l=new M;l.crossVectors(a,r),l.crossVectors(r,l),l.normalize();let c=s*.5,h=Math.max(this.desiredDistance,c),d=Math.sqrt(h*h-c*c),f=l.clone();f.multiplyScalar(d),f.add(o),hn(this.gameObject,f);let p=o.clone();p.sub(l),this.gameObject.lookAt(p)}}class Iw{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(i=>{$.foreachComponent(i,s=>{var o;const r=s;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,i){var s;for(const r of this.behaviourComponents)(s=r.createBehaviours)==null||s.call(r,this,t,i)}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 i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const s of this.behaviours)s.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 Fne=Object.defineProperty,Une=Object.getOwnPropertyDescriptor,gR=(n,e,t,i)=>{for(var s=i>1?void 0:i?Une(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Fne(e,t,s),s};class Ad extends Ds{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=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom){const i=t=new n3(this.context.scene,this.context.mainCamera,{blendFunction:kt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});i.inverted=!0}else t=new uI;return this.intensity.onValueChanged=i=>{t.intensity=i},this.threshold.onValueChanged=i=>{t.luminanceMaterial.threshold=i},this.scatter.onValueChanged=i=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=i},t}}gR([w(Tt)],Ad.prototype,"threshold",2);gR([w(Tt)],Ad.prototype,"intensity",2);gR([w(Tt)],Ad.prototype,"scatter",2);Ho("Bloom",Ad);var Nne=Object.defineProperty,zne=Object.getOwnPropertyDescriptor,_a=(n,e,t,i)=>{for(var s=i>1?void 0:i?zne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Nne(e,t,s),s};class cl extends we{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 t;(t=this.context.physics.engine)==null||t.removeBody(this)}}_a([w(ji)],cl.prototype,"attachedRigidbody",2);_a([w()],cl.prototype,"isTrigger",2);_a([w()],cl.prototype,"sharedMaterial",2);class Dv extends cl{constructor(){super(...arguments);u(this,"radius",.5);u(this,"center",new M(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this,this.center,this.radius)}}_a([w()],Dv.prototype,"radius",2);_a([w(M)],Dv.prototype,"center",2);class kv extends cl{constructor(){super(...arguments);u(this,"size",new M(1,1,1));u(this,"center",new M(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.center,this.size)}}_a([w(M)],kv.prototype,"size",2);_a([w(M)],kv.prototype,"center",2);class Ov extends cl{constructor(){super(...arguments);u(this,"sharedMesh");u(this,"convex",!1)}onEnable(){var t,i,s,r,o;if(super.onEnable(),(t=this.sharedMesh)!=null&&t.isMesh||this.gameObject instanceof ye&&(this.sharedMesh=this.gameObject),(i=this.sharedMesh)!=null&&i.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,as(this.gameObject));else{const a=this.sharedMesh;if(a!=null&&a.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 l in a.children){const c=a.children[l];c.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,c,this.convex,as(this.gameObject)))}}}}}_a([w()],Ov.prototype,"convex",2);class Rh extends cl{constructor(){super(...arguments);u(this,"center",new M(0,0,0));u(this,"radius",.5);u(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.center,this.height,this.radius)}}_a([w(M)],Rh.prototype,"center",2);_a([w()],Rh.prototype,"radius",2);_a([w()],Rh.prototype,"height",2);function AR(n){const e=n[Ga];return e||(n.parent?AR(n.parent):null)}function D_(n,e){if(!n)return;const t=n.material;if((t==null?void 0:t.isMaterial)===!0){const i=n.parent;i&&i.isText,t.side=e.doubleSided??!0?Mi:Rs,t.shadowSide=e.doubleSided?Mi:Rs,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of n.children)D_(i,e)}function Bf(n,e,t){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const i=Proxy.revocable(n[e],{set(o,a,l,c){const h=o[a],d=Reflect.set(o,a,l,c);return t(l,h),d}}),s=i.revoke,r=n[e];return i.revoke=()=>{n[e]=r,s()},n[e]=i.proxy,i}const ak=Symbol("Scheduled action");function Gne(n,e,t=Yr.OnBeforeRender){let i=n[ak];i||(i=n[ak]={});const s=e.name;i[t]||(i[t]={});const r=i[t];if(r[s])return;function*a(){e==null||e.call(n),r[s]=null}const l=n.startCoroutine(a(),t);r[s]=l}var Hne=Object.defineProperty,Qne=Object.getOwnPropertyDescriptor,vd=(n,e,t,i)=>{for(var s=i>1?void 0:i?Qne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Hne(e,t,s),s};const zC=se("debugui"),GC=se("debuguilayout");class vR{constructor(){u(this,"width");u(this,"height")}}class yR{constructor(){u(this,"x");u(this,"y");u(this,"width");u(this,"height")}}const Ko=new M,qm=new De,A0=new Le,VG=class extends ma{constructor(){super(...arguments);u(this,"_anchoredPosition");u(this,"sizeDelta",new K(100,100));u(this,"pivot",new K(.5,.5));u(this,"anchorMin",new K(0,0));u(this,"anchorMax",new K(1,1));u(this,"offsetMin",new K(0,0));u(this,"offsetMax",new K(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 K),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;let i=e*t;return i+=this.sizeDelta.x,i}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;let i=e*t;return i+=this.sizeDelta.y,i}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new K),this.lastMatrix=new De,this.rectBlock=new ke,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Bf(this,"_anchoredPosition",()=>{this.markDirty()}),Bf(this,"sizeDelta",()=>{this.markDirty()}),Bf(this,"pivot",()=>{this.markDirty()}),Bf(this,"anchorMin",()=>{this.markDirty()}),Bf(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var e;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(e=this.Canvas)==null||e.registerTransform(this)}onDisable(){var e;super.onDisable(),this.removeShadowComponent(),(e=this.Canvas)==null||e.unregisterTransform(this)}onParentRectTransformChanged(e){this._transformNeedsUpdate||this.onApplyTransform(GC?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(GC&&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(e){var s;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=$.getComponentInParent(this.gameObject.parent,VG):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,GC&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,Ko.set(0,0,0),this.applyPivot(Ko),t.matrix.setPosition(Ko.x,Ko.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(A0.copy(this.gameObject.quaternion),A0.x*=-1,A0.z*=-1,qm.makeRotationFromQuaternion(A0),t.matrix.premultiply(qm)),Ko.set(0,0,0),this.applyAnchoring(Ko),(s=this.Canvas)!=null&&s.screenspace?Ko.z+=.1:Ko.z+=.01,qm.identity(),qm.setPosition(Ko.x,Ko.y,Ko.z),t.matrix.premultiply(qm),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of rI(this.gameObject,ma,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new K);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),e.x+=this._initialPosition.x-this.gameObject.position.x,e.y+=this._initialPosition.y-this.gameObject.position.y,e.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=i.height*.5*r,e.y+=s;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,e.x+=o}}applyPivot(e){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;e.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;e.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const e={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(e),e}ensureValidSize(e,t=1e-4){return e.width<=0&&(e.width=t),e.height<=0&&(e.height=1e-4),e}createNewBlock(e){e={...this.getBasicOptions(),...e},zC&&console.log(this.name,e);const t=new aR(e);return this._createdBlocks.push(t),t}createNewText(e){zC&&console.log(e),e={...this.getBasicOptions(),...e},zC&&console.log(this.name,e);const t=new LG(e);return this._createdTextBlocks.push(t),t}};let fs=VG;vd([w(K)],fs.prototype,"anchoredPosition",1);vd([w(K)],fs.prototype,"sizeDelta",2);vd([w(K)],fs.prototype,"pivot",2);vd([w(K)],fs.prototype,"anchorMin",2);vd([w(K)],fs.prototype,"anchorMax",2);vd([w(K)],fs.prototype,"offsetMin",2);vd([w(K)],fs.prototype,"offsetMax",2);class Vne extends OG{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const s in t[i])e._simpleState__statesProperties[s]||(e._simpleState__statesProperties[s]=[]),e._simpleState__statesProperties[s].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._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 i=[];for(const s in t)this._simpleState__statesProperties[s]||(this._simpleState__statesProperties[s]=[],i.push(s)),this._simpleState__statesProperties[s].push(e);for(const s of this._components)i.indexOf(s.id)>-1&&(this._simpleState__normalStyles[s.id]=s.inline?s.inline:s._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 i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);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 Wne=Object.defineProperty,jne=Object.getOwnPropertyDescriptor,WG=(n,e,t,i)=>{for(var s=i>1?void 0:i?jne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Wne(e,t,s),s};class rm extends we{constructor(){super(...arguments);u(this,"effectColor");u(this,"effectDistance")}}WG([w(_i)],rm.prototype,"effectColor",2);WG([w(K)],rm.prototype,"effectDistance",2);var Xne=Object.defineProperty,qne=Object.getOwnPropertyDescriptor,jG=(n,e,t,i)=>{for(var s=i>1?void 0:i?qne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Xne(e,t,s),s};const v0={backgroundColor:new ve(1,1,1),backgroundOpacity:1,borderColor:new ve(1,1,1),borderOpacity:1};var OE;const kb=(OE=class extends ma{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 _i(1,1,1,1)),this._color}set color(e){(!this._color||this._color.r!==e.r||this._color.g!==e.g||this._color.b!==e.b||this._color.alpha!==e.alpha)&&(this._color||(this._color=new _i(1,1,1,1)),this._color.copy(e))}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(v0.backgroundColor=this._color,v0.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(v0,this._alphaFactor),this.uiObject.set(v0),this.markDirty())}get m_Color(){return this._color}get rectTransform(){return this._rect||(this._rect=$.getComponent(this.gameObject,fs)),this._rect}onParentRectTransformChanged(){var e;(e=this.uiObject)==null||e.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(e){this.makePanel(),this.uiObject&&(this.uiObject.setState(e),this==null||this.markDirty())}setupState(e){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Vne(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),Bf(this,"_color",()=>Gne(this,this.onColorChanged))}onEnable(){var e;super.onEnable(),this.uiObject&&((e=this.rectTransform.shadowComponent)==null||e.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 e=.015;const t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:e};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(e){}onCreate(e){this.uiObject=this.rectTransform.createNewBlock(e),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(e,t=1){var s;const i=(s=this.gameObject)==null?void 0:s.getComponent(rm);i&&(i.effectDistance&&(e.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(e.borderColor=i.effectColor,e.borderOpacity=i.effectColor.alpha*t))}async setTexture(e){if(this.setOptions({backgroundOpacity:0}),e){if(e.colorSpace===nt)if(kb.textureCache.has(e))e=kb.textureCache.get(e);else{const t=e.clone();t.colorSpace=Jn,kb.textureCache.set(e,t),e=t}this.setOptions({backgroundImage:e,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(OE,"textureCache",new Map),OE);let yd=kb;jG([w(_i)],yd.prototype,"color",1);jG([w()],yd.prototype,"raycastTarget",2);class Lv extends yd{constructor(){super(...arguments);u(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var Yne=Object.defineProperty,Kne=Object.getOwnPropertyDescriptor,Rw=(n,e,t,i)=>{for(var s=i>1?void 0:i?Kne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yne(e,t,s),s};let bR=class{constructor(){u(this,"texture",null);u(this,"rect")}};Rw([w(Gt)],bR.prototype,"texture",2);let om=class extends Lv{constructor(){super(...arguments);u(this,"_sprite");u(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new bR),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,i,s,r,o,a,l,c;switch((i=(t=this.sprite)==null?void 0:t.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(r=(s=this.sprite)==null?void 0:s.texture)==null?void 0:r.image)==null?void 0:o.width)===32&&((c=(l=(a=this.sprite)==null?void 0:a.texture)==null?void 0:l.image)==null?void 0:c.height)===32}onBeforeCreate(t){var i,s;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((s=(i=this.sprite)==null?void 0:i.texture)==null?void 0:s.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};Rw([w(bR)],om.prototype,"sprite",1);Rw([w()],om.prototype,"pixelsPerUnitMultiplier",2);class Pw extends Lv{constructor(){super(...arguments);u(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(t){this._mainTexture!==t&&(this._mainTexture=t,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Rw([w(Gt)],Pw.prototype,"mainTexture",1);var Jne=Object.defineProperty,Zne=Object.getOwnPropertyDescriptor,$r=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jne(e,t,s),s};const df=se("debugbutton");class bd{constructor(){u(this,"colorMultiplier");u(this,"disabledColor");u(this,"fadeDuration");u(this,"highlightedColor");u(this,"normalColor");u(this,"pressedColor");u(this,"selectedColor")}}$r([w()],bd.prototype,"colorMultiplier",2);$r([w(_i)],bd.prototype,"disabledColor",2);$r([w()],bd.prototype,"fadeDuration",2);$r([w(_i)],bd.prototype,"highlightedColor",2);$r([w(_i)],bd.prototype,"normalColor",2);$r([w(_i)],bd.prototype,"pressedColor",2);$r([w(_i)],bd.prototype,"selectedColor",2);class wc extends we{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(t){var i,s;df&&console.log("Button Enter",(i=this.animationTriggers)==null?void 0:i.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 t,i;df&&console.log("Button Exit",(t=this.animationTriggers)==null?void 0:t.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&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(t){var i,s;df&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.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(t){var i,s;df&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.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(t){var i;this.interactable&&t.pointerId===0&&(df&&(console.warn("Button Click",this.onClick),yn("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(i=this.onClick)==null||i.invoke())}set interactable(t){this._interactable=t,this._image&&(this._image.setInteractable(t),t?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(t){this.interactable=t}awake(){super.awake(),df&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(t){var i;this._requestedAnimatorTrigger=t,yield,yield,this._requestedAnimatorTrigger==t&&((i=this.animator)==null||i.SetTrigger(t))}init(){this._isInit||(this._isInit=!0,this._image=$.getComponent(this.gameObject,om),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(t){var p,m,A,v,g;t.setInteractable(this.interactable);const i=this.getFinalColor(t.color,(p=this.colors)==null?void 0:p.normalColor),s={state:"normal",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};t.setupState(s);const r=this.getFinalColor(t.color,(m=this.colors)==null?void 0:m.highlightedColor),o={state:"hovered",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};t.setupState(o);const a=this.getFinalColor(t.color,(A=this.colors)==null?void 0:A.pressedColor),l={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(l);const c=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.selectedColor),h={state:"selected",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};t.setupState(h);const d=this.getFinalColor(t.color,(g=this.colors)==null?void 0:g.disabledColor),f={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};t.setupState(f)}getFinalColor(t,i){return i?t.clone().multiply(i):t.clone()}}$r([w(yr)],wc.prototype,"onClick",2);$r([w()],wc.prototype,"colors",2);$r([w()],wc.prototype,"transition",2);$r([w()],wc.prototype,"animationTriggers",2);$r([w(ir)],wc.prototype,"animator",2);$r([w()],wc.prototype,"interactable",1);var $ne=Object.defineProperty,ese=Object.getOwnPropertyDescriptor,En=(n,e,t,i)=>{for(var s=i>1?void 0:i?ese(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$ne(e,t,s),s};const lk=se("debuguilayout");class Vh{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}}En([w()],Vh.prototype,"left",2);En([w()],Vh.prototype,"right",2);En([w()],Vh.prototype,"top",2);En([w()],Vh.prototype,"bottom",2);class eo extends we{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(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(lk&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){lk&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(fs);const t=this.gameObject.getComponentInParent(ps);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(ps);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}En([w()],eo.prototype,"childAlignment",2);En([w()],eo.prototype,"reverseArrangement",2);En([w()],eo.prototype,"spacing",2);En([w(Vh)],eo.prototype,"padding",2);En([w()],eo.prototype,"minWidth",2);En([w()],eo.prototype,"minHeight",2);En([w()],eo.prototype,"flexibleHeight",2);En([w()],eo.prototype,"flexibleWidth",2);En([w()],eo.prototype,"preferredHeight",2);En([w()],eo.prototype,"preferredWidth",2);class Wh extends eo{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(t){var R;const i=this.primaryAxis,s=t.width;let r=s;const o=t.height;let a=o;r-=this.padding.horizontal,a-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const l=i==="x",c=l?"y":"x",h=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,f=l?this.childForceExpandWidth:this.childForceExpandHeight,p=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:r,A=l?s:o,v=.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 E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],k=$.getComponent(T,fs);k!=null&&k.activeAndEnabled&&(y+=1,l?b+=k.width:b+=k.height)}let _=0;const x=this.spacing*(y-1);if(f||h){let E=0;l?E=r-=x:E=a-=x,y>0&&(_=E/y)}let S=0;S+=this.padding.left,S-=this.padding.right,v!==0&&(g=A-b,g*=v,g-=x*v,l?(g-=this.padding.right*v,g+=this.padding.left*(1-v),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*v,g+=this.padding.top*(1-v),g<this.padding.top&&(g=this.padding.top)));let I=1;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],k=$.getComponent(T,fs);if(k!=null&&k.activeAndEnabled){(R=k.pivot)==null||R.set(.5,.5),k.anchorMin.set(0,1),k.anchorMax.set(0,1);const W=s*.5+S*.5;k.anchoredPosition.x!==W&&(k.anchoredPosition.x=W);const U=o*-.5;k.anchoredPosition.y!==U&&(k.anchoredPosition.y=U),p&&d&&k.sizeDelta[c]!==m&&(k.sizeDelta[c]=m),f&&h&&k.sizeDelta[i]!==_&&(k.sizeDelta[i]=_);const z=l?k.width:k.height;let Q=z*.5;if(g+=Q,f){let X=_*I-_*.5;X>g&&(g=X-_*.5+z+this.padding.left,g-=Q)}let ee=g;i==="y"&&(ee=-ee),k.anchoredPosition[i]!==ee&&(k.anchoredPosition[i]=ee),g+=Q,g+=this.spacing,I+=1}}}}En([w()],Wh.prototype,"childControlHeight",2);En([w()],Wh.prototype,"childControlWidth",2);En([w()],Wh.prototype,"childForceExpandHeight",2);En([w()],Wh.prototype,"childForceExpandWidth",2);En([w()],Wh.prototype,"childScaleHeight",2);En([w()],Wh.prototype,"childScaleWidth",2);class _R extends Wh{get primaryAxis(){return"y"}}class xR extends Wh{get primaryAxis(){return"x"}}class wR extends eo{onCalculateLayout(){}}var tse=Object.defineProperty,ise=Object.getOwnPropertyDescriptor,hl=(n,e,t,i)=>{for(var s=i>1?void 0:i?ise(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&tse(e,t,s),s},XG=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(XG||{});const HC=se("debuguilayout"),qG=class extends Mv{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 e,t,i,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(t=this.shadowComponent)==null||t.updateWorldMatrix(!0,!0),qs.ensureUpdateMeshUI(LC,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),qs.ensureUpdateMeshUI(LC,this.context))});u(this,"onAfterRenderRoutine",()=>{var e,t;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r==null||r.add(this.gameObject)}else this.previousParent.add(this.gameObject);const i=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(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),qs.ensureUpdateMeshUI(LC,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=i,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(t=this._lastMatrixWorld)==null||t.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(e){e!==this._renderOnTop&&(this._renderOnTop=e,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(e){this._depthWrite!==e&&(this._depthWrite=e,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(e){this._doubleSided!==e&&(this._doubleSided=e,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(e){this._castShadows!==e&&(this._castShadows=e,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(e){this._renderMode!==e&&(this._renderMode=e,this.onRenderSettingsChanged())}set rootCanvas(e){this._rootCanvas instanceof qG||(this._rootCanvas=e)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(e){this._scaleFactor=e}awake(){var e;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,HC&&console.log("Canvas.Awake()",((e=this.previousParent)==null?void 0:e.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new De,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 e=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);e!==-1&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(e){this._rectTransforms.push(e)}unregisterTransform(e){const t=this._rectTransforms.indexOf(e);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(e){const t=e.gameObject;this._layoutGroups.set(t,e)}unregisterLayoutGroup(e){const t=e.gameObject;this._layoutGroups.delete(t)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new De);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);HC&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);let t=!1;for(const i of this._rectTransforms){e&&i.markDirty();let s=this._layoutGroups.get(i.gameObject);i.isDirty&&!s&&(s=i.gameObject.getComponentInParent(eo)),(i.isDirty||s!=null&&s.isDirty)&&(HC&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),s==null||s.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Yr.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),D_(this.shadowComponent,this);for(const e of $.getComponentsInChildren(this.gameObject,ma))D_(e.shadowComponent,this)}}onUpdateRenderMode(e=!1){if(!e&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=et.lerp(t.nearClipPlane,t.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const s=i+.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(fs);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=t.fieldOfView*Math.PI/180,l=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=l/this.context.domHeight,this.gameObject.scale.y=l/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r==null||r.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let ps=qG;hl([w()],ps.prototype,"renderOnTop",1);hl([w()],ps.prototype,"depthWrite",1);hl([w()],ps.prototype,"doubleSided",1);hl([w()],ps.prototype,"castShadows",1);hl([w()],ps.prototype,"receiveShadows",1);hl([w()],ps.prototype,"renderMode",1);hl([w(ps)],ps.prototype,"rootCanvas",1);hl([w()],ps.prototype,"scaleFactor",1);hl([w(Ni)],ps.prototype,"worldCamera",2);hl([w()],ps.prototype,"planeDistance",2);var nse=Object.defineProperty,sse=Object.getOwnPropertyDescriptor,SR=(n,e,t,i)=>{for(var s=i>1?void 0:i?sse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&nse(e,t,s),s};class Ph extends we{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(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Yr.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const t of $.getComponentsInChildren(this.gameObject,ma,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}SR([w()],Ph.prototype,"alpha",1);SR([w()],Ph.prototype,"interactable",2);SR([w()],Ph.prototype,"blocksRaycasts",2);var rse=Object.defineProperty,ose=Object.getOwnPropertyDescriptor,Ri=(n,e,t,i)=>{for(var s=i>1?void 0:i?ose(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rse(e,t,s),s};class _d extends we{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 M);u(this,"targetRot",new Le);u(this,"targetScale",new M)}*moveToTarget(){if(!this.target||!this.object)return;const t=xt(this.object).clone(),i=xt(this.target).clone(),s=On(this.object).clone(),r=On(this.target).clone(),o=as(this.object).clone(),a=as(this.target).clone(),l=t.distanceTo(i),c=s.angleTo(r),h=o.distanceTo(a);if(l<.01&&c<.01&&h<.01){hn(this.object,i),wr(this.object,r),B1(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(s,r,f),this.targetScale.lerpVectors(o,a,f),hn(this.object,this.targetPos),wr(this.object,this.targetRot),B1(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let l=0,c=0;for(;l<1;)l+=this.context.time.deltaTime/this.duration,l>1&&(l=1),c=l<.5?4*l*l*l:1-Math.pow(-2*l+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,c),this.object.quaternion.slerpQuaternions(i,this.targetRot,c),this.object.scale.lerpVectors(s,this.targetScale,c),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new hs("Move to "+((i=this.target)==null?void 0:i.name),br.tapTrigger(this.gameObject),ci.transformAction(this.object,this.target,this.duration,this.relativeMotion?oM.Relative:oM.Absolute));t.addBehavior(s)}}}Ri([w(ke)],_d.prototype,"object",2);Ri([w(ke)],_d.prototype,"target",2);Ri([w()],_d.prototype,"duration",2);Ri([w()],_d.prototype,"relativeMotion",2);var LE;const Mu=(LE=class extends we{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 e=$.findObjectsOfType(Ui);for(const t of e)t.sharedMaterial===this.materialToSwitch&&this._objectsWithThisMaterial.push(t)}}onPointerClick(){if(this.variantMaterial)for(const e of this._objectsWithThisMaterial)e.sharedMaterial=this.variantMaterial}async beforeCreateDocument(e,t){this.targetModels=[],Mu._materialTriggersPerId={},this.materialToSwitch&&await Ur.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Ur.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.gameObject.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(Mu._materialTriggersPerId[this.materialToSwitch.uuid]||(Mu._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Mu._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=Mu._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const o of i){const a=o.createVariants();a&&a.length>0&&(s[o.selfModel.uuid]=a)}const r=[];for(const o of i){for(const a in s)a!==o.selfModel.uuid&&r.push(s[a]);o.createAndAttachBehaviors(e,s[o.selfModel.uuid],r)}}delete Mu._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);for(const a of this.targetModels){const l=ci.fadeAction(a,o,!1);r.push(l)}for(const a of i)r.push(ci.fadeAction(a,o,!1));for(const a of t)s.push(ci.fadeAction(a,o,!1)),r.push(ci.fadeAction(a,o,!0));e.addBehavior(new hs("Select "+this.selfModel.name,br.tapTrigger(this.selfModel),ci.parallel(...r))),e.addBehavior(new hs("Start hidden "+this.selfModel.name,br.sceneStartTrigger(),ci.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&mr.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},u(LE,"_materialTriggersPerId",{}),LE);let am=Mu;Ri([w(Bt)],am.prototype,"materialToSwitch",2);Ri([w(Bt)],am.prototype,"variantMaterial",2);Ri([w()],am.prototype,"fadeDuration",2);class lm extends we{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(t,i,s){i.uuid===this.gameObject.uuid&&(this.selfModel=i)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(t,i){if(this.target){if(this.otherModel=i.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())&&tz.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(ci.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(ci.fadeAction(this.toggleModel,0,!0)),r.push(ci.fadeAction(this.otherModel,0,this.targetState)),t.addBehavior(new hs("Toggle_"+this.selfModel.name+"_hideSelf",br.tapTrigger(this.selfModel),ci.sequence(...r))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(ci.fadeAction(this.toggleModel,0,!1)),o.push(ci.fadeAction(this.selfModel,0,!0)),o.push(ci.fadeAction(this.otherModel,0,!this.targetState)),t.addBehavior(new hs("Toggle_"+this.selfModel.name+"_toggleSelf",br.tapTrigger(this.toggleModel),ci.sequence(...o))),t.addBehavior(new hs("HideOnStart_"+this.gameObject.name,br.sceneStartTrigger(),ci.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Ri([w(ke)],lm.prototype,"target",2);Ri([w()],lm.prototype,"targetState",2);Ri([w()],lm.prototype,"hideSelf",2);class CR extends we{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new hs("HideOnStart_"+this.gameObject.name,br.sceneStartTrigger(),ci.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class cm extends we{constructor(){super(...arguments);u(this,"target");u(this,"duration",.5);u(this,"motionType",MI.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new hs("emphasize "+this.name,br.tapTrigger(this.gameObject),ci.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}Ri([w()],cm.prototype,"target",2);Ri([w()],cm.prototype,"duration",2);Ri([w()],cm.prototype,"motionType",2);class hm extends we{constructor(){super(...arguments);u(this,"target");u(this,"clip","");u(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const t=this.gameObject.addNewComponent(wn);t&&(t.spatialBlend=1,t.volume=1,t.loop=!1,this.target=t)}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(t,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const o=this.target?this.target.gameObject:this.gameObject,a=r.split("/").pop(),l=this.target?this.target.volume:1,c=this.target&&this.target.spatialBlend==0?aM.NonSpatial:aM.Spatial,h=new hs("playAudio "+this.name,br.tapTrigger(this.gameObject),ci.playAudioAction(o,"audio/"+a,az.Play,l,c));t.addBehavior(h)}}async afterSerialize(t,i){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(),l=await(await(await fetch(this.clip)).blob()).arrayBuffer(),c=new Uint8Array(l);i.files["audio/"+r]=c}}Ri([w(wn)],hm.prototype,"target",2);Ri([w(URL)],hm.prototype,"clip",2);Ri([w()],hm.prototype,"toggleOnClick",2);var FE;const Df=(FE=class extends we{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 e;this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}onAfterHierarchy(){Df.animationActions=[]}afterCreateDocument(e,t){if(!this.stateAnimation||!this.stateAnimationModel)return;t.document.traverse(s=>{var r,o;if(s.uuid===((r=this.target)==null?void 0:r.uuid)&&this.stateAnimation){const a=[];let l=Df.animationActions.find(h=>h.affectedObjects==s&&h.start==this.stateAnimation.start&&h.duration==this.stateAnimation.duration);if(l||(l=ci.startAnimationAction(s,this.stateAnimation.start,this.stateAnimation.duration),Df.animationActions.push(l)),a.push(l),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let h=Df.animationActions.find(f=>f.affectedObjects==s&&f.start==this.stateAfterPlayingAnimation.start&&f.duration==this.stateAfterPlayingAnimation.duration);h||(h=ci.startAnimationAction(s,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),Df.animationActions.push(h));const d=ci.sequence(h);this.loopAfterPlaying&&d.makeLooping(),a.push(d)}const c=new hs("tap "+this.name+" for "+this.stateName+" on "+((o=this.target)==null?void 0:o.name),br.tapTrigger(this.selfModel),ci.sequence(...a));e.addBehavior(c)}})}createAnimation(e,t,i){var s,r,o,a;if(this.target&&this.animator){const l=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);this.stateAnimationModel=t,this.stateAnimation=e.registerAnimation(this.target,l==null?void 0:l.motion.clip);const c=(a=(o=this.animator)==null?void 0:o.runtimeAnimatorController)==null?void 0:a.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=t,this.stateAfterPlayingAnimation=e.registerAnimation(this.target,c==null?void 0:c.motion.clip)}}},u(FE,"animationActions",[]),FE);let jh=Df;Ri([w(ke)],jh.prototype,"target",2);Ri([w(ir)],jh.prototype,"animator",2);Ri([w()],jh.prototype,"stateName",2);Ri([w()],jh.prototype,"stateNameAfterPlaying",2);Ri([w()],jh.prototype,"loopAfterPlaying",2);class um extends we{constructor(){super(...arguments);u(this,"target")}getType(){}getDuration(){}}Ri([w(ke)],um.prototype,"target",2);class Fv extends we{constructor(){super(...arguments);u(this,"target")}}Ri([w(um)],Fv.prototype,"target",2);class Uv extends um{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}}Ri([w()],Uv.prototype,"type",2);Ri([w()],Uv.prototype,"duration",2);class ER extends Fv{}var ase=Object.defineProperty,lse=Object.getOwnPropertyDescriptor,Sc=(n,e,t,i)=>{for(var s=i>1?void 0:i?lse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ase(e,t,s),s};class xd extends we{constructor(){super(...arguments);u(this,"center",new M(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 t=this.rigidbody,i=this.gameObject.getComponent(Rh);i||(i=this.gameObject.addNewComponent(Rh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){for(const i of t.contacts)if(i.normal.y>.1){this._activeGroundCollisions.add(t);break}}onCollisionExit(t){this._activeGroundCollisions.delete(t)}get isGrounded(){return this._activeGroundCollisions.size>0}}Sc([w(M)],xd.prototype,"center",2);Sc([w()],xd.prototype,"radius",2);Sc([w()],xd.prototype,"height",2);class Cc extends we{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 M(0,0,0));u(this,"_currentAngularSpeed",new M(0,0,0));u(this,"_temp",new M(0,0,0));u(this,"_jumpCount",0);u(this,"_currentRotation");u(this,"_raycastOptions",new va)}awake(){this._currentRotation=new Le}update(){var c,h,d,f,p,m,A,v,g,b,y;(c=this.controller)!=null&&c.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((h=this.animator)==null||h.setBool("doubleJump",!1)));const t=this.context.input.isKeyPressed("w"),i=this.context.input.isKeyPressed("s"),s=this.context.input.isKeyPressed("a"),r=this.context.input.isKeyPressed("d"),o=this.context.input.isKeyDown(" "),a=(t?1:0)+(i?-1:0);this._currentSpeed.z+=a*this.movementSpeed*this.context.time.deltaTime,(d=this.animator)==null||d.setBool("running",a!=0),(p=this.animator)==null||p.setBool("jumping",((f=this.controller)==null?void 0:f.isGrounded)===!0&&o),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 l=(s?1:0)+(r?-1:0);if(this._currentAngularSpeed.y+=et.toRadians(l*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const _=this.context.mainCameraComponent.forward;_.y=0,_.normalize(),this._currentRotation.setFromUnitVectors(new M(0,0,1),_),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&&o&&this.jumpForce>0){let _=(m=this.controller)==null?void 0:m.isGrounded;if(this.doubleJumpForce>0&&!((A=this.controller)!=null&&A.isGrounded)&&this._jumpCount===1&&(_=!0,(v=this.animator)==null||v.setBool("doubleJump",!0)),_){this._jumpCount+=1;const x=this.controller.rigidbody,S=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;x.applyImpulse(new M(0,1,0).multiplyScalar(S))}}if(this.controller){const _=(g=this.controller)==null?void 0:g.rigidbody.getVelocity().y;if(_<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new ol),this._raycastOptions.ray.origin.copy(xt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const x=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const S=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(x),(S.length&&S[0].distance>2||_<-10)&&((b=this.animator)==null||b.setBool("falling",!0))}else(y=this.animator)==null||y.setBool("falling",!1)}}}Sc([w(xd)],Cc.prototype,"controller",2);Sc([w()],Cc.prototype,"movementSpeed",2);Sc([w()],Cc.prototype,"rotationSpeed",2);Sc([w()],Cc.prototype,"jumpForce",2);Sc([w()],Cc.prototype,"doubleJumpForce",2);Sc([w(ir)],Cc.prototype,"animator",2);var cse=Object.defineProperty,hse=Object.getOwnPropertyDescriptor,use=(n,e,t,i)=>{for(var s=i>1?void 0:i?hse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&cse(e,t,s),s};class Nv extends Ds{constructor(){super(...arguments);u(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new $N;return t.offset=new K(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}use([w(Tt)],Nv.prototype,"intensity",2);Ho("ChromaticAberration",Nv);var dse=Object.defineProperty,fse=Object.getOwnPropertyDescriptor,Bw=(n,e,t,i)=>{for(var s=i>1?void 0:i?fse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&dse(e,t,s),s};class Xh extends Ds{constructor(){super(...arguments);u(this,"postExposure");u(this,"contrast");u(this,"hueShift");u(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=t=>(t=Math.pow(2,t),t),this.postExposure.defaultValue=0,this.contrast.valueProcessor=t=>{let i=1;return t>0?i=200:t<0&&(i=100),t/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=t=>Math.PI*t/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=t=>t<0?t/100:t/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Ys&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=dA);const t=new ZN;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Ys&&(this.context.renderer.toneMapping=dA),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{t.contrast=s};const i=new t3;return this.hueShift.onValueChanged=s=>i.hue=s,this.saturation.onValueChanged=s=>i.saturation=s,[i,t]}}Bw([w(Tt)],Xh.prototype,"postExposure",2);Bw([w(Tt)],Xh.prototype,"contrast",2);Bw([w(Tt)],Xh.prototype,"hueShift",2);Bw([w(Tt)],Xh.prototype,"saturation",2);Ho("ColorAdjustments",Xh);const pse=(Math.sqrt(5)-1)/4,es=(5-Math.sqrt(5))/20,y0=n=>Math.floor(n)|0,b0=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 mse(n=Math.random){const e=gse(n),t=new Float64Array(e).map(o=>b0[o%32*4]),i=new Float64Array(e).map(o=>b0[o%32*4+1]),s=new Float64Array(e).map(o=>b0[o%32*4+2]),r=new Float64Array(e).map(o=>b0[o%32*4+3]);return function(a,l,c,h){let d,f,p,m,A;const v=(a+l+c+h)*pse,g=y0(a+v),b=y0(l+v),y=y0(c+v),_=y0(h+v),x=(g+b+y+_)*es,S=g-x,I=b-x,R=y-x,E=_-x,T=a-S,k=l-I,W=c-R,U=h-E;let z=0,Q=0,ee=0,X=0;T>k?z++:Q++,T>W?z++:ee++,T>U?z++:X++,k>W?Q++:ee++,k>U?Q++:X++,W>U?ee++:X++;const J=z>=3?1:0,ie=Q>=3?1:0,oe=ee>=3?1:0,Y=X>=3?1:0,te=z>=2?1:0,xe=Q>=2?1:0,be=ee>=2?1:0,Se=X>=2?1:0,Ce=z>=1?1:0,We=Q>=1?1:0,He=ee>=1?1:0,lt=X>=1?1:0,Ct=T-J+es,tt=k-ie+es,H=W-oe+es,Fe=U-Y+es,me=T-te+2*es,Oe=k-xe+2*es,_e=W-be+2*es,Ze=U-Se+2*es,Xe=T-Ce+3*es,Ye=k-We+3*es,ft=W-He+3*es,Et=U-lt+3*es,qt=T-1+4*es,N=k-1+4*es,O=W-1+4*es,he=U-1+4*es,Te=g&255,Ie=b&255,Ue=y&255,V=_&255;let de=.6-T*T-k*k-W*W-U*U;if(de<0)d=0;else{const Be=Te+e[Ie+e[Ue+e[V]]];de*=de,d=de*de*(t[Be]*T+i[Be]*k+s[Be]*W+r[Be]*U)}let ae=.6-Ct*Ct-tt*tt-H*H-Fe*Fe;if(ae<0)f=0;else{const Be=Te+J+e[Ie+ie+e[Ue+oe+e[V+Y]]];ae*=ae,f=ae*ae*(t[Be]*Ct+i[Be]*tt+s[Be]*H+r[Be]*Fe)}let Ve=.6-me*me-Oe*Oe-_e*_e-Ze*Ze;if(Ve<0)p=0;else{const Be=Te+te+e[Ie+xe+e[Ue+be+e[V+Se]]];Ve*=Ve,p=Ve*Ve*(t[Be]*me+i[Be]*Oe+s[Be]*_e+r[Be]*Ze)}let qe=.6-Xe*Xe-Ye*Ye-ft*ft-Et*Et;if(qe<0)m=0;else{const Be=Te+Ce+e[Ie+We+e[Ue+He+e[V+lt]]];qe*=qe,m=qe*qe*(t[Be]*Xe+i[Be]*Ye+s[Be]*ft+r[Be]*Et)}let Ge=.6-qt*qt-N*N-O*O-he*he;if(Ge<0)A=0;else{const Be=Te+1+e[Ie+1+e[Ue+1+e[V+1]]];Ge*=Ge,A=Ge*Ge*(t[Be]*qt+i[Be]*N+s[Be]*O+r[Be]*he)}return 27*(d+f+p+m+A)}}function gse(n){const t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){const s=i+~~(n()*(256-i)),r=t[i];t[i]=t[s],t[s]=r}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Ase=Object.defineProperty,vse=Object.getOwnPropertyDescriptor,Z=(n,e,t,i)=>{for(var s=i>1?void 0:i?vse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ase(e,t,s),s};const _0=se("debugparticles");var Xl=(n=>(n[n.Billboard=0]="Billboard",n[n.Stretch=1]="Stretch",n[n.HorizontalBillboard=2]="HorizontalBillboard",n[n.VerticalBillboard=3]="VerticalBillboard",n[n.Mesh=4]="Mesh",n))(Xl||{});class qh{constructor(){u(this,"alphaKeys");u(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let i,s=0,r=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const l=this.alphaKeys[a];(l.time<e||!i)&&(i=l,s=a)}for(let a=0;a<this.colorKeys.length;a++){const l=this.colorKeys[a];(l.time<e||!r)&&(r=l,o=a)}if(r)if(o+1<this.colorKeys.length){const l=this.colorKeys[o+1],c=et.remap(e,r.time,l.time,0,1);t.r=et.lerp(r.color.r,l.color.r,c),t.g=et.lerp(r.color.g,l.color.g,c),t.b=et.lerp(r.color.b,l.color.b,c)}else t.r=r.color.r,t.g=r.color.g,t.b=r.color.b;if(i)if(s+1<this.alphaKeys.length){const l=this.alphaKeys[s+1],c=et.remap(e,i.time,l.time,0,1);t.alpha=et.lerp(i.alpha,l.alpha,c)}else t.alpha=i.alpha;return t}}Z([w()],qh.prototype,"alphaKeys",2);Z([w()],qh.prototype,"colorKeys",2);var Dw=(n=>(n[n.Local=0]="Local",n[n.World=1]="World",n[n.Custom=2]="Custom",n))(Dw||{}),YG=(n=>(n[n.Sphere=0]="Sphere",n[n.SphereShell=1]="SphereShell",n[n.Hemisphere=2]="Hemisphere",n[n.HemisphereShell=3]="HemisphereShell",n[n.Cone=4]="Cone",n[n.Box=5]="Box",n[n.Mesh=6]="Mesh",n[n.ConeShell=7]="ConeShell",n[n.ConeVolume=8]="ConeVolume",n[n.ConeVolumeShell=9]="ConeVolumeShell",n[n.Circle=10]="Circle",n[n.CircleEdge=11]="CircleEdge",n[n.SingleSidedEdge=12]="SingleSidedEdge",n[n.MeshRenderer=13]="MeshRenderer",n[n.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",n[n.BoxShell=15]="BoxShell",n[n.BoxEdge=16]="BoxEdge",n[n.Donut=17]="Donut",n[n.Rectangle=18]="Rectangle",n[n.Sprite=19]="Sprite",n[n.SpriteRenderer=20]="SpriteRenderer",n))(YG||{});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 i=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 s=e*this.curveMin.duration,r=e*this.curveMax.duration;return et.lerp(this.curveMin.evaluate(s),this.curveMax.evaluate(r),i%1)*this.curveMultiplier;case 3:return et.lerp(this.constantMin,this.constantMax,i%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 i=0;i<e.keys.length;i++){const s=e.keys[i];s.value>t&&(t=s.value)}return t}}Z([w()],at.prototype,"mode",2);Z([w()],at.prototype,"constant",2);Z([w()],at.prototype,"constantMin",2);Z([w()],at.prototype,"constantMax",2);Z([w(fd)],at.prototype,"curve",2);Z([w(fd)],at.prototype,"curveMin",2);Z([w(fd)],at.prototype,"curveMax",2);Z([w()],at.prototype,"curveMultiplier",2);var ib;const na=(ib=class{constructor(){u(this,"mode");u(this,"color");u(this,"colorMin");u(this,"colorMax");u(this,"gradient");u(this,"gradientMin");u(this,"gradientMax")}evaluate(n,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(n,na._temp),na._temp;case 2:return na._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(n,na._temp),this.gradientMax.evaluate(n,na._temp2),na._temp.lerp(na._temp2,t)}return na._temp.set(16711935),na._temp.alpha=1,na._temp}},u(ib,"_temp",new _i(0,0,0,1)),u(ib,"_temp2",new _i(0,0,0,1)),ib);let Sr=na;Z([w(_i)],Sr.prototype,"color",2);Z([w(_i)],Sr.prototype,"colorMin",2);Z([w(_i)],Sr.prototype,"colorMax",2);Z([w(qh)],Sr.prototype,"gradient",2);Z([w(qh)],Sr.prototype,"gradientMin",2);Z([w(qh)],Sr.prototype,"gradientMax",2);class vs{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")}}Z([w(at)],vs.prototype,"gravityModifier",2);Z([w(Sr)],vs.prototype,"startColor",2);Z([w(at)],vs.prototype,"startDelay",2);Z([w(at)],vs.prototype,"startLifetime",2);Z([w(at)],vs.prototype,"startRotation",2);Z([w(at)],vs.prototype,"startRotationX",2);Z([w(at)],vs.prototype,"startRotationY",2);Z([w(at)],vs.prototype,"startRotationZ",2);Z([w(at)],vs.prototype,"startSize",2);Z([w(at)],vs.prototype,"startSizeX",2);Z([w(at)],vs.prototype,"startSizeY",2);Z([w(at)],vs.prototype,"startSizeZ",2);Z([w(at)],vs.prototype,"startSpeed",2);class HA{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 i=this.time+this.repeatInterval*this._performed;if(e>=i&&(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 s=Math.random();t=et.lerp(this.count.curveMin.evaluate(s),this.count.curveMax.evaluate(s),Math.random());break}}return t}}class ul{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 i=this.bursts[t];this.system.main.loop&&i.time>=this.system.time&&i.reset(),e+=Math.round(i.run(this.system.time))}return e}}Z([w()],ul.prototype,"enabled",2);Z([w()],ul.prototype,"bursts",2);Z([w(at)],ul.prototype,"rateOverTime",2);Z([w()],ul.prototype,"rateOverTimeMultiplier",2);Z([w(at)],ul.prototype,"rateOverDistance",2);Z([w()],ul.prototype,"rateOverDistanceMultiplier",2);class zv{constructor(){u(this,"enabled");u(this,"color")}}Z([w(Sr)],zv.prototype,"color",2);class Yh{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 M)}evaluate(e,t,i){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,i)*this.xMultiplier,t.y=this.y.evaluate(e,i)*this.yMultiplier,t.z=this.z.evaluate(e,i)*this.zMultiplier;else{const s=this.size.evaluate(e,i)*this.sizeMultiplier;t.x=s}return t}}Z([w(at)],Yh.prototype,"size",2);Z([w(at)],Yh.prototype,"x",2);Z([w(at)],Yh.prototype,"y",2);Z([w(at)],Yh.prototype,"z",2);var nb;const xg=(nb=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 cs);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 De);u(this,"_worldSpaceMatrixInverse",new De);u(this,"_vector",new M(0,0,0));u(this,"_temp",new M(0,0,0));u(this,"_dir",new M);u(this,"_loopTime",0);u(this,"_loopDirection",1);_0&&console.log(this)}get type(){return YG[this.shapeType]}initialize(n){this.getPosition(),n.position.copy(this._vector)}toJSON(){return this}clone(){return new xg}update(n,e,t,i){this.system=n,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(n){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",n.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const n=this._temp.copy(this.position),e=this._space===1;e&&n.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:_0&&tc.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(n);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)),_0&&tc.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(n){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=n.x,i=n.y,s=n.z;this._dir.set(t,i,s),(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),_0&&(tc.DrawSphere(n,.01,8925952,.5,!0),tc.DrawDirection(n,this._dir,8925952,.5,!0)),this._dir}randomizePosition(n,e){if(e<=0)return;const t=xg._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,n.add(t)}randomizeDirection(n,e){if(e===0)return;const t=xg._randomQuat,i=xg._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),n.applyQuaternion(t)}spherizeDirection(n,e){if(e===0)return;const t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),s=Math.sin(i)*Math.cos(t),r=Math.sin(i)*Math.sin(t),o=Math.cos(i),a=new M(s,r,o);n.lerp(a,e)}randomSpherePoint(n,e,t,i,s){const r=Math.random(),o=Math.random(),a=2*Math.PI*r*(i/360),l=Math.acos(2*o-1),c=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,h=n.x+this.scale.x*(-c*Math.sin(l)*Math.cos(a)),d=n.y+this.scale.y*(c*Math.sin(l)*Math.sin(a)),f=n.z+this.scale.z*(c*Math.cos(l));s.x=h,s.y=d,s.z=f}randomCirclePoint(n,e,t,i,s){const r=Math.random(),o=2*Math.PI*r*(i/360),a=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,l=n.x+this.scale.x*a*Math.cos(o),c=n.y+this.scale.y*a*Math.sin(o),h=n.z;s.x=l,s.y=c,s.z=h}randomConePoint(n,e,t,i,s,r,o){let a=0,l=0;switch(r){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*(s/360);switch(r){case 2:case 1:c+=Math.PI+.5,c+=this._loopTime*Math.PI*2,c%=et.toRadians(s);break}const h=Math.acos(2*l-1),d=et.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,f=n.x+-d*Math.sin(h)*Math.cos(c),p=n.y+d*Math.sin(h)*Math.sin(c),m=n.z;o.x=f*this.scale.x,o.y=p*this.scale.y,o.z=m*this.scale.z}},u(nb,"_randomQuat",new Le),u(nb,"_tempVec",new M),nb);let dn=xg;Z([w()],dn.prototype,"shapeType",2);Z([w()],dn.prototype,"enabled",2);Z([w()],dn.prototype,"alignToDirection",2);Z([w()],dn.prototype,"angle",2);Z([w()],dn.prototype,"arc",2);Z([w()],dn.prototype,"arcSpread",2);Z([w()],dn.prototype,"arcSpeedMultiplier",2);Z([w()],dn.prototype,"arcMode",2);Z([w(M)],dn.prototype,"boxThickness",2);Z([w(M)],dn.prototype,"position",2);Z([w(M)],dn.prototype,"rotation",2);Z([w(M)],dn.prototype,"scale",2);Z([w()],dn.prototype,"radius",2);Z([w()],dn.prototype,"radiusThickness",2);Z([w()],dn.prototype,"sphericalDirectionAmount",2);Z([w()],dn.prototype,"randomDirectionAmount",2);Z([w()],dn.prototype,"randomPositionAmount",2);class gi{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 M)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,i,s,r,o){if(!this.enabled)return;this._noise||(this._noise=mse(()=>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=r/o;let f=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=f*this.strengthXMultiplier,this._temp.y*=f*this.strengthYMultiplier,this._temp.z*=f*this.strengthZMultiplier):(this.strengthX&&(f*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(f)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}Z([w()],gi.prototype,"damping",2);Z([w()],gi.prototype,"enabled",2);Z([w()],gi.prototype,"frequency",2);Z([w()],gi.prototype,"octaveCount",2);Z([w()],gi.prototype,"octaveMultiplier",2);Z([w()],gi.prototype,"octaveScale",2);Z([w(at)],gi.prototype,"positionAmount",2);Z([w()],gi.prototype,"quality",2);Z([w(at)],gi.prototype,"remap",2);Z([w()],gi.prototype,"remapEnabled",2);Z([w()],gi.prototype,"remapMultiplier",2);Z([w(at)],gi.prototype,"remapX",2);Z([w()],gi.prototype,"remapXMultiplier",2);Z([w(at)],gi.prototype,"remapY",2);Z([w()],gi.prototype,"remapYMultiplier",2);Z([w(at)],gi.prototype,"remapZ",2);Z([w()],gi.prototype,"remapZMultiplier",2);Z([w()],gi.prototype,"scrollSpeedMultiplier",2);Z([w()],gi.prototype,"separateAxes",2);Z([w()],gi.prototype,"strengthMultiplier",2);Z([w(at)],gi.prototype,"strengthX",2);Z([w()],gi.prototype,"strengthXMultiplier",2);Z([w(at)],gi.prototype,"strengthY",2);Z([w()],gi.prototype,"strengthYMultiplier",2);Z([w(at)],gi.prototype,"strengthZ",2);Z([w()],gi.prototype,"strengthZMultiplier",2);class Gi{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,i,s){let r=this.widthOverTrail.evaluate(i,s);return e*=r,e}getColor(e,t,i){const s=this.colorOverTrail.evaluate(i),r=this.colorOverLifetime.evaluate(t);e.x*=s.r*r.r,e.y*=s.g*r.g,e.z*=s.b*r.b,e.w*=s.alpha*r.alpha}}Z([w()],Gi.prototype,"enabled",2);Z([w()],Gi.prototype,"attachRibbonToTransform",2);Z([w(Sr)],Gi.prototype,"colorOverLifetime",2);Z([w(Sr)],Gi.prototype,"colorOverTrail",2);Z([w()],Gi.prototype,"dieWithParticles",2);Z([w()],Gi.prototype,"inheritParticleColor",2);Z([w(at)],Gi.prototype,"lifetime",2);Z([w()],Gi.prototype,"lifetimeMultiplier",2);Z([w()],Gi.prototype,"minVertexDistance",2);Z([w()],Gi.prototype,"mode",2);Z([w()],Gi.prototype,"ratio",2);Z([w()],Gi.prototype,"ribbonCount",2);Z([w()],Gi.prototype,"shadowBias",2);Z([w()],Gi.prototype,"sizeAffectsLifetime",2);Z([w()],Gi.prototype,"sizeAffectsWidth",2);Z([w()],Gi.prototype,"splitSubEmitterRibbons",2);Z([w()],Gi.prototype,"textureMode",2);Z([w(at)],Gi.prototype,"widthOverTrail",2);Z([w()],Gi.prototype,"widthOverTrailMultiplier",2);Z([w()],Gi.prototype,"worldSpace",2);class Xi{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 M);u(this,"_temp2",new M);u(this,"_temp3",new M);u(this,"_hasOrbital",!1);u(this,"_index",0);u(this,"_orbitalMatrix",new De)}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,i,s,r,o,a){var p;if(!this.enabled)return;const l=o/a,c=this.speedModifier.evaluate(l)*this.speedModifierMultiplier,h=this.x.evaluate(l),d=this.y.evaluate(l),f=this.z.evaluate(l);if(this._temp.set(-h,d,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((p=this._system)==null?void 0:p.worldPos)){const A=this._temp2.set(i.x,i.y,i.z),v=this.orbitalXMultiplier,g=this.orbitalYMultiplier,b=this.orbitalZMultiplier,y=c*Math.PI*2*10,_=Math.cos(y*v),x=Math.sin(y*v),S=Math.cos(y*g),I=Math.sin(y*g),R=Math.cos(y*b),E=Math.sin(y*b),T=A.x*(S*R)+A.y*(S*E)+A.z*-I,k=A.x*(x*I*R-_*E)+A.y*(x*I*E+_*R)+A.z*(x*S),W=A.x*(_*I*R+x*E)+A.y*(_*I*E-x*R)+A.z*(_*S),U=this._temp3.set(A.x-T,A.y-k,A.z-W);U.normalize(),U.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),s.x+=U.x,s.y+=U.y,s.z+=U.z}s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z,s.x*=c,s.y*=c,s.z*=c}}Z([w()],Xi.prototype,"enabled",2);Z([w()],Xi.prototype,"space",2);Z([w(at)],Xi.prototype,"orbitalX",2);Z([w(at)],Xi.prototype,"orbitalY",2);Z([w(at)],Xi.prototype,"orbitalZ",2);Z([w()],Xi.prototype,"orbitalXMultiplier",2);Z([w()],Xi.prototype,"orbitalYMultiplier",2);Z([w()],Xi.prototype,"orbitalZMultiplier",2);Z([w()],Xi.prototype,"orbitalOffsetX",2);Z([w()],Xi.prototype,"orbitalOffsetY",2);Z([w()],Xi.prototype,"orbitalOffsetZ",2);Z([w(at)],Xi.prototype,"speedModifier",2);Z([w()],Xi.prototype,"speedModifierMultiplier",2);Z([w(at)],Xi.prototype,"x",2);Z([w()],Xi.prototype,"xMultiplier",2);Z([w(at)],Xi.prototype,"y",2);Z([w()],Xi.prototype,"yMultiplier",2);Z([w(at)],Xi.prototype,"z",2);Z([w()],Xi.prototype,"zMultiplier",2);class ys{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 i=this.frameOverTime.evaluate(e%1);return i*=this.frameOverTimeMultiplier,i*=t,i=i%t,i=Math.floor(i),i}}Z([w()],ys.prototype,"animation",2);Z([w()],ys.prototype,"enabled",2);Z([w()],ys.prototype,"cycleCount",2);Z([w(at)],ys.prototype,"frameOverTime",2);Z([w()],ys.prototype,"frameOverTimeMultiplier",2);Z([w()],ys.prototype,"numTilesX",2);Z([w()],ys.prototype,"numTilesY",2);Z([w(at)],ys.prototype,"startFrame",2);Z([w()],ys.prototype,"startFrameMultiplier",2);Z([w()],ys.prototype,"rowMode",2);Z([w()],ys.prototype,"rowIndex",2);Z([w()],ys.prototype,"spriteCount",2);Z([w()],ys.prototype,"timeMode",2);class Qo{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}}Z([w()],Qo.prototype,"enabled",2);Z([w()],Qo.prototype,"separateAxes",2);Z([w(at)],Qo.prototype,"x",2);Z([w()],Qo.prototype,"xMultiplier",2);Z([w(at)],Qo.prototype,"y",2);Z([w()],Qo.prototype,"yMultiplier",2);Z([w(at)],Qo.prototype,"z",2);Z([w()],Qo.prototype,"zMultiplier",2);class to{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 i=et.lerp(this.range.x,this.range.y,t);return this.z.evaluate(i)*-1}return 0}}Z([w()],to.prototype,"enabled",2);Z([w()],to.prototype,"range",2);Z([w()],to.prototype,"separateAxes",2);Z([w(at)],to.prototype,"x",2);Z([w()],to.prototype,"xMultiplier",2);Z([w(at)],to.prototype,"y",2);Z([w()],to.prototype,"yMultiplier",2);Z([w(at)],to.prototype,"z",2);Z([w()],to.prototype,"zMultiplier",2);class Mn{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 M);u(this,"_temp2",new M)}apply(e,t,i,s,r,o,a){if(this.enabled){const l=this.limit.evaluate(r)*this.limitMultiplier;if(t.length()>l){this._temp.copy(t).normalize().multiplyScalar(l);let h=this.dampen*.5;t.x=et.lerp(t.x,this._temp.x,h),t.y=et.lerp(t.y,this._temp.y,h),t.z=et.lerp(t.z,this._temp.z,h),i.x=et.lerp(i.x,this._temp.x,h),i.y=et.lerp(i.y,this._temp.y,h),i.z=et.lerp(i.z,this._temp.z,h)}}}}Z([w()],Mn.prototype,"enabled",2);Z([w()],Mn.prototype,"dampen",2);Z([w(at)],Mn.prototype,"drag",2);Z([w()],Mn.prototype,"dragMultiplier",2);Z([w(at)],Mn.prototype,"limit",2);Z([w()],Mn.prototype,"limitMultiplier",2);Z([w()],Mn.prototype,"separateAxes",2);Z([w(at)],Mn.prototype,"limitX",2);Z([w()],Mn.prototype,"limitXMultiplier",2);Z([w(at)],Mn.prototype,"limitY",2);Z([w()],Mn.prototype,"limitYMultiplier",2);Z([w(at)],Mn.prototype,"limitZ",2);Z([w()],Mn.prototype,"limitZMultiplier",2);Z([w()],Mn.prototype,"multiplyDragByParticleSize",2);Z([w()],Mn.prototype,"multiplyDragByParticleVelocity",2);Z([w()],Mn.prototype,"space",2);class Kh{constructor(){u(this,"enabled");u(this,"curve");u(this,"curveMultiplier");u(this,"mode");u(this,"system");u(this,"_lastWorldPosition");u(this,"_velocity",new M);u(this,"_temp",new M)}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,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const s=this.curve.evaluate(t,i);this._temp.copy(this._velocity).multiplyScalar(s),e.add(this._temp)}}}Z([w()],Kh.prototype,"enabled",2);Z([w(at)],Kh.prototype,"curve",2);Z([w()],Kh.prototype,"curveMultiplier",2);Z([w()],Kh.prototype,"mode",2);class sr{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,i,s){const r=e.length(),o=et.remap(r,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,i);return s*a}}Z([w()],sr.prototype,"enabled",2);Z([w(K)],sr.prototype,"range",2);Z([w()],sr.prototype,"separateAxes",2);Z([w(at)],sr.prototype,"size",2);Z([w()],sr.prototype,"sizeMultiplier",2);Z([w(at)],sr.prototype,"x",2);Z([w()],sr.prototype,"xMultiplier",2);Z([w(at)],sr.prototype,"y",2);Z([w()],sr.prototype,"yMultiplier",2);Z([w(at)],sr.prototype,"z",2);Z([w()],sr.prototype,"zMultiplier",2);class wd{constructor(){u(this,"enabled");u(this,"range");u(this,"color")}evaluate(e,t,i){const s=e.length(),r=et.remap(s,this.range.x,this.range.y,0,1),o=this.color.evaluate(r,t);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}Z([w()],wd.prototype,"enabled",2);Z([w(K)],wd.prototype,"range",2);Z([w(Sr)],wd.prototype,"color",2);function yse(n){const e=n.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 i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const r=document.createElement("img");return r.id="button",s.appendChild(r),n.domElement.appendChild(t),s}function bse(){var n=new Date;const e=n.getMonth()+1,t=n.getDate(),i=n.getHours(),s=n.getMinutes(),r=n.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,l=(i<10?"0":"")+i,c=(s<10?"0":"")+s,h=(r<10?"0":"")+r;return n.getFullYear()+o+a+"-"+l+c+h}const x0=se("debugusdz");function _se(n,e){const t=[],i=$.getComponentsInChildren(n,ir);let s=!1;x0&&console.log(i);for(const r of i){if(!r||!r.runtimeAnimatorController)continue;x0&&console.log(r);const o=[];for(const a of r.runtimeAnimatorController.enumerateActions()){x0&&console.log(a);const l=a.getClip();if(!s&&l.tracks.length>0){s=!0;const c=l.tracks[0],h=c.name.substring(0,c.name.lastIndexOf(".")),d=new qr(h+".position",[0,.01],[0,0,0,0,0,0]),f=new qr(h+".quaternion",[0,.01],[0,0,0,1,0,0,0,1]);o.push(new Ks("rest",.01,[d,f]))}o.includes(l)||o.push(l)}t.push({root:r.gameObject,clips:o})}x0&&console.log(t);for(const r of t)for(const o of r.clips)e.registerAnimation(r.root,o)}var xse=Object.defineProperty,wse=Object.getOwnPropertyDescriptor,Ec=(n,e,t,i)=>{for(var s=i>1?void 0:i?wse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&xse(e,t,s),s};const fu=se("debugtext");var Bn=(n=>(n[n.UpperLeft=0]="UpperLeft",n[n.UpperCenter=1]="UpperCenter",n[n.UpperRight=2]="UpperRight",n[n.MiddleLeft=3]="MiddleLeft",n[n.MiddleCenter=4]="MiddleCenter",n[n.MiddleRight=5]="MiddleRight",n[n.LowerLeft=6]="LowerLeft",n[n.LowerCenter=7]="LowerCenter",n[n.LowerRight=8]="LowerRight",n))(Bn||{}),KG=(n=>(n[n.Normal=0]="Normal",n[n.Bold=1]="Bold",n[n.Italic=2]="Italic",n[n.BoldAndItalic=3]="BoldAndItalic",n))(KG||{});class rr extends yd{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(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;(t=this.uiObject)==null||t.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var t;this.uiObject&&((t=this.Canvas)!=null&&t.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var i;const t=(i=this.uiObject)==null?void 0:i._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(t){fu&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,fu&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),fu&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let t=this.fontSize;const i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var s,r,o;if(fu&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let a=this.getNextTag(t);if(a){if(a.startIndex>0){for(let h=this.uiObject.children.length-1;h>=0;h--){const d=this.uiObject.children[h];d.isUI&&(this.uiObject.remove(d),d.clear())}const c=new Bb({textContent:t.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(c)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const l=[];for(;a;){const c=this.getNextTag(t,a.endIndex),h={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(c){h.textContent=this.getText(t,a,c),this.handleTag(a,h,l);const d=new Bb(h);(r=this.uiObject)==null||r.add(d)}else{h.textContent=t.substring(a.endIndex),this.handleTag(a,h,l);const d=new Bb(h);(o=this.uiObject)==null||o.add(d)}a=c}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,s={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(t[o]===!0)continue;r=!0;const a=this._textMeshUi[o];a.textContent&&(D_(a,s),t[o]=!0)}if(!r)break;yield}}handleTag(t,i,s){if(!t.isEndTag){if(t.type.includes("color")){const r=new QC(t,{color:i.color});if(s.push(r),t.type.length>6){const o=parseInt("0x"+t.type.substring(7));i.color=o}else i.color=new ve(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const r=new QC(t,{fontWeight:700});s.push(r)}else if(t.type=="i"){this.setFont(i,2);const r=new QC(t,{fontStyle:"italic"});s.push(r)}}}getText(t,i,s){return t.substring(i.endIndex,s.startIndex)}getNextTag(t,i=0){const s=t.indexOf("<",i),r=t.indexOf(">",s);if(s>=0&&r>=0){const o=t.substring(s+1,r);return{type:o,startIndex:s,endIndex:r+1,isEndTag:o.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;let s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,i);fu&&console.log("Selected font family:"+r);let o=pM.getFontFamily(r);switch(o||(o=pM.addFontFamily(r)),t.fontFamily=o,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let a=o.getVariant(t.fontWeight,t.fontStyle);if(!a){let l=r;l!=null&&l.endsWith("-msdf.json")||(l+="-msdf.json");let c=r;c!=null&&c.endsWith(".png")||(c+=".png"),a=o.addVariant(t.fontWeight,t.fontStyle,l,c),a==null||a.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var h;const s=t.lastIndexOf("-");if(s<0)return t;const r=(h=t.substring(s+1))==null?void 0:h.toLowerCase();if(Sse.includes(r))return fu&&console.warn("Unsupported font style: "+r),t;const o=t.lastIndexOf("/");let a=t;o>=0&&(a=a.substring(o+1));let l=a[0]===a[0].toUpperCase();const c=t.substring(0,s);switch(fu&&console.log("Select font: ",t,KG[i],a,l,c),i){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 t}}}Ec([w()],rr.prototype,"alignment",2);Ec([w()],rr.prototype,"verticalOverflow",2);Ec([w()],rr.prototype,"horizontalOverflow",2);Ec([w()],rr.prototype,"lineSpacing",2);Ec([w()],rr.prototype,"supportRichText",2);Ec([w(URL)],rr.prototype,"font",2);Ec([w()],rr.prototype,"fontStyle",2);Ec([w()],rr.prototype,"text",1);Ec([w()],rr.prototype,"fontSize",1);class QC{constructor(e,t){u(this,"tag");u(this,"previousValues");this.tag=e,this.previousValues=t}}const Sse=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class dh{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 i=this.font.map(r=>`"${r}"`).join(", ");t.appendLine(`string[] font = [ ${i} ]`),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(dh,"global_id",0);class kw{static singleLine(e,t,i){const s=new dh("text_"+dh.getId());return s.content=e,t&&(s.pointSize=t),i&&(s.depth=i),s}static multiLine(e,t,i,s,r,o){const a=new dh("text_"+dh.getId());return a.content=e,a.width=t,a.height=i,a.horizontalAlignment=s,a.verticalAlignment=r,o!==void 0&&(a.wrapMode=o),a}}const Cse=new De().makeRotationY(Math.PI),Ese=new De().makeScale(-1,1,-1);class Gv{get extensionName(){return"text"}onExportObject(e,t,i){}exportText(e,t,i){const s=$.getComponent(e,rr);if(!s)return;const r=$.getComponent(e,fs);let o=100,a=100;r&&(o=r.width,a=r.height),t.matrix=Cse.clone(),r&&t.matrix.premultiply(Ese);const l=new ve().copySRGBToLinear(s.color);t.material=new fa({color:l,emissive:l}),t.addEventListener("serialize",(c,h)=>{let d=s.text;d=d.replace(/\n/g,"\\n");const f=kw.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(f,s.alignment),this.setOverflow(f,s),t.material&&(f.material=t.material),f.pointSize=this.convertToTextSize(s.fontSize),f.depth=.001,f.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 Bn.LowerLeft:case Bn.MiddleLeft:case Bn.UpperLeft:e.horizontalAlignment="left";break;case Bn.LowerCenter:case Bn.MiddleCenter:case Bn.UpperCenter:e.horizontalAlignment="center";break;case Bn.LowerRight:case Bn.MiddleRight:case Bn.UpperRight:e.horizontalAlignment="right";break}switch(t){case Bn.LowerLeft:case Bn.LowerCenter:case Bn.LowerRight:e.verticalAlignment="bottom";break;case Bn.MiddleLeft:case Bn.MiddleCenter:case Bn.MiddleRight:e.verticalAlignment="middle";break;case Bn.UpperLeft:case Bn.UpperCenter:case Bn.UpperRight:e.verticalAlignment="top";break}}}class Ow{get extensionName(){return"tmui"}onExportObject(e,t,i){const s=$.getComponent(e,ps);if(s&&s.activeAndEnabled&&s.renderMode===XG.WorldSpace){const r=new Gv,o=$.getComponent(e,fs),a=$.getComponent(e,Ph);if(o){o.width,o.height;const l=mr.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const h=c.matrix;l.matrix.copy(h);const d=new Map,f=new Map;d.set(c,l),f.set(c,a?a.alpha:1),c.traverse(p=>{if(p===c)return;const m=mr.createEmpty();m.matrix.copy(p.matrix);const A=p.parent,v=A&&typeof A.textContent=="string"&&A.textContent.length;let g=f.get(A)||1;const b=$.getComponent(p,Ph);if(b&&(g*=b.alpha),p instanceof ye&&v){const _=p[Ga].gameObject;r.exportText(_,m,i)}if(p instanceof ye&&!v){const _=p.geometry.clone();_.scale(1,1,-1),this.flipWindingOrder(_),m.geometry=_;const x=new ve,S=p.material.opacity;x.copy(p.material.color),m.material=new fi({color:x,opacity:S*g,map:p.material.map,transparent:!0})}d.set(p,m),f.set(p,g);const y=d.get(A);if(!y){console.error("Error when exporting UI: shadow component parent not found!",p,p.parent);return}y.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let i=0,s=t.length/3;i<s;i++){let r=t[i*3];t[i*3]=t[i*3+2],t[i*3+2]=r}e.index.needsUpdate=!0}}var Mse=Object.defineProperty,Tse=Object.getOwnPropertyDescriptor,io=(n,e,t,i)=>{for(var s=i>1?void 0:i?Tse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Mse(e,t,s),s};const zn=se("debugusdz");class Jh{constructor(){u(this,"callToAction");u(this,"checkoutTitle");u(this,"checkoutSubtitle");u(this,"callToActionURL")}}io([w()],Jh.prototype,"callToAction",2);io([w()],Jh.prototype,"checkoutTitle",2);io([w()],Jh.prototype,"checkoutSubtitle",2);io([w()],Jh.prototype,"callToActionURL",2);class no extends we{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",t=>{t.preventDefault(),this.exportAsync()});u(this,"lastCallback");u(this,"_quicklookButton");u(this,"_quicklookButtonContainer",null)}start(){var t,i,s;zn&&(console.log(this),console.log("Debug USDZ, press 't' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),Dh()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((i=(t=this.objectToExport)==null?void 0:t.children)!=null&&i.length)&&!((s=this.objectToExport)!=null&&s.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Iw),this.extensions.push(new Mw),this.extensions.push(new Gv),this.extensions.push(new Ow))}onEnable(){var s;const t=hA(),i=Gl();(zn||t&&i)&&((zn||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=yse(this.context),this.link.addEventListener("message",this.lastCallback)),zn&&yn("USDZ Exporter enabled: "+this.name),(s=document.getElementById("open-in-ar"))==null||s.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var s,r;(s=this.link)==null||s.removeEventListener("message",this.lastCallback);const t=hA(),i=Gl();(zn||t&&i)&&this.removeQuicklookButton(),zn&&yn("USDZ Exporter disabled: "+this.name),(r=document.getElementById("open-in-ar"))==null||r.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var A;let t=this.exportFileName??((A=this.objectToExport)==null?void 0:A.name)??this.name;if(ip()||(t+="-MadeWithNeedle"),t+="-"+bse(),this.customUsdzFile){zn&&console.log("Exporting custom usdz",this.customUsdzFile);const v=this.buildQuicklookOverlay();zn&&console.log(v);const g=v.callToAction?encodeURIComponent(v.callToAction):"",b=v.checkoutTitle?encodeURIComponent(v.checkoutTitle):"",y=v.checkoutSubtitle?encodeURIComponent(v.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${g}&checkoutTitle=${b}&checkoutSubtitle=${y}&callToActionURL=${v.callToActionURL}`,zn&&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 i=$.getComponentsInChildren(this.objectToExport,Ui),s=new Array;for(const v of i)for(const g of v.sharedMaterials)if(g){const b=v.loadProgressiveTextures(g);b instanceof Promise&&s.push(b)}zn&&yn("Load textures: "+s.length),await Promise.all(s),zn&&yn("Load textures: done"),this.applyWebARSessionRoot();const r=new EJ,o=[...this.extensions],a=new cw;o.push(a),this.autoExportAnimations&&_se(this.objectToExport,a);const l={self:this,exporter:r,extensions:o,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:l})),r.debug=zn,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 r.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();zn&&console.log(d);const f=d.callToAction?encodeURIComponent(d.callToAction):"",p=d.checkoutTitle?encodeURIComponent(d.checkoutTitle):"",m=d.checkoutSubtitle?encodeURIComponent(d.checkoutSubtitle):"";this.link.href=URL.createObjectURL(h)+`#callToAction=${f}&checkoutTitle=${p}&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(t){if((t==null?void 0:t.data)=="_apple_ar_quicklook_button_tapped"){zn&&Fo("Quicklook closed via call to action button");var i=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(i),!i.defaultPrevented){const s=new URLSearchParams(this.link.href);if(s){const r=s.get("callToActionURL");zn&&yn("Quicklook url: "+r),r&&(ip()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var s,r,o,a,l,c;const t={};return this.customBranding&&Object.assign(t,this.customBranding),ip()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),t.callToAction="Close",t.checkoutTitle="🌵 Made with Needle",t.checkoutSubtitle="_"),(((s=t.callToAction)==null?void 0:s.length)||((r=t.checkoutTitle)==null?void 0:r.length)||((o=t.checkoutSubtitle)==null?void 0:o.length))&&((a=t.callToAction)!=null&&a.length||(t.callToAction="\0"),(l=t.checkoutTitle)!=null&&l.length||(t.checkoutTitle="\0"),(c=t.checkoutSubtitle)!=null&&c.length||(t.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:t})),t}async createQuicklookButton(){var t,i;if(!this.webxr)if(await ZA(1),this.webxr=$.findObjectOfType(St)??void 0,this.webxr)if(this.webxr.VRButton&&((t=this.webxr.VRButton.parentElement)==null||t.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const s=(i=this.webxr.ARButton.parentElement)==null?void 0:i.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",Dt.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var t;(t=this._quicklookButton)==null||t.remove()}applyWebARSessionRoot(){if(zn&&console.log("applyWebARSessionRoot"),!this.objectToExport)return;let t=$.getComponentInParent(this.objectToExport,rl);const i=t!=null;if(t||(t=$.getComponentInChildren(this.objectToExport,rl)),!t){zn&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const s=i?this.objectToExport:t.gameObject,r=1/t.arScale;zn&&console.log("Scale",r,s),s.matrix.makeScale(r,r,r),t.invertForward&&s.matrix.multiply(new De().makeRotationY(Math.PI))}}io([w(ke)],no.prototype,"objectToExport",2);io([w()],no.prototype,"autoExportAnimations",2);io([w()],no.prototype,"exportFileName",2);io([w(URL)],no.prototype,"customUsdzFile",2);io([w(Jh)],no.prototype,"customBranding",2);io([w()],no.prototype,"anchoringType",2);io([w()],no.prototype,"planeAnchoringAlignment",2);io([w()],no.prototype,"interactive",2);io([w()],no.prototype,"allowCreateQuicklookButton",2);const ck=se("debugdeletable");class Lw extends To{}class MR extends we{constructor(){super(...arguments);u(this,"deleteBoxes",[])}awake(){this.deleteBoxes=$.findObjectsOfType(Lw,this.context)}update(){for(const t of this.deleteBoxes){const i=this.gameObject;if(t.isInBox(i)===!0){const r=$.getComponentInParent(this.gameObject,Yp);r?ck&&console.warn("Can not delete object with usage marker",this.guid,r):(ck&&console.log("DESTROY",this.gameObject),Xx(this.gameObject,this.context.connection))}}}}var Ise=Object.defineProperty,Rse=Object.getOwnPropertyDescriptor,Sd=(n,e,t,i)=>{for(var s=i>1?void 0:i?Rse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ise(e,t,s),s};class xa extends Ds{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=i=>{const s=i/300,r=2;return et.lerp(r,.01,s)};const t=20;this.aperture.valueProcessor=i=>{const s=1-i/32;return et.lerp(1,t,s)}}onCreateEffect(){if(this.mode===0)return;const t=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;Dh()&&(s=.6),this.resolutionScale=new Tt(s*t)}const i=new e3(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{i.circleOfConfusionMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>i.circleOfConfusionMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>i.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>i.resolution.scale=s),[i]}unapply(){}}Sd([w()],xa.prototype,"mode",2);Sd([w(Tt)],xa.prototype,"focusDistance",2);Sd([w(Tt)],xa.prototype,"focalLength",2);Sd([w(Tt)],xa.prototype,"aperture",2);Sd([w(Tt)],xa.prototype,"gaussianMaxRadius",2);Sd([w(Tt)],xa.prototype,"resolutionScale",2);Sd([w(Tt)],xa.prototype,"bokehScale",2);Ho("DepthOfField",xa);var Pse=Object.defineProperty,Bse=Object.getOwnPropertyDescriptor,Dse=(n,e,t,i)=>{for(var s=i>1?void 0:i?Bse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Pse(e,t,s),s};class Fw extends we{constructor(){super(...arguments);u(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||$.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:kse()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}Dse([w()],Fw.prototype,"visibleOn",2);let w0;function kse(){if(w0===!0||w0===!1)return w0;let n=!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)))&&(n=!0)}(navigator.userAgent||navigator.vendor||window.opera),w0=n,n}class TR{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var Ose=Object.defineProperty,Lse=Object.getOwnPropertyDescriptor,JG=(n,e,t,i)=>{for(var s=i>1?void 0:i?Lse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ose(e,t,s),s},ZG=(n=>(n.SelectStart="selectstart",n.SelectEnd="selectend",n))(ZG||{}),sb;const sh=(sb=class extends qp{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 K}static get HasAnySelected(){return this._active>0}addDragEventListener(e,t){switch(e){case"selectstart":this.selectStartEventListener.push(t);break;case"selectend":this.selectEndEventListener.push(t);break}}start(){this.orbit=$.findObjectOfType(xc,this.context),this.gameObject.getComponentInParent(mc)||this.gameObject.addNewComponent(mc)}allowEdit(e=null){return this.context.connection.allowEditing}onPointerEnter(e){if(!this.allowEdit(this.gameObject)||St.IsInWebXR)return;const t=$.getComponentInParent(e.object,sh);!t||t!==this||(sh.lastHovered=e.object,this.context.domElement.style.cursor="pointer")}onPointerExit(e){this.allowEdit(this.gameObject)&&(St.IsInWebXR||sh.lastHovered===e.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(e){this.allowEdit(this.gameObject)&&(St.IsInWebXR||(sh._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=e.clone(),e.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(e){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(sh._active>0&&(sh._active-=1),!St.IsInWebXR&&(this.onDragEnd(e),e.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var e;if(!St.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const i=this.context.input.getPointerPositionDelta(0);if(i&&this._dragDelta.add(i),this._dragDelta.length()>2)this._didDrag=!0;else return}const t=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(t)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((e=this._dragHelper)==null?void 0:e.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(e){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new Ob(this.context.mainCamera);else return;if(!e||!e.object)return;const t=$.getComponentInParent(e.object,sh);if(!t||t!==this)return;let i=e.object;this.transformSelf&&(i=this.gameObject);const s={selected:i,attached:i};for(const l of this.selectStartEventListener)l(this,s);if(this._activePointerId=e.pointerId,!s.attached)return;s.attached,i=s.attached,this._isDragging=!0,this._dragHelper.setSelected(i,this.context),this.orbit&&(this.orbit.enabled=!1);const r=$.getComponentInChildren(i,Th);r&&(r.fastMode=!0,r==null||r.requestOwnership()),this._marker=$.addNewComponent(i,Yp),this._draggingRigidbodies.length=0;const o=$.getComponentsInChildren(i,ji);o&&this._draggingRigidbodies.push(...o);const a=qb();$.invokeOnChildren(this._dragHelper.selected,a("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities()}}onDragEnd(e){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 t=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),e!=null&&e.object){const s=$.getComponentInChildren(e.object,Th);s&&(s.fastMode=!1)}this._marker&&this._marker.destroy();for(const s of this.selectEndEventListener)s(this);const i=qb();$.invokeOnChildren(t,i("onDragEnd"))}},u(sb,"_active",0),u(sb,"lastHovered"),sb);let dm=sh;JG([w()],dm.prototype,"showGizmo",2);JG([w()],dm.prototype,"useViewAngle",2);const AP=class{constructor(e){u(this,"showGizmo",!0);u(this,"useViewAngle",!0);u(this,"_selected",null);u(this,"_context",null);u(this,"_camera");u(this,"_cameraPlane",new Co);u(this,"_hasGroundPlane",!1);u(this,"_groundPlane",new Co);u(this,"_groundOffset",new M);u(this,"_groundOffsetFactor",0);u(this,"_groundDistance",0);u(this,"_groundPlanePoint",new M);u(this,"_raycaster",new Fp);u(this,"_cameraPlaneOffset",new M);u(this,"_intersection",new M);u(this,"_worldPosition",new M);u(this,"_inverseMatrix",new De);u(this,"_rbs",[]);u(this,"_groundLine");u(this,"_groundMarker");u(this,"_groundOffsetVector",new M(0,1,0));u(this,"_requireUpdateGroundPlane",!0);u(this,"_didDragOnGroundPlaneLastFrame",!1);this._camera=e;const t=new ln(AP.geometry),i=t.material;i.color=new ve(.4,.4,.4),t.layers.set(2),t.name="line",t.scale.y=1,this._groundLine=t;const s=new No(.5,22,22),r=new fi({color:i.color}),o=new ye(s,r);o.visible=!1,o.layers.set(2),this._groundMarker=o}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(e,t){if(this._selected&&t)for(const i of this._rbs)i.wakeUp(),i.setVelocity(0,0,0);if(this._selected&&Zs.Remove(t,this._selected),this._selected=e,this._context=t,this._rbs.length=0,e?(t.scene.add(this._groundLine),t.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!t){console.error("DragHelper: no context");return}Zs.Add(t,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(e){var a,l,c,h,d;if(!this._context)return;const t="Space",i="KeyD",s=((a=this._context)==null?void 0:a.input.isKeyPressed(t))||((l=this._context)==null?void 0:l.input.isKeyPressed(i)),r=this._context.input.getTouchesPressedCount()>=2||s;if(r){const f=this._context.input.getPointerPositionDelta(0);f&&(this._groundOffsetVector.set(0,1,0),(c=this._selected)==null||c.rotateOnWorldAxis(this._groundOffsetVector,f.x*this._context.time.deltaTime))}const o=this._context.input.getPointerPositionRC(0);if(o&&(this._raycaster.setFromCamera(o,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const f=xt(this._camera).clone().sub(xt(this._selected)).normalize(),p=Math.abs(f.dot(this._groundOffsetVector)),m=((h=this._context)==null?void 0:h.input.isKeyPressed(t))||((d=this._context)==null?void 0:d.input.isKeyPressed(i));let A=!this.useViewAngle||p>.2;(r||m||this._context.input.getPointerPressedCount()>1)&&(A=!1);const v=this._didDragOnGroundPlaneLastFrame!==A;if(this._didDragOnGroundPlaneLastFrame=A,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!A||v)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const g=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=g,A){this._groundOffsetVector.set(0,1,0);const b=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(b,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(e,t,i){if(this._selected){if(i){const s=xt(this._selected);s.y=e.y,e=s}if(hn(this._selected,e),hn(this._groundLine,e),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=t!==null&&this.showGizmo,t){const s=xt(this._camera).distanceTo(t)*.01;this._groundMarker.scale.set(s,s,s),hn(this._groundMarker,t)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const e=this._context.input.getPointerPositionRC(0);e&&(this._raycaster.setFromCamera(e,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 e=xt(this._selected),t=new ol(new M(0,.1,0).add(e),new M(0,-1,0)),i=new va;i.ignore=[this._selected];const s=this._context.physics.raycastFromRay(t,i);for(let r=0;r<s.length;r++){const o=s[r];if(!o.face||this.contains(this._selected,o.object))continue;const a=new M(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(a,o.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(t.direction.multiplyScalar(-1),t.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(e),this._groundOffset.copy(this._intersection).sub(e)}onDidUpdate(){vr.markDirty(this._selected);for(const e of this._rbs)e.wakeUp(),e.resetForcesAndTorques(),e.setAngularVelocity(0,0,0)}contains(e,t){if(e===t)return!0;if(e.children){for(const i of e.children)if(this.contains(i,t))return!0}return!1}};let Ob=AP;u(Ob,"geometry",new wt().setFromPoints([new M(0,0,0),new M(0,-1,0)]));function IR(n,e,t){console.warn("Adding components on object has been temporarily disabled")}var $G=(n=>(n.File_Spawned="file-spawned",n))($G||{});class e4{constructor(e,t,i,s,r,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=i,this.file_name=s,this.file_hash=r,this.file_size=o,this.position=a,this.sender=e,this.serverUrl=l}}async function t4(n,e,t){const i=n.name;return i.endsWith(".gltf")||i.endsWith(".glb")?new Promise((s,r)=>{const o=new FileReader;o.readAsArrayBuffer(n),o.onloadend=async a=>{const l=o.result,c=qx(),h=new Js(c),d=await pa().parseSync(e,l,n.name,h);if(d&&d.scene){const f=d.scene;if(!f.guid){const p=new Js(c);f.guid=p.generateUUID()}t&&Fse(e.connection,n,c,f,t),IR(),s(d)}}}):(console.warn("Unsupported file type: "+i,n),null)}async function i4(n,e){return new Promise(async(t,i)=>{const s=qx(),r=new Js(s),o=n.toString(),a=await pa().loadSync(e,o,o,r);a&&a.scene?(a.scene,IR(),t(a)):console.warn("Unsupported file type: "+n.toString())})}Li.registerCallback(Ws.ContextCreated,n=>{n4(n.context)});function n4(n){n.connection.beginListen("file-spawned",async e=>{if(e.sender!==n.connection.connectionId){console.log("received file event",e),Use(e,n);let t=null;try{t=await fI(e.file_name,e.file_hash,e.file_size,e.serverUrl)}finally{Nse(e)}if(t){const i=new Js(e.seed),s=await pa().parseSync(n,t,e.file_name,i);if(s&&s.scene){const r=s.scene;if(IR(),e.parentGuid){const o=mv(e.parentGuid,n.scene);o&&"add"in o&&o.add(r)}r.parent||n.scene.add(r),e.position!==null&&r.position.copy(e.position)}}else console.error("download didnt return file")}})}async function Fse(n,e,t,i,s){if(!n.connectionId){console.error("Can not upload file - no connection id");return}if(!i.guid){console.error("Can not upload file - no guid",i,i.guid);return}const r=await u3(e,s);if(!r)return;if(!r.filename){console.error("Can not send upload event - no filename",e.name);return}if(!r.hash){console.error("Can not send upload event - no hash",e.name);return}const o=new e4(n.connectionId,t,i.guid,r.filename,r.hash,e.size,i.position,r.url??s);i.parent&&(o.parentGuid=i.parent.guid),n.send("file-spawned",o)}const vM={};function Use(n,e){const t=new Ai,i=new ye(t,new fi({color:65280})),s=new Bx(i,5592405);if(vM[n.guid]=s,e.scene.add(s),n.parentGuid){const r=mv(n.parentGuid,e.scene);r&&r.add(s)}n.position&&s.position.copy(n.position)}function Nse(n,e){const t=n.guid,i=vM[t];i&&(delete vM[t],i.removeFromParent())}var zse=Object.defineProperty,Gse=Object.getOwnPropertyDescriptor,RR=(n,e,t,i)=>{for(var s=i>1?void 0:i?Gse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&zse(e,t,s),s};const Hse=se("debugnet"),yM=class extends we{constructor(){super(...arguments);u(this,"url",null);u(this,"urlParameterName",null);u(this,"localhost",null)}awake(){Hse&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let e=this.url?yM.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const r=se(this.urlParameterName);r&&typeof r=="string"&&(e=r)}if(!e)return null;const i=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(e);return i!=null&&i.groups?(i==null?void 0:i.groups.socket_prefix)?e:"wss://"+(i==null?void 0:i.groups.url):null}static GetUrl(e,t){let i=e;const s=yM.IsLocalNetwork()&&t;return s&&(i=t),e!=null&&e.startsWith("/")&&(i=(s?i:window.location.origin)+e),i}static IsLocalNetwork(e=window.location.hostname){return $s(e)}};let Cd=yM;RR([w()],Cd.prototype,"url",2);RR([w()],Cd.prototype,"urlParameterName",2);RR([w()],Cd.prototype,"localhost",2);var Qse=Object.defineProperty,Vse=Object.getOwnPropertyDescriptor,s4=(n,e,t,i)=>{for(var s=i>1?void 0:i?Vse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qse(e,t,s),s};const ff=se("debugdroplistener");class Hv extends we{constructor(){super(...arguments);u(this,"filesBackendUrl");u(this,"localhost");u(this,"onDrag",t=>{t.preventDefault()});u(this,"onDrop",async t=>{if(ff&&console.log(t),!t.dataTransfer)return;t.preventDefault();const i=t.dataTransfer.items;if(i)for(const s in i){const r=i[s];if(r.kind==="file"){const o=r.getAsFile();if(!o)continue;await this.addFiles(o)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(async o=>{ff&&console.log("dropped url",o);try{const a=new URL(o);if(!a)return;const l=await i4(a,this.context);l&&this.addObject(t,l)}catch{console.log("dropped string is not a valid URL!",o)}})}})}onEnable(){this.filesBackendUrl=Cd.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,ff&&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(...t){if(ff&&console.log("Add files",t),!!Array.isArray(t)&&t.length)for(const i of t){if(!i)continue;ff&&console.log("Register file "+i.name+" to",this.filesBackendUrl,i);const s=await t4(i,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:i})),s&&this.addObject(void 0,s)}}async addObject(t,i){ff&&console.log("Dropped",i);const s=i.scene;if(t!==void 0){const r=new va;r.setMask(16777215),r.screenPointFromOffset(t.offsetX,t.offsetY);const o=this.context.physics.raycast(r);if(o&&o.length>0)for(const a of o){s.position.copy(a.point);break}}this.gameObject.add(s),this.dispatchEvent(new CustomEvent("object-added",{detail:i}))}}s4([w()],Hv.prototype,"filesBackendUrl",2);s4([w()],Hv.prototype,"localhost",2);var Wse=Object.defineProperty,jse=Object.getOwnPropertyDescriptor,Uw=(n,e,t,i)=>{for(var s=i>1?void 0:i?jse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Wse(e,t,s),s};class Ed extends qp{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 i,s;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((i=this.object.position)==null?void 0:i.clone())??new M(0,0,0),this._startQuaternion=((s=this.object.quaternion)==null?void 0:s.clone())??new Le(0,0,0,1)}const t=$.getComponentInParent(this.gameObject,dm);t?t.addDragEventListener(ZG.SelectStart,(r,o)=>{if(this._currentCount>=this.limitCount){o.attached=null;return}const a=this.handleDuplication(o.selected);a&&(console.assert(a!==o.selected,"Duplicated object is original"),o.attached=a)}):console.warn("Could no find drag controls in parent",this.name),Ji.addEventListener(Nl.SelectStart,(r,o)=>{if(this._currentCount>=this.limitCount){o.grab=null;return}const a=this.handleDuplication(o.selected);a&&(o.grab=a)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(t){var i;if(this._currentCount>=this.limitCount||!this.object)return null;if(t===this.gameObject||this.handleMultiObject(t)){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 sl;this.parent||(this.parent=this.gameObject.parent),this.parent&&(s.parent=this.parent.guid??((i=this.parent.userData)==null?void 0:i.guid),s.keepWorldPosition=!0),s.position=this.worldPosition,s.rotation=this.worldQuaternion,s.context=this.context,this._currentCount+=1;const r=$.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(t){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,t):!1}isInChildren(t,i){if(!t)return!1;if(t===i)return!0;if(t.children){for(let s of t.children)if(this.isInChildren(s,i))return!0}return!1}}Uw([w(ke)],Ed.prototype,"parent",2);Uw([w(ke)],Ed.prototype,"object",2);Uw([w()],Ed.prototype,"limitCount",2);Uw([w()],Ed.prototype,"limitInterval",2);var kf=(n=>(n[n.PointerEnter=0]="PointerEnter",n[n.PointerExit=1]="PointerExit",n[n.PointerDown=2]="PointerDown",n[n.PointerUp=3]="PointerUp",n[n.PointerClick=4]="PointerClick",n[n.Drag=5]="Drag",n[n.Drop=6]="Drop",n[n.Scroll=7]="Scroll",n[n.UpdateSelected=8]="UpdateSelected",n[n.Select=9]="Select",n[n.Deselect=10]="Deselect",n[n.Move=11]="Move",n[n.InitializePotentialDrag=12]="InitializePotentialDrag",n[n.BeginDrag=13]="BeginDrag",n[n.EndDrag=14]="EndDrag",n[n.Submit=15]="Submit",n[n.Cancel=16]="Cancel",n))(kf||{}),Xse=Object.defineProperty,qse=Object.getOwnPropertyDescriptor,PR=(n,e,t,i)=>{for(var s=i>1?void 0:i?qse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Xse(e,t,s),s};class BR{constructor(){u(this,"eventID");u(this,"callback")}}PR([w()],BR.prototype,"eventID",2);PR([w(yr)],BR.prototype,"callback",2);class Nw extends we{constructor(){super(...arguments);u(this,"triggers")}invoke(t){if(this.triggers)for(const i of this.triggers)i.eventID===t&&i.callback.invoke()}onPointerClick(t){this.invoke(kf.PointerClick)}onPointerEnter(t){this.invoke(kf.PointerEnter)}onPointerExit(t){this.invoke(kf.PointerExit)}onPointerDown(t){this.invoke(kf.PointerDown)}onPointerUp(t){this.invoke(kf.PointerUp)}}PR([w(BR)],Nw.prototype,"triggers",2);var Yse=Object.defineProperty,Kse=Object.getOwnPropertyDescriptor,DR=(n,e,t,i)=>{for(var s=i>1?void 0:i?Kse(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yse(e,t,s),s};class kR extends we{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)}}DR([w(ji)],kR.prototype,"connectedBody",2);class OR extends kR{createJoint(e,t){var i;(i=this.context.physics.engine)==null||i.addFixedJoint(e,t)}}class Qv extends kR{constructor(){super(...arguments);u(this,"anchor");u(this,"axis")}createJoint(t,i){var s;this.axis&&this.anchor&&((s=this.context.physics.engine)==null||s.addHingeJoint(t,i,this.anchor,this.axis))}}DR([w(M)],Qv.prototype,"anchor",2);DR([w(M)],Qv.prototype,"axis",2);const Jse={type:"change"};let Zse=class extends Un{constructor(e,t){super(),this.object=e,this.domElement=t,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const i=this,s=1e-6,r=new Le,o=new M;this.tmpQuaternion=new Le,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 M(0,0,0),this.rotationVector=new M(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 m=this.getContainerDimensions(),A=m.size[0]/2,v=m.size[1]/2;this.moveState.yawLeft=-(p.pageX-m.offset[0]-A)/A,this.moveState.pitchDown=(p.pageY-m.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 m=p*i.movementSpeed,A=p*i.rollSpeed;i.object.translateX(i.moveVector.x*m),i.object.translateY(i.moveVector.y*m),i.object.translateZ(i.moveVector.z*m),i.tmpQuaternion.set(i.rotationVector.x*A,i.rotationVector.y*A,i.rotationVector.z*A,1).normalize(),i.object.quaternion.multiply(i.tmpQuaternion),(o.distanceToSquared(i.object.position)>s||8*(1-r.dot(i.object.quaternion))>s)&&(i.dispatchEvent(Jse),r.copy(i.object.quaternion),o.copy(i.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",a),this.domElement.removeEventListener("pointerdown",c),this.domElement.removeEventListener("pointermove",l),this.domElement.removeEventListener("pointerup",h),window.removeEventListener("keydown",d),window.removeEventListener("keyup",f)};const a=this.contextMenu.bind(this),l=this.pointermove.bind(this),c=this.pointerdown.bind(this),h=this.pointerup.bind(this),d=this.keydown.bind(this),f=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",a),this.domElement.addEventListener("pointerdown",c),this.domElement.addEventListener("pointermove",l),this.domElement.addEventListener("pointerup",h),window.addEventListener("keydown",d),window.addEventListener("keyup",f),this.updateMovementVector(),this.updateRotationVector()}};class LR extends we{constructor(){super(...arguments);u(this,"_controls",null)}onEnable(){var i;const t=(i=$.getComponent(this.gameObject,Ni))==null?void 0:i.cam;this._controls=new Zse(t,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var t;(t=this._controls)==null||t.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var $se=Object.defineProperty,ere=Object.getOwnPropertyDescriptor,FR=(n,e,t,i)=>{for(var s=i>1?void 0:i?ere(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$se(e,t,s),s};class fm extends we{constructor(){super(...arguments);u(this,"_fog")}get fog(){return this._fog||(this._fog=new AT(0,0,50)),this._fog}get mode(){return 1}set near(t){this.fog.near=t}get near(){return this.fog.near}set far(t){this.fog.far=t}get far(){return this.fog.far}set color(t){this.fog.color.copy(t)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}FR([w()],fm.prototype,"near",1);FR([w()],fm.prototype,"far",1);FR([w(ve)],fm.prototype,"color",1);let S0,VC,pf,C0;function WC(n,e=1/0,t=null){VC||(VC=new Kr(2,2,1,1)),pf||(pf=new Ot({uniforms:{blitTexture:new Ee(n)},vertexShader:`
5022
5022
  varying vec2 vUv;
5023
5023
  void main(){
5024
5024
  vUv = uv;