@needle-tools/engine 3.27.1-beta → 3.27.2-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.
@@ -4252,7 +4252,7 @@ outputColor=vec4(color,inputColor.a);}`,HN=class extends ba{constructor({blendFu
4252
4252
  *
4253
4253
  * @author Feross Aboukhadijeh <https://feross.org>
4254
4254
  * @license MIT
4255
- */var GY=function(n){return n!=null&&(qN(n)||HY(n)||!!n._isBuffer)};function qN(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function HY(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&qN(n.slice(0,0))}(function(){var n=zY,e=YD.utf8,t=GY,i=YD.bin,s=function(r,o){r.constructor==String?o&&o.encoding==="binary"?r=i.stringToBytes(r):r=e.stringToBytes(r):t(r)?r=Array.prototype.slice.call(r,0):!Array.isArray(r)&&r.constructor!==Uint8Array&&(r=r.toString());for(var a=n.bytesToWords(r),c=r.length*8,l=1732584193,u=-271733879,d=-1732584194,f=271733878,p=0;p<a.length;p++)a[p]=(a[p]<<8|a[p]>>>24)&16711935|(a[p]<<24|a[p]>>>8)&4278255360;a[c>>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;for(var m=s._ff,A=s._gg,v=s._hh,g=s._ii,p=0;p<a.length;p+=16){var b=l,y=u,_=d,E=f;l=m(l,u,d,f,a[p+0],7,-680876936),f=m(f,l,u,d,a[p+1],12,-389564586),d=m(d,f,l,u,a[p+2],17,606105819),u=m(u,d,f,l,a[p+3],22,-1044525330),l=m(l,u,d,f,a[p+4],7,-176418897),f=m(f,l,u,d,a[p+5],12,1200080426),d=m(d,f,l,u,a[p+6],17,-1473231341),u=m(u,d,f,l,a[p+7],22,-45705983),l=m(l,u,d,f,a[p+8],7,1770035416),f=m(f,l,u,d,a[p+9],12,-1958414417),d=m(d,f,l,u,a[p+10],17,-42063),u=m(u,d,f,l,a[p+11],22,-1990404162),l=m(l,u,d,f,a[p+12],7,1804603682),f=m(f,l,u,d,a[p+13],12,-40341101),d=m(d,f,l,u,a[p+14],17,-1502002290),u=m(u,d,f,l,a[p+15],22,1236535329),l=A(l,u,d,f,a[p+1],5,-165796510),f=A(f,l,u,d,a[p+6],9,-1069501632),d=A(d,f,l,u,a[p+11],14,643717713),u=A(u,d,f,l,a[p+0],20,-373897302),l=A(l,u,d,f,a[p+5],5,-701558691),f=A(f,l,u,d,a[p+10],9,38016083),d=A(d,f,l,u,a[p+15],14,-660478335),u=A(u,d,f,l,a[p+4],20,-405537848),l=A(l,u,d,f,a[p+9],5,568446438),f=A(f,l,u,d,a[p+14],9,-1019803690),d=A(d,f,l,u,a[p+3],14,-187363961),u=A(u,d,f,l,a[p+8],20,1163531501),l=A(l,u,d,f,a[p+13],5,-1444681467),f=A(f,l,u,d,a[p+2],9,-51403784),d=A(d,f,l,u,a[p+7],14,1735328473),u=A(u,d,f,l,a[p+12],20,-1926607734),l=v(l,u,d,f,a[p+5],4,-378558),f=v(f,l,u,d,a[p+8],11,-2022574463),d=v(d,f,l,u,a[p+11],16,1839030562),u=v(u,d,f,l,a[p+14],23,-35309556),l=v(l,u,d,f,a[p+1],4,-1530992060),f=v(f,l,u,d,a[p+4],11,1272893353),d=v(d,f,l,u,a[p+7],16,-155497632),u=v(u,d,f,l,a[p+10],23,-1094730640),l=v(l,u,d,f,a[p+13],4,681279174),f=v(f,l,u,d,a[p+0],11,-358537222),d=v(d,f,l,u,a[p+3],16,-722521979),u=v(u,d,f,l,a[p+6],23,76029189),l=v(l,u,d,f,a[p+9],4,-640364487),f=v(f,l,u,d,a[p+12],11,-421815835),d=v(d,f,l,u,a[p+15],16,530742520),u=v(u,d,f,l,a[p+2],23,-995338651),l=g(l,u,d,f,a[p+0],6,-198630844),f=g(f,l,u,d,a[p+7],10,1126891415),d=g(d,f,l,u,a[p+14],15,-1416354905),u=g(u,d,f,l,a[p+5],21,-57434055),l=g(l,u,d,f,a[p+12],6,1700485571),f=g(f,l,u,d,a[p+3],10,-1894986606),d=g(d,f,l,u,a[p+10],15,-1051523),u=g(u,d,f,l,a[p+1],21,-2054922799),l=g(l,u,d,f,a[p+8],6,1873313359),f=g(f,l,u,d,a[p+15],10,-30611744),d=g(d,f,l,u,a[p+6],15,-1560198380),u=g(u,d,f,l,a[p+13],21,1309151649),l=g(l,u,d,f,a[p+4],6,-145523070),f=g(f,l,u,d,a[p+11],10,-1120210379),d=g(d,f,l,u,a[p+2],15,718787259),u=g(u,d,f,l,a[p+9],21,-343485551),l=l+b>>>0,u=u+y>>>0,d=d+_>>>0,f=f+E>>>0}return n.endian([l,u,d,f])};s._ff=function(r,o,a,c,l,u,d){var f=r+(o&a|~o&c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._gg=function(r,o,a,c,l,u,d){var f=r+(o&c|a&~c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._hh=function(r,o,a,c,l,u,d){var f=r+(o^a^c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._ii=function(r,o,a,c,l,u,d){var f=r+(a^(o|~c))+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._blocksize=16,s._digestsize=16,WN.exports=function(r,o){if(r==null)throw new Error("Illegal argument "+r);var a=n.wordsToBytes(s(r,o));return o&&o.asBytes?a:o&&o.asString?i.bytesToString(a):n.bytesToHex(a)}})();var VY=WN.exports;const QY=HA(VY);class mM{constructor(e,t,i,s){h(this,"success");h(this,"filename");h(this,"hash");h(this,"size");h(this,"url");this.success=e,this.filename=t,this.hash=i,this.size=s}}async function XN(n,e){const t=await n.arrayBuffer(),i=WT(t),s=n.name.split(".").pop(),r=i+"."+s,o=n.name.split(".").shift();console.assert(o!==void 0);const a={alias:o,filename:r},l=await(await fetch(e+"/exists",{method:"POST",body:JSON.stringify(a)})).json();if(l.success||console.warn("exists check did fail"),l.exists)return console.log("file already exists",i),new mM(!0,r,i,n.size);console.log("begin uploading file",o,n.size);const u=new FormData;u.append("file",n);const d={};d.filesize=n.size,o&&(d.alias=o);const p=await(await fetch(e+"/upload/file",{method:"POST",body:u,headers:d})).json();if((p==null?void 0:p.success)===!1)return p.message!==void 0?console.error("Upload failed:",p.message):console.error("Upload failed"),null;console.assert(p.hash_sum===i,"hash sum did not match","received:",p.hash_sum,"expected:",i),p.success&&console.log("successfully uploaded",i,p.id);const m=new mM(p.success,r,i,n.size);return m.url=e,m}function WT(n){return QY(new Uint8Array(n))}async function jT(n,e,t,i,s=!1){try{const r=await fetch(i+"/download/file",{method:"POST",body:n});if(r.status!==200)return console.error("download failed",r),null;const o=await r.blob(),a=await o.arrayBuffer();s||console.assert(o.size===t,"size mismatch","expected:",t,"got:",o.size);const c=WT(a);return s||console.assert(c===e,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(r){console.error(r)}return null}async function YN(n,e){var u;const t=await fetch(n),i=(u=t.body)==null?void 0:u.getReader(),s=t.headers.get("Content-Length"),r=s?parseInt(s):0;if(!i)return null;let o=0;const a=[];for(;;){const{done:d,value:f}=await i.read();if(f&&(a.push(f),o+=f.length,e.call(null,new ProgressEvent("progress",{loaded:o,total:r}))),d)break}const c=new Uint8Array(o);let l=0;for(const d of a)c.set(d,l),l+=d.length;return c}let JN,JD=null;function fa(){return JN}function qT(n){if(n==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}JD!==n&&(JD=n,JN=new n)}const Ll=re("debugaddressables");class KN{constructor(e){h(this,"_context");h(this,"_assetReferences",{});this._context=e,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.uri&&(this._assetReferences[e.uri]?console.warn("Asset reference already registered",e):this._assetReferences[e.uri]=e),e}dispose(){for(const e in this._assetReferences){const t=this._assetReferences[e];t==null||t.unload()}this._assetReferences={}}unregisterAssetReference(e){e.uri&&delete this._assetReferences[e.uri]}}const US=Symbol("assetReference"),Tf=class{constructor(e,t,i=null){h(this,"_loading");h(this,"_asset");h(this,"_glbRoot");h(this,"_url");h(this,"_progressListeners",[]);h(this,"_hash");h(this,"_hashedUri");h(this,"_isLoadingRawBinary",!1);h(this,"_rawBinary");this._url=e,this._hash=t,e.includes("?v=")?this._hashedUri=e:this._hashedUri=t?e+"?v="+t:e,i!==null&&(this.asset=i),XU(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(e,t,i){if(typeof e=="string"){if(!i&&(i=Lt.Current,!i))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else i=e.context,e=e.sourceId;const s=fl(e,t);Ll&&console.log("GetOrCreate Addressable from",e,t,"FinalPath=",s);const r=i.addressables,o=r.findAssetReference(s);if(o)return o;const a=new Tf(s,i.hash);return r.registerAssetReference(a),a}get asset(){return this._glbRoot??this._asset}set asset(e){this._asset=e}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(e){return e===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||yx(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(Ll&&console.log("Unload",this.asset),this.asset.scene&&ic(this.asset.scene,!0,!0),ic(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Lt.Current&&Lt.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,Ll&&console.log("Preload",this._hashedUri);const e=await YN(this._hashedUri,t=>{this.raiseProgressEvent(t)});return this._rawBinary=(e==null?void 0:e.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(e){if(Ll&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(e&&this._progressListeners.push(e),this._loading!==void 0)return this._loading;const t=Lt.Current;this._rawBinary?(this._loading=fa().parseSync(t,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(Ll&&console.log("Load async",this.uri),this._loading=fa().loadSync(t,this._hashedUri,this.uri,null,s=>{this.raiseProgressEvent(s)}));const i=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(i),this._loading=void 0,i)return i[US]=this,this._glbRoot&&(this._glbRoot[US]=this),this.asset&&(this.asset[US]=this),Nb(t),i.scene!==void 0&&(this.asset=i),this.asset}async instantiate(e){return this.onInstantiate(e,!1)}async instantiateSynced(e,t=!0){return this.onInstantiate(e,!0,t)}beginListenDownload(e){this._progressListeners.indexOf(e)<0&&this._progressListeners.push(e)}endListenDownload(e){const t=this._progressListeners.indexOf(e);t>=0&&this._progressListeners.splice(t,1)}raiseProgressEvent(e){for(const t of this._progressListeners)t(this,e)}async onInstantiate(e,t=!1,i){const s=Lt.Current;if(this.mustLoad&&await this.loadAssetAsync(),Ll&&console.log("Instantiate",this.uri,"parent:",e),this.asset){Ll&&console.log("Add to scene",this.asset);let r=e instanceof tc?e:null;r||(r=new tc),typeof e=="object"&&(e instanceof _e?r.parent=e:Object.assign(r,e)),r.parent||(r.parent=s.scene);let o=Tf.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,Tf.currentlyInstantiating.set(this.uri,o),t){r.context=s;const a=this.asset;a.guid=this.uri;const c=RT(a,r,void 0,i);if(c)return c}else{const a=KA(this.asset,r);if(a)return a}}finally{s.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,Tf.currentlyInstantiating.set(this.uri,o)})}}else Ll&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(e){if(e&&e.scene){const t=e.scene;return t.isGroup&&t.children.length===1&&t.children[0].name+"glb"===t.name?t.children[0]:t}return null}};let _n=Tf;h(_n,"currentlyInstantiating",new Map);class WY extends ml{constructor(){super([_n])}onSerialize(e,t){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,t){if(typeof e=="string")return t.context?t.gltfId?_n.getOrCreate(t.gltfId,e,t.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof _e){if(!t.context)return console.error("Missing context"),null;if(!t.gltfId)return console.error("Missing source id"),null;const i=e,s=t.context,r=i.guid??i.uuid,o=s.addressables.findAssetReference(r);if(o)return o;const a=new _n(r,void 0,i);return s.addressables.registerAssetReference(a),a}return null}}new WY;const jY=Promise.resolve(null),Rg=class{constructor(e){h(this,"url");h(this,"_bitmap");h(this,"_bitmapObject");h(this,"loader",null);this.url=e}static getOrCreate(e){let t=Rg.imageReferences.get(e);return t||(t=new Rg(e),Rg.imageReferences.set(e,t)),t}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const e=new Image;return e.src=this.url,e}createTexture(){return this.url?(this.loader||(this.loader=new Zc),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):jY}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((e,t)=>{const i=document.createElement("img");i.addEventListener("load",()=>{this._bitmap=createImageBitmap(i).then(s=>(this._bitmapObject=s,e(s),s))}),i.addEventListener("error",s=>{console.error("Failed to load image:"+this.url,s),e(null)}),i.src=this.url}),this._bitmap)}};let kf=Rg;h(kf,"imageReferences",new Map);class ZN extends ml{constructor(){super([kf])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=fl(t.gltfId,e);return kf.getOrCreate(i)}}}new ZN;const xo=re("debugenvlight");var Lf=(n=>(n[n.Skybox=0]="Skybox",n[n.Trilight=1]="Trilight",n[n.Flat=3]="Flat",n[n.Custom=4]="Custom",n))(Lf||{}),Gb=(n=>(n[n.Skybox=0]="Skybox",n[n.Custom=1]="Custom",n))(Gb||{});class $N{constructor(e){h(this,"context");h(this,"_currentLightSettingsId");h(this,"_sceneLightSettings");h(this,"_timevec4",new et);h(this,"__currentReflectionId",null);h(this,"_waitPromise");h(this,"_lighting",{});this.context=e,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const e=this.context.time;this._timevec4.x=e.time,this._timevec4.y=Math.sin(e.time),this._timevec4.z=Math.cos(e.time),this._timevec4.w=e.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const e=this._sceneLightSettings.get(this._currentLightSettingsId);return e?e.ambientIntensity:1}get sceneLightSettings(){var e;return(e=this._sceneLightSettings)==null?void 0:e.values()}enable(e){var i;e instanceof _n&&(e=e.uri);const t=(i=this._sceneLightSettings)==null?void 0:i.get(e);return t?(xo&&console.log("Enable scene light settings",e,t),e!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=e,t.enabled=!0,!0):!1}disable(e){var i;if(e instanceof _n&&(e=e.uri),e==null)return!1;const t=(i=this._sceneLightSettings)==null?void 0:i.get(e);return t?(xo&&console.log("Disable scene light settings",e,t),t.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const e=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),e}return null}internalRegisterSceneLightSettings(e){const t=e.sourceId;if(!t){console.error("Missing source id for scene light settings, can not register:",e);return}xo&&console.log("Register "+(e==null?void 0:e.sourceId)+" lighting",e),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(t,e)}internalUnregisterSceneLightSettings(e){const t=e.sourceId;if(!t){console.error("Missing source id for scene light settings, can not unregister:",e);return}xo&&console.log("Unregister "+(e==null?void 0:e.sourceId)+" lighting",e),this._sceneLightSettings&&this._sceneLightSettings.delete(t)}internalRegisterReflection(e,t){xo&&console.log("Register reflection",e,t);const i=new e3(this.context,t,1);this._lighting[e]=i}internalGetReflection(e){return this._lighting[e]}internalEnableReflection(e){var i;this.__currentReflectionId=e;const t=(i=this._sceneLightSettings)==null?void 0:i.get(e);switch(xo&&console.log("Enable reflection",e,t?Lf[t.ambientMode]:"Unknown ambient mode"),t==null?void 0:t.ambientMode){case 0:case 4:const s=this.internalGetReflection(e);if(s&&s.Source){xo&&console.log("Setting environment reflection",s);const r=this.context.scene,o=s.Source;o.colorSpace=nt,o.mapping=Oo,r.environment=o;return}else xo&&console.warn("Could not find reflection for source",e);break}if((t==null?void 0:t.environmentReflectionSource)===1)switch(t==null?void 0:t.ambientMode){case 1:if(t.ambientTrilight){const s=t.ambientTrilight,r=LY(s[0],s[1],s[2],64,64);r.colorSpace=nt,r.mapping=Oo,this.context.scene.environment=r}else console.error("Missing ambient trilight",t.sourceId);return;case 3:if(t.ambientLight){const s=VN(t.ambientLight,64);s.colorSpace=nt,s.mapping=Oo,this.context.scene.environment=s}else console.error("Missing ambientlight",t.sourceId);return;default:return}}internalDisableReflection(e){if(e&&e!==this.__currentReflectionId){xo&&console.log("Not disabling reflection for",e,"because it is not the current light settings id",this.__currentReflectionId);return}xo&&console.log("Disable reflection",e);const t=this.context.scene;t.environment=null}async internalGetSceneLightingData(e){return xo&&console.log("GET SCENE LIGHT DATA",e),this._waitPromise?this._waitPromise:(this._waitPromise=new Promise((t,i)=>{const s=setInterval(async()=>{const r=this.internalGetReflection(e);r&&(clearInterval(s),t(r.getSphericalHarmonicsArray(this.environmentIntensity??1)))},10)}),this._waitPromise)}}class e3{constructor(e,t,i=1){h(this,"_context");h(this,"_source");h(this,"_sphericalHarmonics",null);h(this,"_sphericalHarmonicsArray");h(this,"_ambientScale",1);h(this,"_lightProbe");this._context=e,this._source=t,this._ambientScale=i,t.mapping=Oo,t.colorSpace=nt}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}getSphericalHarmonicsArray(e=1){var t;if((t=this._sphericalHarmonicsArray)!=null&&t.length&&this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:this._lightProbe};try{const i=this._source;let s=null;if(i){xo&&console.log("GENERATING LIGHT PROBE",i,this.Source);const r=Math.min(i.image.width,512);s=new T_(r).fromEquirectangularTexture(this._context.renderer,i)}if(this._sphericalHarmonicsArray=[],s){const r=OY.fromCubeRenderTarget(this._context.renderer,s);this._lightProbe=r;const o=this._ambientScale*(e*e*Math.PI*.5)-1;if(this._sphericalHarmonics=r.sh,this._sphericalHarmonicsArray=this._sphericalHarmonics.toArray(),this._sphericalHarmonicsArray){const a=e/(Math.PI*.5);for(let c=0;c<this._sphericalHarmonicsArray.length;c++)this._sphericalHarmonicsArray[c]*=a;if(r.sh.scale(o),this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:r}}}}catch(i){console.error(i)}return null}}var Hb=(n=>(n.Visible="application-visible",n.Hidden="application-hidden",n.MuteChanged="application-mutechanged",n))(Hb||{});class t3 extends EventTarget{constructor(t){super();h(this,"_mute",!1);h(this,"context");h(this,"_isVisible",!0);this.context=t,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}get muted(){return this._mute}set muted(t){t!==this._mute&&(this._mute=t,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(t){switch(t.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}}/*!
4255
+ */var GY=function(n){return n!=null&&(qN(n)||HY(n)||!!n._isBuffer)};function qN(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function HY(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&qN(n.slice(0,0))}(function(){var n=zY,e=YD.utf8,t=GY,i=YD.bin,s=function(r,o){r.constructor==String?o&&o.encoding==="binary"?r=i.stringToBytes(r):r=e.stringToBytes(r):t(r)?r=Array.prototype.slice.call(r,0):!Array.isArray(r)&&r.constructor!==Uint8Array&&(r=r.toString());for(var a=n.bytesToWords(r),c=r.length*8,l=1732584193,u=-271733879,d=-1732584194,f=271733878,p=0;p<a.length;p++)a[p]=(a[p]<<8|a[p]>>>24)&16711935|(a[p]<<24|a[p]>>>8)&4278255360;a[c>>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;for(var m=s._ff,A=s._gg,v=s._hh,g=s._ii,p=0;p<a.length;p+=16){var b=l,y=u,_=d,E=f;l=m(l,u,d,f,a[p+0],7,-680876936),f=m(f,l,u,d,a[p+1],12,-389564586),d=m(d,f,l,u,a[p+2],17,606105819),u=m(u,d,f,l,a[p+3],22,-1044525330),l=m(l,u,d,f,a[p+4],7,-176418897),f=m(f,l,u,d,a[p+5],12,1200080426),d=m(d,f,l,u,a[p+6],17,-1473231341),u=m(u,d,f,l,a[p+7],22,-45705983),l=m(l,u,d,f,a[p+8],7,1770035416),f=m(f,l,u,d,a[p+9],12,-1958414417),d=m(d,f,l,u,a[p+10],17,-42063),u=m(u,d,f,l,a[p+11],22,-1990404162),l=m(l,u,d,f,a[p+12],7,1804603682),f=m(f,l,u,d,a[p+13],12,-40341101),d=m(d,f,l,u,a[p+14],17,-1502002290),u=m(u,d,f,l,a[p+15],22,1236535329),l=A(l,u,d,f,a[p+1],5,-165796510),f=A(f,l,u,d,a[p+6],9,-1069501632),d=A(d,f,l,u,a[p+11],14,643717713),u=A(u,d,f,l,a[p+0],20,-373897302),l=A(l,u,d,f,a[p+5],5,-701558691),f=A(f,l,u,d,a[p+10],9,38016083),d=A(d,f,l,u,a[p+15],14,-660478335),u=A(u,d,f,l,a[p+4],20,-405537848),l=A(l,u,d,f,a[p+9],5,568446438),f=A(f,l,u,d,a[p+14],9,-1019803690),d=A(d,f,l,u,a[p+3],14,-187363961),u=A(u,d,f,l,a[p+8],20,1163531501),l=A(l,u,d,f,a[p+13],5,-1444681467),f=A(f,l,u,d,a[p+2],9,-51403784),d=A(d,f,l,u,a[p+7],14,1735328473),u=A(u,d,f,l,a[p+12],20,-1926607734),l=v(l,u,d,f,a[p+5],4,-378558),f=v(f,l,u,d,a[p+8],11,-2022574463),d=v(d,f,l,u,a[p+11],16,1839030562),u=v(u,d,f,l,a[p+14],23,-35309556),l=v(l,u,d,f,a[p+1],4,-1530992060),f=v(f,l,u,d,a[p+4],11,1272893353),d=v(d,f,l,u,a[p+7],16,-155497632),u=v(u,d,f,l,a[p+10],23,-1094730640),l=v(l,u,d,f,a[p+13],4,681279174),f=v(f,l,u,d,a[p+0],11,-358537222),d=v(d,f,l,u,a[p+3],16,-722521979),u=v(u,d,f,l,a[p+6],23,76029189),l=v(l,u,d,f,a[p+9],4,-640364487),f=v(f,l,u,d,a[p+12],11,-421815835),d=v(d,f,l,u,a[p+15],16,530742520),u=v(u,d,f,l,a[p+2],23,-995338651),l=g(l,u,d,f,a[p+0],6,-198630844),f=g(f,l,u,d,a[p+7],10,1126891415),d=g(d,f,l,u,a[p+14],15,-1416354905),u=g(u,d,f,l,a[p+5],21,-57434055),l=g(l,u,d,f,a[p+12],6,1700485571),f=g(f,l,u,d,a[p+3],10,-1894986606),d=g(d,f,l,u,a[p+10],15,-1051523),u=g(u,d,f,l,a[p+1],21,-2054922799),l=g(l,u,d,f,a[p+8],6,1873313359),f=g(f,l,u,d,a[p+15],10,-30611744),d=g(d,f,l,u,a[p+6],15,-1560198380),u=g(u,d,f,l,a[p+13],21,1309151649),l=g(l,u,d,f,a[p+4],6,-145523070),f=g(f,l,u,d,a[p+11],10,-1120210379),d=g(d,f,l,u,a[p+2],15,718787259),u=g(u,d,f,l,a[p+9],21,-343485551),l=l+b>>>0,u=u+y>>>0,d=d+_>>>0,f=f+E>>>0}return n.endian([l,u,d,f])};s._ff=function(r,o,a,c,l,u,d){var f=r+(o&a|~o&c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._gg=function(r,o,a,c,l,u,d){var f=r+(o&c|a&~c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._hh=function(r,o,a,c,l,u,d){var f=r+(o^a^c)+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._ii=function(r,o,a,c,l,u,d){var f=r+(a^(o|~c))+(l>>>0)+d;return(f<<u|f>>>32-u)+o},s._blocksize=16,s._digestsize=16,WN.exports=function(r,o){if(r==null)throw new Error("Illegal argument "+r);var a=n.wordsToBytes(s(r,o));return o&&o.asBytes?a:o&&o.asString?i.bytesToString(a):n.bytesToHex(a)}})();var VY=WN.exports;const QY=HA(VY);class mM{constructor(e,t,i,s){h(this,"success");h(this,"filename");h(this,"hash");h(this,"size");h(this,"url");this.success=e,this.filename=t,this.hash=i,this.size=s}}async function XN(n,e){const t=await n.arrayBuffer(),i=WT(t),s=n.name.split(".").pop(),r=i+"."+s,o=n.name.split(".").shift();console.assert(o!==void 0);const a={alias:o,filename:r},l=await(await fetch(e+"/exists",{method:"POST",body:JSON.stringify(a)})).json();if(l.success||console.warn("exists check did fail"),l.exists)return console.log("file already exists",i),new mM(!0,r,i,n.size);console.log("begin uploading file",o,n.size);const u=new FormData;u.append("file",n);const d={};d.filesize=n.size,o&&(d.alias=o);const p=await(await fetch(e+"/upload/file",{method:"POST",body:u,headers:d})).json();if((p==null?void 0:p.success)===!1)return p.message!==void 0?console.error("Upload failed:",p.message):console.error("Upload failed"),null;console.assert(p.hash_sum===i,"hash sum did not match","received:",p.hash_sum,"expected:",i),p.success&&console.log("successfully uploaded",i,p.id);const m=new mM(p.success,r,i,n.size);return m.url=e,m}function WT(n){return QY(new Uint8Array(n))}async function jT(n,e,t,i,s=!1){try{const r=await fetch(i+"/download/file",{method:"POST",body:n});if(r.status!==200)return console.error("download failed",r),null;const o=await r.blob(),a=await o.arrayBuffer();s||console.assert(o.size===t,"size mismatch","expected:",t,"got:",o.size);const c=WT(a);return s||console.assert(c===e,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(r){console.error(r)}return null}async function YN(n,e){var u;const t=await fetch(n),i=(u=t.body)==null?void 0:u.getReader(),s=t.headers.get("Content-Length"),r=s?parseInt(s):0;if(!i)return null;let o=0;const a=[];for(;;){const{done:d,value:f}=await i.read();if(f&&(a.push(f),o+=f.length,e.call(null,new ProgressEvent("progress",{loaded:o,total:r}))),d)break}const c=new Uint8Array(o);let l=0;for(const d of a)c.set(d,l),l+=d.length;return c}let JN,JD=null;function fa(){return JN}function qT(n){if(n==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}JD!==n&&(JD=n,JN=new n)}const Ll=re("debugaddressables");class KN{constructor(e){h(this,"_context");h(this,"_assetReferences",{});this._context=e,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.uri&&(this._assetReferences[e.uri]?console.warn("Asset reference already registered",e):this._assetReferences[e.uri]=e),e}dispose(){for(const e in this._assetReferences){const t=this._assetReferences[e];t==null||t.unload()}this._assetReferences={}}unregisterAssetReference(e){e.uri&&delete this._assetReferences[e.uri]}}const US=Symbol("assetReference"),Tf=class{constructor(e,t,i=null){h(this,"_loading");h(this,"_asset");h(this,"_glbRoot");h(this,"_url");h(this,"_progressListeners",[]);h(this,"_hash");h(this,"_hashedUri");h(this,"_isLoadingRawBinary",!1);h(this,"_rawBinary");this._url=e,this._hash=t,e.includes("?v=")?this._hashedUri=e:this._hashedUri=t?e+"?v="+t:e,i!==null&&(this.asset=i),XU(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(e,t,i){if(typeof e=="string"){if(!i&&(i=Lt.Current,!i))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else i=e.context,e=e.sourceId;const s=fl(e,t);Ll&&console.log("GetOrCreate Addressable from",e,t,"FinalPath=",s);const r=i.addressables,o=r.findAssetReference(s);if(o)return o;const a=new Tf(s,i.hash);return r.registerAssetReference(a),a}get asset(){return this._glbRoot??this._asset}set asset(e){this._asset=e}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(e){return e===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||yx(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(Ll&&console.log("Unload",this.asset),this.asset.scene&&ic(this.asset.scene,!0,!0),ic(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Lt.Current&&Lt.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,Ll&&console.log("Preload",this._hashedUri);const e=await YN(this._hashedUri,t=>{this.raiseProgressEvent(t)});return this._rawBinary=(e==null?void 0:e.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(e){if(Ll&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(e&&this._progressListeners.push(e),this._loading!==void 0)return this._loading.then(s=>this.asset);const t=Lt.Current;this._rawBinary?(this._loading=fa().parseSync(t,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(Ll&&console.log("Load async",this.uri),this._loading=fa().loadSync(t,this._hashedUri,this.uri,null,s=>{this.raiseProgressEvent(s)}));const i=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(i),this._loading=void 0,i)return i[US]=this,this._glbRoot&&(this._glbRoot[US]=this),this.asset&&(this.asset[US]=this),Nb(t),i.scene!==void 0&&(this.asset=i),this.asset}async instantiate(e){return this.onInstantiate(e,!1)}async instantiateSynced(e,t=!0){return this.onInstantiate(e,!0,t)}beginListenDownload(e){this._progressListeners.indexOf(e)<0&&this._progressListeners.push(e)}endListenDownload(e){const t=this._progressListeners.indexOf(e);t>=0&&this._progressListeners.splice(t,1)}raiseProgressEvent(e){for(const t of this._progressListeners)t(this,e)}async onInstantiate(e,t=!1,i){const s=Lt.Current;if(this.mustLoad&&await this.loadAssetAsync(),Ll&&console.log("Instantiate",this.uri,"parent:",e),this.asset){Ll&&console.log("Add to scene",this.asset);let r=e instanceof tc?e:null;r||(r=new tc),typeof e=="object"&&(e instanceof _e?r.parent=e:Object.assign(r,e)),r.parent||(r.parent=s.scene);let o=Tf.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,Tf.currentlyInstantiating.set(this.uri,o),t){r.context=s;const a=this.asset;a.guid=this.uri;const c=RT(a,r,void 0,i);if(c)return c}else{const a=KA(this.asset,r);if(a)return a}}finally{s.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,Tf.currentlyInstantiating.set(this.uri,o)})}}else Ll&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(e){if(e&&e.scene){const t=e.scene;return t.isGroup&&t.children.length===1&&t.children[0].name+"glb"===t.name?t.children[0]:t}return null}};let _n=Tf;h(_n,"currentlyInstantiating",new Map);class WY extends ml{constructor(){super([_n])}onSerialize(e,t){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,t){if(typeof e=="string")return t.context?t.gltfId?_n.getOrCreate(t.gltfId,e,t.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof _e){if(!t.context)return console.error("Missing context"),null;if(!t.gltfId)return console.error("Missing source id"),null;const i=e,s=t.context,r=i.guid??i.uuid,o=s.addressables.findAssetReference(r);if(o)return o;const a=new _n(r,void 0,i);return s.addressables.registerAssetReference(a),a}return null}}new WY;const jY=Promise.resolve(null),Rg=class{constructor(e){h(this,"url");h(this,"_bitmap");h(this,"_bitmapObject");h(this,"loader",null);this.url=e}static getOrCreate(e){let t=Rg.imageReferences.get(e);return t||(t=new Rg(e),Rg.imageReferences.set(e,t)),t}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const e=new Image;return e.src=this.url,e}createTexture(){return this.url?(this.loader||(this.loader=new Zc),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):jY}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((e,t)=>{const i=document.createElement("img");i.addEventListener("load",()=>{this._bitmap=createImageBitmap(i).then(s=>(this._bitmapObject=s,e(s),s))}),i.addEventListener("error",s=>{console.error("Failed to load image:"+this.url,s),e(null)}),i.src=this.url}),this._bitmap)}};let kf=Rg;h(kf,"imageReferences",new Map);class ZN extends ml{constructor(){super([kf])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const i=fl(t.gltfId,e);return kf.getOrCreate(i)}}}new ZN;const xo=re("debugenvlight");var Lf=(n=>(n[n.Skybox=0]="Skybox",n[n.Trilight=1]="Trilight",n[n.Flat=3]="Flat",n[n.Custom=4]="Custom",n))(Lf||{}),Gb=(n=>(n[n.Skybox=0]="Skybox",n[n.Custom=1]="Custom",n))(Gb||{});class $N{constructor(e){h(this,"context");h(this,"_currentLightSettingsId");h(this,"_sceneLightSettings");h(this,"_timevec4",new et);h(this,"__currentReflectionId",null);h(this,"_waitPromise");h(this,"_lighting",{});this.context=e,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const e=this.context.time;this._timevec4.x=e.time,this._timevec4.y=Math.sin(e.time),this._timevec4.z=Math.cos(e.time),this._timevec4.w=e.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const e=this._sceneLightSettings.get(this._currentLightSettingsId);return e?e.ambientIntensity:1}get sceneLightSettings(){var e;return(e=this._sceneLightSettings)==null?void 0:e.values()}enable(e){var i;e instanceof _n&&(e=e.uri);const t=(i=this._sceneLightSettings)==null?void 0:i.get(e);return t?(xo&&console.log("Enable scene light settings",e,t),e!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=e,t.enabled=!0,!0):!1}disable(e){var i;if(e instanceof _n&&(e=e.uri),e==null)return!1;const t=(i=this._sceneLightSettings)==null?void 0:i.get(e);return t?(xo&&console.log("Disable scene light settings",e,t),t.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const e=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),e}return null}internalRegisterSceneLightSettings(e){const t=e.sourceId;if(!t){console.error("Missing source id for scene light settings, can not register:",e);return}xo&&console.log("Register "+(e==null?void 0:e.sourceId)+" lighting",e),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(t,e)}internalUnregisterSceneLightSettings(e){const t=e.sourceId;if(!t){console.error("Missing source id for scene light settings, can not unregister:",e);return}xo&&console.log("Unregister "+(e==null?void 0:e.sourceId)+" lighting",e),this._sceneLightSettings&&this._sceneLightSettings.delete(t)}internalRegisterReflection(e,t){xo&&console.log("Register reflection",e,t);const i=new e3(this.context,t,1);this._lighting[e]=i}internalGetReflection(e){return this._lighting[e]}internalEnableReflection(e){var i;this.__currentReflectionId=e;const t=(i=this._sceneLightSettings)==null?void 0:i.get(e);switch(xo&&console.log("Enable reflection",e,t?Lf[t.ambientMode]:"Unknown ambient mode"),t==null?void 0:t.ambientMode){case 0:case 4:const s=this.internalGetReflection(e);if(s&&s.Source){xo&&console.log("Setting environment reflection",s);const r=this.context.scene,o=s.Source;o.colorSpace=nt,o.mapping=Oo,r.environment=o;return}else xo&&console.warn("Could not find reflection for source",e);break}if((t==null?void 0:t.environmentReflectionSource)===1)switch(t==null?void 0:t.ambientMode){case 1:if(t.ambientTrilight){const s=t.ambientTrilight,r=LY(s[0],s[1],s[2],64,64);r.colorSpace=nt,r.mapping=Oo,this.context.scene.environment=r}else console.error("Missing ambient trilight",t.sourceId);return;case 3:if(t.ambientLight){const s=VN(t.ambientLight,64);s.colorSpace=nt,s.mapping=Oo,this.context.scene.environment=s}else console.error("Missing ambientlight",t.sourceId);return;default:return}}internalDisableReflection(e){if(e&&e!==this.__currentReflectionId){xo&&console.log("Not disabling reflection for",e,"because it is not the current light settings id",this.__currentReflectionId);return}xo&&console.log("Disable reflection",e);const t=this.context.scene;t.environment=null}async internalGetSceneLightingData(e){return xo&&console.log("GET SCENE LIGHT DATA",e),this._waitPromise?this._waitPromise:(this._waitPromise=new Promise((t,i)=>{const s=setInterval(async()=>{const r=this.internalGetReflection(e);r&&(clearInterval(s),t(r.getSphericalHarmonicsArray(this.environmentIntensity??1)))},10)}),this._waitPromise)}}class e3{constructor(e,t,i=1){h(this,"_context");h(this,"_source");h(this,"_sphericalHarmonics",null);h(this,"_sphericalHarmonicsArray");h(this,"_ambientScale",1);h(this,"_lightProbe");this._context=e,this._source=t,this._ambientScale=i,t.mapping=Oo,t.colorSpace=nt}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}getSphericalHarmonicsArray(e=1){var t;if((t=this._sphericalHarmonicsArray)!=null&&t.length&&this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:this._lightProbe};try{const i=this._source;let s=null;if(i){xo&&console.log("GENERATING LIGHT PROBE",i,this.Source);const r=Math.min(i.image.width,512);s=new T_(r).fromEquirectangularTexture(this._context.renderer,i)}if(this._sphericalHarmonicsArray=[],s){const r=OY.fromCubeRenderTarget(this._context.renderer,s);this._lightProbe=r;const o=this._ambientScale*(e*e*Math.PI*.5)-1;if(this._sphericalHarmonics=r.sh,this._sphericalHarmonicsArray=this._sphericalHarmonics.toArray(),this._sphericalHarmonicsArray){const a=e/(Math.PI*.5);for(let c=0;c<this._sphericalHarmonicsArray.length;c++)this._sphericalHarmonicsArray[c]*=a;if(r.sh.scale(o),this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:r}}}}catch(i){console.error(i)}return null}}var Hb=(n=>(n.Visible="application-visible",n.Hidden="application-hidden",n.MuteChanged="application-mutechanged",n))(Hb||{});class t3 extends EventTarget{constructor(t){super();h(this,"_mute",!1);h(this,"context");h(this,"_isVisible",!0);this.context=t,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}get muted(){return this._mute}set muted(t){t!==this._mute&&(this._mute=t,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(t){switch(t.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}}/*!
4256
4256
  fflate - fast JavaScript compression/decompression
4257
4257
  <https://101arrowz.github.io/fflate>
4258
4258
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
@@ -5186,7 +5186,7 @@ Using the assigned clip instead:`,this.clip),e=this.clip);let t=!this.sound||e&&
5186
5186
  #include <colorspace_fragment>
5187
5187
 
5188
5188
  }
5189
- `,a={map:{value:e},height:{value:t.height||15},radius:{value:t.radius||100}},c=new FA(1,16),l=new Bt({uniforms:a,fragmentShader:o,vertexShader:r,side:_i});super(c,l)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}var Gie=Object.defineProperty,Hie=Object.getOwnPropertyDescriptor,Es=(n,e,t,i)=>{for(var s=i>1?void 0:i?Hie(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&&Gie(e,t,s),s};const s0=re("freecam"),Tm=re("debugcamerafit"),r0=re("smoothcam"),Vie={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let vC;class dA extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class Ni extends Ie{constructor(){super(...arguments);h(this,"autoFit",!1);h(this,"enableRotate",!0);h(this,"autoRotate",!1);h(this,"autoRotateSpeed",1);h(this,"enableKeys",!0);h(this,"enableDamping",!0);h(this,"dampingFactor",.1);h(this,"enableZoom",!0);h(this,"minZoom",0);h(this,"maxZoom",1/0);h(this,"enablePan",!0);h(this,"lookAtConstraint",null);h(this,"lookAtConstraint01",1);h(this,"allowInterrupt",!0);h(this,"middleClickToFocus",!0);h(this,"doubleClickToFocus",!0);h(this,"useSlerp",!0);h(this,"debugLog",!1);h(this,"targetLerpDuration",1);h(this,"autoTarget",!0);h(this,"_controls",null);h(this,"_cameraObject",null);h(this,"_lookTargetLerpActive",!1);h(this,"_lookTargetStartPosition",new w);h(this,"_lookTargetEndPosition",new w);h(this,"_lookTargetLerp01",0);h(this,"_lookTargetLerpDuration",0);h(this,"_cameraLerpActive",!1);h(this,"_cameraStartPosition",new w);h(this,"_cameraEndPosition",new w);h(this,"_cameraLerp01",0);h(this,"_cameraLerpDuration",0);h(this,"_inputs",0);h(this,"_enableTime",0);h(this,"_startedListeningToKeyEvents",!1);h(this,"_eventSystem");h(this,"_afterHandleInputFn");h(this,"_camera",null);h(this,"_syncedTransform");h(this,"_didStart",!1);h(this,"targetElement",null);h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});h(this,"_shouldDisable",!1);h(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)}get targetLerpSpeed(){return 5}set targetLerpSpeed(t){this.targetLerpDuration=1/t}awake(){this._didStart=!1,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const t=ne.getComponent(this.gameObject,Ui);if(t&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const s=pt(t.cam).length(),r=new w(0,0,-s).applyMatrix4(t.cam.matrixWorld);this.setLookTargetPosition(r,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const i=new eo;i.screenPoint=new te(0,0),i.lineThreshold=.1;const s=this.context.physics.raycast(i);s.length>0&&this.setLookTargetPosition(s[0].point,!0),Tm&&console.log("OrbitControls hits",...s)}this.autoFit&&this.fitCamera()}this._eventSystem=nr.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(zM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(zM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=ne.getComponent(this.gameObject,Ui);this._camera=t;const i=t==null?void 0:t.cam;if(i&&ok(i,this,!0),!this._controls){if(!i){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}i&&(this._cameraObject=i);const s=this.targetElement??this.context.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new $te(i,s),i==null||i.quaternion.copy(r),vC===void 0&&(vC={...this._controls.keys})}this._controls&&(s0&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,pl()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?s0||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):s0||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=ne.getComponent(this.gameObject,mh)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&ok(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))}onBeforeRender(){var i,s;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((i=this.context.input.getPointerPositionDelta(0))!=null&&i.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!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._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new dA(this,"camera"));else{const r=Ye.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,r)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new dA(this,"lookat"));else{const r=Ye.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,r)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?vC:Vie,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,typeof r0=="number"||r0===!0){this._controls.enableDamping=!0;const r=typeof r0=="number"?r0:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,r))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!s0&&((s=this.lookAtConstraint)!=null&&s.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update())}}setCameraAndLookTarget(t){if(!t||!(t instanceof _e))return;const i=pt(t),s=xT(t);this.setTargetFromRaycast(new Aa(i,s)),this.setCameraTargetPosition(i)}setCameraTargetPosition(t,i=!1){var s,r;t&&(t instanceof _e&&(t=pt(t)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(t),i===!0?(this._cameraLerpActive=!1,(s=this.controllerObject)==null||s.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((r=this._cameraObject)==null?void 0:r.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(t=null,i=!1){this._controls&&t&&(t instanceof _e&&(t=pt(t)),this._lookTargetEndPosition.copy(t),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(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._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(t,i){return this.lerpLookTarget(t,i)}lerpLookTarget(t,i){this._controls&&(i>=1?this._controls.target.copy(t):this._controls.target.lerp(t,i))}setTargetFromRaycast(t){var s,r;if(!this.controls)return;const i=t?this.context.physics.raycastFromRay(t):this.context.physics.raycast();for(const o of i)if(o.distance>0&&ne.isActiveInHierarchy(o.object)){const a=Qx(o.object);if(a){const c=a.canvas;if(c!=null&&c.screenspace)break}if(this.setLookTargetPosition(o.point),this.context.mainCamera){const l=pt(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(r=(s=this._cameraObject)==null?void 0:s.parent)==null||r.worldToLocal(l),this.setCameraTargetPosition(l)}break}}fitCamera(t,i=1.1,s=!0){const r=this._cameraObject,o=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0||!r||!o)return;const a=new w,c=new w,l=new Dn;l.makeEmpty();const u=[];function d(y){let _=!0;if(y.visible&&zie(y)!==!1&&!(y.type==="TransformControlsGizmo"||y.type==="TransformControlsPlane")&&(y instanceof NE&&(_=!1),y instanceof pT&&(_=!1),y instanceof _G&&(_=!1),y.material instanceof j_&&(_=!1),y instanceof ge||(_=!1),y!==r&&y.isUI!==!0)){if(_){Tm&&console.log(y.name,y.type,y);const E=y.children;y.children=u;const M=y.position,T=y.scale;if(Number.isNaN(M.x)||Number.isNaN(M.y)||Number.isNaN(M.z)){console.warn(`Object "${y.name}" has NaN values in position or scale.... will ignore it`,M,T);return}l.expandByObject(y,!0),y.children=E}for(const E of y.children)d(E)}}for(const y of t)y.updateMatrixWorld(),d(y);if(r.updateMatrixWorld(),r.updateProjectionMatrix(),l.getCenter(c),l.applyMatrix4(r.matrixWorldInverse),l.getSize(a),l.setFromCenterAndSize(c,a),Number.isNaN(a.x)||Number.isNaN(a.y)||Number.isNaN(a.z)){console.warn("Camera fit size resultet in NaN",r,l,[...t]);return}if(a.length()<=1e-10){Tm&&console.warn("Camera fit size is zero",l,[...t]);return}const f=r.fov,p=2*Math.atan(Math.tan(f*Math.PI/360/2)*r.aspect)/Math.PI*360,m=a.y/(2*Math.atan(Math.PI*f/360)),A=a.x/(2*Math.atan(Math.PI*p/360)),v=i*Math.max(m,A)+a.z/2;Tm&&console.log("Fit camera to objects",m,A,"distance",v);const g=pt(r),b=o.target.clone().sub(g).normalize().multiplyScalar(v);if(o.maxDistance=v*10,o.minDistance=v*.01,this.setLookTargetPosition(c,s),this.autoTarget=!1,r.near=v/100,r.far=v*100,r.updateMatrixWorld(),r.updateProjectionMatrix(),r.parent){const y=r.parent.worldToLocal(o.target.clone().sub(b));this.setCameraTargetPosition(y,s)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(Tm){const y=new NE(l);this.context.scene.add(y),wT(y,GA(r)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",_=>{_.code==="KeyF"&&this.fitCamera(t)}))}o.update()}}Es([x()],Ni.prototype,"autoFit",2);Es([x()],Ni.prototype,"enableRotate",2);Es([x()],Ni.prototype,"autoRotate",2);Es([x()],Ni.prototype,"autoRotateSpeed",2);Es([x()],Ni.prototype,"enableKeys",2);Es([x()],Ni.prototype,"enableDamping",2);Es([x()],Ni.prototype,"dampingFactor",2);Es([x()],Ni.prototype,"enableZoom",2);Es([x()],Ni.prototype,"minZoom",2);Es([x()],Ni.prototype,"maxZoom",2);Es([x()],Ni.prototype,"enablePan",2);Es([x(av)],Ni.prototype,"lookAtConstraint",2);Es([x()],Ni.prototype,"lookAtConstraint01",2);Es([x()],Ni.prototype,"allowInterrupt",2);Es([x()],Ni.prototype,"middleClickToFocus",2);Es([x()],Ni.prototype,"doubleClickToFocus",2);Es([x()],Ni.prototype,"targetLerpDuration",2);var Qie=Object.defineProperty,Wie=Object.getOwnPropertyDescriptor,ro=(n,e,t,i)=>{for(var s=i>1?void 0:i?Wie(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&&Qie(e,t,s),s},Vu=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(Vu||{});const Au=re("debugcam"),ck=re("debugscreenpointtoray");var C0;const Jm=(C0=class extends Ie{constructor(){super(...arguments);h(this,"_nearClipPlane",.1);h(this,"_farClipPlane",1e3);h(this,"orthographic",!1);h(this,"orthographicSize",5);h(this,"ARBackgroundAlpha",0);h(this,"_cullingMask",4294967295);h(this,"_backgroundBlurriness");h(this,"_backgroundIntensity");h(this,"_environmentIntensity");h(this,"_targetTexture",null);h(this,"_backgroundColor");h(this,"_fov");h(this,"_cam",null);h(this,"_clearFlags",2);h(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("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 cullingLayer(e){this.cullingMask=(1<<e|0)>>>0}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}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}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){const s=this.cam,r=Jm._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),ck&&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=Jm._direction.set(r.x,r.y,r.z),a=pt(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new Aa(a.clone(),o.clone())}awake(){ck&&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);Qa.DrawRay(s.origin,s.direction,r,10)})}onEnable(){Au&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Vu[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),qie(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),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;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}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 qt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof qt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new qt(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 dl(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){Au&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Au){const e=`Camera "${this.name}" clear flags: ${Vu[this._clearFlags]}`;console.log(e)}switch(this._clearFlags){case 1:if(Jm.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;Jm.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else Au&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new jie(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,c;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;if(typeof t._transparent=="boolean")return t._transparent;const i=t.environmentBlendMode;Au&&An("Environment blend mode: "+i+" on "+navigator.userAgent);let s=i==="additive"||i==="alpha-blend";return e.xrSessionMode===tA.ImmersiveAR&&i==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((c=navigator.userAgent)!=null&&c.includes("Mobile WebXRViewer/v2")))&&(s=!0),t._transparent=s,s}},h(C0,"_origin",new w),h(C0,"_direction",new w),C0);let Ui=Jm;ro([x()],Ui.prototype,"fieldOfView",1);ro([x()],Ui.prototype,"nearClipPlane",1);ro([x()],Ui.prototype,"farClipPlane",1);ro([x()],Ui.prototype,"clearFlags",1);ro([x()],Ui.prototype,"orthographic",2);ro([x()],Ui.prototype,"orthographicSize",2);ro([x()],Ui.prototype,"ARBackgroundAlpha",2);ro([x()],Ui.prototype,"cullingMask",1);ro([x()],Ui.prototype,"backgroundBlurriness",1);ro([x()],Ui.prototype,"backgroundIntensity",1);ro([x()],Ui.prototype,"environmentIntensity",1);ro([x(bi)],Ui.prototype,"backgroundColor",1);ro([x(sh)],Ui.prototype,"targetTexture",1);class jie{constructor(e){h(this,"_camera");h(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&&(Au&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=nt,this._skybox.mapping=Oo,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(Au||Vt())&&rs(`Camera "${this._camera.name}" has no skybox texture`))}}function qie(n){re("freecam")&&n.context.mainCameraComponent===n&&ne.getOrAddComponent(n.gameObject,Ni)}class rh extends Ie{constructor(){super(...arguments);h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new lF),this._listener}awake(){Cn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=this.context.mainCameraComponent||ne.getComponentInParent(this.gameObject,Ui);i!=null&&i.cam?i.cam.add(t):this.gameObject.add(t)})}}var Xie=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,Wx=(n,e,t,i)=>{for(var s=i>1?void 0:i?Yie(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&&Xie(e,t,s),s};const Jie=re("debugsignals");class lv{constructor(){h(this,"guid")}}Wx([x()],lv.prototype,"guid",2);class Dp{constructor(){h(this,"signal");h(this,"reaction")}}Wx([x(lv)],Dp.prototype,"signal",2);Wx([x(gs)],Dp.prototype,"reaction",2);var ZC;const Ic=(ZC=class extends Ie{constructor(){super(...arguments);h(this,"events")}static invoke(e){if(Ic.receivers[e]){const t=Ic.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){Jie&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Ic.receivers[e.signal.guid]||(Ic.receivers[e.signal.guid]=[]),Ic.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Ic.receivers[e.signal.guid]){const t=Ic.receivers[e.signal.guid].indexOf(this);t>=0&&Ic.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const 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)}}},h(ZC,"receivers",{}),ZC);let Op=Ic;Wx([x(Dp)],Op.prototype,"events",2);var Ur=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(Ur||{}),Pa=(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))(Pa||{}),VI=(n=>(n.Signal="SignalEmitter",n))(VI||{});const Xc=re("debugtimeline");class hv{constructor(){h(this,"director");h(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;const a=!1;if(r.easeInDuration>0){const c=Math.min((e-r.start)/r.easeInDuration,1);o*=c}if(r.easeOutDuration>0&&!a){const c=Math.min((r.end-e)/r.easeOutDuration,1);o*=c}return o}return 0}}class Kie{constructor(e){h(this,"clip");h(this,"rootPositionOffset");h(this,"rootQuaternionOffset");h(this,"rootStartPosition");h(this,"rootEndPosition");h(this,"rootStartQuaternion");h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const i=e.getRoot(),s=i.name+".position",r=i.name+".quaternion";Xc&&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 w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Xc&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new Se().fromArray(o.values,0),this.rootEndQuaternion=new Se().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Xc)){const a=new yn().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class jx extends hv{constructor(){super(...arguments);h(this,"models",[]);h(this,"trackOffset");h(this,"target");h(this,"mixer");h(this,"clips",[]);h(this,"actions",[]);h(this,"_actionOffsets",[]);h(this,"_didBind",!1);h(this,"_animator",null);h(this,"_useclipOffsets",!0);h(this,"_totalOffsetPosition",new w);h(this,"_totalOffsetRotation",new Se);h(this,"_totalOffsetPosition2",new w);h(this,"_totalOffsetRotation2",new Se);h(this,"_summedPos",new w);h(this,"_tempPos",new w);h(this,"_summedRot",new Se);h(this,"_tempRot",new Se);h(this,"_clipRotQuat",new Se)}onStateChanged(){this._animator&&lk(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var u,d;if(((u=i.tracks)==null?void 0:u.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 c=!1,l=!1;for(const f of i.tracks)f.name.endsWith(o)?(c=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(l=!0,this.createRotationInterpolant(i,t,f));if(!c||!l){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(c){if(!l){const b=i.tracks[0].name.substring(0,m)+".quaternion";Xc&&console.warn("Create quaternion track",v,g);const y=g.quaternion,_=new ec(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";Xc&&console.warn("Create position track",v,g);const y=g.position,_=new al(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,Xc&&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 Kie(t);this._actionOffsets.push(i)}this.target&&(this._animator=ne.getComponent(this.target,ys)??null,this._animator&&lk(this._animator.gameObject,this,!0));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 w(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new Se(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 w(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Se(i.x,i.y,i.z,i.w)))}}evaluate(t){var c,l,u,d,f,p,m;if(this.track.muted||!this.mixer)return;this.bind(),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,a=0;for(let A=0;A<this.clips.length;A++){const v=this.models[A],g=this.actions[A],b=v.asset;g.weight=0;const y=t>=v.start&&t<=v.end,_=v.preExtrapolationMode,E=v.postExtrapolationMode,M=A<this.clips.length-1?this.models[A+1]:null;let T=y,R=!1;if(!T&&!r&&v.end<t&&E!==Pa.None?(!M||M.start>t)&&(T=!0,r=!0):A==0&&!T&&!o&&v.start>t&&_!==Pa.None&&(!M||M.start<t)&&(T=!0,R=!0,o=!0),T){let C=1;C*=this.evaluateWeight(t,A,this.models,T),C*=this.director.weight;let I=y;if(R)switch(_){case Pa.Hold:break;case Pa.Loop:t+=v.start,I=!0;break;default:t+=v.start,I=!0;break}let D=this.getClipTime(t,v),W=0;const F=b.duration;if(R&&_===Pa.Hold&&(D=0),I){if(b.loop)for(W+=Math.floor(D/(F+1e-6));D>F;)D-=F}else if(!y&&r)switch(E){case Pa.Hold:D=this.getClipTime(v.end,v);break;case Pa.Loop:D%=F;break;case Pa.PingPong:const z=Math.floor(D/F)%2!==0;D%=F,z&&(D=F-D);break}v.reversed===!0?g.time=g.getClip().duration-D:g.time=D,g.timeScale=0;const H=Math.max(0,C);if(g.weight=H,a+=H,g.clampWhenFinished=!1,g.isRunning()||g.play(),this._useclipOffsets){const j=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,z=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(s=1-C),i+=1;const L=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),$=this._summedRot.identity(),Z=this._tempRot.identity(),q=b.rotation;q&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(q,C));const ie=this._actionOffsets[A];if(ie.hasOffsets)for(let pe=0;pe<W;pe++)ie.rootPositionOffset?G.copy(ie.rootPositionOffset):G.set(0,0,0),G.applyQuaternion($),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),ie.rootQuaternionOffset&&(Z.copy(ie.rootQuaternionOffset),$.multiply(Z)),L.add(G);this._clipRotQuat&&z.multiply(this._clipRotQuat),z.multiply($),b.position&&L.add(b.position),j.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.__mixerError===void 0&&(Xc||Vt())&&((l=(c=this._animator)==null?void 0:c.runtimeAnimatorController)!=null&&l.mixer)&&this.mixer!==((d=(u=this._animator)==null?void 0:u.runtimeAnimatorController)==null?void 0:d.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(f=this._animator)!=null&&f.runtimeAnimatorController){const A=Math.max(0,1-a);(m=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||m.update(A)}else this.mixer.update(t)}createRotationInterpolant(t,i,s){var c;const r=s.createInterpolant.bind(s),o=new Se;this.ensureTrackOffsets();const a=(c=this.trackOffset)==null?void 0:c.rotation;s.createInterpolant=()=>{const l=r(),u=l.evaluate.bind(l);return l.evaluate=d=>{var p;const f=u(d);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const m of this.director.animationCallbackReceivers)(p=m==null?void 0:m.onTimelineRotation)==null||p.call(m,this.director,this.target,d,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},l}}createPositionInterpolant(t,i,s){var u,d;const r=s.createInterpolant.bind(s),o=new w;this.ensureTrackOffsets();const a=(u=this.trackOffset)==null?void 0:u.rotation,c=(d=this.trackOffset)==null?void 0:d.position;let l;s.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=m=>{var v,g,b;const A=p(m);if(o.set(A[0],A[1],A[2]),i.removeStartOffset&&(l===void 0?(l=null,l=(g=(v=this._actionOffsets.find(y=>y.clip===t))==null?void 0:v.rootStartPosition)==null?void 0:g.clone()):l!=null&&l.isVector3&&o.sub(l)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),c&&(o.x-=c.x,o.y+=c.y,o.z+=c.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(b=y==null?void 0:y.onTimelinePosition)==null||b.call(y,this.director,this.target,m,o);return A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const Zie=re("mutetimeline"),Rf=class extends hv{constructor(){super(...arguments);h(this,"models",[]);h(this,"listener");h(this,"audio",[]);h(this,"audioContextTimeOffset",[]);h(this,"lastTime",0);h(this,"audioSource");h(this,"_audioLoader",null)}getAudioFilePath(t){const i=this.director.sourceId;return fl(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 uT(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(Zie||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],c=o.asset;if((!a||!a.buffer)&&this.isInTimeRange(o,t-1,t+1)&&this.handleAudioLoading(o,a),Cn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale*this.director.speed,a.loop=c.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 u=o.clipIn+(t-o.start)*o.timeScale,d=a.context.currentTime-a._startedAt+a.offset;Math.abs(u-d)>.3&&(a.offset=u,a.stop(),a.play(s))}let l=c.volume;if(this.track.volume!==void 0&&(l*=this.track.volume),i&&(l=0),o.easeInDuration>0){const u=Math.min((t-o.start)/o.easeInDuration,1);l*=u}if(o.easeOutDuration>0){const u=Math.min((o.end-t)/o.easeOutDuration,1);l*=u}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 c of this.models)if(this.isInTimeRange(c,o,a)){const l=this.audio[this.models.indexOf(c)],u=this.handleAudioLoading(c,l);u!==null&&(r===null&&(r=[]),r.push(u))}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(){Rf._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new Sb);const s=this.getAudioFilePath(t.asset.clip);if(Rf._audioBuffers.get(s)){const o=Rf._audioBuffers.get(s);return o.then(a=>{a&&i.setBuffer(a)}),o}Xc&&console.warn("LOAD audio track",s,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(s,c=>{i.setBuffer(c),o(c)},void 0,c=>{console.error("Error loading audio",c),o(null)})});return Rf._audioBuffers.set(s,r),r}};let Ou=Rf;h(Ou,"_audioBuffers",new Map);class fA extends hv{constructor(){super(...arguments);h(this,"models",[]);h(this,"didTrigger",[]);h(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],c=o.time-t;let l=!1;if(o.retroActive)l=c<=1e-6;else{const u=Math.abs(c);(u===0||u>=1e-5&&u<i)&&(l=!0)}if(l){if(!a)if(Xc&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((s=this.receivers)==null?void 0:s.length)<=0)Op.invoke(o.asset);else for(const u of this.receivers)u&&u.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class qx extends hv{constructor(){super(...arguments);h(this,"models",[]);h(this,"timelines",[]);h(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=ne.getComponent(r.sourceObject,rl);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 c=o.sourceObject;c.visible=!0}if(o.updateDirector){const c=this.timelines[s];c&&(c.isPlaying&&c.pause(),c.time=a,c.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const c=o.sourceObject;(a==null?void 0:a.sourceObject)!==c&&(c.visible=!1)}}}}}const Xd=re("debugtimeline"),f_=class extends Ie{constructor(){super(...arguments);h(this,"playableAsset");h(this,"playOnAwake");h(this,"extrapolationMode",1);h(this,"waitForAudio",!0);h(this,"_visibilityChangeEvt");h(this,"_clonedPlayableAsset",!1);h(this,"_speed",1);h(this,"_guidsMap");h(this,"_isPlaying",!1);h(this,"_internalUpdateRoutine");h(this,"_isPaused",!1);h(this,"_isStopping",!1);h(this,"_time",0);h(this,"_duration",0);h(this,"_weight",1);h(this,"_animationTracks",[]);h(this,"_audioTracks",[]);h(this,"_signalTracks",[]);h(this,"_controlTracks",[]);h(this,"_customTracks",[]);h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);h(this,"animationCallbackReceivers",[])}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:(Xd||cr())&&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;Xd&&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,s;for(const r of this._audioTracks)(t=r.onEnable)==null||t.call(r);for(const r of this._customTracks)(i=r.onEnable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onEnable)==null||s.call(r);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,s;this.stop();for(const r of this._audioTracks)(t=r.onDisable)==null||t.call(r);for(const r of this._customTracks)(i=r.onDisable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onDisable)==null||s.call(r);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&&!Cn.userInteractionRegistered&&this.waitForAudio;)await dh(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),is.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;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.internalEvaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),i&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}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)}invokeStateChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onStateChanged)==null||t.call(i,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(t=!1){if(!this.isValid())return;let i=this._time;switch(this.extrapolationMode){case 0:this._speed>0?i=Math.min(i,this._duration):this._speed<0&&(i=Math.max(i,0)),this._time=i;break;case 1:i%=this._duration,this._time=i;break;case 2:if(i>this._duration){this.stop();return}break}const s=this._time;for(const r of this.playableAsset.tracks)if(!r.muted)switch(r.type){case Ur.Activation:if(!t&&!this._isPlaying)continue;for(let o=0;o<r.outputs.length;o++){const a=r.outputs[o];if(typeof a=="object"){let c=!1;if(r.clips)for(const u of r.clips)u.start<=s&&s<=u.end&&(c=!0);const l=a;l.visible!==void 0&&l.visible!==c&&(l.visible=c,Xd&&console.warn(this.name,"set ActivationTrack-"+o,l.name,c,s))}}break}if(!this._isStopping)for(const r of this._animationTracks)r.evaluate(s);for(const r of this._audioTracks)r.evaluate(s);for(const r of this._signalTracks)r.evaluate(s);for(const r of this._controlTracks)r.evaluate(s);for(const r of this._customTracks)r.evaluate(s)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=ix(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=ne.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(s,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Xd&&console.log("Resolved binding",r,"to",o),i.outputs[s]=o)}else if(r===null){if(i.outputs.splice(s,1),f_.createTrackFunctions[i.type])continue;i.type!==Ur.Audio&&i.type!==Ur.Control&&i.type!==Ur.Marker&&i.type!==Ur.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===Ur.Control&&i.clips)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=ne.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Xd&&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){if(t.clips)for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);if(t.markers)for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,s,r;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let t=ne.findObjectOfType(rh,this.context);for(const o of this.playableAsset.tracks){const a=o.type,c=f_.createTrackFunctions[a];if(c!=null){const l=c(this,o);if(typeof l.evaluate=="function"){l.director=this,l.track=o,this._customTracks.push(l);continue}}if(o.type===Ur.Animation){if(!o.clips||o.clips.length<=0){Xd&&console.warn("Animation track has no clips",o);continue}for(let l=o.outputs.length-1;l>=0;l--){let u=o.outputs[l];if(u instanceof _e){const f=ne.getOrAddComponent(u,ys);f&&(u=f)}const d=(i=u==null?void 0:u.gameObject)==null?void 0:i.animations;if(d){const f=new jx;f.trackOffset=o.trackOffset,f.director=this,f.track=o;for(let p=0;p<o.clips.length;p++){const m=o.clips[p],A=m.asset;if(!A){console.error("MISSING anim model?","clip#"+p,m,o,this.playableAsset,this.name);continue}const v=A.clip;let g=v;if((typeof g=="string"||typeof g=="number")&&(g=d.find(y=>y.name===v)),!g){console.warn("Could not find animationClip for model",m,o.name,this.name,(s=this.playableAsset)==null?void 0:s.name);continue}u instanceof ys&&u.runtimeAnimatorController&&(u.__internalDidAwakeAndStart||u.initializeRuntimeAnimatorController(),u.runtimeAnimatorController.mixer||u.runtimeAnimatorController.bind(u),f.mixer=u.runtimeAnimatorController.mixer),f.mixer||(f.mixer=new ex(u.gameObject)),f.clips.push(g),f.mixer.uncacheAction(g),f.createHooks(m.asset,g);const b=f.mixer.clipAction(g);f.actions.push(b),f.models.push(m)}this._animationTracks.push(f)}}}else if(o.type===Ur.Audio){if(!o.clips||o.clips.length<=0)continue;const l=new Ou;l.director=this,l.track=o,l.audioSource=o.outputs.find(u=>u instanceof Cn),this._audioTracks.push(l),t||(t=(r=this.context.mainCameraComponent)==null?void 0:r.gameObject.addNewComponent(rh)),l.listener=t.listener;for(let u=0;u<o.clips.length;u++){const d=o.clips[u];l.addModel(d)}}else if(o.type===Ur.Marker){const l=new fA;if(l.director=this,l.track=o,o.markers)for(const u of o.markers)switch(u.type){case VI.Signal:l.models.push(u),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const u=ne.getComponent(this.gameObject,Op);u&&(l.receivers.push(u),this._signalTracks.push(l))}}else if(o.type===Ur.Signal){const l=new fA;if(l.director=this,l.track=o,o.markers)for(const u of o.markers)l.models.push(u),l.didTrigger.push(!1);for(const u of o.outputs)l.receivers.push(u);this._signalTracks.push(l)}else if(o.type===Ur.Control){const l=new qx;if(l.director=this,l.track=o,o.clips)for(const u of o.clips)l.models.push(u);l.resolveSourceObjects(this.context),this._controlTracks.push(l)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const i=this.animationCallbackReceivers.indexOf(t);i!==-1&&this.animationCallbackReceivers.splice(i,1)}};let rl=f_;h(rl,"createTrackFunctions",{});const ob=Symbol("objectIsAnimatedData");function lk(n,e,t){if(!n)return;if(n[ob]===void 0){if(!t)return;n[ob]=new Set}const i=n[ob];t?i.add(e):i.has(e)&&i.delete(e)}function $ie(n){if(!n)return!1;const e=n[ob];return e!==void 0&&e.size>0}Ii.registerCallback(Zn.ContextCreated,n=>{const e=n.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true")&&n.files)for(const t of n.files)ne.foreachComponent(t.file.scene,s=>{if(s.enabled!==!1){if(s instanceof no&&s.playAutomatically||s instanceof ys||s instanceof rl&&s.playOnAwake===!0)return!0;if(s instanceof no)return s.playAutomatically=!0,!0;if(s instanceof rl)return s.playOnAwake=!0,!0}},!0)!==!0&&ene(t.file)});function ene(n){if(!n||!n.animations)return;for(let t=0;t<n.animations.length;t++){const i=n.animations[t];if(!(!i.tracks||i.tracks.length<=0))for(const s in i.tracks){const r=i.tracks[s],o=r.__objectName??r.name.substring(0,r.name.indexOf("."));let a=n.scene.getObjectByName(o);if(!a&&(a=n.scene.getObjectByProperty("uuid",o),!a))continue;let c=e(a);c||(c=wh(n.scene,new no));const l=c.animations=c.animations||[];i.name_animator=c.name,l.indexOf(i)<0&&l.push(i)}}function e(t){var s;if(!t)return;const i=(s=t.userData)==null?void 0:s.components;if(i&&i.length>0)for(let r=0;r<i.length;r++){const o=i[r];if(o instanceof ys||o instanceof no)return t}return e(t.parent)}}var tne=Object.defineProperty,ine=Object.getOwnPropertyDescriptor,Xx=(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 hk=re("debuganimator");class ys extends Ie{constructor(){super(...arguments);h(this,"applyRootMotion",!1);h(this,"hasRootMotion",!1);h(this,"keepAnimatorControllerStateOnDisable",!1);h(this,"_parametersAreDirty",!1);h(this,"_isDirty",!1);h(this,"speed",1);h(this,"normalizedStartOffset",0);h(this,"_animatorController",null);h(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(t){var i;this._animatorController&&this._animatorController.model===t||(t?t instanceof Fo?(t.animator&&t.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(i=t.model)==null?void 0:i.name),t.model||console.error("AnimatorController has no model"),t=new Fo(t.model)),this._animatorController=t,this._animatorController.bind(this)):(hk&&console.log("Assign animator controller",t,this),this._animatorController=new Fo(t),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(t,i=-1,s=Number.NEGATIVE_INFINITY,r=0){this.play(t,i,s,r)}play(t,i=-1,s=Number.NEGATIVE_INFINITY,r=0){var o;(o=this.runtimeAnimatorController)==null||o.play(t,i,s,r),this._isDirty=!0}Reset(){this.reset()}reset(){var t;(t=this._animatorController)==null||t.reset(),this._isDirty=!0}SetBool(t,i){this.setBool(t,i)}setBool(t,i){var s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getBool(t))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setBool(t,i)}GetBool(t){return this.getBool(t)}getBool(t){var i;return((i=this.runtimeAnimatorController)==null?void 0:i.getBool(t))??!1}SetFloat(t,i){this.setFloat(t,i)}setFloat(t,i){var s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getFloat(t))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setFloat(t,i)}GetFloat(t){return this.getFloat(t)}getFloat(t){var i;return((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(t))??-1}SetInteger(t,i){this.setInteger(t,i)}setInteger(t,i){var s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getInteger(t))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setInteger(t,i)}GetInteger(t){return this.getInteger(t)}getInteger(t){var i;return((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(t))??-1}SetTrigger(t){this.setTrigger(t)}setTrigger(t){var i;(i=this.runtimeAnimatorController)==null||i.setTrigger(t),this._parametersAreDirty=!0}ResetTrigger(t){this.resetTrigger(t)}resetTrigger(t){var i;(i=this.runtimeAnimatorController)==null||i.resetTrigger(t),this._parametersAreDirty=!0}GetTrigger(t){this.getTrigger(t)}getTrigger(t){var i;(i=this.runtimeAnimatorController)==null||i.getTrigger(t)}IsInTransition(){return this.isInTransition()}isInTransition(){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.isInTransition())??!1}SetSpeed(t){return this.setSpeed(t)}setSpeed(t){var i;t!==this.speed&&(this.speed=t,(i=this._animatorController)==null||i.setSpeed(t))}set minMaxSpeed(t){this.speed=Ye.lerp(t.x,t.y,Math.random())}set minMaxOffsetNormalized(t){this.normalizedStartOffset=Ye.lerp(t.x,t.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){hk&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(t=!1){const i=t||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&i){const s=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=s,s?(console.assert(this.runtimeAnimatorController!==s),this.runtimeAnimatorController=s,console.assert(this.runtimeAnimatorController===s),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this.speed),this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var t;this.keepAnimatorControllerStateOnDisable||(t=this._animatorController)==null||t.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!$ie(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}Xx([x()],ys.prototype,"applyRootMotion",2);Xx([x()],ys.prototype,"hasRootMotion",2);Xx([x()],ys.prototype,"keepAnimatorControllerStateOnDisable",2);Xx([x()],ys.prototype,"runtimeAnimatorController",1);const Hf=re("debugusdzanimation"),GM=re("debugusdzanimationserialization");class Yx{constructor(e,t,i){h(this,"_start");h(this,"ext");h(this,"root");h(this,"clip");this.ext=e,this.root=t,this.clip=i}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}class Bo{constructor(e,t,i){h(this,"clip");h(this,"pos");h(this,"rot");h(this,"scale");h(this,"root");h(this,"target");h(this,"duration",0);h(this,"useRootMotion",!1);this.root=e,this.target=t,this.clip=i,i?this.duration=i.duration:this.duration=1/this.frameRate;const s=ne.getComponent(e,ys);s&&(this.useRootMotion=s.applyRootMotion)}get frameRate(){return 60}addTrack(e){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it – this is likely a bug");return}e.name.endsWith("position")&&(this.pos=e),e.name.endsWith("quaternion")&&(this.rot=e),e.name.endsWith("scale")&&(this.scale=e)}getFrames(){var e,t,i,s,r,o;return this.clip?Math.max(((t=(e=this.pos)==null?void 0:e.times)==null?void 0:t.length)??0,((s=(i=this.rot)==null?void 0:i.times)==null?void 0:s.length)??0,((o=(r=this.scale)==null?void 0:r.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(e=!0,t=!0,i=!0){var c,l,u;if(!this.clip)return[0,this.duration];const s=(c=this.pos)==null?void 0:c.times,r=(l=this.rot)==null?void 0:l.times,o=(u=this.scale)==null?void 0:u.times,a=[];if(e&&s)for(const d of s)a.push(d);if(t&&r)for(const d of r)a.push(d);if(i&&o)for(const d of o)a.push(d);return a.includes(0)||a.push(0),a.sort((d,f)=>d-f),[...new Set(a)]}*getValues(e,t=!0,i=!0,s=!0){var f,p,m;const r=new w,o=new Se,a=new w(1,1,1),c=this.target,l=t?(f=this.pos)==null?void 0:f.createInterpolant():void 0,u=i?(p=this.rot)==null?void 0:p.createInterpolant():void 0,d=s?(m=this.scale)==null?void 0:m.createInterpolant():void 0;l||r.set(c.position.x,c.position.y,c.position.z),u||o.set(c.quaternion.x,c.quaternion.y,c.quaternion.z,c.quaternion.w),d||a.set(c.scale.x,c.scale.y,c.scale.z);for(let A=0;A<e.length;A++){const v=e[A];if(l){const g=l.evaluate(v);r.set(g[0],g[1],g[2])}if(u){const g=u.evaluate(v);o.set(g[0],g[1],g[2],g[3])}if(d){const g=d.evaluate(v);a.set(g[0],g[1],g[2])}if(this.useRootMotion&&c===this.root){const g=new Te;g.compose(r,o,a),g.multiply(c.matrix),g.decompose(r,o,a)}yield{time:v,translation:r,rotation:o,scale:a,index:A}}}}h(Bo,"animationDurationPadding",1);class uv{constructor(e){h(this,"dict",new Map);h(this,"rootTargetMap",new Map);h(this,"rootAndClipToRegisteredAnimationMap",new Map);h(this,"rootToRegisteredClipCount",new Map);h(this,"serializers",[]);h(this,"injectRestPoses",!1);h(this,"injectImplicitBehaviours",!1);this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}getClipCount(e){let t=this.rootToRegisteredClipCount.get(e);return this.injectRestPoses&&(t=t?t-1:0),t??0}getStartTime01(e,t){const i=this.rootTargetMap.get(e);if(!i)return 0;const s=this.dict.get(i[0]);if(!s)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let r=0;for(let o=0;o<s.length&&s[o].clip!==t;o++)r+=s[o].getDuration()+Bo.animationDurationPadding;return r}registerAnimation(e,t){if(!t||!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const i=e.uuid+t.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(i))return this.rootAndClipToRegisteredAnimationMap.get(i);Hf&&console.log("registerAnimation",e,t);const s=this.injectRestPoses?1:0,r=this.rootToRegisteredClipCount.get(e)??s,o=this.rootTargetMap.get(e),a=new Set(o);if(t.tracks)for(const l of t.tracks){const u=Gt.parseTrackName(l.name),d=Gt.findNode(e,u.nodeName);if(!d){console.warn("no object found for track",l.name,"using "+e.name+" instead");continue}this.dict.has(d)||this.dict.set(d,[]);const f=this.dict.get(d);if(!f)continue;if(a.delete(d),this.injectRestPoses&&!f[0]){const m=new Bo(null,d,void 0);f[0]=m}let p=f[r];p||(p=new Bo(e,d,t),f[r]=p),p.addTrack(l),o!=null&&o.includes(d)||o==null||o.push(d)}for(const l of a){const u=this.dict.get(l);if(!u)continue;if(this.injectRestPoses&&!u[0]){const f=new Bo(null,l,void 0);u[0]=f}let d=u[r];d||(Hf&&console.log("Adding padding clip for ",l,t),d=new Bo(e,l,t),u[r]=d)}const c=new Yx(this,e,t);return this.rootAndClipToRegisteredAnimationMap.set(i,c),this.rootToRegisteredClipCount.set(e,r+1),c}onAfterHierarchy(e){Hf&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,i;for(const s of this.serializers){const r=(t=s.model)==null?void 0:t.parent,o=(r==null?void 0:r.isDynamic)===!0;GM&&console.log(o,(i=s.model)==null?void 0:i.parent),o&&s.registerCallback(r)}}onExportObject(e,t,i){ne.foreachComponent(e,r=>{const o=r;typeof o.createAnimation=="function"&&o.createAnimation(this,t,i)},!1);const s=new nne(e,this.dict);this.serializers.push(s),s.registerCallback(t)}}class nne{constructor(e,t){h(this,"object");h(this,"dict");h(this,"model");h(this,"callback");this.object=e,this.dict=t}registerCallback(e){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),GM&&console.log("REPARENT",e),this.model=e,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){const i=this.model,s=this.dict;if(i&&i.skinnedMesh){let r=function(T){const R=[];for(const[C,I]of T){let D=`${C} : [`;const W=[];for(const F of I)W.push(`(${Jn(F.x)}, ${Jn(F.y)}, ${Jn(F.z)})`);D=D.concat(W.join(", ")),D=D.concat("],"),R.push(D)}return R},o=function(T){const R=[];for(const[C,I]of T){let D=`${C} : [`;const W=[];for(const F of I)W.push(`(${Jn(F.w)}, ${Jn(F.x)}, ${Jn(F.y)}, ${Jn(F.z)})`);D=D.concat(W.join(", ")),D=D.concat("],"),R.push(D)}return R},a=function(T){let R=!0,C;for(const[D,W]of T)if(C===void 0&&(C=W.length),C!==W.length){R=!1;break}Hf&&console.log("Bone count: ",T.size,"TransformData entries per bone: ",C),console.assert(R,"All bones should have the same number of TransformData entries",T);const I=[];for(const[D,W]of T){const F=new Array;let H=0;for(let j=0;j<W.length;j++)F.push(H),H+=W[j].getDuration()+Bo.animationDurationPadding;for(let j=0;j<W.length;j++){const z=W[j],L=F[j];I.length<=j&&I.push({pos:[],rot:[],scale:[],timeOffset:L});const G=I[j];G.pos.push(...z.getSortedTimesArray(!0,!1,!1)),G.rot.push(...z.getSortedTimesArray(!1,!0,!1)),G.scale.push(...z.getSortedTimesArray(!1,!1,!0))}}for(const D of I)D.pos.sort((W,F)=>W-F),D.rot.sort((W,F)=>W-F),D.scale.sort((W,F)=>W-F),D.pos=[...new Set(D.pos)],D.rot=[...new Set(D.rot)],D.scale=[...new Set(D.scale)];return I},c=function(T,R,C){const I=new Map,D=new Map,W=new Map,F=R.length;for(const H of C){const j=T.get(H);let z;j?console.assert(j.length===F,"We should have the same number of TransformData entries for each bone",j,R):z=new Bo(null,H,void 0);for(let L=0;L<F;L++){const G=j?j[L]:z,$=R[L];for(const{time:Z,translation:q}of G.getValues($.pos,!0,!1,!1)){const pe=(Z+$.timeOffset)*60;I.has(pe)||I.set(pe,new Array),I.get(pe).push(q.clone())}for(const{time:Z,rotation:q}of G.getValues($.rot,!1,!0,!1)){const pe=(Z+$.timeOffset)*60;D.has(pe)||D.set(pe,new Array),D.get(pe).push(q.clone())}for(const{time:Z,scale:q}of G.getValues($.scale,!1,!1,!0)){const pe=(Z+$.timeOffset)*60;W.has(pe)||W.set(pe,new Array),W.get(pe).push(q.clone())}}}return{position:I.size==0?void 0:I,quaternion:D.size==0?void 0:D,scale:W.size==0?void 0:W}},l=function(T){const R=[];for(const C of T)R.push(`(${Jn(C.x)}, ${Jn(C.y)}, ${Jn(C.z)})`);return R.join(", ")},u=function(T){const R=[];for(const C of T)R.push(`(${Jn(C.w)}, ${Jn(C.x)}, ${Jn(C.y)}, ${Jn(C.z)})`);return R.join(", ")},d=function(T){const R=new Map;if(Hf){const C=new Array;for(const[I,D]of s)C.push(I.uuid+": "+D.length+" "+D.map(W=>{var F;return(F=W.clip)==null?void 0:F.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
5189
+ `,a={map:{value:e},height:{value:t.height||15},radius:{value:t.radius||100}},c=new FA(1,16),l=new Bt({uniforms:a,fragmentShader:o,vertexShader:r,side:_i});super(c,l)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}var Gie=Object.defineProperty,Hie=Object.getOwnPropertyDescriptor,Es=(n,e,t,i)=>{for(var s=i>1?void 0:i?Hie(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&&Gie(e,t,s),s};const s0=re("freecam"),Tm=re("debugcamerafit"),r0=re("smoothcam"),Vie={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let vC;class dA extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class Ni extends Ie{constructor(){super(...arguments);h(this,"autoFit",!1);h(this,"enableRotate",!0);h(this,"autoRotate",!1);h(this,"autoRotateSpeed",1);h(this,"enableKeys",!0);h(this,"enableDamping",!0);h(this,"dampingFactor",.1);h(this,"enableZoom",!0);h(this,"minZoom",0);h(this,"maxZoom",1/0);h(this,"enablePan",!0);h(this,"lookAtConstraint",null);h(this,"lookAtConstraint01",1);h(this,"allowInterrupt",!0);h(this,"middleClickToFocus",!0);h(this,"doubleClickToFocus",!0);h(this,"useSlerp",!0);h(this,"debugLog",!1);h(this,"targetLerpDuration",1);h(this,"autoTarget",!0);h(this,"_controls",null);h(this,"_cameraObject",null);h(this,"_lookTargetLerpActive",!1);h(this,"_lookTargetStartPosition",new w);h(this,"_lookTargetEndPosition",new w);h(this,"_lookTargetLerp01",0);h(this,"_lookTargetLerpDuration",0);h(this,"_cameraLerpActive",!1);h(this,"_cameraStartPosition",new w);h(this,"_cameraEndPosition",new w);h(this,"_cameraLerp01",0);h(this,"_cameraLerpDuration",0);h(this,"_inputs",0);h(this,"_enableTime",0);h(this,"_startedListeningToKeyEvents",!1);h(this,"_eventSystem");h(this,"_afterHandleInputFn");h(this,"_camera",null);h(this,"_syncedTransform");h(this,"_didStart",!1);h(this,"targetElement",null);h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});h(this,"_shouldDisable",!1);h(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)}get targetLerpSpeed(){return 5}set targetLerpSpeed(t){this.targetLerpDuration=1/t}awake(){this._didStart=!1,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const t=ne.getComponent(this.gameObject,Ui);if(t&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const s=pt(t.cam).length(),r=new w(0,0,-s).applyMatrix4(t.cam.matrixWorld);this.setLookTargetPosition(r,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const i=new eo;i.screenPoint=new te(0,0),i.lineThreshold=.1;const s=this.context.physics.raycast(i);s.length>0&&this.setLookTargetPosition(s[0].point,!0),Tm&&console.log("OrbitControls hits",...s)}this.autoFit&&this.fitCamera()}this._eventSystem=nr.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(zM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(zM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=ne.getComponent(this.gameObject,Ui);this._camera=t;const i=t==null?void 0:t.cam;if(i&&ok(i,this,!0),!this._controls){if(!i){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}i&&(this._cameraObject=i);const s=this.targetElement??this.context.renderer.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new $te(i,s),i==null||i.quaternion.copy(r),vC===void 0&&(vC={...this._controls.keys})}this._controls&&(s0&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,pl()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?s0||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):s0||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=ne.getComponent(this.gameObject,mh)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&ok(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))}onBeforeRender(){var i,s;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((i=this.context.input.getPointerPositionDelta(0))!=null&&i.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!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._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new dA(this,"camera"));else{const r=Ye.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,r)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new dA(this,"lookat"));else{const r=Ye.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,r)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?vC:Vie,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,typeof r0=="number"||r0===!0){this._controls.enableDamping=!0;const r=typeof r0=="number"?r0:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,r))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!s0&&((s=this.lookAtConstraint)!=null&&s.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update())}}setCameraAndLookTarget(t){if(!t||!(t instanceof _e))return;const i=pt(t),s=xT(t);this.setTargetFromRaycast(new Aa(i,s)),this.setCameraTargetPosition(i)}setCameraTargetPosition(t,i=!1){var s,r;t&&(t instanceof _e&&(t=pt(t)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(t),i===!0?(this._cameraLerpActive=!1,(s=this.controllerObject)==null||s.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((r=this._cameraObject)==null?void 0:r.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(t=null,i=!1){this._controls&&t&&(t instanceof _e&&(t=pt(t)),this._lookTargetEndPosition.copy(t),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(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._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(t,i){return this.lerpLookTarget(t,i)}lerpLookTarget(t,i){this._controls&&(i>=1?this._controls.target.copy(t):this._controls.target.lerp(t,i))}setTargetFromRaycast(t){var s,r;if(!this.controls)return;const i=t?this.context.physics.raycastFromRay(t):this.context.physics.raycast();for(const o of i)if(o.distance>0&&ne.isActiveInHierarchy(o.object)){const a=Qx(o.object);if(a){const c=a.canvas;if(c!=null&&c.screenspace)break}if(this.setLookTargetPosition(o.point),this.context.mainCamera){const l=pt(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(r=(s=this._cameraObject)==null?void 0:s.parent)==null||r.worldToLocal(l),this.setCameraTargetPosition(l)}break}}fitCamera(t,i=1.1,s=!0){const r=this._cameraObject,o=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0||!r||!o)return;const a=new w,c=new w,l=new Dn;l.makeEmpty();const u=[];function d(y){let _=!0;if(y.visible&&zie(y)!==!1&&!(y.type==="TransformControlsGizmo"||y.type==="TransformControlsPlane")&&(y instanceof NE&&(_=!1),y instanceof pT&&(_=!1),y instanceof _G&&(_=!1),y.material instanceof j_&&(_=!1),y instanceof ge||(_=!1),y!==r&&y.isUI!==!0)){if(_){Tm&&console.log(y.name,y.type,y);const E=y.children;y.children=u;const M=y.position,T=y.scale;if(Number.isNaN(M.x)||Number.isNaN(M.y)||Number.isNaN(M.z)){console.warn(`Object "${y.name}" has NaN values in position or scale.... will ignore it`,M,T);return}l.expandByObject(y,!0),y.children=E}for(const E of y.children)d(E)}}for(const y of t)y.updateMatrixWorld(),d(y);if(r.updateMatrixWorld(),r.updateProjectionMatrix(),l.getCenter(c),l.applyMatrix4(r.matrixWorldInverse),l.getSize(a),l.setFromCenterAndSize(c,a),Number.isNaN(a.x)||Number.isNaN(a.y)||Number.isNaN(a.z)){console.warn("Camera fit size resultet in NaN",r,l,[...t]);return}if(a.length()<=1e-10){Tm&&console.warn("Camera fit size is zero",l,[...t]);return}const f=r.fov,p=2*Math.atan(Math.tan(f*Math.PI/360/2)*r.aspect)/Math.PI*360,m=a.y/(2*Math.atan(Math.PI*f/360)),A=a.x/(2*Math.atan(Math.PI*p/360)),v=i*Math.max(m,A)+a.z/2;Tm&&console.log("Fit camera to objects",m,A,"distance",v);const g=pt(r),b=o.target.clone().sub(g).normalize().multiplyScalar(v);if(o.maxDistance=v*10,o.minDistance=v*.01,this.setLookTargetPosition(c,s),this.autoTarget=!1,r.near=v/100,r.far=v*100,r.updateMatrixWorld(),r.updateProjectionMatrix(),r.parent){const y=r.parent.worldToLocal(o.target.clone().sub(b));this.setCameraTargetPosition(y,s)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(Tm){const y=new NE(l);this.context.scene.add(y),wT(y,GA(r)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",_=>{_.code==="KeyF"&&this.fitCamera(t)}))}o.update()}}Es([x()],Ni.prototype,"autoFit",2);Es([x()],Ni.prototype,"enableRotate",2);Es([x()],Ni.prototype,"autoRotate",2);Es([x()],Ni.prototype,"autoRotateSpeed",2);Es([x()],Ni.prototype,"enableKeys",2);Es([x()],Ni.prototype,"enableDamping",2);Es([x()],Ni.prototype,"dampingFactor",2);Es([x()],Ni.prototype,"enableZoom",2);Es([x()],Ni.prototype,"minZoom",2);Es([x()],Ni.prototype,"maxZoom",2);Es([x()],Ni.prototype,"enablePan",2);Es([x(av)],Ni.prototype,"lookAtConstraint",2);Es([x()],Ni.prototype,"lookAtConstraint01",2);Es([x()],Ni.prototype,"allowInterrupt",2);Es([x()],Ni.prototype,"middleClickToFocus",2);Es([x()],Ni.prototype,"doubleClickToFocus",2);Es([x()],Ni.prototype,"targetLerpDuration",2);var Qie=Object.defineProperty,Wie=Object.getOwnPropertyDescriptor,ro=(n,e,t,i)=>{for(var s=i>1?void 0:i?Wie(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&&Qie(e,t,s),s},Vu=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(Vu||{});const Au=re("debugcam"),ck=re("debugscreenpointtoray");var C0;const Jm=(C0=class extends Ie{constructor(){super(...arguments);h(this,"_nearClipPlane",.1);h(this,"_farClipPlane",1e3);h(this,"orthographic",!1);h(this,"orthographicSize",5);h(this,"ARBackgroundAlpha",0);h(this,"_cullingMask",4294967295);h(this,"_backgroundBlurriness");h(this,"_backgroundIntensity");h(this,"_environmentIntensity");h(this,"_targetTexture",null);h(this,"_backgroundColor");h(this,"_fov");h(this,"_cam",null);h(this,"_clearFlags",2);h(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("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 cullingLayer(e){this.cullingMask=(1<<e|0)>>>0}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}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}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){const s=this.cam,r=Jm._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),ck&&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=Jm._direction.set(r.x,r.y,r.z),a=pt(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new Aa(a.clone(),o.clone())}awake(){ck&&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);Qa.DrawRay(s.origin,s.direction,r,10)})}onEnable(){Au&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Vu[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),qie(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),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;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}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 qt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof qt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new qt(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 dl(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){Au&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Au){const e=`Camera "${this.name}" clear flags: ${Vu[this._clearFlags]}`;console.log(e)}switch(this._clearFlags){case 1:if(Jm.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;Jm.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else Au&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new jie(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,c;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;if(typeof t._transparent=="boolean")return t._transparent;const i=t.environmentBlendMode;Au&&An("Environment blend mode: "+i+" on "+navigator.userAgent);let s=i==="additive"||i==="alpha-blend";return e.xrSessionMode===tA.ImmersiveAR&&i==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((c=navigator.userAgent)!=null&&c.includes("Mobile WebXRViewer/v2")))&&(s=!0),t._transparent=s,s}},h(C0,"_origin",new w),h(C0,"_direction",new w),C0);let Ui=Jm;ro([x()],Ui.prototype,"fieldOfView",1);ro([x()],Ui.prototype,"nearClipPlane",1);ro([x()],Ui.prototype,"farClipPlane",1);ro([x()],Ui.prototype,"clearFlags",1);ro([x()],Ui.prototype,"orthographic",2);ro([x()],Ui.prototype,"orthographicSize",2);ro([x()],Ui.prototype,"ARBackgroundAlpha",2);ro([x()],Ui.prototype,"cullingMask",1);ro([x()],Ui.prototype,"backgroundBlurriness",1);ro([x()],Ui.prototype,"backgroundIntensity",1);ro([x()],Ui.prototype,"environmentIntensity",1);ro([x(bi)],Ui.prototype,"backgroundColor",1);ro([x(sh)],Ui.prototype,"targetTexture",1);class jie{constructor(e){h(this,"_camera");h(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&&(Au&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=nt,this._skybox.mapping=Oo,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(Au||Vt())&&rs(`Camera "${this._camera.name}" has no skybox texture`))}}function qie(n){re("freecam")&&n.context.mainCameraComponent===n&&ne.getOrAddComponent(n.gameObject,Ni)}class rh extends Ie{constructor(){super(...arguments);h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new lF),this._listener}awake(){Cn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=this.context.mainCameraComponent||ne.getComponentInParent(this.gameObject,Ui);i!=null&&i.cam?i.cam.add(t):this.gameObject.add(t)})}}var Xie=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,Wx=(n,e,t,i)=>{for(var s=i>1?void 0:i?Yie(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&&Xie(e,t,s),s};const Jie=re("debugsignals");class lv{constructor(){h(this,"guid")}}Wx([x()],lv.prototype,"guid",2);class Dp{constructor(){h(this,"signal");h(this,"reaction")}}Wx([x(lv)],Dp.prototype,"signal",2);Wx([x(gs)],Dp.prototype,"reaction",2);var ZC;const Ic=(ZC=class extends Ie{constructor(){super(...arguments);h(this,"events")}static invoke(e){if(Ic.receivers[e]){const t=Ic.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){Jie&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Ic.receivers[e.signal.guid]||(Ic.receivers[e.signal.guid]=[]),Ic.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Ic.receivers[e.signal.guid]){const t=Ic.receivers[e.signal.guid].indexOf(this);t>=0&&Ic.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const 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)}}},h(ZC,"receivers",{}),ZC);let Op=Ic;Wx([x(Dp)],Op.prototype,"events",2);var Ur=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(Ur||{}),Pa=(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))(Pa||{}),VI=(n=>(n.Signal="SignalEmitter",n))(VI||{});const Xc=re("debugtimeline");class hv{constructor(){h(this,"director");h(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;const a=!1;if(r.easeInDuration>0){const c=Math.min((e-r.start)/r.easeInDuration,1);o*=c}if(r.easeOutDuration>0&&!a){const c=Math.min((r.end-e)/r.easeOutDuration,1);o*=c}return o}return 0}}class Kie{constructor(e){h(this,"clip");h(this,"rootPositionOffset");h(this,"rootQuaternionOffset");h(this,"rootStartPosition");h(this,"rootEndPosition");h(this,"rootStartQuaternion");h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const i=e.getRoot(),s=i.name+".position",r=i.name+".quaternion";Xc&&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 w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Xc&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new Se().fromArray(o.values,0),this.rootEndQuaternion=new Se().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Xc)){const a=new yn().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class jx extends hv{constructor(){super(...arguments);h(this,"models",[]);h(this,"trackOffset");h(this,"target");h(this,"mixer");h(this,"clips",[]);h(this,"actions",[]);h(this,"_actionOffsets",[]);h(this,"_didBind",!1);h(this,"_animator",null);h(this,"_useclipOffsets",!0);h(this,"_totalOffsetPosition",new w);h(this,"_totalOffsetRotation",new Se);h(this,"_totalOffsetPosition2",new w);h(this,"_totalOffsetRotation2",new Se);h(this,"_summedPos",new w);h(this,"_tempPos",new w);h(this,"_summedRot",new Se);h(this,"_tempRot",new Se);h(this,"_clipRotQuat",new Se)}onStateChanged(){this._animator&&lk(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var u,d;if(((u=i.tracks)==null?void 0:u.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 c=!1,l=!1;for(const f of i.tracks)f.name.endsWith(o)?(c=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(l=!0,this.createRotationInterpolant(i,t,f));if(!c||!l){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(c){if(!l){const b=i.tracks[0].name.substring(0,m)+".quaternion";Xc&&console.warn("Create quaternion track",v,g);const y=g.quaternion,_=new ec(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";Xc&&console.warn("Create position track",v,g);const y=g.position,_=new al(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,Xc&&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 Kie(t);this._actionOffsets.push(i)}this.target&&(this._animator=ne.getComponent(this.target,ys)??null,this._animator&&lk(this._animator.gameObject,this,!0));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 w(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new Se(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 w(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Se(i.x,i.y,i.z,i.w)))}}evaluate(t){var c,l,u,d,f,p,m;if(this.track.muted||!this.mixer)return;this.bind(),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,a=0;for(let A=0;A<this.clips.length;A++){const v=this.models[A],g=this.actions[A],b=v.asset;g.weight=0;const y=t>=v.start&&t<=v.end,_=v.preExtrapolationMode,E=v.postExtrapolationMode,M=A<this.clips.length-1?this.models[A+1]:null;let T=y,R=!1;if(!T&&!r&&v.end<t&&E!==Pa.None?(!M||M.start>t)&&(T=!0,r=!0):A==0&&!T&&!o&&v.start>t&&_!==Pa.None&&(!M||M.start<t)&&(T=!0,R=!0,o=!0),T){let C=1;C*=this.evaluateWeight(t,A,this.models,T),C*=this.director.weight;let I=y;if(R)switch(_){case Pa.Hold:break;case Pa.Loop:t+=v.start,I=!0;break;default:t+=v.start,I=!0;break}let D=this.getClipTime(t,v),W=0;const F=b.duration;if(R&&_===Pa.Hold&&(D=0),I){if(b.loop)for(W+=Math.floor(D/(F+1e-6));D>F;)D-=F}else if(!y&&r)switch(E){case Pa.Hold:D=this.getClipTime(v.end,v);break;case Pa.Loop:D%=F;break;case Pa.PingPong:const z=Math.floor(D/F)%2!==0;D%=F,z&&(D=F-D);break}v.reversed===!0?g.time=g.getClip().duration-D:g.time=D,g.timeScale=0;const H=Math.max(0,C);if(g.weight=H,a+=H,g.clampWhenFinished=!1,g.isRunning()||g.play(),this._useclipOffsets){const j=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,z=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(s=1-C),i+=1;const L=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),$=this._summedRot.identity(),Z=this._tempRot.identity(),q=b.rotation;q&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(q,C));const ie=this._actionOffsets[A];if(ie.hasOffsets)for(let pe=0;pe<W;pe++)ie.rootPositionOffset?G.copy(ie.rootPositionOffset):G.set(0,0,0),G.applyQuaternion($),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),ie.rootQuaternionOffset&&(Z.copy(ie.rootQuaternionOffset),$.multiply(Z)),L.add(G);this._clipRotQuat&&z.multiply(this._clipRotQuat),z.multiply($),b.position&&L.add(b.position),j.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.__mixerError===void 0&&(Xc||Vt())&&((l=(c=this._animator)==null?void 0:c.runtimeAnimatorController)!=null&&l.mixer)&&this.mixer!==((d=(u=this._animator)==null?void 0:u.runtimeAnimatorController)==null?void 0:d.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(f=this._animator)!=null&&f.runtimeAnimatorController){const A=Math.max(0,1-a);(m=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||m.update(A)}else this.mixer.update(t)}createRotationInterpolant(t,i,s){var c;const r=s.createInterpolant.bind(s),o=new Se;this.ensureTrackOffsets();const a=(c=this.trackOffset)==null?void 0:c.rotation;s.createInterpolant=()=>{const l=r(),u=l.evaluate.bind(l);return l.evaluate=d=>{var p;const f=u(d);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const m of this.director.animationCallbackReceivers)(p=m==null?void 0:m.onTimelineRotation)==null||p.call(m,this.director,this.target,d,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},l}}createPositionInterpolant(t,i,s){var u,d;const r=s.createInterpolant.bind(s),o=new w;this.ensureTrackOffsets();const a=(u=this.trackOffset)==null?void 0:u.rotation,c=(d=this.trackOffset)==null?void 0:d.position;let l;s.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=m=>{var v,g,b;const A=p(m);if(o.set(A[0],A[1],A[2]),i.removeStartOffset&&(l===void 0?(l=null,l=(g=(v=this._actionOffsets.find(y=>y.clip===t))==null?void 0:v.rootStartPosition)==null?void 0:g.clone()):l!=null&&l.isVector3&&o.sub(l)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),c&&(o.x-=c.x,o.y+=c.y,o.z+=c.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(b=y==null?void 0:y.onTimelinePosition)==null||b.call(y,this.director,this.target,m,o);return A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const Zie=re("mutetimeline"),Rf=class extends hv{constructor(){super(...arguments);h(this,"models",[]);h(this,"listener");h(this,"audio",[]);h(this,"audioContextTimeOffset",[]);h(this,"lastTime",0);h(this,"audioSource");h(this,"_audioLoader",null)}getAudioFilePath(t){const i=this.director.sourceId;return fl(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 uT(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(Zie||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],c=o.asset;if((!a||!a.buffer)&&this.isInTimeRange(o,t-1,t+1)&&this.handleAudioLoading(o,a),Cn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale*this.director.speed,a.loop=c.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 u=o.clipIn+(t-o.start)*o.timeScale,d=a.context.currentTime-a._startedAt+a.offset;Math.abs(u-d)>.3&&(a.offset=u,a.stop(),a.play(s))}let l=c.volume;if(this.track.volume!==void 0&&(l*=this.track.volume),i&&(l=0),o.easeInDuration>0){const u=Math.min((t-o.start)/o.easeInDuration,1);l*=u}if(o.easeOutDuration>0){const u=Math.min((o.end-t)/o.easeOutDuration,1);l*=u}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 c of this.models)if(this.isInTimeRange(c,o,a)){const l=this.audio[this.models.indexOf(c)],u=this.handleAudioLoading(c,l);u!==null&&(r===null&&(r=[]),r.push(u))}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(){Rf._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new Sb);const s=this.getAudioFilePath(t.asset.clip);if(Rf._audioBuffers.get(s)){const o=Rf._audioBuffers.get(s);return o.then(a=>{a&&i.setBuffer(a)}),o}Xc&&console.warn("LOAD audio track",s,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(s,c=>{i.setBuffer(c),o(c)},void 0,c=>{console.error("Error loading audio",c),o(null)})});return Rf._audioBuffers.set(s,r),r}};let Ou=Rf;h(Ou,"_audioBuffers",new Map);class fA extends hv{constructor(){super(...arguments);h(this,"models",[]);h(this,"didTrigger",[]);h(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],c=o.time-t;let l=!1;if(o.retroActive)l=c<=1e-6;else{const u=Math.abs(c);(u===0||u>=1e-5&&u<i)&&(l=!0)}if(l){if(!a)if(Xc&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((s=this.receivers)==null?void 0:s.length)<=0)Op.invoke(o.asset);else for(const u of this.receivers)u&&u.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class qx extends hv{constructor(){super(...arguments);h(this,"models",[]);h(this,"timelines",[]);h(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=ne.getComponent(r.sourceObject,rl);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 c=o.sourceObject;c.visible=!0}if(o.updateDirector){const c=this.timelines[s];c&&(c.isPlaying&&c.pause(),c.time=a,c.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const c=o.sourceObject;(a==null?void 0:a.sourceObject)!==c&&(c.visible=!1)}}}}}const Xd=re("debugtimeline"),f_=class extends Ie{constructor(){super(...arguments);h(this,"playableAsset");h(this,"playOnAwake");h(this,"extrapolationMode",1);h(this,"waitForAudio",!0);h(this,"_visibilityChangeEvt");h(this,"_clonedPlayableAsset",!1);h(this,"_speed",1);h(this,"_guidsMap");h(this,"_isPlaying",!1);h(this,"_internalUpdateRoutine");h(this,"_isPaused",!1);h(this,"_isStopping",!1);h(this,"_time",0);h(this,"_duration",0);h(this,"_weight",1);h(this,"_animationTracks",[]);h(this,"_audioTracks",[]);h(this,"_signalTracks",[]);h(this,"_controlTracks",[]);h(this,"_customTracks",[]);h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);h(this,"animationCallbackReceivers",[])}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:(Xd||cr())&&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;Xd&&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,s;for(const r of this._audioTracks)(t=r.onEnable)==null||t.call(r);for(const r of this._customTracks)(i=r.onEnable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onEnable)==null||s.call(r);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,s;this.stop();for(const r of this._audioTracks)(t=r.onDisable)==null||t.call(r);for(const r of this._customTracks)(i=r.onDisable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onDisable)==null||s.call(r);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&&!Cn.userInteractionRegistered&&this.waitForAudio;)await dh(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),is.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;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.internalEvaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),i&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}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)}invokeStateChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onStateChanged)==null||t.call(i,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(t=!1){if(!this.isValid())return;let i=this._time;switch(this.extrapolationMode){case 0:this._speed>0?i=Math.min(i,this._duration):this._speed<0&&(i=Math.max(i,0)),this._time=i;break;case 1:i%=this._duration,this._time=i;break;case 2:if(i>this._duration){this.stop();return}break}const s=this._time;for(const r of this.playableAsset.tracks)if(!r.muted)switch(r.type){case Ur.Activation:if(!t&&!this._isPlaying)continue;for(let o=0;o<r.outputs.length;o++){const a=r.outputs[o];if(typeof a=="object"){let c=!1;if(r.clips)for(const u of r.clips)u.start<=s&&s<=u.end&&(c=!0);const l=a;l.visible!==void 0&&l.visible!==c&&(l.visible=c,Xd&&console.warn(this.name,"set ActivationTrack-"+o,l.name,c,s))}}break}if(!this._isStopping)for(const r of this._animationTracks)r.evaluate(s);for(const r of this._audioTracks)r.evaluate(s);for(const r of this._signalTracks)r.evaluate(s);for(const r of this._controlTracks)r.evaluate(s);for(const r of this._customTracks)r.evaluate(s)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=ix(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=ne.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(s,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Xd&&console.log("Resolved binding",r,"to",o),i.outputs[s]=o)}else if(r===null){if(i.outputs.splice(s,1),f_.createTrackFunctions[i.type])continue;i.type!==Ur.Audio&&i.type!==Ur.Control&&i.type!==Ur.Marker&&i.type!==Ur.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===Ur.Control&&i.clips)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=ne.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Xd&&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){if(t.clips)for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);if(t.markers)for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,s,r;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let t=ne.findObjectOfType(rh,this.context);for(const o of this.playableAsset.tracks){const a=o.type,c=f_.createTrackFunctions[a];if(c!=null){const l=c(this,o);if(typeof l.evaluate=="function"){l.director=this,l.track=o,this._customTracks.push(l);continue}}if(o.type===Ur.Animation){if(!o.clips||o.clips.length<=0){Xd&&console.warn("Animation track has no clips",o);continue}for(let l=o.outputs.length-1;l>=0;l--){let u=o.outputs[l];if(u instanceof _e){const f=ne.getOrAddComponent(u,ys);f&&(u=f)}const d=(i=u==null?void 0:u.gameObject)==null?void 0:i.animations;if(d){const f=new jx;f.trackOffset=o.trackOffset,f.director=this,f.track=o;for(let p=0;p<o.clips.length;p++){const m=o.clips[p],A=m.asset;if(!A){console.error("MISSING anim model?","clip#"+p,m,o,this.playableAsset,this.name);continue}const v=A.clip;let g=v;if((typeof g=="string"||typeof g=="number")&&(g=d.find(y=>y.name===v)),!g){console.warn("Could not find animationClip for model",m,o.name,this.name,(s=this.playableAsset)==null?void 0:s.name);continue}u instanceof ys&&u.runtimeAnimatorController&&(u.__internalDidAwakeAndStart||u.initializeRuntimeAnimatorController(),u.runtimeAnimatorController.mixer||u.runtimeAnimatorController.bind(u),f.mixer=u.runtimeAnimatorController.mixer),f.mixer||(f.mixer=new ex(u.gameObject)),f.clips.push(g),f.mixer.uncacheAction(g),f.createHooks(m.asset,g);const b=f.mixer.clipAction(g);f.actions.push(b),f.models.push(m)}this._animationTracks.push(f)}}}else if(o.type===Ur.Audio){if(!o.clips||o.clips.length<=0)continue;const l=new Ou;l.director=this,l.track=o,l.audioSource=o.outputs.find(u=>u instanceof Cn),this._audioTracks.push(l),t||(t=(r=this.context.mainCameraComponent)==null?void 0:r.gameObject.addNewComponent(rh)),l.listener=t.listener;for(let u=0;u<o.clips.length;u++){const d=o.clips[u];l.addModel(d)}}else if(o.type===Ur.Marker){const l=new fA;if(l.director=this,l.track=o,o.markers)for(const u of o.markers)switch(u.type){case VI.Signal:l.models.push(u),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const u=ne.getComponent(this.gameObject,Op);u&&(l.receivers.push(u),this._signalTracks.push(l))}}else if(o.type===Ur.Signal){const l=new fA;if(l.director=this,l.track=o,o.markers)for(const u of o.markers)l.models.push(u),l.didTrigger.push(!1);for(const u of o.outputs)l.receivers.push(u);this._signalTracks.push(l)}else if(o.type===Ur.Control){const l=new qx;if(l.director=this,l.track=o,o.clips)for(const u of o.clips)l.models.push(u);l.resolveSourceObjects(this.context),this._controlTracks.push(l)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const i=this.animationCallbackReceivers.indexOf(t);i!==-1&&this.animationCallbackReceivers.splice(i,1)}};let rl=f_;h(rl,"createTrackFunctions",{});const ob=Symbol("objectIsAnimatedData");function lk(n,e,t){if(!n)return;if(n[ob]===void 0){if(!t)return;n[ob]=new Set}const i=n[ob];t?i.add(e):i.has(e)&&i.delete(e)}function $ie(n){if(!n)return!1;const e=n[ob];return e!==void 0&&e.size>0}Ii.registerCallback(Zn.ContextCreated,n=>{const e=n.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true")&&n.files)for(const t of n.files)ne.foreachComponent(t.file.scene,s=>{if(s.enabled!==!1){if(s instanceof no&&s.playAutomatically||s instanceof ys||s instanceof rl&&s.playOnAwake===!0)return!0;if(s instanceof no)return s.playAutomatically=!0,!0;if(s instanceof rl)return s.playOnAwake=!0,!0}},!0)!==!0&&ene(t.file)});function ene(n){if(!n||!n.animations)return;for(let t=0;t<n.animations.length;t++){const i=n.animations[t];if(!(!i.tracks||i.tracks.length<=0))for(const s in i.tracks){const r=i.tracks[s],o=r.__objectName??r.name.substring(0,r.name.indexOf("."));let a=n.scene.getObjectByName(o);if(!a&&(a=n.scene.getObjectByProperty("uuid",o),!a))continue;let c=e(a);c||(c=wh(n.scene,new no));const l=c.animations=c.animations||[];i.name_animator=c.name,l.indexOf(i)<0&&l.push(i)}}function e(t){var s;if(!t)return;const i=(s=t.userData)==null?void 0:s.components;if(i&&i.length>0)for(let r=0;r<i.length;r++){const o=i[r];if(o instanceof ys||o instanceof no)return t}return e(t.parent)}}var tne=Object.defineProperty,ine=Object.getOwnPropertyDescriptor,Xx=(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 hk=re("debuganimator");class ys extends Ie{constructor(){super(...arguments);h(this,"applyRootMotion",!1);h(this,"hasRootMotion",!1);h(this,"keepAnimatorControllerStateOnDisable",!1);h(this,"_parametersAreDirty",!1);h(this,"_isDirty",!1);h(this,"speed",1);h(this,"normalizedStartOffset",0);h(this,"_animatorController",null);h(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(t){var i;this._animatorController&&this._animatorController.model===t||(t?t instanceof Fo?(t.animator&&t.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(i=t.model)==null?void 0:i.name),t.model||console.error("AnimatorController has no model"),t=new Fo(t.model)),this._animatorController=t,this._animatorController.bind(this)):(hk&&console.log("Assign animator controller",t,this),this._animatorController=new Fo(t),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(t,i=-1,s=Number.NEGATIVE_INFINITY,r=0){this.play(t,i,s,r)}play(t,i=-1,s=Number.NEGATIVE_INFINITY,r=0){var o;(o=this.runtimeAnimatorController)==null||o.play(t,i,s,r),this._isDirty=!0}Reset(){this.reset()}reset(){var t;(t=this._animatorController)==null||t.reset(),this._isDirty=!0}SetBool(t,i){this.setBool(t,i)}setBool(t,i){var s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getBool(t))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setBool(t,i)}GetBool(t){return this.getBool(t)}getBool(t){var i;return((i=this.runtimeAnimatorController)==null?void 0:i.getBool(t))??!1}SetFloat(t,i){this.setFloat(t,i)}setFloat(t,i){var s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getFloat(t))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setFloat(t,i)}GetFloat(t){return this.getFloat(t)}getFloat(t){var i;return((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(t))??-1}SetInteger(t,i){this.setInteger(t,i)}setInteger(t,i){var s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getInteger(t))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setInteger(t,i)}GetInteger(t){return this.getInteger(t)}getInteger(t){var i;return((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(t))??-1}SetTrigger(t){this.setTrigger(t)}setTrigger(t){var i;(i=this.runtimeAnimatorController)==null||i.setTrigger(t),this._parametersAreDirty=!0}ResetTrigger(t){this.resetTrigger(t)}resetTrigger(t){var i;(i=this.runtimeAnimatorController)==null||i.resetTrigger(t),this._parametersAreDirty=!0}GetTrigger(t){this.getTrigger(t)}getTrigger(t){var i;(i=this.runtimeAnimatorController)==null||i.getTrigger(t)}IsInTransition(){return this.isInTransition()}isInTransition(){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.isInTransition())??!1}SetSpeed(t){return this.setSpeed(t)}setSpeed(t){var i;t!==this.speed&&(this.speed=t,(i=this._animatorController)==null||i.setSpeed(t))}set minMaxSpeed(t){this.speed=Ye.lerp(t.x,t.y,Math.random())}set minMaxOffsetNormalized(t){this.normalizedStartOffset=Ye.lerp(t.x,t.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){hk&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(t=!1){const i=t||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&i){const s=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=s,s?(console.assert(this.runtimeAnimatorController!==s),this.runtimeAnimatorController=s,console.assert(this.runtimeAnimatorController===s),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this.speed),this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var t;this.keepAnimatorControllerStateOnDisable||(t=this._animatorController)==null||t.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!$ie(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}Xx([x()],ys.prototype,"applyRootMotion",2);Xx([x()],ys.prototype,"hasRootMotion",2);Xx([x()],ys.prototype,"keepAnimatorControllerStateOnDisable",2);Xx([x()],ys.prototype,"runtimeAnimatorController",1);const Hf=re("debugusdzanimation"),GM=re("debugusdzanimationserialization");class Yx{constructor(e,t,i){h(this,"_start");h(this,"ext");h(this,"root");h(this,"clip");this.ext=e,this.root=t,this.clip=i}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}class Bo{constructor(e,t,i){h(this,"clip");h(this,"pos");h(this,"rot");h(this,"scale");h(this,"root");h(this,"target");h(this,"duration",0);h(this,"useRootMotion",!1);this.root=e,this.target=t,this.clip=i,i?this.duration=i.duration:this.duration=1/this.frameRate;const s=ne.getComponent(e,ys);s&&(this.useRootMotion=s.applyRootMotion)}get frameRate(){return 60}addTrack(e){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it – this is likely a bug");return}e.name.endsWith("position")&&(this.pos=e),e.name.endsWith("quaternion")&&(this.rot=e),e.name.endsWith("scale")&&(this.scale=e)}getFrames(){var e,t,i,s,r,o;return this.clip?Math.max(((t=(e=this.pos)==null?void 0:e.times)==null?void 0:t.length)??0,((s=(i=this.rot)==null?void 0:i.times)==null?void 0:s.length)??0,((o=(r=this.scale)==null?void 0:r.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(e=!0,t=!0,i=!0){var c,l,u;if(!this.clip)return[0,this.duration];const s=(c=this.pos)==null?void 0:c.times,r=(l=this.rot)==null?void 0:l.times,o=(u=this.scale)==null?void 0:u.times,a=[];if(e&&s)for(const d of s)a.push(d);if(t&&r)for(const d of r)a.push(d);if(i&&o)for(const d of o)a.push(d);return a.includes(0)||a.push(0),a.sort((d,f)=>d-f),[...new Set(a)]}*getValues(e,t=!0,i=!0,s=!0){var f,p,m;const r=new w,o=new Se,a=new w(1,1,1),c=this.target,l=t?(f=this.pos)==null?void 0:f.createInterpolant():void 0,u=i?(p=this.rot)==null?void 0:p.createInterpolant():void 0,d=s?(m=this.scale)==null?void 0:m.createInterpolant():void 0;l||r.set(c.position.x,c.position.y,c.position.z),u||o.set(c.quaternion.x,c.quaternion.y,c.quaternion.z,c.quaternion.w),d||a.set(c.scale.x,c.scale.y,c.scale.z);for(let A=0;A<e.length;A++){const v=e[A];if(l){const g=l.evaluate(v);r.set(g[0],g[1],g[2])}if(u){const g=u.evaluate(v);o.set(g[0],g[1],g[2],g[3])}if(d){const g=d.evaluate(v);a.set(g[0],g[1],g[2])}if(this.useRootMotion&&c===this.root){const g=new Te;g.compose(r,o,a),g.multiply(c.matrix),g.decompose(r,o,a)}yield{time:v,translation:r,rotation:o,scale:a,index:A}}}}h(Bo,"animationDurationPadding",1);class uv{constructor(e){h(this,"dict",new Map);h(this,"rootTargetMap",new Map);h(this,"rootAndClipToRegisteredAnimationMap",new Map);h(this,"rootToRegisteredClipCount",new Map);h(this,"serializers",[]);h(this,"injectRestPoses",!1);h(this,"injectImplicitBehaviours",!1);this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}getClipCount(e){let t=this.rootToRegisteredClipCount.get(e);return this.injectRestPoses&&(t=t?t-1:0),t??0}getStartTime01(e,t){const i=this.rootTargetMap.get(e);if(!i)return 0;const s=this.dict.get(i[0]);if(!s)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let r=0;for(let o=0;o<s.length&&s[o].clip!==t;o++)r+=s[o].getDuration()+Bo.animationDurationPadding;return r}registerAnimation(e,t){if(!t||!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const i=e.uuid+t.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(i))return this.rootAndClipToRegisteredAnimationMap.get(i);Hf&&console.log("registerAnimation",e,t);const s=this.injectRestPoses?1:0,r=this.rootToRegisteredClipCount.get(e)??s,o=this.rootTargetMap.get(e),a=new Set(o);if(t.tracks)for(const l of t.tracks){const u=Gt.parseTrackName(l.name),d=Gt.findNode(e,u.nodeName);if(!d){console.warn("no object found for track",l.name,"using "+e.name+" instead");continue}this.dict.has(d)||this.dict.set(d,[]);const f=this.dict.get(d);if(!f)continue;if(a.delete(d),this.injectRestPoses&&!f[0]){const m=new Bo(null,d,void 0);f[0]=m}let p=f[r];p||(p=new Bo(e,d,t),f[r]=p),p.addTrack(l),o!=null&&o.includes(d)||o==null||o.push(d)}for(const l of a){const u=this.dict.get(l);if(!u)continue;if(this.injectRestPoses&&!u[0]){const f=new Bo(null,l,void 0);u[0]=f}let d=u[r];d||(Hf&&console.log("Adding padding clip for ",l,t),d=new Bo(e,l,t),u[r]=d)}const c=new Yx(this,e,t);return this.rootAndClipToRegisteredAnimationMap.set(i,c),this.rootToRegisteredClipCount.set(e,r+1),c}onAfterHierarchy(e){Hf&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,i;for(const s of this.serializers){const r=(t=s.model)==null?void 0:t.parent,o=(r==null?void 0:r.isDynamic)===!0;GM&&console.log(o,(i=s.model)==null?void 0:i.parent),o&&s.registerCallback(r)}}onExportObject(e,t,i){ne.foreachComponent(e,r=>{const o=r;typeof o.createAnimation=="function"&&o.createAnimation(this,t,i)},!1);const s=new nne(e,this.dict);this.serializers.push(s),s.registerCallback(t)}}class nne{constructor(e,t){h(this,"object");h(this,"dict");h(this,"model");h(this,"callback");this.object=e,this.dict=t}registerCallback(e){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),GM&&console.log("REPARENT",e),this.model=e,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){const i=this.model,s=this.dict;if(i&&i.skinnedMesh){let r=function(T){const R=[];for(const[C,I]of T){let D=`${C} : [`;const W=[];for(const F of I)W.push(`(${Jn(F.x)}, ${Jn(F.y)}, ${Jn(F.z)})`);D=D.concat(W.join(", ")),D=D.concat("],"),R.push(D)}return R},o=function(T){const R=[];for(const[C,I]of T){let D=`${C} : [`;const W=[];for(const F of I)W.push(`(${Jn(F.w)}, ${Jn(F.x)}, ${Jn(F.y)}, ${Jn(F.z)})`);D=D.concat(W.join(", ")),D=D.concat("],"),R.push(D)}return R},a=function(T){let R=!0,C;for(const[D,W]of T)if(C===void 0&&(C=W.length),C!==W.length){R=!1;break}Hf&&console.log("Bone count: ",T.size,"TransformData entries per bone: ",C),console.assert(R,"All bones should have the same number of TransformData entries",T);const I=[];for(const[D,W]of T){const F=new Array;let H=0;for(let j=0;j<W.length;j++)F.push(H),H+=W[j].getDuration()+Bo.animationDurationPadding;for(let j=0;j<W.length;j++){const z=W[j],L=F[j];I.length<=j&&I.push({pos:[],rot:[],scale:[],timeOffset:L});const G=I[j];G.pos.push(...z.getSortedTimesArray(!0,!1,!1)),G.rot.push(...z.getSortedTimesArray(!1,!0,!1)),G.scale.push(...z.getSortedTimesArray(!1,!1,!0))}}for(const D of I)D.pos.sort((W,F)=>W-F),D.rot.sort((W,F)=>W-F),D.scale.sort((W,F)=>W-F),D.pos=[...new Set(D.pos)],D.rot=[...new Set(D.rot)],D.scale=[...new Set(D.scale)];return I},c=function(T,R,C){const I=new Map,D=new Map,W=new Map,F=R.length;for(const H of C){const j=T.get(H);let z;j?console.assert(j.length===F,"We should have the same number of TransformData entries for each bone",j,R):z=new Bo(null,H,void 0);for(let L=0;L<F;L++){const G=j?j[L]:z,$=R[L];for(const{time:Z,translation:q}of G.getValues($.pos,!0,!1,!1)){const pe=(Z+$.timeOffset)*60;I.has(pe)||I.set(pe,new Array),I.get(pe).push(q.clone())}for(const{time:Z,rotation:q}of G.getValues($.rot,!1,!0,!1)){const pe=(Z+$.timeOffset)*60;D.has(pe)||D.set(pe,new Array),D.get(pe).push(q.clone())}for(const{time:Z,scale:q}of G.getValues($.scale,!1,!1,!0)){const pe=(Z+$.timeOffset)*60;W.has(pe)||W.set(pe,new Array),W.get(pe).push(q.clone())}}}return{position:I.size==0?void 0:I,quaternion:D.size==0?void 0:D,scale:W.size==0?void 0:W}},l=function(T){const R=[];for(const C of T)R.push(`(${Jn(C.x)}, ${Jn(C.y)}, ${Jn(C.z)})`);return R.join(", ")},u=function(T){const R=[];for(const C of T)R.push(`(${Jn(C.w)}, ${Jn(C.x)}, ${Jn(C.y)}, ${Jn(C.z)})`);return R.join(", ")},d=function(T){const R=new Map;if(Hf){const C=new Array;for(const[I,D]of s)C.push(I.uuid+": "+D.length+" "+D.map(W=>{var F;return(F=W.clip)==null?void 0:F.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
5190
5190
  `+C.join(`
5191
5191
  `))}for(const C of T){const I=s.get(C);I&&R.set(C,I)}return R},f=function(T){const R=d(T),C=a(R);return c(R,C,T)};const p=i.skinnedMesh.skeleton,m=new Array;for(const T in p.bones){const R=p.bones[T],C=p.boneInverses[T];m.push({bone:R,inverse:C})}for(const T of cG(p.bones))m.push({bone:T,inverse:T.matrixWorld.clone().invert()});const A=m[0].bone.parent;A||console.error("No bone parent found for skinned mesh during USDZ export",i.skinnedMesh),m.sort((T,R)=>zf(T.bone,A)>zf(R.bone,A)?1:-1);const v=[],g=[],b=[],y=[];for(const{bone:T}of m)v.push(T.matrix.clone()),g.push(T.position),b.push(T.quaternion),y.push(T.scale);const _=m.map(T=>'"'+zf(T.bone,A)+'"').join(", "),E=m.map(T=>_f(T.inverse.clone().invert())).join(", ");e.beginBlock('def Skeleton "Rig"'),e.appendLine(`uniform matrix4d[] bindTransforms = [${E}]`),e.appendLine(`uniform token[] joints = [${_}]`),e.appendLine('uniform token purpose = "guide"'),e.appendLine(`uniform matrix4d[] restTransforms = [${v.map(T=>_f(T)).join(", ")}]`),e.appendLine(`matrix4d xformOp:transform = ${_f(new Te)}`),e.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const M=f(m.map(T=>T.bone));if(e.beginBlock('def SkelAnimation "_anim"'),e.appendLine(`uniform token[] joints = [${_}]`),e.appendLine(`quatf[] rotations = [${u(b)}]`),M&&M.quaternion){e.beginBlock("quatf[] rotations.timeSamples = {","");const T=o(M.quaternion);for(const R of T)e.appendLine(R);e.closeBlock()}if(e.appendLine(`half3[] scales = [${l(y)}]`),M&&M.scale){e.beginBlock("half3[] scales.timeSamples = {","");const T=r(M.scale);for(const R of T)e.appendLine(R);e.closeBlock()}if(e.appendLine(`float3[] translations = [${l(g)}]`),M&&M.position){e.beginBlock("float3[] translations.timeSamples = {","");const T=r(M.position);for(const R of T)e.appendLine(R);e.closeBlock()}e.closeBlock(),e.closeBlock()}}onSerialize(e,t){var c;if(!this.model)return;this.skinnedMeshExport(e,t);const i=this.object,s=this.dict.get(i);if(!s||i.isSkinnedMesh)return;GM&&console.log("SERIALIZE",this.model.name,this.object.type,s);const r=new Te;e.appendLine("matrix4d xformOp:transform.timeSamples = {"),e.indent++;const o=new Array;let a=0;for(let l=0;l<s.length;l++)o.push(a),a+=s[l].getDuration()+Bo.animationDurationPadding;for(let l=0;l<s.length;l++){const u=s[l];if(!u)continue;const d=o[l];{const f=u.getSortedTimesArray();if(!f||f.length===0){console.error("got an animated object but no time values?",i,u);continue}if(Hf){const p=((c=u.clip)==null?void 0:c.name)??"rest",m=u.getDuration();console.log("Write .timeSamples:",p,d,m,s),e.appendLine("# "+p+": start="+(d*u.frameRate).toFixed(3)+", length="+(m*u.frameRate).toFixed(3)+", frames="+u.getFrames())}for(const{time:p,translation:m,rotation:A,scale:v}of u.getValues(f)){r.compose(m,A,v);const g=`${(d+p)*u.frameRate}: ${_f(r)},`;e.appendLine(g)}}}e.indent--,e.appendLine("}")}}var sne=Object.defineProperty,rne=Object.getOwnPropertyDescriptor,xG=(n,e,t,i)=>{for(var s=i>1?void 0:i?rne(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&&sne(e,t,s),s};class Rt{constructor(e){h(this,"_active",!0);h(this,"_value");h(this,"_valueRaw");h(this,"_defaultValue");h(this,"valueProcessor");h(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}}xG([x()],Rt.prototype,"overrideState",1);xG([x()],Rt.prototype,"value",1);var one=Object.defineProperty,ane=Object.getOwnPropertyDescriptor,cne=(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&&one(e,t,s),s};const lne=re("debugpost");class Ws extends Sh{constructor(t=void 0){super();h(this,"active",!0);h(this,"_result");h(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const s=t[i],r=this[i];r instanceof Rt&&(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(){lne&&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 Rt&&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]===Rt){const a=t[r];if(a!==void 0){const c=this[r];c.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof Rt){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]===Rt&&(this[i]||(this[i]=new Rt))}}cne([x()],Ws.prototype,"active",2);var hne=Object.defineProperty,une=Object.getOwnPropertyDescriptor,dne=(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&&hne(e,t,s),s};const fne=re("debugpost"),HM={};function Qo(n,e){HM[n]=e}function pne(n){return n.__type in HM?HM[n.__type]:(fne&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Ws)}class dv{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}dne([Ep([n=>pne(n),Ws])],dv.prototype,"components",2);var mne=Object.defineProperty,gne=Object.getOwnPropertyDescriptor,Ane=(n,e,t,i)=>{for(var s=i>1?void 0:i?gne(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&&mne(e,t,s),s};class fv extends Ws{constructor(){super(...arguments);h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new MY({preset:of.HIGH,edgeDetectionMode:zT.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}Ane([x(Rt)],fv.prototype,"preset",2);Qo("Antialiasing",fv);class Jx{constructor(){h(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,i){const s=ne.getComponents(e,Cn);if(s.length)for(const r of s){if(!r.clip||typeof r.clip!="string"||!r.playOnAwake)continue;const o=r.clip.split("/").pop();this.files.includes(r.clip)||this.files.push(r.clip),t.addEventListener("serialize",(a,c)=>{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}}}const Sf=re("debugnetworkingstreams");var ja=(n=>(n.Connected="peer-user-connected",n.StreamReceived="receive-stream",n.StreamEnded="call-ended",n.Disconnected="peer-user-disconnected",n.UserJoined="user-joined",n))(ja||{});class wG{constructor(e,t){h(this,"type","call-ended");h(this,"userId");h(this,"direction");this.userId=e,this.direction=t}}class SG{constructor(e,t){h(this,"type","receive-stream");h(this,"stream");h(this,"target");this.stream=e,this.target=t}}class vne{constructor(e,t){h(this,"guid");h(this,"peerId");h(this,"dontSave",!0);this.guid=e.id,this.peerId=t}}var CG=(n=>(n.Incoming="incoming",n.Outgoing="outgoing",n))(CG||{});class yne extends Qn{constructor(t,i,s){super();h(this,"userId");h(this,"direction");h(this,"call");h(this,"_stream",null);h(this,"_isDisposed",!1);this.userId=t,this.call=i,this.direction=s,this._stream=null,i.on("stream",r=>{if(Sf&&console.log("Receive video",r.getAudioTracks(),r.getVideoTracks()),this._stream=r,s==="incoming"){const o=new SG(r,this);this.dispatchEvent(o)}}),i.on("close",()=>{this.dispatchEvent(new wG(t,s))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),Yc(this._stream))}get isOpen(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connected"}get isOpening(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const Pf=class extends Qn{constructor(t,i){super();h(this,"id");h(this,"context");h(this,"_peer");h(this,"_incomingCalls",[]);h(this,"_outgoingCalls",[]);h(this,"_enabled",!1);h(this,"_enabledPeer",!1);h(this,"onConnectRoomFn",this.onConnectRoom.bind(this));h(this,"onPeerConnectFn",this.onPeerConnect.bind(this));h(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this));this.context=t,this.id=i,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,i){if(Pf.instances.has(i))return Pf.instances.get(i);const s=new Pf(t,i);return Pf.instances.set(i,s),s}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,i){var o;const s={metadata:{userId:this.context.connection.connectionId}},r=(o=this._peer)==null?void 0:o.call(t,i,s);if(r)return this.registerCall(r,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(Li.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(Li.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const t=this.getMyPeerId();t?this._peer=LU(t):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(t){Sf&&console.log("Peer connected as",t),this.context.connection.send("peer-user-connected",new vne(this,t))}onPeerReceivingCall(t){t.answer(),this.registerCall(t,"incoming")}registerCall(t,i){const s=t.metadata;(!s||!s.userId)&&console.error("Missing call metadata",t);const r=s.userId;i==="incoming"&&Sf?console.log("Receive call from",t.metadata):Sf&&console.log("Make call to",t.metadata);const o=i==="incoming"?this._incomingCalls:this._outgoingCalls,a=new yne(r,t,i);return o.push(a),t.on("error",c=>{console.error("Call error",c)}),t.on("close",()=>{Sf&&console.log("Call ended",t.metadata),t.close();const c=o.indexOf(a);c!==-1&&o.splice(c,1)}),a.addEventListener("call-ended",c=>{this.dispatchEvent(c)}),i==="incoming"&&(a.addEventListener("receive-stream",c=>{this.dispatchEvent(c)}),t.on("stream",()=>{let c=0;const l=setInterval(()=>{const u=c===0;!a.isOpen&&u&&(c+=1,clearInterval(l),a.close())},2e3)})),a}};let Vf=Pf;h(Vf,"instances",new Map);class pv extends Qn{constructor(t,i){super();h(this,"context");h(this,"peer");h(this,"_sendingStreams",new Map);h(this,"debug",!1);h(this,"onJoinedRoom",t=>{this.debug&&console.log(`${t.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});h(this,"onReceiveStream",t=>{this.debug&&console.log("RECEIVE STREAM",t),this.dispatchEvent({type:"receive-stream",target:this,stream:t.stream,userId:t.userId})});h(this,"onCallEnded",t=>{this.dispatchEvent(t)});h(this,"onUserConnected",t=>{if(this.peer.id===t.guid){this.debug&&console.log("USER CONNECTED",t.guid,t);const i=this._sendingStreams.keys().next().value;this.peer.makeCall(t.peerId,i)}});h(this,"onUserLeft",t=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=t,this.peer=i,Sf&&(this.debug=!0)}static create(t){const i=Vf.getOrCreate(t.context,t.context.connection.connectionId);return new pv(t.context,i)}startSendingStream(t){this._sendingStreams.has(t)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(t,[]),this.updateSendingCalls())}stopSendingStream(t){if(t){const i=this._sendingStreams.get(t);if(i){this.debug&&console.log("Closing calls",i);for(const s of i)s.close()}this._sendingStreams.delete(t),i&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(Li.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Li.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Li.UserLeftRoom,this.onUserLeft)}disable(){this.peer.disable(),this.peer.removeEventListener("receive-stream",this.onReceiveStream),this.peer.removeEventListener("call-ended",this.onCallEnded),this.context.connection.stopListen("peer-user-connected",this.onUserConnected),this.context.connection.stopListen(Li.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Li.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Li.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var s;let t=!1;const i=this.context.connection.connectionId;for(const r of this._sendingStreams.keys()){const o=this._sendingStreams.get(r)||[];for(const a of this.context.connection.usersInRoom()){if(a===i)continue;const c=o.find(l=>l.userId===a);if(!c||((s=c.stream)==null?void 0:s.active)===!1){this.debug&&console.log("Starting call to",a,i);const l=this.peer.makeCall(this.peer.getPeerIdFromUserId(a),r);l&&(t=!0,o.push(l))}}this._sendingStreams.set(r,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const t of this._sendingStreams.keys()){const i=this._sendingStreams.get(t);if(i)for(let s=i.length-1;s>=0;s--){const r=i[s];this.context.connection.userIsInRoom(r.userId)||(r.close(),i.splice(s,1))}}}}function Yc(n){if(n&&n instanceof MediaStream)for(const e of n.getTracks())e.stop()}var bne=Object.defineProperty,_ne=Object.getOwnPropertyDescriptor,EG=(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 MG="noVoip",xne=re("debugvoip");class Ih extends Ie{constructor(){super(...arguments);h(this,"autoConnect",!1);h(this,"runInBackground",!0);h(this,"debug",!1);h(this,"_net");h(this,"_outputStream",null);h(this,"onJoinedRoom",async()=>{await dh(300),this.autoConnect&&!this.isSending&&this.connect()});h(this,"_incomingStreams",new Map);h(this,"onReceiveStream",t=>{const i=t.target.userId,s=t.stream,r=this._incomingStreams.get(i);if(r)r.srcObject=s,r.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(i,o),o.setAttribute("autoplay","true"),o.srcObject=s}});h(this,"onStreamEnded",t=>{const i=this._incomingStreams.get(t.userId);Yc(i==null?void 0:i.srcObject),this._incomingStreams.delete(t.userId)});h(this,"onEnabledChanged",()=>{for(const t of this._incomingStreams){const i=t[1];i.muted=!this.enabled}});h(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const i=!(document.visibilityState==="visible");this.setMuted(i);for(const s of this._incomingStreams){const r=s[1];r.muted=i}})}awake(){xne&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async t=>{t.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=pv.create(this)),this._net.addEventListener(ja.StreamReceived,this.onReceiveStream),this._net.addEventListener(ja.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(Li.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var t;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(ja.StreamReceived,this.onReceiveStream),this._net.removeEventListener(ja.StreamEnded,this.onStreamEnded),(t=this._net)==null||t.disable(),this.context.connection.stopListen(Li.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(t){if(this.context.connection.isConnected){if(!await GE())return console.error("Cannot connect to voice chat - microphone permissions not granted"),!1}else return console.error("Cannot connect to voice chat - not connected to server"),!1;return this._net.stopSendingStream(this._outputStream),Yc(this._outputStream),this._outputStream=await this.getAudioStream(t),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await GE()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):kF("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),Yc(this._outputStream),this._outputStream=null}setMuted(t){var s;const i=(s=this._outputStream)==null?void 0:s.getAudioTracks();if(i)for(const r of i)r.enabled=!t}get isMuted(){var i;if(this._outputStream===null)return!1;const t=(i=this._outputStream)==null?void 0:i.getAudioTracks();if(t){for(const s of t)if(!s.enabled)return!0}return!1}getFrequency(t){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,Vt()&&rs("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(t){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:t??!0,video:!1}).catch(s=>(console.warn("VOIP failed getting audio stream",s),null)):(console.error("No getDisplayMedia support"),null)}}EG([x()],Ih.prototype,"autoConnect",2);EG([x()],Ih.prototype,"runInBackground",2);var wne=Object.defineProperty,Sne=Object.getOwnPropertyDescriptor,TG=(n,e,t,i)=>{for(var s=i>1?void 0:i?Sne(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};const Cne=re("debugmouth");class mv extends Ie{constructor(){super(...arguments);h(this,"idle",[]);h(this,"talking",[]);h(this,"marker",null);h(this,"voip",null);h(this,"lastMouthChangeTime",0);h(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=ne.findObjectOfType(Ih,this.context),this.marker||(this.marker=ne.getComponentInParent(this.gameObject,ts))},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){Cne&&(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)}}}}TG([x(_e)],mv.prototype,"idle",2);TG([x(_e)],mv.prototype,"talking",2);class QI extends Ie{constructor(){super(...arguments);h(this,"voip",null);h(this,"marker",null);h(this,"_startPosition",null)}awake(){this.voip=ne.findObjectOfType(Ih,this.context),this.marker=ne.getComponentInParent(this.gameObject,ts)}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());const s=i/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var Ene=Object.defineProperty,Mne=Object.getOwnPropertyDescriptor,Kx=(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&&Ene(e,t,s),s};class Ku extends Ie{constructor(){super(...arguments);h(this,"eyes",[]);h(this,"lastBlinkTime",0);h(this,"blinkLength",0);h(this,"eyesOpen",!0);h(this,"state",null)}awake(){this.state=ne.getComponentInParent(this.gameObject,Xr)}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)}}}Kx([x(_e)],Ku.prototype,"eyes",2);Kx([x()],Ku.prototype,"lastBlinkTime",2);Kx([x()],Ku.prototype,"blinkLength",2);Kx([x()],Ku.prototype,"eyesOpen",2);var Tne=Object.defineProperty,Ine=Object.getOwnPropertyDescriptor,WI=(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},$C;const IG=($C=class extends Ie{constructor(){super(...arguments);h(this,"head",null);h(this,"eyes",null);h(this,"target",null);h(this,"brain",null);h(this,"vec",new w);h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=ne.getComponentInParent(this.gameObject,hA)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=ne.addNewComponent(this.gameObject,hA)),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=pt(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const s=pt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const o=IG.forward;if(o.set(0,0,1),o.applyQuaternion(Ei(this.head)),o.dot(r)>.45)for(let c=0;c<t.length;c++)t[c].lookAt(this.currentTargetPoint)}}}},h($C,"forward",new w(0,0,1)),$C);let kp=IG;WI([x(_e)],kp.prototype,"head",2);WI([x(_e)],kp.prototype,"eyes",2);WI([x(_e)],kp.prototype,"target",2);var Rne=Object.defineProperty,Pne=Object.getOwnPropertyDescriptor,jI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Pne(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};class Lp extends Ie{constructor(){super(...arguments);h(this,"length",1);h(this,"depthTest",!0);h(this,"isGizmo",!0);h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!YA)return;this._axes||(this._axes=new vp(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),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)}}jI([x()],Lp.prototype,"length",2);jI([x()],Lp.prototype,"depthTest",2);jI([x()],Lp.prototype,"isGizmo",2);class qI extends Ie{constructor(){super(...arguments);h(this,"from");h(this,"to");h(this,"hint");h(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const t=pt(this.to).clone(),i=pt(this.from).clone(),s=t.distanceTo(i),r=t.clone();r.sub(i);const o=i.clone();o.add(t),o.multiplyScalar(.5);const a=pt(this.hint).clone();a.sub(o);const c=new w;c.crossVectors(a,r),c.crossVectors(r,c),c.normalize();const l=s*.5,u=Math.max(this.desiredDistance,l),d=Math.sqrt(u*u-l*l),f=c.clone();f.multiplyScalar(d),f.add(o),bn(this.gameObject,f);const p=o.clone();p.sub(c),this.gameObject.lookAt(p)}}const Bne=re("debugusdz");class Zx{constructor(){h(this,"behaviours",[]);h(this,"behaviourComponents",[]);h(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(i=>{ne.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){Bne&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e));this.behaviours.length=0}}var Dne=Object.defineProperty,One=Object.getOwnPropertyDescriptor,XI=(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&&Dne(e,t,s),s};class Zu extends Ws{constructor(){super(...arguments);h(this,"threshold");h(this,"intensity");h(this,"scatter");h(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 zN(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});i.inverted=!0}else t=new QT;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}}XI([x(Rt)],Zu.prototype,"threshold",2);XI([x(Rt)],Zu.prototype,"intensity",2);XI([x(Rt)],Zu.prototype,"scatter",2);Qo("Bloom",Zu);var kne=Object.defineProperty,Lne=Object.getOwnPropertyDescriptor,Wo=(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&&kne(e,t,s),s};class rc extends Ie{constructor(){super(...arguments);h(this,"attachedRigidbody",null);h(this,"isTrigger",!1);h(this,"sharedMaterial");h(this,"updateProperties",()=>{var t;(t=this.context.physics.engine)==null||t.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}onDisable(){var t;(t=this.context.physics.engine)==null||t.removeBody(this)}get body(){var t;return(t=this.context.physics.engine)==null?void 0:t.getBody(this)}updatePhysicsMaterial(){var t;(t=this.context.physics.engine)==null||t.updatePhysicsMaterial(this)}}Wo([x(Pi)],rc.prototype,"attachedRigidbody",2);Wo([x()],rc.prototype,"isTrigger",2);Wo([x()],rc.prototype,"sharedMaterial",2);class gv extends rc{constructor(){super(...arguments);h(this,"radius",.5);h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this),AT(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),wF(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Wo([Cs(),x()],gv.prototype,"radius",2);Wo([x(w)],gv.prototype,"center",2);class Av extends rc{constructor(){super(...arguments);h(this,"size",new w(1,1,1));h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.size)}onValidate(){this.updateProperties()}}Wo([Cs(),x(w)],Av.prototype,"size",2);Wo([x(w)],Av.prototype,"center",2);class Fp extends rc{constructor(){super(...arguments);h(this,"sharedMesh");h(this,"convex",!1)}onEnable(){var t,i,s,r,o;if(super.onEnable(),(t=this.sharedMesh)!=null&&t.isMesh||this.gameObject instanceof ge&&(this.sharedMesh=this.gameObject),(i=this.sharedMesh)!=null&&i.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,es(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)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const c in a.children){const l=a.children[c];l.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,l,this.convex,es(this.gameObject)))}}}}}Wo([x()],Fp.prototype,"sharedMesh",2);Wo([x()],Fp.prototype,"convex",2);class gh extends rc{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.height,this.radius)}}Wo([x(w)],gh.prototype,"center",2);Wo([x()],gh.prototype,"radius",2);Wo([x()],gh.prototype,"height",2);var Fne=Object.defineProperty,Une=Object.getOwnPropertyDescriptor,YI=(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 $u extends Ie{constructor(){super(...arguments);h(this,"objectBounds",!1);h(this,"color");h(this,"isGizmo",!0);h(this,"_gizmoObject",null);h(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!YA||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new tx(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=iG(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),is.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var t;for(;this._boxHelper;)(t=this._boxHelper)==null||t.update(),yield}}YI([x()],$u.prototype,"objectBounds",2);YI([x(be)],$u.prototype,"color",2);YI([x()],$u.prototype,"isGizmo",2);var Nne=Object.defineProperty,zne=Object.getOwnPropertyDescriptor,vv=(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};const yC=re("debugui"),bC=re("debuguilayout");class JI{constructor(){h(this,"width");h(this,"height")}}class KI{constructor(){h(this,"x");h(this,"y");h(this,"width");h(this,"height")}}const $o=new w,Im=new Te,o0=new Se,RG=class extends pa{constructor(){super(...arguments);h(this,"_anchoredPosition");h(this,"sizeDelta",new te(100,100));h(this,"pivot",new te(.5,.5));h(this,"anchorMin",new te(0,0));h(this,"anchorMax",new te(1,1));h(this,"minWidth");h(this,"minHeight");h(this,"lastMatrix");h(this,"rectBlock");h(this,"_transformNeedsUpdate",!1);h(this,"_initialPosition");h(this,"_parentRectTransform");h(this,"_lastUpdateFrame",-1);h(this,"_lastAnchoring");h(this,"_createdBlocks",[]);h(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 te),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){let e=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const t=this._parentRectTransform.width,i=this.anchorMax.x-this.anchorMin.x;e=t*i,e+=this.sizeDelta.x}return this.minWidth!==void 0&&e<this.minWidth?this.minWidth:e}get height(){let e=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const t=this._parentRectTransform.height,i=this.anchorMax.y-this.anchorMin.y;e=t*i,e+=this.sizeDelta.y}return this.minHeight!==void 0&&e<this.minHeight?this.minHeight:e}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new te),this.lastMatrix=new Te,this.rectBlock=new _e,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,hf(this,"_anchoredPosition",()=>{this.markDirty()}),hf(this,"sizeDelta",()=>{this.markDirty()}),hf(this,"pivot",()=>{this.markDirty()}),hf(this,"anchorMin",()=>{this.markDirty()}),hf(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(bC?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(bC&&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=ne.getComponentInParent(this.gameObject.parent,RG):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,bC&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,$o.set(0,0,0),this.applyPivot($o),t.matrix.setPosition($o.x,$o.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(o0.copy(this.gameObject.quaternion),o0.x*=-1,o0.z*=-1,Im.makeRotationFromQuaternion(o0),t.matrix.premultiply(Im)),$o.set(0,0,0),this.applyAnchoring($o),(s=this.Canvas)!=null&&s.screenspace?$o.z+=.1:$o.z+=.01,Im.identity(),Im.setPosition($o.x,$o.y,$o.z),t.matrix.premultiply(Im),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of UT(this.gameObject,pa,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new te);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},yC&&console.log(this.name,e);const t=new OI(e);return this._createdBlocks.push(t),t}createNewText(e){yC&&console.log(e),e={...this.getBasicOptions(),...e},yC&&console.log(this.name,e);const t=new kI(e);return this._createdTextBlocks.push(t),t}};let ur=RG;vv([x(te)],ur.prototype,"anchoredPosition",1);vv([x(te)],ur.prototype,"sizeDelta",2);vv([x(te)],ur.prototype,"pivot",2);vv([x(te)],ur.prototype,"anchorMin",2);vv([x(te)],ur.prototype,"anchorMax",2);class Gne extends eG{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 Hne=Object.defineProperty,Vne=Object.getOwnPropertyDescriptor,PG=(n,e,t,i)=>{for(var s=i>1?void 0:i?Vne(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};class Up extends Ie{constructor(){super(...arguments);h(this,"effectColor");h(this,"effectDistance")}}PG([x(bi)],Up.prototype,"effectColor",2);PG([x(te)],Up.prototype,"effectDistance",2);var Qne=Object.defineProperty,Wne=Object.getOwnPropertyDescriptor,BG=(n,e,t,i)=>{for(var s=i>1?void 0:i?Wne(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&&Qne(e,t,s),s};const a0={backgroundColor:new be(1,1,1),backgroundOpacity:1,borderColor:new be(1,1,1),borderOpacity:1};var eE;const ab=(eE=class extends pa{constructor(){super(...arguments);h(this,"_alphaFactor",1);h(this,"sRGBColor",new be(1,0,1));h(this,"raycastTarget",!0);h(this,"uiObject",null);h(this,"_color",null);h(this,"_rect",null);h(this,"_stateManager",null);h(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new bi(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 bi(1,1,1,1)),this._color.copy(e),this.onColorChanged())}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),a0.backgroundColor=this.sRGBColor,a0.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(a0,this._alphaFactor),this.uiObject.set(a0),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=ne.getComponent(this.gameObject,ur)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return 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 Gne(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),hf(this,"_color",()=>Uie(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;const e=.015,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(),this.onColorChanged()}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(Up);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(ab.textureCache.has(e))e=ab.textureCache.get(e);else if(!e.isRenderTargetTexture){const t=e.clone();t.colorSpace=xn,ab.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)}},h(eE,"textureCache",new Map),eE);let ed=ab;BG([x(bi)],ed.prototype,"color",1);BG([x()],ed.prototype,"raycastTarget",2);class yv extends ed{constructor(){super(...arguments);h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var jne=Object.defineProperty,qne=Object.getOwnPropertyDescriptor,$x=(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&&jne(e,t,s),s};let ZI=class{constructor(){h(this,"texture",null);h(this,"rect")}};$x([x(Ft)],ZI.prototype,"texture",2);let Np=class extends yv{constructor(){super(...arguments);h(this,"_sprite");h(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new ZI),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,c,l;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&&((l=(c=(a=this.sprite)==null?void 0:a.texture)==null?void 0:c.image)==null?void 0:l.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))}};$x([x(ZI)],Np.prototype,"sprite",1);$x([x()],Np.prototype,"pixelsPerUnitMultiplier",2);class ew extends yv{constructor(){super(...arguments);h(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))}}$x([x(Ft)],ew.prototype,"mainTexture",1);var Xne=Object.defineProperty,Yne=Object.getOwnPropertyDescriptor,oo=(n,e,t,i)=>{for(var s=i>1?void 0:i?Yne(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 Yd=re("debugbutton");class td{constructor(){h(this,"colorMultiplier");h(this,"disabledColor");h(this,"fadeDuration");h(this,"highlightedColor");h(this,"normalColor");h(this,"pressedColor");h(this,"selectedColor")}}oo([x()],td.prototype,"colorMultiplier",2);oo([x(bi)],td.prototype,"disabledColor",2);oo([x()],td.prototype,"fadeDuration",2);oo([x(bi)],td.prototype,"highlightedColor",2);oo([x(bi)],td.prototype,"normalColor",2);oo([x(bi)],td.prototype,"pressedColor",2);oo([x(bi)],td.prototype,"selectedColor",2);class yl extends Ie{constructor(){super(...arguments);h(this,"onClick");h(this,"_isHovered",!1);h(this,"colors");h(this,"transition");h(this,"animationTriggers");h(this,"animator");h(this,"_interactable",!0);h(this,"_requestedAnimatorTrigger");h(this,"_isInit",!1);h(this,"_image")}onPointerEnter(t){var i,s;Yd&&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;Yd&&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;Yd&&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;Yd&&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){!this.interactable||t.pointerId!==0||t.pointerId!==0&&this.context.input.getIsMouse(t.pointerId)||(Yd&&(console.warn("Button Click",this.onClick),An("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),t.use()))}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(),Yd&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable),this.gameObject.getComponentInParent(Th)||this.gameObject.addComponent(Vx)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*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=ne.getComponent(this.gameObject,Np),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),c={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(c);const l=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.selectedColor),u={state:"selected",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};t.setupState(u);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).convertLinearToSRGB():t.clone().convertLinearToSRGB()}}oo([x(gs)],yl.prototype,"onClick",2);oo([x()],yl.prototype,"colors",2);oo([x()],yl.prototype,"transition",2);oo([x()],yl.prototype,"animationTriggers",2);oo([x(ys)],yl.prototype,"animator",2);oo([x()],yl.prototype,"interactable",1);var Jne=Object.defineProperty,Kne=Object.getOwnPropertyDescriptor,Ln=(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&&Jne(e,t,s),s};const uk=re("debuguilayout");class Rh{constructor(){h(this,"left",0);h(this,"right",0);h(this,"top",0);h(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Ln([x()],Rh.prototype,"left",2);Ln([x()],Rh.prototype,"right",2);Ln([x()],Rh.prototype,"top",2);Ln([x()],Rh.prototype,"bottom",2);class ao extends Ie{constructor(){super(...arguments);h(this,"_rectTransform",null);h(this,"_needsUpdate",!1);h(this,"childAlignment",0);h(this,"reverseArrangement",!1);h(this,"spacing",0);h(this,"padding");h(this,"minWidth",0);h(this,"minHeight",0);h(this,"flexibleHeight",0);h(this,"flexibleWidth",0);h(this,"preferredHeight",0);h(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&&(uk&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){uk&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(ur);const t=this.gameObject.getComponentInParent(bs);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(bs);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}Ln([x()],ao.prototype,"childAlignment",2);Ln([x()],ao.prototype,"reverseArrangement",2);Ln([x()],ao.prototype,"spacing",2);Ln([x(Rh)],ao.prototype,"padding",2);Ln([x()],ao.prototype,"minWidth",2);Ln([x()],ao.prototype,"minHeight",2);Ln([x()],ao.prototype,"flexibleHeight",2);Ln([x()],ao.prototype,"flexibleWidth",2);Ln([x()],ao.prototype,"preferredHeight",2);Ln([x()],ao.prototype,"preferredWidth",2);class Ph extends ao{constructor(){super(...arguments);h(this,"childControlHeight",!0);h(this,"childControlWidth",!0);h(this,"childForceExpandHeight",!1);h(this,"childForceExpandWidth",!1);h(this,"childScaleHeight",!1);h(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 c=i==="x",l=c?"y":"x",u=c?this.childControlWidth:this.childControlHeight,d=c?this.childControlHeight:this.childControlWidth,f=c?this.childForceExpandWidth:this.childForceExpandHeight,p=c?this.childForceExpandHeight:this.childForceExpandWidth,m=c?a:r,A=c?s:o,v=.5*(c?this.childAlignment%3:Math.floor(this.childAlignment/3));let g=0;c?g+=this.padding.left:g+=this.padding.top;let b=0,y=0;for(let C=0;C<this.gameObject.children.length;C++){const I=this.gameObject.children[C],D=ne.getComponent(I,ur);D!=null&&D.activeAndEnabled&&(y+=1,c?b+=D.width:b+=D.height)}let _=0;const E=this.spacing*(y-1);if(f||u){let C=0;c?C=r-=E:C=a-=E,y>0&&(_=C/y)}let M=0;M+=this.padding.left,M-=this.padding.right,v!==0&&(g=A-b,g*=v,g-=E*v,c?(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 T=1;for(let C=0;C<this.gameObject.children.length;C++){const I=this.gameObject.children[C],D=ne.getComponent(I,ur);if(D!=null&&D.activeAndEnabled){(R=D.pivot)==null||R.set(.5,.5),D.anchorMin.set(0,1),D.anchorMax.set(0,1);const W=s*.5+M*.5;D.anchoredPosition.x!==W&&(D.anchoredPosition.x=W);const F=o*-.5;D.anchoredPosition.y!==F&&(D.anchoredPosition.y=F),p&&d&&D.sizeDelta[l]!==m&&(D.sizeDelta[l]=m),f&&u&&D.sizeDelta[i]!==_&&(D.sizeDelta[i]=_);const H=c?D.width:D.height,j=H*.5;if(g+=j,f){const L=_*T-_*.5;L>g&&(g=L-_*.5+H+this.padding.left,g-=j)}let z=g;i==="y"&&(z=-z),D.anchoredPosition[i]!==z&&(D.anchoredPosition[i]=z),g+=j,g+=this.spacing,T+=1}}}}Ln([x()],Ph.prototype,"childControlHeight",2);Ln([x()],Ph.prototype,"childControlWidth",2);Ln([x()],Ph.prototype,"childForceExpandHeight",2);Ln([x()],Ph.prototype,"childForceExpandWidth",2);Ln([x()],Ph.prototype,"childScaleHeight",2);Ln([x()],Ph.prototype,"childScaleWidth",2);class $I extends Ph{get primaryAxis(){return"y"}}class eR extends Ph{get primaryAxis(){return"x"}}class tR extends ao{onCalculateLayout(){}}var Zne=Object.defineProperty,$ne=Object.getOwnPropertyDescriptor,oc=(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&&Zne(e,t,s),s},DG=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(DG||{});const _C=re("debuguilayout"),OG=class extends cv{constructor(){super(...arguments);h(this,"_renderOnTop");h(this,"_depthWrite",!1);h(this,"_doubleSided",!0);h(this,"_castShadows",!1);h(this,"_receiveShadows",!1);h(this,"_renderMode",-1);h(this,"_rootCanvas");h(this,"_scaleFactor",1);h(this,"worldCamera");h(this,"planeDistance",-1);h(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));h(this,"previousParent",null);h(this,"_lastMatrixWorld",null);h(this,"_rectTransforms",[]);h(this,"_layoutGroups",new Map);h(this,"_receivers",[]);h(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),this.invokeBeforeRenderEvents(),nr.ensureUpdateMeshUI(pC,this.context,!0);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),this.invokeBeforeRenderEvents(),nr.ensureUpdateMeshUI(pC,this.context))});h(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),this.invokeBeforeRenderEvents(),nr.ensureUpdateMeshUI(pC,this.context,!0),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)}});h(this,"_updateRenderSettingsRoutine");h(this,"_activeRenderMode",-1);h(this,"_lastWidth",-1);h(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 OG||(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,_C&&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 Te,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)}registerEventReceiver(e){this._receivers.push(e)}unregisterEventReceiver(e){const t=this._receivers.indexOf(e);t!==-1&&this._receivers.splice(t,1)}invokeBeforeRenderEvents(){var e;for(const t of this._receivers)(e=t.onBeforeCanvasRender)==null||e.call(t,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Te);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);_C&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const 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(ao)),(i.isDirty||s!=null&&s.isDirty)&&(_C&&!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(),is.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),n_(this.shadowComponent,this);for(const e of ne.getComponentsInChildren(this.gameObject,pa))n_(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=Ye.lerp(t.nearClipPlane,t.farClipPlane,.01)),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(ur);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,c=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=c/this.context.domHeight,this.gameObject.scale.y=c/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 bs=OG;oc([x()],bs.prototype,"renderOnTop",1);oc([x()],bs.prototype,"depthWrite",1);oc([x()],bs.prototype,"doubleSided",1);oc([x()],bs.prototype,"castShadows",1);oc([x()],bs.prototype,"receiveShadows",1);oc([x()],bs.prototype,"renderMode",1);oc([x(bs)],bs.prototype,"rootCanvas",1);oc([x()],bs.prototype,"scaleFactor",1);oc([x(Ui)],bs.prototype,"worldCamera",2);oc([x()],bs.prototype,"planeDistance",2);var ese=Object.defineProperty,tse=Object.getOwnPropertyDescriptor,iR=(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&&ese(e,t,s),s};class Ah extends Ie{constructor(){super(...arguments);h(this,"_alpha",1);h(this,"interactable",!0);h(this,"blocksRaycasts",!0);h(this,"_isDirty",!1);h(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(),is.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const t of ne.getComponentsInChildren(this.gameObject,pa,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}iR([x()],Ah.prototype,"alpha",1);iR([x()],Ah.prototype,"interactable",2);iR([x()],Ah.prototype,"blocksRaycasts",2);var ise=Object.defineProperty,nse=Object.getOwnPropertyDescriptor,cn=(n,e,t,i)=>{for(var s=i>1?void 0:i?nse(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};function bv(n){n&&(n.getComponentInParent(Th)||(Vt()&&console.warn("Create Raycaster on "+n.name+" because no raycaster was found in the hierarchy"),n.addNewComponent(ma)))}class id extends Ie{constructor(){super(...arguments);h(this,"object");h(this,"target");h(this,"duration",1);h(this,"relativeMotion",!1);h(this,"coroutine",null);h(this,"targetPos",new w);h(this,"targetRot",new Se);h(this,"targetScale",new w)}start(){bv(this.gameObject)}onPointerClick(t){t.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const t=pt(this.object).clone(),i=pt(this.target).clone(),s=Ei(this.object).clone(),r=Ei(this.target).clone(),o=es(this.object).clone(),a=es(this.target).clone(),c=t.distanceTo(i),l=s.angleTo(r),u=o.distanceTo(a);if(c<.01&&l<.01&&u<.01){bn(this.object,i),lr(this.object,r),Rb(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),bn(this.object,this.targetPos),lr(this.object,this.targetRot),Rb(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 c=0,l=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),l=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,l),this.object.quaternion.slerpQuaternions(i,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new As("Move to "+((i=this.target)==null?void 0:i.name),or.tapTrigger(this.gameObject),yi.transformAction(this.object,this.target,this.duration,this.relativeMotion?LM.Relative:LM.Absolute));t.addBehavior(s)}}}cn([x(_e)],id.prototype,"object",2);cn([x(_e)],id.prototype,"target",2);cn([x()],id.prototype,"duration",2);cn([x()],id.prototype,"relativeMotion",2);var E0;const Rc=(E0=class extends Ie{constructor(){super(...arguments);h(this,"materialToSwitch");h(this,"variantMaterial");h(this,"fadeDuration",0);h(this,"_objectsWithThisMaterial",[]);h(this,"selfModel");h(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const e=ne.findObjectsOfType(Sn);for(const t of e)for(let i=0;i<t.sharedMaterials.length;i++){const s=t.sharedMaterials[i];if(s===this.materialToSwitch){if(t.gameObject instanceof ge)this._objectsWithThisMaterial.push(t.gameObject);else if(t.gameObject instanceof er)for(const r of t.gameObject.children)r instanceof ge&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}start(){bv(this.gameObject)}onPointerClick(e){if(e.use(),!!this.variantMaterial)for(let t=0;t<this._objectsWithThisMaterial.length;t++){const i=this._objectsWithThisMaterial[t];i.material=this.variantMaterial}}async beforeCreateDocument(e,t){this.targetModels=[],Rc._materialTriggersPerId={},Rc.variantSwitchIndex=0,this.materialToSwitch&&await Qr.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Qr.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(Rc._materialTriggersPerId[this.materialToSwitch.uuid]||(Rc._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Rc._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=Rc._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const r of i){const o=r.createVariants();o&&o.length>0&&(s[r.selfModel.uuid]=o)}for(const r of i){const o=[];for(const a in s)a!==r.selfModel.uuid&&o.push(...s[a]);r.createAndAttachBehaviors(e,s[r.selfModel.uuid],o)}}delete Rc._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);r.push(yi.fadeAction([...this.targetModels,...i],o,!1)),s.push(yi.fadeAction(t,o,!1)),r.push(yi.fadeAction(t,o,!0)),e.addBehavior(new As("Select_"+this.selfModel.name,or.tapTrigger(this.selfModel),yi.parallel(...r))),e.addBehavior(new As("StartHidden_"+this.selfModel.name,or.sceneStartTrigger(),yi.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+"_"+Rc.variantSwitchIndex++,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&Cr.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},h(E0,"_materialTriggersPerId",{}),h(E0,"variantSwitchIndex",0),E0);let zp=Rc;cn([x(Ut)],zp.prototype,"materialToSwitch",2);cn([x(Ut)],zp.prototype,"variantMaterial",2);cn([x()],zp.prototype,"fadeDuration",2);class Gp extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"toggleOnClick",!1);h(this,"targetState",!0);h(this,"hideSelf",!0);h(this,"selfModel");h(this,"otherModel");h(this,"toggleModel");h(this,"stateBeforeCreatingDocument",!1)}start(){bv(this.gameObject)}onPointerClick(t){t.use(),!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())&&lG.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(yi.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(yi.fadeAction(this.toggleModel,0,!0)),r.push(yi.fadeAction(this.otherModel,0,this.targetState)),t.addBehavior(new As("Toggle_"+this.selfModel.name+"_hideSelf",or.tapTrigger(this.selfModel),yi.sequence(...r))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(yi.fadeAction(this.toggleModel,0,!1)),o.push(yi.fadeAction(this.selfModel,0,!0)),o.push(yi.fadeAction(this.otherModel,0,!this.targetState)),t.addBehavior(new As("Toggle_"+this.selfModel.name+"_toggleSelf",or.tapTrigger(this.toggleModel),yi.sequence(...o))),t.addBehavior(new As("HideOnStart_"+this.gameObject.name,or.sceneStartTrigger(),yi.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}cn([x(_e)],Gp.prototype,"target",2);cn([x()],Gp.prototype,"targetState",2);cn([x()],Gp.prototype,"hideSelf",2);class nR extends Ie{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new As("HideOnStart_"+this.gameObject.name,or.sceneStartTrigger(),yi.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Hp extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"duration",.5);h(this,"motionType",NI.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new As("emphasize "+this.name,or.tapTrigger(this.gameObject),yi.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}cn([x()],Hp.prototype,"target",2);cn([x()],Hp.prototype,"duration",2);cn([x()],Hp.prototype,"motionType",2);class Vp extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"clip","");h(this,"toggleOnClick",!1)}start(){bv(this.gameObject)}onPointerClick(t){if(t.use(),!!this.clip){if(!this.target){const i=this.gameObject.addNewComponent(Cn);i&&(this.target=i,i.spatialBlend=1,i.volume=1,i.loop=!1)}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||typeof r!="string")return;const o=this.target?this.target.gameObject:this.gameObject,a=r.split("/").pop(),c=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?FM.NonSpatial:FM.Spatial,u=new As("playAudio "+this.name,or.tapTrigger(this.gameObject),yi.playAudioAction(o,"audio/"+a,pG.Play,c,l));t.addBehavior(u)}}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||typeof s!="string")return;const r=s.split("/").pop(),c=await(await(await fetch(this.clip)).blob()).arrayBuffer(),l=new Uint8Array(c);i.files["audio/"+r]=l}}cn([x(Cn)],Vp.prototype,"target",2);cn([x(URL)],Vp.prototype,"clip",2);cn([x()],Vp.prototype,"toggleOnClick",2);var M0;const Ql=(M0=class extends Ie{constructor(){super(...arguments);h(this,"animator");h(this,"stateName");h(this,"trigger","tap");h(this,"selfModel");h(this,"stateAnimationModel");h(this,"animationSequence",new Array);h(this,"animationLoopAfterSequence",new Array)}get target(){var e;return(e=this.animator)==null?void 0:e.gameObject}start(){bv(this.gameObject)}onPointerClick(e){var t;e.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}afterSerialize(){if(Ql.rootsWithExclusivePlayback.size>1){const e='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';Vt()&&rs(e),console.warn(e,...Ql.rootsWithExclusivePlayback)}Ql.animationActions=[],Ql.rootsWithExclusivePlayback=new Set}afterCreateDocument(e,t){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const i=t.document,s=t.extensions.find(a=>a instanceof uv);if(!s)return;const r=s.getClipCount(this.target)>1;r&&(Vt()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+s.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Ql.rootsWithExclusivePlayback.add(this.target));const o=(a,c)=>{let l=Ql.animationActions.find(u=>u.affectedObjects==a&&u.start==c.start&&u.duration==c.duration);return l||(l=yi.startAnimationAction(a,c.start,c.duration),Ql.animationActions.push(l)),l};i.traverse(a=>{var c,l;if(a.uuid===((c=this.target)==null?void 0:c.uuid)){const u=yi.sequence();if(this.animationSequence!==void 0)for(const f of this.animationSequence)u.addAction(o(a,f));if(this.animationLoopAfterSequence!==void 0){const f=u.actions.length==0?u:yi.sequence();for(const p of this.animationLoopAfterSequence)f.addAction(o(a,p));f.makeLooping(),u!==f&&u.addAction(f)}const d=new As("tap "+this.name+" for "+this.stateName+" on "+((l=this.target)==null?void 0:l.name),this.trigger=="tap"?or.tapTrigger(this.selfModel):or.sceneStartTrigger(),u);r&&d.makeExclusive(!0),e.addBehavior(d)}})}createAnimation(e,t,i){var c,l,u,d;if(!this.target||!this.animator)return;const s=(c=this.animator)==null?void 0:c.runtimeAnimatorController;let r=s==null?void 0:s.findState(this.stateName),o=[],a=[];if(s&&r){const f=new Array;f.push(r);let p=!1;for(;f.length<100;){if(!r||r===null||!r.transitions||r.transitions.length===0){(l=r.motion)!=null&&l.isLooping&&(p=!0);break}const m=r.transitions.find(v=>v.conditions.length===0),A=m?s.getState(m.destinationState,0):null;if(A&&f.includes(A)){r=A,p=!0;break}else if(m){if(r=A,!r)break;f.push(r)}else{p=((u=r.motion)==null?void 0:u.isLooping)??!1;break}}if(p&&r){const m=f.indexOf(r);o=f.slice(0,m),a=f.slice(m),console.log("found loop from "+this.stateName,"states until loop",o,"states looping",a)}else o=f,a=[],console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(f=>{var p,m,A;return((p=f.motion)==null?void 0:p.clip)&&((A=(m=f.motion)==null?void 0:m.clip.tracks)==null?void 0:A.length)>0}),a=a.filter(f=>{var p,m,A;return((p=f.motion)==null?void 0:p.clip)&&((A=(m=f.motion)==null?void 0:m.clip.tracks)==null?void 0:A.length)>0}),o.length===0&&a.length===0){console.warn("No clips found for state "+this.stateName+" on "+((d=this.animator)==null?void 0:d.name)+", can't export animation data");return}if(this.stateAnimationModel=t,o.length>0){this.animationSequence=new Array;for(const f of o)this.animationSequence.push(e.registerAnimation(this.target,f.motion.clip))}if(a.length>0){this.animationLoopAfterSequence=new Array;for(const f of a)this.animationLoopAfterSequence.push(e.registerAnimation(this.target,f.motion.clip))}}},h(M0,"animationActions",[]),h(M0,"rootsWithExclusivePlayback",new Set),M0);let Qp=Ql;cn([x(ys)],Qp.prototype,"animator",2);cn([x()],Qp.prototype,"stateName",2);class Wp extends Ie{constructor(){super(...arguments);h(this,"target")}getType(){}getDuration(){}}cn([x(_e)],Wp.prototype,"target",2);class _v extends Ie{constructor(){super(...arguments);h(this,"target")}}cn([x(Wp)],_v.prototype,"target",2);class xv extends Wp{constructor(){super(...arguments);h(this,"type",1);h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}cn([x()],xv.prototype,"type",2);cn([x()],xv.prototype,"duration",2);class sR extends _v{}var sse=Object.defineProperty,rse=Object.getOwnPropertyDescriptor,bl=(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&&sse(e,t,s),s};const dk=re("debugcharactercontroller");class nd extends Ie{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2);h(this,"_rigidbody",null);h(this,"_activeGroundCollisions");h(this,"_contactVelocity",new w)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Pi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Pi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(gh);i||(i=this.gameObject.addNewComponent(gh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const s=new w(0,0,1),r=new w(1,0,0),o=new w(0,1,0),a=this.gameObject.getWorldDirection(new w);a.y=0;const c=r.dot(a)<0?-1:1,l=s.angleTo(a)*c;this.gameObject.setRotationFromAxisAngle(o,l),t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){(t.contacts.length==0||t.contacts.some(i=>i.normal.y>.2))&&(this._activeGroundCollisions.add(t),dk&&console.log(`Collision(${this._activeGroundCollisions.size}): ${t.contacts.map(i=>i.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(t){this._activeGroundCollisions.delete(t),dk&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var t;this._contactVelocity.set(0,0,0);for(const i of this._activeGroundCollisions){const s=(t=this.context.physics.engine)==null?void 0:t.getLinearVelocity(i.collider);s&&(this._contactVelocity.x+=s.x,this._contactVelocity.y+=s.y,this._contactVelocity.z+=s.z)}return this._contactVelocity}}bl([x(w)],nd.prototype,"center",2);bl([x()],nd.prototype,"radius",2);bl([x()],nd.prototype,"height",2);class _l extends Ie{constructor(){super(...arguments);h(this,"controller");h(this,"movementSpeed",2);h(this,"rotationSpeed",2);h(this,"jumpForce",1);h(this,"doubleJumpForce",2);h(this,"animator");h(this,"lookForward",!0);h(this,"lookInput",new te(0,0));h(this,"moveInput",new te(0,0));h(this,"jumpInput",!1);h(this,"_currentSpeed",new w(0,0,0));h(this,"_currentAngularSpeed",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_jumpCount",0);h(this,"_currentRotation");h(this,"_raycastOptions",new eo)}awake(){this._currentRotation=new Se}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(t,i,s){var r,o,a,c,l,u,d,f,p,m,A;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(l=this.animator)==null||l.setBool("jumping",((c=this.controller)==null?void 0:c.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=Ye.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const v=this.context.mainCameraComponent.forward;v.y=0,v.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),v),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&&s&&this.jumpForce>0){let v=(u=this.controller)==null?void 0:u.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(v=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),v){this._jumpCount+=1;const g=this.controller.rigidbody,b=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;g.applyImpulse(new w(0,1,0).multiplyScalar(b))}}if(this.controller){const v=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(v<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Aa),this._raycastOptions.ray.origin.copy(pt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const g=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const b=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(g),(b.length&&b[0].distance>2||v<-10)&&((m=this.animator)==null||m.setBool("falling",!0))}else(A=this.animator)==null||A.setBool("falling",!1)}}}bl([x(nd)],_l.prototype,"controller",2);bl([x()],_l.prototype,"movementSpeed",2);bl([x()],_l.prototype,"rotationSpeed",2);bl([x()],_l.prototype,"jumpForce",2);bl([x()],_l.prototype,"doubleJumpForce",2);bl([x(ys)],_l.prototype,"animator",2);var ose=Object.defineProperty,ase=Object.getOwnPropertyDescriptor,cse=(n,e,t,i)=>{for(var s=i>1?void 0:i?ase(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};class wv extends Ws{constructor(){super(...arguments);h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new LN;return t.offset=new te(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}}cse([x(Rt)],wv.prototype,"intensity",2);Qo("ChromaticAberration",wv);var lse=Object.defineProperty,hse=Object.getOwnPropertyDescriptor,tw=(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&&lse(e,t,s),s};class Bh extends Ws{constructor(){super(...arguments);h(this,"postExposure");h(this,"contrast");h(this,"hueShift");h(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===sr&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Fg);const t=new kN;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===sr&&(this.context.renderer.toneMapping=Fg),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{t.contrast=s};const i=new UN;return this.hueShift.onValueChanged=s=>i.hue=s,this.saturation.onValueChanged=s=>i.saturation=s,[i,t]}}tw([x(Rt)],Bh.prototype,"postExposure",2);tw([x(Rt)],Bh.prototype,"contrast",2);tw([x(Rt)],Bh.prototype,"hueShift",2);tw([x(Rt)],Bh.prototype,"saturation",2);Qo("ColorAdjustments",Bh);const use=(Math.sqrt(5)-1)/4,cs=(5-Math.sqrt(5))/20,c0=n=>Math.floor(n)|0,l0=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 dse(n=Math.random){const e=fse(n),t=new Float64Array(e).map(o=>l0[o%32*4]),i=new Float64Array(e).map(o=>l0[o%32*4+1]),s=new Float64Array(e).map(o=>l0[o%32*4+2]),r=new Float64Array(e).map(o=>l0[o%32*4+3]);return function(a,c,l,u){let d,f,p,m,A;const v=(a+c+l+u)*use,g=c0(a+v),b=c0(c+v),y=c0(l+v),_=c0(u+v),E=(g+b+y+_)*cs,M=g-E,T=b-E,R=y-E,C=_-E,I=a-M,D=c-T,W=l-R,F=u-C;let H=0,j=0,z=0,L=0;I>D?H++:j++,I>W?H++:z++,I>F?H++:L++,D>W?j++:z++,D>F?j++:L++,W>F?z++:L++;const G=H>=3?1:0,$=j>=3?1:0,Z=z>=3?1:0,q=L>=3?1:0,ie=H>=2?1:0,pe=j>=2?1:0,Ae=z>=2?1:0,Ee=L>=2?1:0,Me=H>=1?1:0,Ge=j>=1?1:0,Qe=z>=1?1:0,ut=L>=1?1:0,Mt=I-G+cs,st=D-$+cs,X=W-Z+cs,Fe=F-q+cs,ve=I-ie+2*cs,Le=D-pe+2*cs,Ce=W-Ae+2*cs,tt=F-Ee+2*cs,qe=I-Me+3*cs,Je=D-Ge+3*cs,vt=W-Qe+3*cs,Tt=F-ut+3*cs,Kt=I-1+4*cs,V=D-1+4*cs,k=W-1+4*cs,he=F-1+4*cs,Pe=g&255,Be=b&255,Ue=y&255,J=_&255;let de=.6-I*I-D*D-W*W-F*F;if(de<0)d=0;else{const ke=Pe+e[Be+e[Ue+e[J]]];de*=de,d=de*de*(t[ke]*I+i[ke]*D+s[ke]*W+r[ke]*F)}let ce=.6-Mt*Mt-st*st-X*X-Fe*Fe;if(ce<0)f=0;else{const ke=Pe+G+e[Be+$+e[Ue+Z+e[J+q]]];ce*=ce,f=ce*ce*(t[ke]*Mt+i[ke]*st+s[ke]*X+r[ke]*Fe)}let je=.6-ve*ve-Le*Le-Ce*Ce-tt*tt;if(je<0)p=0;else{const ke=Pe+ie+e[Be+pe+e[Ue+Ae+e[J+Ee]]];je*=je,p=je*je*(t[ke]*ve+i[ke]*Le+s[ke]*Ce+r[ke]*tt)}let Xe=.6-qe*qe-Je*Je-vt*vt-Tt*Tt;if(Xe<0)m=0;else{const ke=Pe+Me+e[Be+Ge+e[Ue+Qe+e[J+ut]]];Xe*=Xe,m=Xe*Xe*(t[ke]*qe+i[ke]*Je+s[ke]*vt+r[ke]*Tt)}let Ve=.6-Kt*Kt-V*V-k*k-he*he;if(Ve<0)A=0;else{const ke=Pe+1+e[Be+1+e[Ue+1+e[J+1]]];Ve*=Ve,A=Ve*Ve*(t[ke]*Kt+i[ke]*V+s[ke]*k+r[ke]*he)}return 27*(d+f+p+m+A)}}function fse(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 pse=Object.defineProperty,mse=Object.getOwnPropertyDescriptor,se=(n,e,t,i)=>{for(var s=i>1?void 0:i?mse(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};const h0=re("debugparticles");var Lc=(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))(Lc||{});let Dh=class{constructor(){h(this,"alphaKeys");h(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 c=this.alphaKeys[a];(c.time<e||!i)&&(i=c,s=a)}for(let a=0;a<this.colorKeys.length;a++){const c=this.colorKeys[a];(c.time<e||!r)&&(r=c,o=a)}if(r)if(o+1<this.colorKeys.length){const c=this.colorKeys[o+1],l=Ye.remap(e,r.time,c.time,0,1);t.r=Ye.lerp(r.color.r,c.color.r,l),t.g=Ye.lerp(r.color.g,c.color.g,l),t.b=Ye.lerp(r.color.b,c.color.b,l)}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 c=this.alphaKeys[s+1],l=Ye.remap(e,i.time,c.time,0,1);t.alpha=Ye.lerp(i.alpha,c.alpha,l)}else t.alpha=i.alpha;return t}};se([x()],Dh.prototype,"alphaKeys",2);se([x()],Dh.prototype,"colorKeys",2);var pA=(n=>(n[n.Local=0]="Local",n[n.World=1]="World",n[n.Custom=2]="Custom",n))(pA||{}),kG=(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))(kG||{});class ht{constructor(){h(this,"mode");h(this,"constant");h(this,"constantMin");h(this,"constantMax");h(this,"curve");h(this,"curveMin");h(this,"curveMax");h(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=Ye.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const s=e*this.curveMin.duration,r=e*this.curveMax.duration;return Ye.lerp(this.curveMin.evaluate(s),this.curveMax.evaluate(r),i%1)*this.curveMultiplier;case 3:return Ye.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}}se([x()],ht.prototype,"mode",2);se([x()],ht.prototype,"constant",2);se([x()],ht.prototype,"constantMin",2);se([x()],ht.prototype,"constantMax",2);se([x(Ju)],ht.prototype,"curve",2);se([x(Ju)],ht.prototype,"curveMin",2);se([x(Ju)],ht.prototype,"curveMax",2);se([x()],ht.prototype,"curveMultiplier",2);var T0;const ta=(T0=class{constructor(){h(this,"mode");h(this,"color");h(this,"colorMin");h(this,"colorMax");h(this,"gradient");h(this,"gradientMin");h(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,ta._temp),ta._temp;case 2:return ta._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(n,ta._temp),this.gradientMax.evaluate(n,ta._temp2),ta._temp.lerp(ta._temp2,t)}return ta._temp.set(16711935),ta._temp.alpha=1,ta._temp}},h(T0,"_temp",new bi(0,0,0,1)),h(T0,"_temp2",new bi(0,0,0,1)),T0);let Ir=ta;se([x(bi)],Ir.prototype,"color",2);se([x(bi)],Ir.prototype,"colorMin",2);se([x(bi)],Ir.prototype,"colorMax",2);se([x(Dh)],Ir.prototype,"gradient",2);se([x(Dh)],Ir.prototype,"gradientMin",2);se([x(Dh)],Ir.prototype,"gradientMax",2);var VM=(n=>(n[n.Hierarchy=0]="Hierarchy",n[n.Local=1]="Local",n[n.Shape=2]="Shape",n))(VM||{});class Ms{constructor(){h(this,"cullingMode");h(this,"duration");h(this,"emitterVelocityMode");h(this,"flipRotation");h(this,"gravityModifier");h(this,"gravityModifierMultiplier");h(this,"loop");h(this,"maxParticles");h(this,"playOnAwake");h(this,"prewarm");h(this,"ringBufferLoopRange");h(this,"ringBufferMode");h(this,"scalingMode");h(this,"simulationSpace");h(this,"simulationSpeed");h(this,"startColor");h(this,"startDelay");h(this,"startDelayMultiplier");h(this,"startLifetime");h(this,"startLifetimeMultiplier");h(this,"startRotation");h(this,"startRotationMultiplier");h(this,"startRotation3D");h(this,"startRotationX");h(this,"startRotationXMultiplier");h(this,"startRotationY");h(this,"startRotationYMultiplier");h(this,"startRotationZ");h(this,"startRotationZMultiplier");h(this,"startSize");h(this,"startSize3D");h(this,"startSizeMultiplier");h(this,"startSizeX");h(this,"startSizeXMultiplier");h(this,"startSizeY");h(this,"startSizeYMultiplier");h(this,"startSizeZ");h(this,"startSizeZMultiplier");h(this,"startSpeed");h(this,"startSpeedMultiplier");h(this,"stopAction");h(this,"useUnscaledTime")}}se([x(ht)],Ms.prototype,"gravityModifier",2);se([x(Ir)],Ms.prototype,"startColor",2);se([x(ht)],Ms.prototype,"startDelay",2);se([x(ht)],Ms.prototype,"startLifetime",2);se([x(ht)],Ms.prototype,"startRotation",2);se([x(ht)],Ms.prototype,"startRotationX",2);se([x(ht)],Ms.prototype,"startRotationY",2);se([x(ht)],Ms.prototype,"startRotationZ",2);se([x(ht)],Ms.prototype,"startSize",2);se([x(ht)],Ms.prototype,"startSizeX",2);se([x(ht)],Ms.prototype,"startSizeY",2);se([x(ht)],Ms.prototype,"startSizeZ",2);se([x(ht)],Ms.prototype,"startSpeed",2);class mA{constructor(){h(this,"cycleCount");h(this,"maxCount");h(this,"minCount");h(this,"probability");h(this,"repeatInterval");h(this,"time");h(this,"count");h(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=Ye.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=Ye.lerp(this.count.curveMin.evaluate(s),this.count.curveMax.evaluate(s),Math.random());break}}return t}}class ac{constructor(){h(this,"enabled");h(this,"bursts");h(this,"rateOverTime");h(this,"rateOverTimeMultiplier");h(this,"rateOverDistance");h(this,"rateOverDistanceMultiplier");h(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}}se([x()],ac.prototype,"enabled",2);se([x()],ac.prototype,"bursts",2);se([x(ht)],ac.prototype,"rateOverTime",2);se([x()],ac.prototype,"rateOverTimeMultiplier",2);se([x(ht)],ac.prototype,"rateOverDistance",2);se([x()],ac.prototype,"rateOverDistanceMultiplier",2);class Sv{constructor(){h(this,"enabled");h(this,"color")}}se([x(Ir)],Sv.prototype,"color",2);class Oh{constructor(){h(this,"enabled");h(this,"separateAxes");h(this,"size");h(this,"sizeMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier");h(this,"_time",0);h(this,"_temp",new w)}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}}se([x(ht)],Oh.prototype,"size",2);se([x(ht)],Oh.prototype,"x",2);se([x(ht)],Oh.prototype,"y",2);se([x(ht)],Oh.prototype,"z",2);var I0;const Km=(I0=class{constructor(){h(this,"shapeType",5);h(this,"enabled",!0);h(this,"alignToDirection",!1);h(this,"angle",0);h(this,"arc",360);h(this,"arcSpread");h(this,"arcSpeedMultiplier");h(this,"arcMode");h(this,"boxThickness");h(this,"position");h(this,"rotation");h(this,"_rotation",new yn);h(this,"scale");h(this,"radius");h(this,"radiusThickness");h(this,"sphericalDirectionAmount");h(this,"randomDirectionAmount");h(this,"randomPositionAmount");h(this,"system");h(this,"_space");h(this,"_worldSpaceMatrix",new Te);h(this,"_worldSpaceMatrixInverse",new Te);h(this,"_vector",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_dir",new w);h(this,"_loopTime",0);h(this,"_loopDirection",1);h0&&console.log(this)}get type(){return kG[this.shapeType]}initialize(n){this.getPosition(),n.position.copy(this._vector)}toJSON(){return this}clone(){return new Km}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=Ye.toRadians(this.rotation.x),this._rotation.y=Ye.toRadians(this.rotation.y),this._rotation.z=Ye.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:h0&&Qa.DrawWireBox(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)),h0&&Qa.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),h0&&(Qa.DrawSphere(n,.01,8925952,.5,!0),Qa.DrawDirection(n,this._dir,8925952,.5,!0)),this._dir}randomizePosition(n,e){if(e<=0)return;const t=Km._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=Km._randomQuat,i=Km._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 w(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),c=Math.acos(2*o-1),l=Ye.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,u=n.x+this.scale.x*(-l*Math.sin(c)*Math.cos(a)),d=n.y+this.scale.y*(l*Math.sin(c)*Math.sin(a)),f=n.z+this.scale.z*(l*Math.cos(c));s.x=u,s.y=d,s.z=f}randomCirclePoint(n,e,t,i,s){const r=Math.random(),o=2*Math.PI*r*(i/360),a=Ye.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,c=n.x+this.scale.x*a*Math.cos(o),l=n.y+this.scale.y*a*Math.sin(o),u=n.z;s.x=c,s.y=l,s.z=u}randomConePoint(n,e,t,i,s,r,o){let a=0,c=0;switch(r){case 0:a=Math.random(),c=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,c=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let l=2*Math.PI*a*(s/360);switch(r){case 2:case 1:l+=Math.PI+.5,l+=this._loopTime*Math.PI*2,l%=Ye.toRadians(s);break}const u=Math.acos(2*c-1),d=Ye.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,f=n.x+-d*Math.sin(u)*Math.cos(l),p=n.y+d*Math.sin(u)*Math.sin(l),m=n.z;o.x=f*this.scale.x,o.y=p*this.scale.y,o.z=m*this.scale.z}},h(I0,"_randomQuat",new Se),h(I0,"_tempVec",new w),I0);let En=Km;se([x()],En.prototype,"shapeType",2);se([x()],En.prototype,"enabled",2);se([x()],En.prototype,"alignToDirection",2);se([x()],En.prototype,"angle",2);se([x()],En.prototype,"arc",2);se([x()],En.prototype,"arcSpread",2);se([x()],En.prototype,"arcSpeedMultiplier",2);se([x()],En.prototype,"arcMode",2);se([x(w)],En.prototype,"boxThickness",2);se([x(w)],En.prototype,"position",2);se([x(w)],En.prototype,"rotation",2);se([x(w)],En.prototype,"scale",2);se([x()],En.prototype,"radius",2);se([x()],En.prototype,"radiusThickness",2);se([x()],En.prototype,"sphericalDirectionAmount",2);se([x()],En.prototype,"randomDirectionAmount",2);se([x()],En.prototype,"randomPositionAmount",2);class vi{constructor(){h(this,"damping");h(this,"enabled");h(this,"frequency");h(this,"octaveCount");h(this,"octaveMultiplier");h(this,"octaveScale");h(this,"positionAmount");h(this,"quality");h(this,"remap");h(this,"remapEnabled");h(this,"remapMultiplier");h(this,"remapX");h(this,"remapXMultiplier");h(this,"remapY");h(this,"remapYMultiplier");h(this,"remapZ");h(this,"remapZMultiplier");h(this,"scrollSpeedMultiplier");h(this,"separateAxes");h(this,"strengthMultiplier");h(this,"strengthX");h(this,"strengthXMultiplier");h(this,"strengthY");h(this,"strengthYMultiplier");h(this,"strengthZ");h(this,"strengthZMultiplier");h(this,"_noise");h(this,"_time",0);h(this,"_temp",new w)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,i,s,r,o){if(!this.enabled)return;this._noise||(this._noise=dse(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),c=this._noise(a.x,a.y,a.z,this._time),l=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),u=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(c,l,u).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}}se([x()],vi.prototype,"damping",2);se([x()],vi.prototype,"enabled",2);se([x()],vi.prototype,"frequency",2);se([x()],vi.prototype,"octaveCount",2);se([x()],vi.prototype,"octaveMultiplier",2);se([x()],vi.prototype,"octaveScale",2);se([x(ht)],vi.prototype,"positionAmount",2);se([x()],vi.prototype,"quality",2);se([x(ht)],vi.prototype,"remap",2);se([x()],vi.prototype,"remapEnabled",2);se([x()],vi.prototype,"remapMultiplier",2);se([x(ht)],vi.prototype,"remapX",2);se([x()],vi.prototype,"remapXMultiplier",2);se([x(ht)],vi.prototype,"remapY",2);se([x()],vi.prototype,"remapYMultiplier",2);se([x(ht)],vi.prototype,"remapZ",2);se([x()],vi.prototype,"remapZMultiplier",2);se([x()],vi.prototype,"scrollSpeedMultiplier",2);se([x()],vi.prototype,"separateAxes",2);se([x()],vi.prototype,"strengthMultiplier",2);se([x(ht)],vi.prototype,"strengthX",2);se([x()],vi.prototype,"strengthXMultiplier",2);se([x(ht)],vi.prototype,"strengthY",2);se([x()],vi.prototype,"strengthYMultiplier",2);se([x(ht)],vi.prototype,"strengthZ",2);se([x()],vi.prototype,"strengthZMultiplier",2);class qi{constructor(){h(this,"enabled");h(this,"attachRibbonToTransform",!1);h(this,"colorOverLifetime");h(this,"colorOverTrail");h(this,"dieWithParticles",!0);h(this,"inheritParticleColor",!0);h(this,"lifetime");h(this,"lifetimeMultiplier");h(this,"minVertexDistance",.2);h(this,"mode",0);h(this,"ratio",1);h(this,"ribbonCount",1);h(this,"shadowBias",0);h(this,"sizeAffectsLifetime",!1);h(this,"sizeAffectsWidth",!1);h(this,"splitSubEmitterRibbons",!1);h(this,"textureMode",0);h(this,"widthOverTrail");h(this,"widthOverTrailMultiplier");h(this,"worldSpace",!1)}getWidth(e,t,i,s){const 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}}se([x()],qi.prototype,"enabled",2);se([x()],qi.prototype,"attachRibbonToTransform",2);se([x(Ir)],qi.prototype,"colorOverLifetime",2);se([x(Ir)],qi.prototype,"colorOverTrail",2);se([x()],qi.prototype,"dieWithParticles",2);se([x()],qi.prototype,"inheritParticleColor",2);se([x(ht)],qi.prototype,"lifetime",2);se([x()],qi.prototype,"lifetimeMultiplier",2);se([x()],qi.prototype,"minVertexDistance",2);se([x()],qi.prototype,"mode",2);se([x()],qi.prototype,"ratio",2);se([x()],qi.prototype,"ribbonCount",2);se([x()],qi.prototype,"shadowBias",2);se([x()],qi.prototype,"sizeAffectsLifetime",2);se([x()],qi.prototype,"sizeAffectsWidth",2);se([x()],qi.prototype,"splitSubEmitterRibbons",2);se([x()],qi.prototype,"textureMode",2);se([x(ht)],qi.prototype,"widthOverTrail",2);se([x()],qi.prototype,"widthOverTrailMultiplier",2);se([x()],qi.prototype,"worldSpace",2);class Zi{constructor(){h(this,"enabled");h(this,"space",0);h(this,"orbitalX");h(this,"orbitalY");h(this,"orbitalZ");h(this,"orbitalXMultiplier");h(this,"orbitalYMultiplier");h(this,"orbitalZMultiplier");h(this,"orbitalOffsetX");h(this,"orbitalOffsetY");h(this,"orbitalOffsetZ");h(this,"speedModifier");h(this,"speedModifierMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier");h(this,"_system");h(this,"_temp",new w);h(this,"_temp2",new w);h(this,"_temp3",new w);h(this,"_hasOrbital",!1);h(this,"_index",0);h(this,"_orbitalMatrix",new Te)}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 c=o/a,l=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,u=this.x.evaluate(c),d=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-u,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=l*Math.PI*2*10,_=Math.cos(y*v),E=Math.sin(y*v),M=Math.cos(y*g),T=Math.sin(y*g),R=Math.cos(y*b),C=Math.sin(y*b),I=A.x*(M*R)+A.y*(M*C)+A.z*-T,D=A.x*(E*T*R-_*C)+A.y*(E*T*C+_*R)+A.z*(E*M),W=A.x*(_*T*R+E*C)+A.y*(_*T*C-E*R)+A.z*(_*M),F=this._temp3.set(A.x-I,A.y-D,A.z-W);F.normalize(),F.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),s.x+=F.x,s.y+=F.y,s.z+=F.z}s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z,s.x*=l,s.y*=l,s.z*=l}}se([x()],Zi.prototype,"enabled",2);se([x()],Zi.prototype,"space",2);se([x(ht)],Zi.prototype,"orbitalX",2);se([x(ht)],Zi.prototype,"orbitalY",2);se([x(ht)],Zi.prototype,"orbitalZ",2);se([x()],Zi.prototype,"orbitalXMultiplier",2);se([x()],Zi.prototype,"orbitalYMultiplier",2);se([x()],Zi.prototype,"orbitalZMultiplier",2);se([x()],Zi.prototype,"orbitalOffsetX",2);se([x()],Zi.prototype,"orbitalOffsetY",2);se([x()],Zi.prototype,"orbitalOffsetZ",2);se([x(ht)],Zi.prototype,"speedModifier",2);se([x()],Zi.prototype,"speedModifierMultiplier",2);se([x(ht)],Zi.prototype,"x",2);se([x()],Zi.prototype,"xMultiplier",2);se([x(ht)],Zi.prototype,"y",2);se([x()],Zi.prototype,"yMultiplier",2);se([x(ht)],Zi.prototype,"z",2);se([x()],Zi.prototype,"zMultiplier",2);class Ts{constructor(){h(this,"animation");h(this,"enabled");h(this,"cycleCount");h(this,"frameOverTime");h(this,"frameOverTimeMultiplier");h(this,"numTilesX");h(this,"numTilesY");h(this,"startFrame");h(this,"startFrameMultiplier");h(this,"rowMode");h(this,"rowIndex");h(this,"spriteCount");h(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}}se([x()],Ts.prototype,"animation",2);se([x()],Ts.prototype,"enabled",2);se([x()],Ts.prototype,"cycleCount",2);se([x(ht)],Ts.prototype,"frameOverTime",2);se([x()],Ts.prototype,"frameOverTimeMultiplier",2);se([x()],Ts.prototype,"numTilesX",2);se([x()],Ts.prototype,"numTilesY",2);se([x(ht)],Ts.prototype,"startFrame",2);se([x()],Ts.prototype,"startFrameMultiplier",2);se([x()],Ts.prototype,"rowMode",2);se([x()],Ts.prototype,"rowIndex",2);se([x()],Ts.prototype,"spriteCount",2);se([x()],Ts.prototype,"timeMode",2);class jo{constructor(){h(this,"enabled");h(this,"separateAxes");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}se([x()],jo.prototype,"enabled",2);se([x()],jo.prototype,"separateAxes",2);se([x(ht)],jo.prototype,"x",2);se([x()],jo.prototype,"xMultiplier",2);se([x(ht)],jo.prototype,"y",2);se([x()],jo.prototype,"yMultiplier",2);se([x(ht)],jo.prototype,"z",2);se([x()],jo.prototype,"zMultiplier",2);class co{constructor(){h(this,"enabled");h(this,"range");h(this,"separateAxes");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const i=Ye.lerp(this.range.x,this.range.y,t);return this.z.evaluate(i)*-1}return 0}}se([x()],co.prototype,"enabled",2);se([x()],co.prototype,"range",2);se([x()],co.prototype,"separateAxes",2);se([x(ht)],co.prototype,"x",2);se([x()],co.prototype,"xMultiplier",2);se([x(ht)],co.prototype,"y",2);se([x()],co.prototype,"yMultiplier",2);se([x(ht)],co.prototype,"z",2);se([x()],co.prototype,"zMultiplier",2);class Fn{constructor(){h(this,"enabled");h(this,"dampen");h(this,"drag");h(this,"dragMultiplier");h(this,"limit");h(this,"limitMultiplier");h(this,"separateAxes");h(this,"limitX");h(this,"limitXMultiplier");h(this,"limitY");h(this,"limitYMultiplier");h(this,"limitZ");h(this,"limitZMultiplier");h(this,"multiplyDragByParticleSize",!1);h(this,"multiplyDragByParticleVelocity",!1);h(this,"space");h(this,"_temp",new w);h(this,"_temp2",new w)}apply(e,t,i,s,r,o,a){if(this.enabled){const c=this.limit.evaluate(r)*this.limitMultiplier;if(t.length()>c){this._temp.copy(t).normalize().multiplyScalar(c);const u=this.dampen*.5;t.x=Ye.lerp(t.x,this._temp.x,u),t.y=Ye.lerp(t.y,this._temp.y,u),t.z=Ye.lerp(t.z,this._temp.z,u),i.x=Ye.lerp(i.x,this._temp.x,u),i.y=Ye.lerp(i.y,this._temp.y,u),i.z=Ye.lerp(i.z,this._temp.z,u)}}}}se([x()],Fn.prototype,"enabled",2);se([x()],Fn.prototype,"dampen",2);se([x(ht)],Fn.prototype,"drag",2);se([x()],Fn.prototype,"dragMultiplier",2);se([x(ht)],Fn.prototype,"limit",2);se([x()],Fn.prototype,"limitMultiplier",2);se([x()],Fn.prototype,"separateAxes",2);se([x(ht)],Fn.prototype,"limitX",2);se([x()],Fn.prototype,"limitXMultiplier",2);se([x(ht)],Fn.prototype,"limitY",2);se([x()],Fn.prototype,"limitYMultiplier",2);se([x(ht)],Fn.prototype,"limitZ",2);se([x()],Fn.prototype,"limitZMultiplier",2);se([x()],Fn.prototype,"multiplyDragByParticleSize",2);se([x()],Fn.prototype,"multiplyDragByParticleVelocity",2);se([x()],Fn.prototype,"space",2);class kh{constructor(){h(this,"enabled");h(this,"curve");h(this,"curveMultiplier");h(this,"mode");h(this,"system");h(this,"_lastWorldPosition");h(this,"_velocity",new w);h(this,"_temp",new w)}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)}}}se([x()],kh.prototype,"enabled",2);se([x(ht)],kh.prototype,"curve",2);se([x()],kh.prototype,"curveMultiplier",2);se([x()],kh.prototype,"mode",2);class pr{constructor(){h(this,"enabled");h(this,"range");h(this,"separateAxes");h(this,"size");h(this,"sizeMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t,i,s){const r=e.length(),o=Ye.remap(r,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,i);return s*a}}se([x()],pr.prototype,"enabled",2);se([x(te)],pr.prototype,"range",2);se([x()],pr.prototype,"separateAxes",2);se([x(ht)],pr.prototype,"size",2);se([x()],pr.prototype,"sizeMultiplier",2);se([x(ht)],pr.prototype,"x",2);se([x()],pr.prototype,"xMultiplier",2);se([x(ht)],pr.prototype,"y",2);se([x()],pr.prototype,"yMultiplier",2);se([x(ht)],pr.prototype,"z",2);se([x()],pr.prototype,"zMultiplier",2);class sd{constructor(){h(this,"enabled");h(this,"range");h(this,"color")}evaluate(e,t,i){const s=e.length(),r=Ye.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}}se([x()],sd.prototype,"enabled",2);se([x(te)],sd.prototype,"range",2);se([x(Ir)],sd.prototype,"color",2);const gse={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
5192
5192
 
@@ -6663,8 +6663,8 @@ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-en
6663
6663
  display: block;
6664
6664
  width: max(600px, 100%);
6665
6665
  height: max(300px, 100%);
6666
- font-family: 'Roboto', sans-serif;
6667
6666
  }
6667
+
6668
6668
  @media (max-width: 600px) {
6669
6669
  :host {
6670
6670
  width: 100%;