@needle-tools/engine 3.37.7-beta → 3.37.7-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/needle-engine.js +9 -8
- package/dist/needle-engine.light.js +9 -8
- package/dist/needle-engine.light.min.js +2 -2
- package/dist/needle-engine.light.umd.cjs +2 -2
- package/dist/needle-engine.min.js +2 -2
- package/dist/needle-engine.umd.cjs +2 -2
- package/lib/engine-components/export/usdz/extensions/Animation.js +3 -2
- package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
- package/package.json +1 -1
- package/src/engine-components/export/usdz/extensions/Animation.ts +3 -2
|
@@ -4340,7 +4340,7 @@ void main() {
|
|
|
4340
4340
|
}`),h(pa,"blipMaterial"),h(pa,"mesh");function WO(i){return pa.copyTexture(i)}function _Y(i,e=!1){return pa.textureToCanvas(i,e)}function xY(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&i instanceof ImageBitmap}let yb=!1;gW((...i)=>{var e;ut()&&(e=ni.Current)!=null&&e.isInXR&&(kp(!0),qO("error",...i))});function kp(i){if(i){if(yb)return;yb=!0,SY()}else{if(!yb)return;yb=!1,CY()}}const vg={log:void 0,warn:void 0,error:void 0};class wY{constructor(){h(this,"familyName","needle-xr"),h(this,"root",null),h(this,"context",null),h(this,"defaultFontSize",.06),h(this,"targetObject",new ge),h(this,"userForwardViewPoint",new S),h(this,"oneEuroFilter",new xE(90,.8)),h(this,"_lastElementRemoveTime",0),h(this,"onBeforeRender",()=>{var e,t;const n=(e=this.context)==null?void 0:e.mainCamera;if(this.context&&n instanceof Ut){const r=this.getRoot();Number.isNaN(r.position.x)&&r.position.set(0,0,0),Number.isNaN(r.quaternion.x)&&r.quaternion.set(0,0,0,1),this.context.scene.add(this.targetObject);const s=((t=this.context.xr)==null?void 0:t.rigScale)??1,o=3.5*s,a=n.worldForward;a.y=0,a.normalize().multiplyScalar(o),this.userForwardViewPoint.copy(n.worldPosition).sub(a),this.targetObject.position.distanceTo(this.userForwardViewPoint)>2*s&&(this.targetObject.position.copy(this.userForwardViewPoint),pg(this.targetObject,n,!0,!0),this.targetObject.rotateY(Math.PI)),this.oneEuroFilter.filter(this.targetObject.position,r.position,this.context.time.time);const l=this.context.time.deltaTime;if(r.quaternion.slerp(this.targetObject.quaternion,l*5),r.scale.setScalar(s),this.targetObject.removeFromParent(),this.context.scene.add(r),this.context.time.time-this._lastElementRemoveTime>.1){this._lastElementRemoveTime=this.context.time.time;const c=Date.now();for(let u=0;u<this._activeTexts.length;u++){const d=this._activeTexts[u];if(d instanceof Mi.Text&&c-d._activatedTime>2e4){d.removeFromParent(),this._textBuffer.push(d),this._activeTexts.splice(u,1);break}}}}}),h(this,"textOptions",{fontSize:this.defaultFontSize,fontFamily:this.familyName,padding:.03,margin:.005,color:0,backgroundColor:16777215,backgroundOpacity:.4,borderRadius:.03,offset:.025}),h(this,"_textBuffer",[]),h(this,"_activeTexts",[]),this.ensureFont()}onEnable(){this.context=ni.Current||ni.All[0],this.context.pre_render_callbacks.push(this.onBeforeRender)}onDisable(){var e,t,n;(t=this.context)==null||t.pre_render_callbacks.splice((e=this.context)==null?void 0:e.pre_render_callbacks.indexOf(this.onBeforeRender),1),(n=this.root)==null||n.removeFromParent()}addLog(e,t){const n=this.getRoot(),r=this.getText();let s=16777215,o=0;switch(e){case"log":s=16777215,o=0;break;case"warn":s=16772761,o=4465152;break;case"error":s=16755370,o=7798784;break}t.length>1e3&&(t=t.substring(0,1e3)+"...");const a=new Date().toISOString().split("T")[1].split(".")[0];r.textContent="["+a+"] "+t,r.visible=!0,r._activatedTime=Date.now(),n.add(r),this._activeTexts.push(r),this.context&&this.context.scene.add(n),r.set({backgroundColor:s,color:o}),Mi.update()}ensureFont(){let e=Mi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Mi.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t?.addEventListener("ready",()=>{Mi.update()})}}getText(){const e=this.getRoot();if(this._textBuffer.length>0){const n=this._textBuffer.pop();return n.visible=!0,setTimeout(()=>this.disableDepthTestRecursive(n),100),n}if(e.children.length>20&&this._activeTexts.length>0)return this._activeTexts.shift();const t=new Mi.Text(this.textOptions);return setTimeout(()=>this.disableDepthTestRecursive(t),500),setTimeout(()=>this.disableDepthTestRecursive(t),1500),t}disableDepthTestRecursive(e,t=0){for(let r=0;r<e.children.length;r++){const s=e.children[r];s instanceof ge&&this.disableDepthTestRecursive(s,t+1)}e.renderOrder=10*t,e.layers.set(2);const n=e.material;n&&(n.depthWrite=!1,n.depthTest=!1,n.transparent=!0),t===0&&Mi.update()}getRoot(){if(this.root)return this.root;const e=this.defaultFontSize,t={boxSizing:"border-box",fontFamily:this.familyName,width:"2.6",fontSize:e,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:0,whiteSpace:"pre-wrap",flexDirection:"column-reverse"};return this.root=new Mi.Block(t),this.root}}let fa=null;function SY(){fa||(fa=new wY),fa.onEnable();for(const i in vg){vg[i]=console[i];let e=!1;console[i]=function(){var t;if((t=vg[i])==null||t.apply(console,arguments),!e)try{e=!0,qO(i,...arguments)}finally{e=!1}}}}function CY(){fa?.onDisable();for(const i in vg)console[i]=vg[i]}const Ag=new Map;function qO(i,...e){try{switch(Ag.clear(),i){case"log":fa?.addLog("log",t());break;case"warn":fa?.addLog("warn",t());break;case"error":fa?.addLog("error",t());break}}catch(s){console.error("Error in spatial console",s)}finally{Ag.clear()}function t(){let s="";for(let o=0;o<e.length;o++){const a=e[o];s+=n(a),o<e.length-1&&(s+=", ")}return s}function n(s,o=0){if(typeof s=="string")return'"'+s+'"';if(typeof s=="number"){if(s%1!==0){const a=s.toFixed(5),l=a.indexOf(".");let c=a.length-1;for(;c>l&&a[c]==="0";)c--;return a.substring(0,c+1)}return s.toString()}else if(Array.isArray(s)){let a="[";for(let l=0;l<s.length;l++){const c=s[l];a+=n(c,o+1),l<s.length-1&&(a+=", ")}return a+="]",a}else{if(s===null)return"null";if(s===void 0)return"undefined";if(typeof s=="function")return s.name+"()"}if(s instanceof $)return`(${n(s.x)}, ${n(s.y)})`;if(s instanceof S)return`(${n(s.x)}, ${n(s.y)}, ${n(s.z)})`;if(s instanceof Ye)return`(${n(s.x)}, ${n(s.y)}, ${n(s.z)}, ${n(s.w)})`;if(s instanceof Me)return`(${n(s.x)}, ${n(s.y)}, ${n(s.z)}, ${n(s.w)})`;if(s instanceof It||s instanceof gt)return s.name;if(s instanceof Dt)return`[${s.elements.join(", ")}]`;if(s instanceof Ce)return`[${s.elements.join(", ")}]`;if(s instanceof Gr)return s.mask.toString();if(typeof s=="object"){if(Ag.has(s))return"*";let a=`{
|
|
4341
4341
|
`;a+=r(o);const l=Object.keys(s);let c="";for(let u=0;u<l.length;u++){const d=l[u],p=s[d];if(Ag.has(p)){c+="";continue}Ag.set(p,!0),c+=d+":"+n(p,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
|
|
4342
4342
|
`,c+=r(o),a+=c,c="")}return a+=c,a+=`
|
|
4343
|
-
}`,a}return s}function r(s){let o="";for(let a=0;a<s;a++)o+=" ";return o}}const EY=ee("nodevlogs");function Hi(i,e=Ks.Log){za(e,i)}function $i(i){Hi(i,Ks.Warn)}function RE(i){Hi(i,Ks.Error)}let PE;function ut(){return EY?!1:PE!==void 0?PE:Qs()}function MY(i){PE=i}const XO=ee("debugdefines");Op('if(!globalThis[""3.37.7-beta""]) globalThis[""3.37.7-beta""] = "0.0.0";'),Op('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Op('if(!globalThis[""Mon Apr 29 2024
|
|
4343
|
+
}`,a}return s}function r(s){let o="";for(let a=0;a<s;a++)o+=" ";return o}}const EY=ee("nodevlogs");function Hi(i,e=Ks.Log){za(e,i)}function $i(i){Hi(i,Ks.Warn)}function RE(i){Hi(i,Ks.Error)}let PE;function ut(){return EY?!1:PE!==void 0?PE:Qs()}function MY(i){PE=i}const XO=ee("debugdefines");Op('if(!globalThis[""3.37.7-beta.1""]) globalThis[""3.37.7-beta.1""] = "0.0.0";'),Op('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Op('if(!globalThis[""Mon Apr 29 2024 17:15:53 GMT+0200 (Central European Summer Time)""]) globalThis[""Mon Apr 29 2024 17:15:53 GMT+0200 (Central European Summer Time)""] = "unknown";'),Op('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.37.7-beta.1";'),Op('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),Op('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Apr 29 2024 17:15:53 GMT+0200 (Central European Summer Time)";');const Hl="3.37.7-beta.1",bb="undefined",BE="Mon Apr 29 2024 17:15:53 GMT+0200 (Central European Summer Time)";XO&&console.log(`Engine version: ${Hl} (generator: ${bb})
|
|
4344
4344
|
Project built at ${BE}`);const Vl="needle_isActiveInHierarchy",Pu="builtin_components",yg="needle_editor_guid";function Op(i){try{(0,eval)(i)}catch(e){XO&&console.error(e)}}const TY='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',IY=btoa(TY),RY="data:image/svg+xml;base64,"+IY,PY=RY,BY=`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 1014 282" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m665.95 132.73v44.88l-10.56-8.4c-0.8-0.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18 0.4-6.06 1.2s-3.54 1.8-4.98 3-2.56 2.5-3.36 3.9-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c0.32 0.24 0.56 0.44 0.72 0.6s0.36 0.32 0.6 0.48c0.96-1.2 2.14-2.28 3.54-3.24s2.92-1.76 4.56-2.4 3.34-1.14 5.1-1.5 3.44-0.54 5.04-0.54c1.44 0 2.92 0.04 4.44 0.12s2.84 0.28 3.96 0.6c4.56 1.12 7.8 3.12 9.72 6s2.88 6.56 2.88 11.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m732.38 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m795.93 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m858.57 97.21c0.64 0.48 0.96 1.16 0.96 2.04v74.88c-0.08 1.04-0.12 2.12-0.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18s-2.06-1.66-2.46-1.98c-1.76 2.48-4.26 4.44-7.5 5.88s-7.02 2.16-11.34 2.16c-3.84 0-7.4-0.7-10.68-2.1s-6.14-3.44-8.58-6.12-4.34-5.94-5.7-9.78-2.04-8.16-2.04-12.96c0-4.32 0.78-8.34 2.34-12.06s3.6-6.92 6.12-9.6 5.38-4.78 8.58-6.3 6.48-2.28 9.84-2.28c2.56 0 4.82 0.22 6.78 0.66s3.68 1.06 5.16 1.86 2.78 1.74 3.9 2.82 2.16 2.22 3.12 3.42v-35.04l10.68 8.64zm-27.96 67.92c3.6 0 6.52-0.68 8.76-2.04s3.98-3.06 5.22-5.1 2.1-4.22 2.58-6.54 0.72-4.44 0.72-6.36v-1.2c0-1.12-0.22-2.7-0.66-4.74s-1.28-4.06-2.52-6.06-3-3.7-5.28-5.1-5.22-2.02-8.82-1.86c-3.44 0-6.26 0.74-8.46 2.22s-3.96 3.26-5.28 5.34-2.24 4.2-2.76 6.36-0.78 3.92-0.78 5.28c0 1.84 0.24 3.92 0.72 6.24s1.36 4.48 2.64 6.48 3.04 3.68 5.28 5.04 5.12 2.04 8.64 2.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m882.81 97.09c0.64 0.48 0.96 1.12 0.96 1.92l-0.12 41.04v37.08l-10.56-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-77.88l10.8 8.64z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m950.36 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.8559 0 0 .7642 45.348 36.475)"> <g transform="translate(2.7114)"> <path d="m3.935 173.02c-0.331 0-0.497-0.402-0.497-1.207v-51.002c0-0.738 0.138-1.107 0.414-1.107h1.781c0.277 0 0.415 0.335 0.415 1.006v5.935c0 0.336 0.027 0.553 0.083 0.654 0.055 0.101 0.151-0.017 0.289-0.352 0.912-1.744 1.754-3.236 2.527-4.477 0.773-1.24 1.554-2.179 2.341-2.816s1.65-0.956 2.588-0.956c1.685 0 3.011 0.922 3.977 2.766 0.967 1.845 1.602 3.84 1.905 5.986 0.056 0.268 0.139 0.369 0.249 0.302s0.221-0.235 0.331-0.503c0.939-1.811 1.802-3.353 2.589-4.628 0.787-1.274 1.581-2.246 2.382-2.917s1.671-1.006 2.61-1.006c2.016 0 3.569 1.392 4.66 4.175 1.09 2.783 1.636 6.421 1.636 10.915v37.925c0 0.871-0.18 1.307-0.539 1.307h-1.739c-0.138 0-0.249-0.1-0.332-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.338-6.321-1.015-8.3-0.676-1.978-1.76-2.967-3.251-2.967-0.884 0-1.726 0.386-2.527 1.157s-1.519 1.727-2.154 2.867-1.201 2.213-1.699 3.219c-0.248 0.469-0.421 0.905-0.517 1.308-0.097 0.402-0.145 0.972-0.145 1.71v37.221c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.166 0-0.29-0.1-0.373-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.332-6.321-0.994-8.3-0.663-1.978-1.754-2.967-3.273-2.967-1.242 0-2.375 0.704-3.396 2.112-1.022 1.409-2.223 3.555-3.604 6.439v39.031c0 0.805-0.18 1.207-0.539 1.207h-1.698z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m53.642 166.28c-1.077 2.549-2.237 4.477-3.479 5.785-1.243 1.307-2.61 1.961-4.101 1.961-2.154 0-3.853-1.324-5.095-3.973-1.243-2.649-1.864-6.187-1.864-10.613 0-3.488 0.4-6.489 1.201-9.004s1.988-4.51 3.562-5.985c1.574-1.476 3.521-2.414 5.841-2.817l3.686-0.704c0.221-0.067 0.394-0.218 0.518-0.453 0.124-0.234 0.187-0.587 0.187-1.056v-2.917c0-3.89-0.504-6.975-1.512-9.255s-2.354-3.42-4.039-3.42c-1.298 0-2.472 0.72-3.521 2.162s-2.002 3.572-2.858 6.388c-0.083 0.268-0.159 0.453-0.228 0.554-0.069 0.1-0.172 0.083-0.311-0.051l-1.698-1.71c-0.083-0.134-0.138-0.285-0.166-0.453-0.027-0.167 0.014-0.452 0.125-0.855 0.856-3.353 2.009-6.052 3.459-8.098 1.449-2.045 3.224-3.068 5.322-3.068 1.74 0 3.211 0.687 4.412 2.062s2.112 3.37 2.734 5.986c0.621 2.615 0.932 5.7 0.932 9.255v35.712c0 0.536-0.035 0.888-0.104 1.056s-0.2 0.251-0.393 0.251h-1.533c-0.166 0-0.29-0.117-0.373-0.352-0.083-0.234-0.124-0.553-0.124-0.955l-0.083-5.231c-0.055-0.939-0.221-1.006-0.497-0.202zm0.456-19.314c0-1.14-0.194-1.643-0.58-1.509l-3.107 0.603c-1.436 0.202-2.686 0.638-3.749 1.308-1.063 0.671-1.953 1.543-2.671 2.616s-1.257 2.33-1.616 3.772-0.538 3.102-0.538 4.98c0 3.152 0.455 5.616 1.367 7.393 0.911 1.778 2.14 2.666 3.686 2.666 0.939 0 1.85-0.419 2.734-1.257s1.671-1.895 2.361-3.169c0.663-1.408 1.181-2.85 1.553-4.326 0.373-1.475 0.56-2.883 0.56-4.225v-8.852z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m79.034 173.02c-0.166 0-0.297-0.117-0.394-0.352-0.096-0.234-0.145-0.553-0.145-0.955v-4.628c0-0.536-0.041-0.838-0.124-0.905s-0.207 0.1-0.373 0.503c-0.276 0.67-0.69 1.593-1.242 2.766-0.553 1.174-1.271 2.23-2.154 3.169-0.884 0.939-1.961 1.408-3.231 1.408-1.74 0-3.314-0.989-4.722-2.967-1.409-1.979-2.534-4.963-3.376-8.953-0.843-3.991-1.264-8.937-1.264-14.838 0-5.701 0.415-10.68 1.243-14.939s1.988-7.595 3.479-10.009c1.492-2.415 3.204-3.622 5.137-3.622 1.436 0 2.616 0.57 3.541 1.71 0.926 1.14 1.719 2.381 2.382 3.722 0.249 0.47 0.414 0.637 0.497 0.503s0.125-0.536 0.125-1.207v-23.841c0-0.805 0.151-1.208 0.455-1.208h1.864c0.276 0 0.414 0.369 0.414 1.107v72.128c0 0.537-0.041 0.905-0.124 1.107-0.083 0.201-0.235 0.301-0.455 0.301h-1.533zm-0.621-42.049c-0.939-2.213-1.885-3.94-2.838-5.181s-2.009-1.861-3.169-1.861c-1.463 0-2.768 0.889-3.914 2.666s-2.044 4.376-2.693 7.796-0.973 7.578-0.973 12.474c0 5.097 0.338 9.272 1.015 12.524 0.676 3.253 1.567 5.651 2.672 7.193 1.104 1.543 2.305 2.314 3.603 2.314 1.188 0 2.258-0.704 3.211-2.113 0.952-1.408 1.705-3.118 2.257-5.13s0.829-3.957 0.829-5.835v-24.847z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m89.514 149.38c0 3.42 0.345 6.606 1.035 9.557 0.691 2.951 1.609 5.315 2.755 7.092s2.437 2.666 3.873 2.666c1.519 0 2.837-0.738 3.956-2.213 1.118-1.476 2.064-3.655 2.837-6.539 0.083-0.336 0.166-0.52 0.249-0.554 0.083-0.033 0.179 0.017 0.29 0.151l1.408 1.912c0.221 0.268 0.235 0.67 0.041 1.207-0.69 2.548-1.47 4.661-2.34 6.337-0.87 1.677-1.857 2.935-2.962 3.773-1.104 0.838-2.319 1.257-3.645 1.257-2.043 0-3.838-1.14-5.385-3.42-1.546-2.28-2.761-5.482-3.645-9.607-0.884-4.124-1.325-8.836-1.325-14.134 0-5.901 0.455-10.931 1.367-15.089 0.911-4.158 2.14-7.377 3.686-9.658 1.547-2.28 3.3-3.42 5.261-3.42 1.988 0 3.714 1.073 5.178 3.219 1.463 2.146 2.595 5.231 3.396 9.255s1.201 8.886 1.201 14.587c0 0.469-0.02 0.939-0.062 1.408-0.041 0.469-0.214 0.704-0.517 0.704h-16.362c-0.083 0-0.152 0.151-0.207 0.453-0.056 0.302-0.083 0.654-0.083 1.056zm13.752-6.237c0.304 0 0.497-0.1 0.58-0.302 0.083-0.201 0.124-0.57 0.124-1.106 0-3.219-0.283-6.187-0.849-8.903s-1.367-4.896-2.402-6.539c-1.036-1.643-2.272-2.464-3.708-2.464-1.629 0-2.996 0.955-4.101 2.867-1.104 1.911-1.94 4.342-2.506 7.293s-0.849 6.002-0.849 9.154h13.711z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m148.54 119.7c0.165 0 0.283 0.117 0.352 0.352s0.076 0.52 0.02 0.855l-6.254 50.902c-0.028 0.47-0.104 0.788-0.228 0.956s-0.297 0.251-0.518 0.251h-1.615c-0.442 0-0.718-0.402-0.829-1.207l-5.26-40.138c-0.111-0.604-0.201-0.905-0.27-0.905s-0.131 0.301-0.186 0.905l-5.012 40.138c-0.028 0.47-0.097 0.788-0.207 0.956-0.111 0.168-0.277 0.251-0.497 0.251h-1.74c-0.442 0-0.718-0.402-0.829-1.207l-6.503-50.801c-0.055-0.403-0.048-0.721 0.021-0.956s0.2-0.352 0.393-0.352h1.823c0.166 0 0.297 0.067 0.393 0.201 0.097 0.134 0.159 0.403 0.187 0.805l5.302 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.219-41.949c0.055-0.268 0.124-0.47 0.207-0.604s0.193-0.201 0.331-0.201h1.533c0.138 0 0.262 0.067 0.373 0.201 0.11 0.134 0.179 0.403 0.207 0.805l5.468 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.053-41.849c0.055-0.335 0.138-0.57 0.249-0.704 0.11-0.134 0.234-0.201 0.373-0.201h1.284z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m156.49 171.51c0 0.604-0.042 1.006-0.125 1.208-0.082 0.201-0.262 0.301-0.538 0.301h-1.533c-0.221 0-0.366-0.083-0.435-0.251s-0.103-0.486-0.103-0.956v-50.902c0-0.805 0.152-1.207 0.456-1.207h1.822c0.304 0 0.456 0.402 0.456 1.207v50.6zm0.165-63.979c0 1.207-0.207 1.811-0.621 1.811h-1.905c-0.221 0-0.366-0.135-0.435-0.403s-0.104-0.67-0.104-1.207v-7.847c0-1.006 0.18-1.509 0.539-1.509h1.988c0.359 0 0.538 0.47 0.538 1.409v7.746z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m168.3 124.83c-0.221 0-0.331 0.269-0.331 0.805v33.801c0 3.42 0.221 5.667 0.663 6.74 0.441 1.073 1.09 1.609 1.946 1.609h3.024c0.138 0 0.242 0.084 0.311 0.252 0.069 0.167 0.103 0.419 0.103 0.754v2.716c0 0.537-0.138 0.906-0.414 1.107-0.248 0.067-0.614 0.134-1.098 0.201-0.483 0.067-0.959 0.118-1.429 0.151-0.469 0.034-0.828 0.05-1.077 0.05-1.712 0-2.934-0.955-3.665-2.867-0.732-1.911-1.098-5.013-1.098-9.305v-35.108c0-0.604-0.124-0.906-0.373-0.906h-3.521c-0.248 0-0.373-0.268-0.373-0.804v-3.521c0-0.537 0.111-0.805 0.332-0.805h3.686c0.166 0 0.263-0.268 0.29-0.805l0.415-16.095c0-0.805 0.124-1.207 0.372-1.207h1.492c0.303 0 0.455 0.436 0.455 1.307v15.995c0 0.537 0.097 0.805 0.29 0.805h5.468c0.221 0 0.331 0.268 0.331 0.805v3.521c0 0.536-0.124 0.804-0.373 0.804h-5.426z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m179.4 173.02c-0.331 0-0.497-0.402-0.497-1.207v-72.329c0-0.738 0.138-1.107 0.414-1.107h1.782c0.276 0 0.414 0.336 0.414 1.006v27.162c0 0.335 0.034 0.536 0.103 0.603s0.159-0.033 0.27-0.302c0.994-1.81 1.898-3.319 2.713-4.526 0.814-1.208 1.629-2.113 2.444-2.717 0.814-0.603 1.691-0.905 2.63-0.905 2.182 0 3.839 1.375 4.971 4.125 1.132 2.749 1.698 6.404 1.698 10.965v37.925c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.165 0-0.29-0.1-0.373-0.301-0.082-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.366-6.321-1.097-8.3-0.732-1.978-1.899-2.967-3.501-2.967-0.883 0-1.705 0.318-2.464 0.956-0.76 0.637-1.526 1.576-2.299 2.816-0.773 1.241-1.643 2.834-2.61 4.779v39.031c0 0.805-0.179 1.207-0.538 1.207h-1.699z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> </g> <g transform="matrix(.80638 0 0 .80638 452.53 65.421)" fill-rule="nonzero"> <path d="m79.32 36.98v150.76l15.68-13.2 6.59-156.31-22.27 18.75z" fill="url(#f)"/> <path d="m79.32 36.98-22.27-18.75 6.59 156.31 15.68 13.2v-150.76z" fill="url(#e)"/> <path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z" fill="url(#d)"/> <path d="m25.19 104.83-25.19-14.59 16.97 53.86 16.85 9.77-8.63-49.04z" fill="url(#c)"/> <path d="M43.86,82.5L18.69,67.98L0,90.24L25.18,104.83L43.86,82.5Z" fill="#9c3"/> <path d="m134.82 78.69-9.97 56.5 15.58-9.04 19.57-62.05-25.18 14.59z" fill="url(#b)"/> <path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z" fill="url(#a)"/> <path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33 25.19-14.59z" fill="#ffe113"/> <path d="M101.59,18.23L79.32,0L57.05,18.23L79.32,36.98L101.59,18.23Z" fill="#f3e600"/> </g> <defs> <linearGradient id="f" x2="1" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)" gradientUnits="userSpaceOnUse"><stop stop-color="#62d399" offset="0"/><stop stop-color="#acd842" offset=".51"/><stop stop-color="#d7db0a" offset=".9"/><stop stop-color="#d7db0a" offset="1"/></linearGradient> <linearGradient id="e" x2="1" gradientTransform="matrix(-1.6,-162.13,162.13,-1.6,69.68,178.9)" gradientUnits="userSpaceOnUse"><stop stop-color="#0ba398" offset="0"/><stop stop-color="#4ca352" offset=".5"/><stop stop-color="#76a30a" offset="1"/></linearGradient> <linearGradient id="d" x2="1" gradientTransform="matrix(-1.9,-67.98,67.98,-1.9,36.6,152.17)" gradientUnits="userSpaceOnUse"><stop stop-color="#36a382" offset="0"/><stop stop-color="#36a382" offset=".19"/><stop stop-color="#49a459" offset=".54"/><stop stop-color="#76a30b" offset="1"/></linearGradient> <linearGradient id="c" x2="1" gradientTransform="matrix(2.18,-62.38,62.38,2.18,15.82,153.24)" gradientUnits="userSpaceOnUse"><stop stop-color="#267880" offset="0"/><stop stop-color="#457a5c" offset=".51"/><stop stop-color="#717516" offset="1"/></linearGradient> <linearGradient id="b" x2="1" gradientTransform="matrix(13.85,-71.96,71.96,13.85,135.08,135.43)" gradientUnits="userSpaceOnUse"><stop stop-color="#b0d939" offset="0"/><stop stop-color="#eadb04" offset="1"/></linearGradient> <linearGradient id="a" x2="1" gradientTransform="matrix(26.159 -64.737 64.737 26.159 107.42 128.14)" gradientUnits="userSpaceOnUse"><stop stop-color="#74af52" offset="0"/><stop stop-color="#74af52" offset=".17"/><stop stop-color="#99be32" offset=".48"/><stop stop-color="#c0c40a" offset="1"/></linearGradient> </defs> </svg>`;btoa(BY);const DY='<svg viewBox="0 0 509 154" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M665.95 132.73v44.88l-10.56-8.4c-.8-.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18.4-6.06 1.2-1.88.8-3.54 1.8-4.98 3-1.44 1.2-2.56 2.5-3.36 3.9-.8 1.4-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-.72-.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c.32.24.56.44.72.6.16.16.36.32.6.48.96-1.2 2.14-2.28 3.54-3.24 1.4-.96 2.92-1.76 4.56-2.4 1.64-.64 3.34-1.14 5.1-1.5 1.76-.36 3.44-.54 5.04-.54 1.44 0 2.92.04 4.44.12 1.52.08 2.84.28 3.96.6 4.56 1.12 7.8 3.12 9.72 6 1.92 2.88 2.88 6.56 2.88 11.04ZM732.38 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM795.93 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM858.57 97.21c.64.48.96 1.16.96 2.04v74.88c-.08 1.04-.12 2.12-.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18-1.24-1-2.06-1.66-2.46-1.98-1.76 2.48-4.26 4.44-7.5 5.88-3.24 1.44-7.02 2.16-11.34 2.16-3.84 0-7.4-.7-10.68-2.1-3.28-1.4-6.14-3.44-8.58-6.12-2.44-2.68-4.34-5.94-5.7-9.78-1.36-3.84-2.04-8.16-2.04-12.96 0-4.32.78-8.34 2.34-12.06 1.56-3.72 3.6-6.92 6.12-9.6 2.52-2.68 5.38-4.78 8.58-6.3 3.2-1.52 6.48-2.28 9.84-2.28 2.56 0 4.82.22 6.78.66 1.96.44 3.68 1.06 5.16 1.86s2.78 1.74 3.9 2.82a35.92 35.92 0 0 1 3.12 3.42V88.57l10.68 8.64Zm-27.96 67.92c3.6 0 6.52-.68 8.76-2.04 2.24-1.36 3.98-3.06 5.22-5.1a20.5 20.5 0 0 0 2.58-6.54c.48-2.32.72-4.44.72-6.36v-1.2c0-1.12-.22-2.7-.66-4.74-.44-2.04-1.28-4.06-2.52-6.06s-3-3.7-5.28-5.1c-2.28-1.4-5.22-2.02-8.82-1.86-3.44 0-6.26.74-8.46 2.22-2.2 1.48-3.96 3.26-5.28 5.34-1.32 2.08-2.24 4.2-2.76 6.36-.52 2.16-.78 3.92-.78 5.28 0 1.84.24 3.92.72 6.24.48 2.32 1.36 4.48 2.64 6.48s3.04 3.68 5.28 5.04c2.24 1.36 5.12 2.04 8.64 2.04ZM882.81 97.09c.64.48.96 1.12.96 1.92l-.12 41.04v37.08l-10.56-8.4c-.72-.64-1.08-1.44-1.08-2.4V88.45l10.8 8.64ZM950.36 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14Z" style="fill-rule:nonzero" transform="translate(-452.406 -63.709) scale(1.00797)"/><path d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75Z" style="fill:url(#a);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98Z" style="fill:url(#b);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33Z" style="fill:url(#c);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04Z" style="fill:url(#d);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5Z" style="fill:#9c3;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59Z" style="fill:url(#e);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5Z" style="fill:url(#f);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1Z" style="fill:#ffe113;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75Z" style="fill:#f3e600;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)"><stop offset="0" style="stop-color:#62d399;stop-opacity:1"/><stop offset=".51" style="stop-color:#acd842;stop-opacity:1"/><stop offset=".9" style="stop-color:#d7db0a;stop-opacity:1"/><stop offset="1" style="stop-color:#d7db0a;stop-opacity:1"/></linearGradient><linearGradient id="b" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-90.565 123.412 54.953) scale(162.14)"><stop offset="0" style="stop-color:#0ba398;stop-opacity:1"/><stop offset=".5" style="stop-color:#4ca352;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30a;stop-opacity:1"/></linearGradient><linearGradient id="c" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="scale(-68) rotate(88.4 .881 -1.396)"><stop offset="0" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".19" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".54" style="stop-color:#49a459;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30b;stop-opacity:1"/></linearGradient><linearGradient id="d" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-88 87.255 68.431) scale(62.42)"><stop offset="0" style="stop-color:#267880;stop-opacity:1"/><stop offset=".51" style="stop-color:#457a5c;stop-opacity:1"/><stop offset="1" style="stop-color:#717516;stop-opacity:1"/></linearGradient><linearGradient id="e" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-79.1 149.53 -14.065) scale(73.28)"><stop offset="0" style="stop-color:#b0d939;stop-opacity:1"/><stop offset="1" style="stop-color:#eadb04;stop-opacity:1"/></linearGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-67.997 148.705 -15.558) scale(69.8226)"><stop offset="0" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".17" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".48" style="stop-color:#99be32;stop-opacity:1"/><stop offset="1" style="stop-color:#c0c40a;stop-opacity:1"/></linearGradient></defs></svg>',kY=btoa(DY),OY="data:image/svg+xml;charset=utf-8;base64,"+kY,LY=OY,ko=ee("debuglicense");let Bu="basic";ko&&console.log("License Type: "+Bu);function ma(){switch(Bu){case"pro":case"enterprise":return!0}return!1}function DE(){switch(Bu){case"indie":return!0}return!1}function Lp(){return ma()||DE()}const YO=[];function UY(i){if(ma()||DE())return i(!0);YO.push(i)}function FY(i){for(const e of YO)try{e(i)}catch{}}ni.registerCallback(pn.ContextRegistered,i=>{jY(i.context),QY(),zY(i.context)});let Du,kE=!1,_b="";async function NY(){if(Du)return Du;if(Bu==="basic")try{const i="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+Hl+"&generator="+encodeURIComponent(bb),e=await fetch(i,{method:"GET"}).catch(t=>{ko&&console.error("License check failed",t)});e?.status===200?(kE=!1,ko&&console.log("License check succeeded"),Bu="pro",FY(!0)):e?.status===403?(kE=!0,_b=await e.text()):ko&&console.log("License check failed with status "+e?.status)}catch(i){ko&&console.error("License check failed",i)}else ko&&console.log('Runtime license check is skipped because license is already applied as "'+Bu+'"')}Du=NY();async function zY(i){function e(){const r=document.createElement("div");r.className="needle-forbidden",r.style.cssText=`
|
|
4345
4345
|
position: fixed;
|
|
4346
4346
|
top: 0;
|
|
@@ -5505,7 +5505,7 @@ Could not find method ${u.method} on object ${p.name}. Please rename ${u.method}
|
|
|
5505
5505
|
in script: `,p),$i("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
|
|
5506
5506
|
Could not find method ${u.method} on object ${p.name}`,p,typeof p[u.method])};if(typeof p[u.method]!="function"){let y=!1,b=p;for(;b;){const _=Object.getOwnPropertyDescriptor(b,u.method);if(_&&(_.writable===!0||_.set)){y=!0;break}b=Object.getPrototypeOf(b)}!y&&(ut()||yr)&&g()}}let m=u.argument;m!==void 0?m=d(m):u.arguments!==void 0&&(m=u.arguments.map(d));const A=f?this.createEventMethod(p,u.method,m):void 0,v=new mf(A,u.enabled);if(v.method||(v[kie]=(o=t.object)==null?void 0:o.name),!p||!v.method){const g=t.object?"Current object: "+t.object.name+", "+t.object.guid:null;p?console.warn('EventList method not found: "'+u.method+'" on',p):console.warn("EventList is missing target - will be ignored",u.target,g,e)}else a.push(v)}const l=new Hn(a);yr&&console.log(l);const c=t.target;return c!==void 0&&t.path!==void 0&&l.setEventTarget(t.path,c),l}}createEventMethod(e,t,n){return(...r)=>{const s=e[t];typeof s=="function"?n!==void 0?Array.isArray(n)?s?.call(e,...n):s?.call(e,n):s?.call(e,...r):e[t]=n}}}const Lie=new Oie;class a4 extends Va{constructor(){super([pf,Ht])}onSerialize(e,t){}onDeserialize(e,t){if(e instanceof gt&&t.type===pf){const n=e,r=new pf(n.image.width,n.image.height,{colorSpace:di});return r.texture=n,n.isRenderTargetTexture=!0,n.flipY=!0,n.offset.y=1,n.repeat.y=-1,n.needsUpdate=!0,n.mipmaps=[],n instanceof La&&(n.isCompressedTexture=!1,n.format=RGBAFormat),r}}}new a4;class l4 extends Va{constructor(){super([URL])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"&&e.length>0)return jl(t.gltfId,e)}}new l4;var Uie=Object.defineProperty,Fie=Object.getOwnPropertyDescriptor,Nie=(i,e,t,n)=>{for(var r=n>1?void 0:n?Fie(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Uie(e,t,r),r};class _v extends Ie{awake(){Ho.createIfNoneExists(this.context)}onEnable(){var e;(e=Ho.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Ho.get(this.context))==null||e.unregister(this)}}class no extends _v{constructor(){super(...arguments),h(this,"targets",null),h(this,"raycastHits",[]),h(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new jo),e.targets=this.targets,e.results=this.raycastHits;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=r=>r instanceof qs?"continue in children":t?t(r):!0);const n=this.context.physics.raycast(e);return e.testObject=t,n}}Nie([x()],no.prototype,"ignoreSkinnedMeshes",2);class V_ extends no{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class xv extends _v{performRaycast(e){if(!_t.active||!(e!=null&&e.ray))return null;const t=e.ray.origin,n=.01;return this.context.physics.sphereOverlap(t,n)}}class W_{static getObject(e){const t=e[Qo];return t&&(t.isComponent===!0?e=t.gameObject:e=t),e}static isInteractable(e,t){if(t&&(t.canvasGroup=void 0,t.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const n=this.tryFindCanvasGroup(e);if(n?.isCanvasGroup===!0&&(t&&(t.canvasGroup=n),n.blocksRaycasts===!1||n.interactable===!1))return!1;const r=Yu(e,s=>{if(s.isGraphic===!0)return s},!1);return t&&r?.isGraphic===!0&&(t.graphic=r),!(r?.raycastTarget===!1||r?.layer===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=Yu(e,n=>{const r=n;if(r.blocksRaycasts!==void 0&&r.interactable!==void 0)return r},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}function iI(i){return i[Qo]||(i.parent?iI(i.parent):null)}function zie(i){return i.isUI===!0||typeof i[Qo]=="object"}function q_(i,e){if(!i)return;const t=i.material;if(t?.isMaterial===!0){const n=i.parent;n&&n.isText,t.side=e.doubleSided??!0?li:cr,t.shadowSide=e.doubleSided?li:cr,i.castShadow=e.castShadows?e.castShadows:!1,i.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const n of i.children)q_(n,e)}function gf(i,e,t){i[e]===void 0&&console.warn("Field",e,"is undefined on",i);const n=Proxy.revocable(i[e],{set(o,a,l,c){const u=o[a],d=Reflect.set(o,a,l,c);return t(l,u),d}}),r=n.revoke,s=i[e];return n.revoke=()=>{i[e]=s,r()},i[e]=n.proxy,n}const c4=Symbol("Scheduled action");function jie(i,e,t=Fi.OnBeforeRender){let n=i[c4];n||(n=i[c4]={});const r=e.name;n[t]||(n[t]={});const s=n[t];if(s[r])return;function*o(){e?.call(i),s[r]=null}const a=i.startCoroutine(o(),t);s[r]=a}const nc=ee("debugeventsystem");var nI=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(nI||{});const rc=class extends Ie{constructor(){super(),h(this,"raycaster",[]),h(this,"_handleInputFn"),h(this,"pressedByID",new Map),h(this,"hoveredByID",new Map),h(this,"_sortedHits",[]),h(this,"_testObjectsCache",new Map),h(this,"_currentlyActiveRaycaster",null),h(this,"_currentPointerEventName",null),h(this,"shouldRaycastObject",i=>{var e;let t=null;if(zie(i)&&(t=(e=i[Qo])==null?void 0:e.gameObject),this._testObjectsCache.has(i)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(i)===!1?"continue in children":!0;{let n=tI(i,this._currentPointerEventName);if(!n&&t&&(n=tI(t,this._currentPointerEventName)),n){this._testObjectsCache.set(i,!0);for(const r of i.children)this.shouldRaycastObject_AddToYesCache(r);return!0}return this._testObjectsCache.set(i,!1),"continue in children"}}),h(this,"_sortingBuffer",[]),h(this,"_noDepthTestingResults",[]),h(this,"out",{}),h(this,"_capturedPointer",{}),h(this,"pointerEnterSymbol",Symbol("pointerEnter")),h(this,"pointerExitSymbol",Symbol("pointerExit")),h(this,"currentActiveMeshUIComponents",[]),rc.systems.push(this)}static createIfNoneExists(i){this.didSearchEventSystem||(this.didSearchEventSystem=!0,rc.systems.length<=0&&rc.systems.push(...re.findObjectsOfType(rc,i)));for(const t of rc.systems)if(t.context===i)return;const e=new ge;re.addNewComponent(e,rc),i.scene.add(e)}static get systems(){const i=Ot.Current;return this._eventSystemMap.has(i)||this._eventSystemMap.set(i,[]),this._eventSystemMap.get(i)}static get(i){const e=this._eventSystemMap.get(i);return e&&e.length>0?e[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(i,e,t=!1){yh.update(i,e,t)}static markUIDirty(i){yh.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){rc.systems.splice(rc.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!re.findObjectOfType(_v,this.context)){const i=re.addNewComponent(this.context.scene,no);this.raycaster.push(i),(ut()||nc)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(i){var e;i&&this.raycaster&&!this.raycaster.includes(i)&&((e=this.raycaster)==null||e.push(i))}unregister(i){var e,t;const n=(e=this.raycaster)==null?void 0:e.indexOf(i);n!==void 0&&n!==-1&&((t=this.raycaster)==null||t.splice(n,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(qi.PointerDown,this._handleInputFn),this.context.input.addEventListener(qi.PointerUp,this._handleInputFn),this.context.input.addEventListener(qi.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(qi.PointerDown,this._handleInputFn),this.context.input.removeEventListener(qi.PointerUp,this._handleInputFn),this.context.input.removeEventListener(qi.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(i){if(i===void 0||i.propagationStopped)return;const e=new dm(this.context.input,i);this._currentPointerEventName=i.type,e.inputSource=this.context.input,e.isClick=i.isClick,e.isDoubleClick=i.isDoubleClick,e.isDown=i.type==qi.PointerDown,e.isUp=i.type==qi.PointerUp,e.isPressed=this.context.input.getPointerPressed(i.pointerId),nc&&(e.isDown?console.log("DOWN",e.pointerId):e.isUp&&console.log("UP",e.pointerId),e.isClick&&console.log("CLICK",e.pointerId));const t=new jo;i.hasRay?t.ray=i.ray:t.screenPoint=this.context.input.getPointerPositionRC(i.pointerId);const n=this.performRaycast(t);if(n)for(const s of n)s.event=i,i.intersections.push(s);nc&&e.isClick&&Hi("EventSystem: "+e.pointerId+" - "+this.context.time.frame+" - Up:"+e.isUp+", Down:"+e.isDown);const r={sender:this,args:e,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:r})),this.handleIntersections(n,e),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:r}))}shouldRaycastObject_AddToYesCache(i){this._testObjectsCache.set(i,!0);for(const e of i.children)this.shouldRaycastObject_AddToYesCache(e)}performRaycast(i){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,i||(i=new jo),i.testObject=this.shouldRaycastObject;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;this._currentlyActiveRaycaster=e;const t=e.performRaycast(i);this._currentlyActiveRaycaster=null,t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.distance),this._sortedHits}assignHitInformation(i,e){e?(i.intersection=e,i.point=e.point,i.normal=e.normal,i.face=e.face,i.distance=e.distance,i.instanceId=e.instanceId):(i.intersection=void 0,i.point=void 0,i.normal=void 0,i.face=void 0,i.distance=void 0,i.instanceId=void 0)}handleIntersections(i,e){var t;if(i!=null&&i.length){i=this.sortCandidates(i);for(const r of i){if(e.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(e,r),this.handleEventOnObject(r.object,e))return!0}}this.assignHitInformation(e,i?.[0]),this.invokePointerCapture(e);const n=this.hoveredByID.get(e.pointerId);return n&&this.propagatePointerExit(n.obj,n.data,null),this.hoveredByID.delete(e.pointerId),e.isUp&&((t=this.pressedByID.get(e.pointerId))==null||t.handlers.forEach(r=>this.invokeOnPointerUp(e,r)),this.pressedByID.delete(e.pointerId)),!1}sortCandidates(i){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<i.length;e++){const t=i[e],n=t.object;if(n.material&&n.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEventOnObject(i,e){if(!this.testIsVisible(i))return e.isClick&&nc&&console.log("not allowed",i),!1;if(e.pointerId===void 0)return nc&&console.error("Event without pointer can't be handled",e),!1;e.object=i;const t=i.parent,n=e.isClick??!1;let r=null;if(t&&t.isUI){const l=(e.isPressed||e.isClick)??!1;if(t[Qo]){const c=t[Qo].gameObject;if(c){if(!W_.isInteractable(c,this.out))return!1;r=this.out.canvasGroup??null,this.handleMeshUIIntersection(i,l),i=c}}}n&&nc&&console.log(this.context.time.frame,i);const s=this.hoveredByID.get(e.pointerId),o=s?.obj;o!==i&&o&&this.propagatePointerExit(o,s.data,i);const a=this.hoveredByID.get(e.pointerId);if(a?(a.obj=i,a.data=e):this.hoveredByID.set(e.pointerId,{obj:i,data:e}),e.isDown){const l=this.pressedByID.get(e.pointerId);l?(l.obj=i,l.data=e):this.pressedByID.set(e.pointerId,{obj:i,data:e,handlers:new Set})}return(r===null||r.interactable)&&this.handleMainInteraction(i,e,o??null),!0}propagate(i,e){for(;i;)re.foreachComponent(i,t=>{e(t)},!1),i=i.parent}handleMainInteraction(i,e,t){const n=this.pressedByID.get(e.pointerId),r=t!==i;let s=!0;switch(e.event.pointerType){case"mouse":case"touch":const o=this.context.input.getPointerPositionLastFrame(e.pointerId),a=this.context.input.getPointerPosition(e.pointerId);s=o&&!Ze.approximately(o,a);break}this.propagate(i,o=>{var a;const l=o;l.interactable!==!1&&(!l.activeAndEnabled||!l.enabled||(l.onPointerEnter&&r&&this.handlePointerEnter(l,e),e.isDown&&l.onPointerDown&&(l.onPointerDown(e),n?.handlers.add(l),this.handlePointerCapture(e,l)),l.onPointerMove&&(s&&l.onPointerMove(e),this.handlePointerCapture(e,l)),e.isUp&&(l.onPointerUp&&(this.invokeOnPointerUp(e,l),n?.handlers.delete(l)),l.onPointerExit&&((a=e.event)==null?void 0:a.pointerType)===r_.Touch&&(this.handlePointerExit(l,e),this.hoveredByID.delete(e.pointerId))),e.isClick&&l.onPointerClick&&l.onPointerClick(e)))}),e.isUp&&(n?.handlers.forEach(o=>{this.invokeOnPointerUp(e,o)}),this.pressedByID.delete(e.pointerId))}propagatePointerExit(i,e,t){this.propagate(i,n=>{if(!n.gameObject||n.destroyed)return;const r=n;if(r.onPointerExit){if(t&&this.isChild(t,n.gameObject))return;this.handlePointerExit(r,e)}})}invokeOnPointerUp(i,e){var t;(t=e.onPointerUp)==null||t.call(e,i),this.releasePointerCapture(i,e)}handlePointerEnter(i,e){i.onPointerEnter&&this.updatePointerState(i,e.pointerId,this.pointerEnterSymbol,!0)&&i.onPointerEnter(e),this.updatePointerState(i,e.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(i,e){i.onPointerExit&&this.updatePointerState(i,e.pointerId,this.pointerExitSymbol,!0)&&i.onPointerExit(e),this.updatePointerState(i,e.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(i,e,t,n){let r=i[t];if(n)return r&&r.includes(e)?!1:(r=r||[],r.push(e),i[t]=r,!0);{if(!r||!r.includes(e))return!1;const s=r.indexOf(e);return s!==-1&&r.splice(s,1),!0}}handlePointerCapture(i,e){if(i.z__pointer_ctured){i.z__pointer_ctured=!1;const t=i.pointerId;if(e.onPointerMove){const n=this._capturedPointer[t]||[];n.push(e),this._capturedPointer[t]=n}else ut()&&!e.z__warned_no_pointermove&&(e.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else i.z__pointer_cture_rleased&&(i.z__pointer_cture_rleased=!1,this.releasePointerCapture(i,e))}releasePointerCapture(i,e){const t=i.pointerId;if(this._capturedPointer[t]){const n=this._capturedPointer[t].indexOf(e);n!==-1&&(this._capturedPointer[t].splice(n,1),nc&&console.log("released pointer capture",t,e,this._capturedPointer))}}invokePointerCapture(i){var e;if(i.event.type===qi.PointerMove){const t=i.pointerId,n=this._capturedPointer[t];if(n){nc&&console.log("Captured",t,n);for(let r=0;r<n.length;r++){const s=n[r];if(s.destroyed){n.splice(r,1),r--;continue}(e=s.onPointerMove)==null||e.call(s,i)}}}}isChild(i,e){return!i||!e?!1:i===e?!0:i.parent?this.isChild(i.parent,e):!1}handleMeshUiObjectWithoutShadowDom(i,e){return!i||!i.isUI?!0:this.handleMeshUIIntersection(i,e)}handleMeshUIIntersection(i,e){const t=yh.updateState(i,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&yh.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let i=0;i<this.currentActiveMeshUIComponents.length;i++){const e=this.currentActiveMeshUIComponents[i];yh.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(i){return i?re.isActiveSelf(i)?this.testIsVisible(i.parent):!1:!0}};let Ho=rc;h(Ho,"_eventSystemMap",new Map),h(Ho,"didSearchEventSystem",!1);class yh{static markDirty(){this.needsUpdate=!0}static update(e,t,n=!1){if(n){e.update();return}const r=t.time.frameCount;for(const s of this.lastUpdateFrame)if(s.context===t){if(r===s.frame)return;s.frame=r;let o=this.needsUpdate||r<1;s.nextUpdate===t.time.frameCount&&(o=!0),o&&(nc&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:r,nextUpdate:r}],e.update()}static updateState(e,t){let n=null;if(e&&(n=this.findBlockInParent(e),n&&n!==this.lastSelected)){if(n.interactable===!1)return null;this.needsUpdate=!0}return n}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}h(yh,"lastSelected",null),h(yh,"lastUpdateFrame",[]),h(yh,"needsUpdate",!1);var Gie=Object.defineProperty,Qie=Object.getOwnPropertyDescriptor,fn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Qie(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Gie(e,t,r),r};const Hie=ee("debugorbit"),X_=ee("freecam"),wv=ee("debugcamerafit"),Y_=ee("smoothcam"),Vie={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let rI;class Sv extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class bi extends Ie{constructor(){super(...arguments),h(this,"autoTarget",!0),h(this,"autoFit",!1),h(this,"enableRotate",!0),h(this,"autoRotate",!1),h(this,"autoRotateSpeed",1),h(this,"minAzimuthAngle",1/0),h(this,"maxAzimuthAngle",1/0),h(this,"minPolarAngle",0),h(this,"maxPolarAngle",Math.PI),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,"_controls",null),h(this,"_cameraObject",null),h(this,"_lookTargetLerpActive",!1),h(this,"_lookTargetStartPosition",new S),h(this,"_lookTargetEndPosition",new S),h(this,"_lookTargetLerp01",0),h(this,"_lookTargetLerpDuration",0),h(this,"_cameraLerpActive",!1),h(this,"_cameraStartPosition",new S),h(this,"_cameraEndPosition",new S),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,"_didSetTarget",!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(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didStart=!1,this._didSetTarget=!1,this._startedListeningToKeyEvents=!1}start(){this._didStart=!0,this._eventSystem=Ho.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(nI.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(nI.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=re.getComponent(this.gameObject,Bi);this._camera=e;let t=e?.cam;if(!t&&this.gameObject instanceof Ut&&(t=this.gameObject),t&&YT(t,this,!0),!this._controls&&t instanceof Ut){this._cameraObject=t;const n=this.targetElement??this.context.renderer.domElement,r=t?.quaternion.clone();this._controls=new gie(t,n),t?.quaternion.copy(r),rI===void 0&&(rI={...this._controls.keys})}this._controls&&(X_&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Js()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?X_||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):X_||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=re.getComponent(this.gameObject,Ah)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&YT(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var e,t;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}this._controls.enabled=!0,this.__handleSetTargetWhenBecomingActiveTheFirstTime(),(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&(e=this.context.input.getPointerPositionDelta(0))!=null&&e.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 n=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(n||(n=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),n&&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 Sv(this,"camera"));else{const r=Ze.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 Sv(this,"lookat"));else{const r=Ze.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?rI: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,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,typeof Y_=="number"||Y_===!0){this._controls.enableDamping=!0;const r=typeof Y_=="number"?Y_:.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||(!X_&&(t=this.lookAtConstraint)!=null&&t.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),Hie&&yt.DrawWireSphere(this._controls.target,.1,65280))}}__handleSetTargetWhenBecomingActiveTheFirstTime(){if(!this._didSetTarget&&(this._didSetTarget=!0,this.autoTarget)){const e=re.getComponent(this.gameObject,Bi);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const t=Pt(e.cam).length(),n=new S(0,0,-t).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(n,!0)}if(!this.autoFit&&!this.setLookTargetFromConstraint()){const t=new jo;t.screenPoint=new $(0,0),t.lineThreshold=.1;const n=this.context.physics.raycast(t);n.length>0&&this.setLookTargetPosition(n[0].point,!0),wv&&console.log("OrbitControls hits",...n)}this.autoFit&&this.fitCamera()}}setCameraAndLookTarget(e){if(!e||!(e instanceof ge))return;const t=Pt(e),n=EE(e);this.setTargetFromRaycast(new Ds(t,n)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var n,r;e&&(e instanceof ge&&(e=Pt(e)),this._cameraEndPosition||(this._cameraEndPosition=new S),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(n=this.controllerObject)==null||n.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((r=this._cameraObject)==null?void 0:r.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof ge&&(e=Pt(e)),this._lookTargetEndPosition.copy(e),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var n;if(!this._controls)return!1;const r=(n=this.lookAtConstraint)==null?void 0:n.sources;if(r&&r.length>0){const s=r[e];if(s)return s.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const n of t)if(n.distance>0&&re.isActiveInHierarchy(n.object)){const r=iI(n.object);if(r){const s=r.canvas;if(s!=null&&s.screenspace)break}this.setLookTargetPosition(n.point);break}}fitCamera(e,t=void 0,n=!0){if(this.context.isInXR)return;t==null&&(t=1.1);const r=this._cameraObject,s=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0){console.warn("No objects to fit camera to...");return}if(!r||!s){console.warn("No camera or controls found to fit camera to objects...");return}const o=new S,a=new S,l=new fi;l.makeEmpty();const c=[];function u(E){let I=!0;if(E.visible&&t4(E)!==!1&&!(E.type==="TransformControlsGizmo"||E.type==="TransformControlsPlane")&&(E instanceof EC&&(I=!1),E instanceof Xy&&(I=!1),E instanceof $N&&(I=!1),E.material instanceof Oy&&(I=!1),E instanceof ue||(I=!1),E!==r&&E.isUI!==!0)){if(I){wv&&console.log(E.name,E.type,E);const T=E.children;E.children=c;const M=E.position,D=E.scale;if(Number.isNaN(M.x)||Number.isNaN(M.y)||Number.isNaN(M.z)){console.warn(`Object "${E.name}" has NaN values in position or scale.... will ignore it`,M,D);return}l.expandByObject(E,!0),E.children=T}for(const T of E.children)u(T)}}let d=!1;for(const E of e)E&&(d=!0,E.updateMatrixWorld(),u(E));if(!d){console.warn("No objects to fit camera to...");return}if(r.updateMatrixWorld(),r.updateProjectionMatrix(),l.getCenter(a),l.applyMatrix4(r.matrixWorldInverse),l.getSize(o),l.setFromCenterAndSize(a,o),Number.isNaN(o.x)||Number.isNaN(o.y)||Number.isNaN(o.z)){console.warn("Camera fit size resultet in NaN",r,l,[...e]);return}if(o.length()<=1e-10){wv&&console.warn("Camera fit size is zero",l,[...e]);return}const p=r.fov,f=2*Math.atan(Math.tan(p*Math.PI/360/2)*r.aspect)/Math.PI*360,m=o.y/(2*Math.atan(Math.PI*p/360)),A=o.x/(2*Math.atan(Math.PI*f/360)),v=t*Math.max(m,A)+o.z/2;wv&&console.log("Fit camera to objects",m,A,"distance",v),s.maxDistance=v*10,s.minDistance=v*.01;const g=.05,y=a.clone();y.y-=o.y*g,this.setLookTargetPosition(y,n),this.autoTarget=!1,r.near=v/1e3,r.far=v*100,r.updateMatrixWorld(),r.updateProjectionMatrix();const b=Pt(r),_=a.clone();if(_.sub(b),_.y=0,_.normalize(),_.multiplyScalar(v),_.y+=-g*4*o.y,r.parent){const E=r.parent.worldToLocal(a.clone().sub(_));this.setCameraTargetPosition(E,n)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(wv){const E=new EC(l);this.context.scene.add(E),IE(E,mg(r)),setTimeout(()=>{this.context.scene.remove(E)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",I=>{I.code==="KeyF"&&this.fitCamera(e,t,n)}))}s.update()}}fn([x()],bi.prototype,"autoTarget",2),fn([x()],bi.prototype,"autoFit",2),fn([x()],bi.prototype,"enableRotate",2),fn([x()],bi.prototype,"autoRotate",2),fn([x()],bi.prototype,"autoRotateSpeed",2),fn([x()],bi.prototype,"minAzimuthAngle",2),fn([x()],bi.prototype,"maxAzimuthAngle",2),fn([x()],bi.prototype,"minPolarAngle",2),fn([x()],bi.prototype,"maxPolarAngle",2),fn([x()],bi.prototype,"enableKeys",2),fn([x()],bi.prototype,"enableDamping",2),fn([x()],bi.prototype,"dampingFactor",2),fn([x()],bi.prototype,"enableZoom",2),fn([x()],bi.prototype,"minZoom",2),fn([x()],bi.prototype,"maxZoom",2),fn([x()],bi.prototype,"enablePan",2),fn([x(ed)],bi.prototype,"lookAtConstraint",2),fn([x()],bi.prototype,"lookAtConstraint01",2),fn([x()],bi.prototype,"allowInterrupt",2),fn([x()],bi.prototype,"middleClickToFocus",2),fn([x()],bi.prototype,"doubleClickToFocus",2),fn([x()],bi.prototype,"targetLerpDuration",2);var Wie=Object.defineProperty,qie=Object.getOwnPropertyDescriptor,Fs=(i,e,t,n)=>{for(var r=n>1?void 0:n?qie(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Wie(e,t,r),r},id=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(id||{});const sc=ee("debugcam"),h4=ee("debugscreenpointtoray");var J_;const Cv=(J_=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",0),h(this,"_backgroundIntensity",1),h(this,"_environmentIntensity"),h(this,"_targetTexture",null),h(this,"_backgroundColor"),h(this,"_fov"),h(this,"_cam",null),h(this,"_clearFlags",2),h(this,"_skybox"),h(this,"_frustum"),h(this,"_projScreenMatrix",new Ce)}get isCamera(){return!0}get aspect(){return this._cam instanceof Ut?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(i){this._cam instanceof Ut&&this._cam.aspect!==i&&(this._cam.aspect=i,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof Ut?this._cam.fov:this._fov}set fieldOfView(i){const e=this.fieldOfView!=i;if(this._fov=i,e&&this._cam&&this._cam instanceof Ut){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(i){const e=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&e&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const e=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&e&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(i){this.cullingMask=(1<<i|0)>>>0}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(i){this._environmentIntensity=i}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,e,t){const n=this.cam,r=Cv._origin;r.set(i,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),h4&&console.log("screenPointToRay",i.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(n);const s=Cv._direction.set(r.x,r.y,r.z),o=Pt(n);return s.sub(o),s.normalize(),t?(t.set(o,s),t):new Ds(o.clone(),s.clone())}getFrustum(){return this._frustum||(this._frustum=new lu,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new lu),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(i,e){return e&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),i===this._projScreenMatrix?i:i.copy(this._projScreenMatrix)}awake(){h4&&window.addEventListener("pointerdown",i=>{const e=i.clientX,t=i.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const n=this.screenPointToRay(e,t),r="#"+Math.floor(Math.random()*16777215).toString(16);yt.DrawRay(n.origin,n.direction,r,10)})}onEnable(){sc&&console.log(`Camera enabled: "${this.name}". ClearFlags=${id[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Yie(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),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 i=this.context.renderer;if(i){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,i),e?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let e=null;if(i?(e=this.gameObject,e?.layers.enableAll(),e instanceof Ut&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Ut&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Ut(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new Ll(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){sc&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,sc){const i=`Camera "${this.name}" clear flags: ${id[this._clearFlags]}`;console.debug(i)}switch(this._clearFlags){case 1:if(Cv.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:sc&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0?this.context.scene.backgroundIntensity=this._backgroundIntensity:sc&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;Cv.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,i)}else sc&&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 Xie(this)),this._skybox.enable()}static backgroundShouldBeTransparent(i){var e,t,n,r;const s=(e=i.renderer.xr)==null?void 0:e.getSession();if(!s)return!1;if(typeof s._transparent=="boolean")return s._transparent;const o=s.environmentBlendMode;sc&&Hi("Environment blend mode: "+o+" on "+navigator.userAgent);let a=o==="additive"||o==="alpha-blend";return i.isInAR&&o==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(n=navigator.userAgent)!=null&&n.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))&&(a=!0),s._transparent=a,a}},h(J_,"_origin",new S),h(J_,"_direction",new S),J_);let Bi=Cv;Fs([x()],Bi.prototype,"aspect",1),Fs([x()],Bi.prototype,"fieldOfView",1),Fs([x()],Bi.prototype,"nearClipPlane",1),Fs([x()],Bi.prototype,"farClipPlane",1),Fs([x()],Bi.prototype,"clearFlags",1),Fs([x()],Bi.prototype,"orthographic",2),Fs([x()],Bi.prototype,"orthographicSize",2),Fs([x()],Bi.prototype,"ARBackgroundAlpha",2),Fs([x()],Bi.prototype,"cullingMask",1),Fs([x()],Bi.prototype,"backgroundBlurriness",1),Fs([x()],Bi.prototype,"backgroundIntensity",1),Fs([x()],Bi.prototype,"environmentIntensity",1),Fs([x(yi)],Bi.prototype,"backgroundColor",1),Fs([x(pf)],Bi.prototype,"targetTexture",1);class Xie{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&&(sc&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Co,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)),(sc||ut())&&$i(`Camera "${this._camera.name}" has no skybox texture`))}}function Yie(i){ee("freecam")&&i.context.mainCameraComponent===i&&re.getOrAddComponent(i.gameObject,bi)}class bh extends Ie{constructor(){super(...arguments),h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new tk),this._listener}awake(){en.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||re.getComponentInParent(this.gameObject,Bi);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var Jie=Object.defineProperty,Kie=Object.getOwnPropertyDescriptor,K_=(i,e,t,n)=>{for(var r=n>1?void 0:n?Kie(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Jie(e,t,r),r};const Zie=ee("debugsignals");class Ev{constructor(){h(this,"guid")}}K_([x()],Ev.prototype,"guid",2);class vf{constructor(){h(this,"signal"),h(this,"reaction")}}K_([x(Ev)],vf.prototype,"signal",2),K_([x(Hn)],vf.prototype,"reaction",2);var sI;const oc=(sI=class extends Ie{constructor(){super(...arguments),h(this,"events")}static invoke(i){if(oc.receivers[i]){const e=oc.receivers[i];if(!e)return;for(const t of e)t.invoke(i)}}awake(){Zie&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)oc.receivers[i.signal.guid]||(oc.receivers[i.signal.guid]=[]),oc.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if(oc.receivers[i.signal.guid]){const e=oc.receivers[i.signal.guid].indexOf(this);e>=0&&oc.receivers[i.signal.guid].splice(e,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;const e=typeof i=="object"?i.guid:i;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(n){console.error(n)}}},h(sI,"receivers",{}),sI);let Af=oc;K_([x(vf)],Af.prototype,"events",2);var ro=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(ro||{}),Za=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Za||{}),oI=(i=>(i.Signal="SignalEmitter",i))(oI||{});const $a=ee("debugtimeline");class Mv{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 n=this.track.clips.length-1;n>=0;n--)yield this.track.clips[n];else for(const n of this.track.clips)yield n}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,n,r=!0){if(t<0||t>=n.length)return 0;const s=n[t];if(r||e>=s.start&&e<=s.end){let o=1;const a=!1;if(s.easeInDuration>0){const l=Math.min((e-s.start)/s.easeInDuration,1);o*=l}if(s.easeOutDuration>0&&!a){const l=Math.min((s.end-e)/s.easeOutDuration,1);o*=l}return o}return 0}}class $ie{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 n=e.getRoot(),r=n.name+".position",s=n.name+".quaternion";$a&&console.log(t.name,t.tracks,r);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(r))this.rootStartPosition=new S().fromArray(o.values,0),this.rootEndPosition=new S().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),$a&&console.log(this.rootPositionOffset);else if(o.name.endsWith(s)&&(this.rootStartQuaternion=new Me().fromArray(o.values,0),this.rootEndQuaternion=new Me().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),$a)){const a=new Ni().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Z_ extends Mv{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 S),h(this,"_totalOffsetRotation",new Me),h(this,"_totalOffsetPosition2",new S),h(this,"_totalOffsetRotation2",new Me),h(this,"_summedPos",new S),h(this,"_tempPos",new S),h(this,"_summedRot",new Me),h(this,"_tempRot",new Me),h(this,"_clipRotQuat",new Me)}onDisable(){var e;(e=this.mixer)==null||e.stopAllAction()}onStateChanged(){this._animator&&u4(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var n,r;if(((n=t.tracks)==null?void 0:n.length)<=0){console.warn("No tracks in AnimationClip",t);return}const s=t.tracks[0].name.split("."),o=s[s.length-2],a=o+".position",l=o+".quaternion";let c=!1,u=!1;for(const d of t.tracks)d.name.endsWith(a)?(c=!0,this.createPositionInterpolant(t,e,d)):d.name.endsWith(l)&&(u=!0,this.createRotationInterpolant(t,e,d));if(!c||!u){const d=(r=this.mixer)==null?void 0:r.getRoot(),p=t.tracks[0],f=p.name.lastIndexOf("."),m=p.name.substring(0,f),A=m.substring(m.lastIndexOf(".")+1),v=d.getObjectByName(A);if(v)if(c){if(!u){const g=t.tracks[0].name.substring(0,f)+".quaternion";$a&&console.warn("Create quaternion track",A,v);const y=v.quaternion,b=new Ua(g,[0,t.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);t.tracks.push(b),this.createRotationInterpolant(t,e,b)}}else{const g=m+".position";$a&&console.warn("Create position track",A,v);const y=v.position,b=new Fl(g,[0,t.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);t.tracks.push(b),this.createPositionInterpolant(t,e,b)}}}bind(){if(!this._didBind){this._didBind=!0,$a&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new $ie(e);this._actionOffsets.push(t)}this.target&&(this._animator=re.getComponent(this.target,Cr)??null,this._animator&&u4(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,n=t.position,r=t.rotation;n&&n.x!==void 0&&(n.isVector3||(t.position=new S(n.x,n.y,n.z)),r.isQuaternion||(t.rotation=new Me(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new S(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Me(t.x,t.y,t.z,t.w)))}}evaluate(e){var t,n,r,s,o,a,l;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 c=0,u=0,d=!1,p=!1,f=0;for(let m=0;m<this.clips.length;m++){const A=this.models[m],v=this.actions[m],g=A.asset;v.weight=0;const y=e>=A.start&&e<=A.end,b=A.preExtrapolationMode,_=A.postExtrapolationMode,E=m<this.clips.length-1?this.models[m+1]:null;let I=y,T=!1;if(!I&&!d&&A.end<e&&_!==Za.None?(!E||E.start>e)&&(I=!0,d=!0):m==0&&!I&&!p&&A.start>e&&b!==Za.None&&(!E||E.start<e)&&(I=!0,T=!0,p=!0),I){let M=1;M*=this.evaluateWeight(e,m,this.models,I),M*=this.director.weight;let D=y;if(T)switch(b){case Za.Hold:break;case Za.Loop:e+=A.start,D=!0;break;default:e+=A.start,D=!0;break}let C=this.getClipTime(e,A),P=0;const j=g.duration;if(T&&b===Za.Hold&&(C=0),D){if(g.loop)for(P+=Math.floor(C/(j+1e-6));C>j;)C-=j}else if(!y&&d)switch(_){case Za.Hold:C=this.getClipTime(A.end,A);break;case Za.Loop:C%=j;break;case Za.PingPong:const O=Math.floor(C/j)%2!==0;C%=j,O&&(C=j-C);break}A.reversed===!0?v.time=v.getClip().duration-C:v.time=C,v.timeScale=0;const Q=Math.max(0,M);if(v.weight=Q,f+=Q,v.clampWhenFinished=!1,v.isRunning()||v.play(),this._useclipOffsets){const O=c==0?this._totalOffsetPosition:this._totalOffsetPosition2,W=c==0?this._totalOffsetRotation:this._totalOffsetRotation2;c<1&&(u=1-M),c+=1;const L=this._summedPos.set(0,0,0),F=this._tempPos.set(0,0,0),z=this._summedRot.identity(),Z=this._tempRot.identity(),K=g.rotation;K&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(K,M));const se=this._actionOffsets[m];if(se.hasOffsets)for(let Ae=0;Ae<P;Ae++)se.rootPositionOffset?F.copy(se.rootPositionOffset):F.set(0,0,0),F.applyQuaternion(z),this._clipRotQuat&&F.applyQuaternion(this._clipRotQuat),se.rootQuaternionOffset&&(Z.copy(se.rootQuaternionOffset),z.multiply(Z)),L.add(F);this._clipRotQuat&&W.multiply(this._clipRotQuat),W.multiply(z),g.position&&L.add(g.position),O.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,u),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,u)),this.__mixerError===void 0&&($a||ut())&&(n=(t=this._animator)==null?void 0:t.runtimeAnimatorController)!=null&&n.mixer&&this.mixer!==((s=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:s.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)),(o=this._animator)!=null&&o.runtimeAnimatorController){const m=Math.max(0,1-f);(l=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null||l.update(m)}else this.mixer.update(e)}createRotationInterpolant(e,t,n){var r;const s=n.createInterpolant.bind(n),o=new Me;this.ensureTrackOffsets();const a=(r=this.trackOffset)==null?void 0:r.rotation;n.createInterpolant=()=>{const l=s(),c=l.evaluate.bind(l);return l.evaluate=u=>{var d;const p=c(u);if(o.set(p[0],p[1],p[2],p[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const f of this.director.animationCallbackReceivers)(d=f?.onTimelineRotation)==null||d.call(f,this.director,this.target,u,o);return p[0]=o.x,p[1]=o.y,p[2]=o.z,p[3]=o.w,p},l}}createPositionInterpolant(e,t,n){var r,s;const o=n.createInterpolant.bind(n),a=new S;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation,c=(s=this.trackOffset)==null?void 0:s.position;let u;n.createInterpolant=()=>{const d=o(),p=d.evaluate.bind(d);return d.evaluate=f=>{var m,A,v;const g=p(f);if(a.set(g[0],g[1],g[2]),t.removeStartOffset&&(u===void 0?(u=null,u=(A=(m=this._actionOffsets.find(y=>y.clip===e))==null?void 0:m.rootStartPosition)==null?void 0:A.clone()):u!=null&&u.isVector3&&a.sub(u)),a.applyQuaternion(this._totalOffsetRotation),a.add(this._totalOffsetPosition),l&&a.applyQuaternion(l),c&&(a.x-=c.x,a.y+=c.y,a.z+=c.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(v=y?.onTimelinePosition)==null||v.call(y,this.director,this.target,f,a);return g[0]=a.x,g[1]=a.y,g[2]=a.z,g},d}}}const ene=ee("mutetimeline"),Tv=class extends Mv{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),h(this,"_playableDirectorResumed",!1)}getAudioFilePath(i){const e=this.director.sourceId;return jl(e,i)}onAllowAudioChanged(i){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(i?t.asset.volume:0)}}addModel(i){const e=new AC(this.listener);this.audio.push(e);const t=i;t._didTriggerPlay=!1,this.models.push(t)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop();for(const i of this.models)i._didTriggerPlay=!1}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}for(const i of this.models)i._didTriggerPlay=!1}onPauseChanged(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(i){if(ene||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=this._playableDirectorResumed;this._playableDirectorResumed=!1;const n=e?.1:0;for(let r=0;r<this.models.length;r++){const s=this.models[r],o=this.audio[r],a=s.asset;if((!o||!o.buffer)&&this.isInTimeRange(s,i-1,i+1)&&this.handleAudioLoading(s,o),en.userInteractionRegistered!==!1&&!(o===null||!o.buffer))if(o.playbackRate=this.director.context.time.timeScale*this.director.speed,o.loop=a.loop,i>=s.start&&i<=s.end&&i<this.director.duration){if(!o.isPlaying||!this.director.isPlaying)(t||!s._didTriggerPlay&&this.lastTime<i)&&(s.duration*s.timeScale>.3?o.offset=s.clipIn+(i-s.start)*s.timeScale:o.offset=0,$a&&console.log("Timeline Audio ("+this.track.name+") play with offset "+o.offset+" - "+s.asset.clip),o.play(n),s._didTriggerPlay=!0);else{const c=s.clipIn+(i-s.start)*s.timeScale,u=o.context.currentTime-o._startedAt+o.offset;Math.abs(c-u)>.3&&(o.offset=c,o.stop(),o.play(n))}let l=a.volume;if(this.track.volume!==void 0&&(l*=this.track.volume),e&&(l=0),s.easeInDuration>0){const c=Math.min((i-s.start)/s.easeInDuration,1);l*=c}if(s.easeOutDuration>0){const c=Math.min((s.end-i)/s.easeOutDuration,1);l*=c}o.setVolume(l*this.director.weight)}else s._didTriggerPlay=!1,this.director.isPlaying&&o.isPlaying&&o.stop()}this.lastTime=i}loadAudio(i,e=0,t=0){let n=null;const r=i-t,s=i+e;for(const o of this.models)if(this.isInTimeRange(o,r,s)){const a=this.audio[this.models.indexOf(o)],l=this.handleAudioLoading(o,a);l!==null&&(n===null&&(n=[]),n.push(l))}return n!==null?Promise.all(n):null}isInTimeRange(i,e,t){return e<=i.start&&t>=i.end||e>=i.start&&e<=i.end||t>=i.start&&t<=i.end}static dispose(){Tv._audioBuffers.clear()}handleAudioLoading(i,e){this._audioLoader||(this._audioLoader=new Qy);const t=this.getAudioFilePath(i.asset.clip);if(Tv._audioBuffers.get(t)){const r=Tv._audioBuffers.get(t);return r.then(s=>{s&&e.setBuffer(s)}),r}$a&&console.warn("LOAD audio track",t,this.director.sourceId);const n=new Promise((r,s)=>{this._audioLoader.load(t,o=>{e.setBuffer(o),r(o)},void 0,o=>{console.error("Error loading audio",o),r(null)})});return Tv._audioBuffers.set(t,n),n}};let Iv=Tv;h(Iv,"_audioBuffers",new Map);class Rv extends Mv{constructor(){super(...arguments),h(this,"models",[]),h(this,"didTrigger",[]),h(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const n=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const s=this.models[r],o=this.didTrigger[r],a=s.time-e;let l=!1;if(s.retroActive)l=a<=1e-6;else{const c=Math.abs(a);(c===0||c>=1e-5&&c<n)&&(l=!0)}if(l){if(!o)if($a&&console.log("Trigger signal",e,s.time,s),this.didTrigger[r]=!0,((t=this.receivers)==null?void 0:t.length)<=0)Af.invoke(s.asset);else for(const c of this.receivers)c&&c.invoke(s.asset)}else s.emitOnce||(this.didTrigger[r]=!1)}}}class $_ extends Mv{constructor(){super(...arguments),h(this,"models",[]),h(this,"timelines",[]),h(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const n=this.models[t].asset;if(!n.sourceObject||typeof n.sourceObject!="object"){console.log("no source object, removing model",t,n),this.models.splice(t,1);continue}else{const r=re.getComponent(n.sourceObject,nd);this.timelines.push(r),r&&n.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let n=0;n<this.models.length;n++){const r=this.models[n],s=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const o=this.getClipTime(e,r);if(s.controlActivation){const a=s.sourceObject;a.visible=!0}if(s.updateDirector){const a=this.timelines[n];a&&(a.isPlaying&&a.pause(),a.time=o,a.evaluate())}}else{const o=(t=this._previousActiveModel)==null?void 0:t.asset;if(s.controlActivation){const a=s.sourceObject;o?.sourceObject!==a&&(a.visible=!1)}}}}}const yf=ee("debugtimeline"),aI=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(i,e){this.createTrackFunctions[i]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(yf||Qs())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,e,t;yf&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var i,e,t;for(const n of this._audioTracks)(i=n.onEnable)==null||i.call(n);for(const n of this._customTracks)(e=n.onEnable)==null||e.call(n);for(const n of this._animationTracks)(t=n.onEnable)==null||t.call(n);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var i,e,t;this.stop();for(const n of this._audioTracks)(i=n.onDisable)==null||i.call(n);for(const n of this._customTracks)(e=n.onDisable)==null||e.call(n);for(const n of this._animationTracks)(t=n.onDisable)==null||t.call(n);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const e of this._allTracks)for(const t of e)(i=t.onDestroy)==null||i.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,i&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const e=[];for(const t of this._audioTracks){const n=t.loadAudio(this._time,1,0);n&&e.push(n)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!en.userInteractionRegistered&&this.waitForAudio;)await ua(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Fi.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.stop();const i=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&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 i of this._allTracks)for(const e of i)yield e}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onPauseChanged)==null||i.call(e)}invokeStateChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onStateChanged)==null||i.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(i=!1){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}const t=this._time;for(const n of this.playableAsset.tracks)if(!n.muted)switch(n.type){case ro.Activation:if(!i&&!this._isPlaying)continue;for(let r=0;r<n.outputs.length;r++){const s=n.outputs[r];if(typeof s=="object"){let o=!1;if(n.clips)for(const l of n.clips)l.start<=t&&t<=l.end&&(o=!0);const a=s;a.visible!==void 0&&a.visible!==o&&(a.visible=o,yf&&console.warn(this.name,"set ActivationTrack-"+r,a.name,o,t))}}break}if(!this._isStopping)for(const n of this._animationTracks)n.evaluate(t);for(const n of this._audioTracks)n.evaluate(t);for(const n of this._signalTracks)n.evaluate(t);for(const n of this._controlTracks)n.evaluate(t);for(const n of this._customTracks)n.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=og(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let n=e.outputs[t];if(typeof n=="string"){this._guidsMap&&this._guidsMap[n]&&(n=this._guidsMap[n]);const r=re.findByGuid(n,i);r===null||typeof r!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",n,e.name,e.type)):(yf&&console.log("Resolved binding",n,"to",r),e.outputs[t]=r)}else if(n===null){if(e.outputs.splice(t,1),aI.createTrackFunctions[e.type])continue;e.type!==ro.Audio&&e.type!==ro.Control&&e.type!==ro.Marker&&e.type!==ro.Signal&&console.warn("Missing binding",n,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===ro.Control&&e.clips)for(let t=0;t<e.clips.length;t++){const n=e.clips[t];let r=n.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const s=re.findByGuid(r,i);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,n):(yf&&console.log("Resolved binding",r,"to",s),n.asset.sourceObject=s)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){if(i.clips)for(const e of i.clips)e.end>this._duration&&(this._duration=e.end);if(i.markers)for(const e of i.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var i,e,t;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let n=re.findObjectOfType(bh,this.context);for(const r of this.playableAsset.tracks){const s=r.type,o=aI.createTrackFunctions[s];if(o!=null){const a=o(this,r);if(typeof a.evaluate=="function"){a.director=this,a.track=r,this._customTracks.push(a);continue}}if(r.type===ro.Animation){if(!r.clips||r.clips.length<=0){yf&&console.warn("Animation track has no clips",r);continue}for(let a=r.outputs.length-1;a>=0;a--){let l=r.outputs[a];if(l instanceof ge){const u=re.getOrAddComponent(l,Cr);u&&(l=u)}const c=(i=l?.gameObject)==null?void 0:i.animations;if(c){const u=new Z_;u.trackOffset=r.trackOffset,u.director=this,u.track=r;for(let d=0;d<r.clips.length;d++){const p=r.clips[d],f=p.asset;if(!f){console.error(`Timeline ${this.name}: clip #${d} on track "${r.name}" has no animation data`);continue}const m=f.clip;let A=m;if((typeof A=="string"||typeof A=="number")&&(A=c.find(g=>g.name===m)),!A){console.warn("Could not find animationClip for model",p,r.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}l instanceof Cr&&l.runtimeAnimatorController&&(l.__internalDidAwakeAndStart||l.initializeRuntimeAnimatorController(),l.runtimeAnimatorController.mixer||l.runtimeAnimatorController.bind(l),u.mixer=l.runtimeAnimatorController.mixer),u.mixer||(u.mixer=new Hy(l.gameObject)),u.clips.push(A),u.mixer.uncacheAction(A),u.createHooks(p.asset,A);const v=u.mixer.clipAction(A);u.actions.push(v),u.models.push(p)}this._animationTracks.push(u)}}}else if(r.type===ro.Audio){if(!r.clips||r.clips.length<=0)continue;const a=new Iv;a.director=this,a.track=r,a.audioSource=r.outputs.find(l=>l instanceof en),this._audioTracks.push(a),n||(n=(t=this.context.mainCameraComponent)==null?void 0:t.gameObject.addNewComponent(bh)),a.listener=n.listener;for(let l=0;l<r.clips.length;l++){const c=r.clips[l];a.addModel(c)}}else if(r.type===ro.Marker){const a=new Rv;if(a.director=this,a.track=r,r.markers)for(const l of r.markers)switch(l.type){case oI.Signal:a.models.push(l),a.didTrigger.push(!1);break}if(a!==null&&a.models.length>0){const l=re.getComponent(this.gameObject,Af);l&&(a.receivers.push(l),this._signalTracks.push(a))}}else if(r.type===ro.Signal){const a=new Rv;if(a.director=this,a.track=r,r.markers)for(const l of r.markers)a.models.push(l),a.didTrigger.push(!1);for(const l of r.outputs)a.receivers.push(l);this._signalTracks.push(a)}else if(r.type===ro.Control){const a=new $_;if(a.director=this,a.track=r,r.clips)for(const l of r.clips)a.models.push(l);a.resolveSourceObjects(this.context),this._controlTracks.push(a)}}}setAudioTracksAllowPlaying(i){for(const e of this._audioTracks)e.onAllowAudioChanged(i)}registerAnimationCallback(i){this.animationCallbackReceivers.push(i)}unregisterAnimationCallback(i){const e=this.animationCallbackReceivers.indexOf(i);e!==-1&&this.animationCallbackReceivers.splice(e,1)}};let nd=aI;h(nd,"createTrackFunctions",{});const ex=Symbol("objectIsAnimatedData");function u4(i,e,t){if(!i)return;if(i[ex]===void 0){if(!t)return;i[ex]=new Set}const n=i[ex];t?n.add(e):n.has(e)&&n.delete(e)}function tne(i){if(!i)return!1;const e=i[ex];return e!==void 0&&e.size>0}ni.registerCallback(pn.ContextCreated,i=>{const e=i.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true")&&i.files)for(const t of i.files)re.foreachComponent(t.file.scene,n=>{if(n.enabled!==!1){if(n instanceof _s&&n.playAutomatically||n instanceof Cr||n instanceof nd&&n.playOnAwake===!0)return!0;if(n instanceof _s)return n.playAutomatically=!0,!0;if(n instanceof nd)return n.playOnAwake=!0,!0}},!0)!==!0&&ine(t.file)});function ine(i){if(!i||!i.animations)return;for(let t=0;t<i.animations.length;t++){const n=i.animations[t];if(!(!n.tracks||n.tracks.length<=0))for(const r in n.tracks){const s=n.tracks[r],o=s.__objectName??s.name.substring(0,s.name.indexOf("."));let a=i.scene.getObjectByName(o);if(!a&&(a=i.scene.getObjectByProperty("uuid",o),!a))continue;let l=e(a);l||(l=ph(i.scene,new _s));const c=l.animations=l.animations||[];n.name_animator=l.name,c.indexOf(n)<0&&c.push(n)}}function e(t){var n;if(!t)return;const r=(n=t.userData)==null?void 0:n.components;if(r&&r.length>0)for(let s=0;s<r.length;s++){const o=r[s];if(o instanceof Cr||o instanceof _s)return t}return e(t.parent)}}class nne{constructor(){h(this,"_context")}get context(){return this._context??Ot.Current}get isStateMachineBehaviour(){return!0}}class Pv{constructor(e,t,n,r){h(this,"name"),h(this,"nameHash"),h(this,"normalizedTime"),h(this,"length"),h(this,"speed"),h(this,"action"),h(this,"hasTransitions");var s;this.name=e.name,this.nameHash=e.hash,this.normalizedTime=t,this.length=n,this.speed=r,this.action=e.motion.action||null,this.hasTransitions=((s=e.transitions)==null?void 0:s.length)>0||!1}}function d4(i,e){return{name:"",isLooping:!1,guid:e?.generateUUID()??Nn.generateUUID(),index:-1,clip:new ps(i,1,[])}}var _h=(i=>(i[i.If=1]="If",i[i.IfNot=2]="IfNot",i[i.Greater=3]="Greater",i[i.Less=4]="Less",i[i.Equals=6]="Equals",i[i.NotEqual=7]="NotEqual",i))(_h||{}),lI=(i=>(i[i.Float=1]="Float",i[i.Int=3]="Int",i[i.Bool=4]="Bool",i[i.Trigger=9]="Trigger",i))(lI||{});const xs=ee("debuganimatorcontroller"),tx=ee("debugrootmotion");class xo{constructor(e){h(this,"_speed",1),h(this,"normalizedStartOffset",0),h(this,"animator"),h(this,"model"),h(this,"_mixer"),h(this,"_activeState"),h(this,"_activeStates",[]),h(this,"rootMotionHandler"),this.model=e,xs&&console.log(this)}static createFromClips(e,t={looping:!1,autoTransition:!0,transitionDuration:0}){const n=[];for(let s=0;s<e.length;s++){const o=e[s],a=[];if(t.autoTransition!==!1){const c=t.transitionDuration??0,u=c/o.duration;let d=s;(t.autoTransition===void 0||t.autoTransition===!0)&&(d=(s+1)%e.length),a.push({exitTime:1-u,offset:0,duration:c,hasExitTime:!0,destinationState:d,conditions:[]})}const l={name:o.name,hash:s,motion:{name:o.name,clip:o,isLooping:t?.looping??!1},transitions:a,behaviours:[]};n.push(l)}const r={name:"AnimatorController",guid:new lr(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:n}}]};return new xo(r)}play(e,t=-1,n=Number.NEGATIVE_INFINITY,r=0){if(t<0)t=0;else if(t>=this.model.layers.length){console.warn("invalid layer");return}const s=this.model.layers[t].stateMachine;for(const o of s.states)if(o.name===e||o.hash===e){xs&&console.log("transition to ",o),this.transitionTo(o,r,n);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,t){var n,r;const s=typeof e=="string"?"name":"hash";return(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(o=>o[s]===e).forEach(o=>o.value=t)}getBool(e){var t,n,r;const s=typeof e=="string"?"name":"hash";return((r=(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.find(o=>o[s]===e))==null?void 0:r.value)??!1}setFloat(e,t){var n,r;const s=typeof e=="string"?"name":"hash",o=(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(a=>a[s]===e);return o.forEach(a=>a.value=t),o?.length>0}getFloat(e){var t,n,r;const s=typeof e=="string"?"name":"hash";return((r=(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.find(o=>o[s]===e))==null?void 0:r.value)??0}setInteger(e,t){var n,r;const s=typeof e=="string"?"name":"hash";return(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(o=>o[s]===e).forEach(o=>o.value=t)}getInteger(e){var t,n,r;const s=typeof e=="string"?"name":"hash";return((r=(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.find(o=>o[s]===e))==null?void 0:r.value)??0}setTrigger(e){var t,n;xs&&console.log("SET TRIGGER",e);const r=typeof e=="string"?"name":"hash";return(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.filter(s=>s[r]===e).forEach(s=>s.value=!0)}resetTrigger(e){var t,n;const r=typeof e=="string"?"name":"hash";return(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.filter(s=>s[r]===e).forEach(s=>s.value=!1)}getTrigger(e){var t,n,r;const s=typeof e=="string"?"name":"hash";return((r=(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.find(o=>o[s]===e))==null?void 0:r.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(e){this._speed=e}FindState(e){return this.findState(e)}findState(e){if(!e)return null;if(Array.isArray(this.model.layers)){for(const t of this.model.layers)for(const n of t.stateMachine.states)if(n.name===e||n.hash==e)return n}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const t=this._activeState.motion.clip.duration,n=t<=0?0:Math.abs(e.time/t);return new Pv(this._activeState,n,t,this._speed)}get currentAction(){return this._activeState&&this._activeState.motion.action||null}get context(){var e;return(e=this.animator)==null?void 0:e.context}get mixer(){return this._mixer}bind(e){e?this.animator!==e&&(this.animator=e,this._mixer=new Hy(this.animator.gameObject),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;xs&&console.warn("AnimatorController clone()",this.model);const e=og(this.model,(t,n,r)=>r==null?!0:!(r.type==="Object3D"||r.isObject3D===!0||VO(r)||r.tracks!==void 0||r instanceof xo));return console.assert(e!==this.model),new xo(e)}update(e){var t,n;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const r=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((t=this.rootMotionHandler)==null||t.onBeforeUpdate(e)),this._mixer.update(r),this.animator.applyRootMotion&&((n=this.rootMotionHandler)==null||n.onAfterUpdate(e))}get activeState(){return this._activeState}updateActiveStates(e){for(let t=0;t<this._activeStates.length;t++){const n=this._activeStates[t],r=n.motion;if(!r.action)this._activeStates.splice(t,1),t--;else{const s=r.action;s.weight=e,s.getEffectiveWeight()<=0&&!s.isRunning()&&(xs&&console.debug("REMOVE",n.name,s.getEffectiveWeight(),s.isRunning(),s.isScheduled()),this._activeStates.splice(t,1),t--)}}}setStartTransition(){for(const e of this.model.layers){const t=e.stateMachine;t.defaultState===void 0&&(xs&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",e),t.defaultState=0);const n=t.states[t.defaultState];this.transitionTo(n,0,this.normalizedStartOffset)}}evaluateTransitions(){var e;let t=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;t=!0}const n=this._activeState,r=n.motion.action;for(const o of n.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let a=!0;for(const l of o.conditions)if(!this.evaluateCondition(l)){a=!1;break}if(a)if(r){const l=n.motion.clip.duration,c=l<=0?1:Math.abs(r.time/l);let u=!1;if(o.hasExitTime?r.timeScale>0?u=c>=o.exitTime:r.timeScale<0&&(u=1-c>=o.exitTime):u=!0,u){for(const d of o.conditions){const p=this.model.parameters.find(f=>f.name===d.parameter);p?.type===lI.Trigger&&p.value&&(p.value=!1)}r.clampWhenFinished=!0,xs&&console.log("transition to "+o.destinationState,o,c,o.exitTime,o.hasExitTime),this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}if(r){let o=n.speed??1;n.speedParameter&&(o*=this.getFloat(n.speedParameter)),o!==void 0&&(r.timeScale=o*this._speed)}let s=!1;if(n.motion.isLooping&&r&&(r.time>=r.getClip().duration?(s=!0,r.reset(),r.time=0,r.play()):r.time<=0&&r.timeScale<0&&(s=!0,r.reset(),r.time=r.getClip().duration,r.play())),!s&&n&&!t&&r&&this.animator&&n.behaviours){const o=r?.getClip().duration,a=r.time/o,l=new Pv(this._activeState,a,o,this._speed);for(const c of n.behaviours)c.instance&&((e=c.instance.onStateUpdate)==null||e.call(c.instance,this.animator,l,0))}}getState(e,t){return typeof e=="number"&&(e==-1&&(e=this.model.layers[t].stateMachine.defaultState,e===void 0&&(xs&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+t),e=0)),e=this.model.layers[t].stateMachine.states[e]),e}transitionTo(e,t,n){var r,s,o,a,l,c,u,d;if(!this.animator)return;const p=0;if(e=this.getState(e,p),!(e!=null&&e.motion)||!e.motion.clip||!(e.motion.clip instanceof ps))return;const f=this._activeState===e;if(f){const g=e.motion;if(!g.action_loopback&&g.clip){const y=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(g.clip,this.animator.gameObject),y&&y.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),g.action_loopback=this.createAction(g.clip)}}if((r=this._activeState)!=null&&r.behaviours&&this._activeState.motion.action){const g=(s=this._activeState)==null?void 0:s.motion.clip.duration,y=this._activeState.motion.action.time/g,b=new Pv(this._activeState,y,g,this._speed);for(const _ of this._activeState.behaviours)(a=(o=_.instance)==null?void 0:o.onStateExit)==null||a.call(_.instance,this.animator,b,p)}const m=(l=this._activeState)==null?void 0:l.motion.action;m&&m.fadeOut(t),f&&(e.motion.action=e.motion.action_loopback,e.motion.action_loopback=m);const A=this._activeState;this._activeState=e;const v=(c=e.motion)==null?void 0:c.action;if(v){if(n=Math.max(0,Math.min(1,n)),e.cycleOffsetParameter){let y=this.getFloat(e.cycleOffsetParameter);typeof y=="number"?(y<0&&(y+=1),n+=y,n%=1):xs&&console.warn("AnimatorController cycle offset parameter is not a number",e.cycleOffsetParameter)}else typeof e.cycleOffset=="number"&&(n+=e.cycleOffset,n%=1);v.isRunning()&&v.stop(),v.reset(),v.enabled=!0;const g=e.motion.clip.duration;if(v.time=f?0:n*g,v.timeScale<0&&(v.time=g-v.time),v.clampWhenFinished=!0,v.setLoop(wm,0),t>0?v.fadeIn(t):v.weight=1,v.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(v),this._activeStates.includes(e)||this._activeStates.push(e),this._activeState.behaviours){const y=new Pv(e,n,g,this._speed);for(const b of this._activeState.behaviours)(d=(u=b.instance)==null?void 0:u.onStateEnter)==null||d.call(b.instance,this.animator,y,p)}}else xs&&(e.__warned_no_motion||(e.__warned_no_motion=!0,console.warn("No action",e.motion,this)));xs&&console.log("TRANSITION FROM "+A?.name+" TO "+e.name,t,m,v,v?.getEffectiveTimeScale(),v?.getEffectiveWeight(),v?.isRunning(),v?.isScheduled(),v?.paused)}createAction(e){var t,n;if(this._mixer.existingAction(e)&&this._mixer.uncacheAction(e,(t=this.animator)==null?void 0:t.gameObject),(n=this.animator)!=null&&n.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new rne(this));const r=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,r,e)}else return this._mixer.clipAction(e)}evaluateCondition(e){const t=this.model.parameters.find(n=>n.name===e.parameter);if(!t)return!1;switch(e.mode){case _h.If:return t.value===!0;case _h.IfNot:return t.value===!1;case _h.Greater:return t.value>e.threshold;case _h.Less:return t.value<e.threshold;case _h.Equals:return t.value===e.threshold;case _h.NotEqual:return t.value!==e.threshold}return!1}createActions(e){var t,n,r,s;xs&&console.log("AnimatorController createActions",this.model);for(const o of this.model.layers){const a=o.stateMachine;for(let l=0;l<a.states.length;l++){const c=a.states[l];c.transitions||(c.transitions=[]);for(const u of c.transitions)u.conditions||(u.conditions=[]);if(c.motion||(c.motion=d4(c.name)),this.animator&&c.motion.clips){const u=(t=c.motion.clips)==null?void 0:t.find(d=>{var p,f;return d.node.name===((f=(p=this.animator)==null?void 0:p.gameObject)==null?void 0:f.name)});u?c.motion.clip=u.clip:(xs||ut())&&console.warn('Could not find clip for animator "'+((r=(n=this.animator)==null?void 0:n.gameObject)==null?void 0:r.name)+'"',c.motion.clips.map(d=>d.node.name))}if(!c.motion.clip){const u=new ps(void 0,void 0,[]);c.motion.clip=u}if((s=c.motion)!=null&&s.clip){const u=c.motion.clip;if(u instanceof ps){const d=this.createAction(u);c.motion.action=d}else(xs||ut())&&console.warn("No valid animationclip assigned",c)}if(c.behaviours&&Array.isArray(c.behaviours))for(const u of c.behaviours){if(!(u!=null&&u.typeName))continue;const d=q.get(u.typeName),p=new d;p.isStateMachineBehaviour&&(p._context=this.context??void 0,Kp(p,u.properties),u.instance=p),xs&&console.log("Created animator controller behaviour",c.name,u.typeName,u.properties,p)}}}}*enumerateActions(){if(this.model.layers)for(const e of this.model.layers){const t=e.stateMachine;for(let n=0;n<t.states.length;n++){const r=t.states[n];r!=null&&r.motion&&(r.motion.action&&(yield r.motion.action),r.motion.action_loopback&&(yield r.motion.action_loopback))}}}}class p4{constructor(e,t){h(this,"track"),h(this,"createdInterpolant"),h(this,"originalEvaluate"),h(this,"customEvaluate"),this.track=e;const n=e,r=n.createInterpolant.bind(e);n.createInterpolant=()=>(n.createInterpolant=r,this.createdInterpolant=r(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=s=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(s);return t(s,o)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}const nr=class{constructor(i,e,t,n,r){if(h(this,"_action"),h(this,"root"),h(this,"clip"),h(this,"positionWrapper",null),h(this,"rotationWrapper",null),h(this,"context"),h(this,"positionChange",new S),h(this,"rotationChange",new Me),h(this,"_prevTime",0),this.context=i,this.root=e,this.clip=t,nr.firstKeyframeRotation[this.cacheId]||(nr.firstKeyframeRotation[this.cacheId]=new Me),r){const s=r.values;nr.firstKeyframeRotation[this.cacheId].set(s[0],s[1],s[2],s[3])}nr.spaceRotation[this.cacheId]||(nr.spaceRotation[this.cacheId]=new Me),nr.effectiveSpaceRotation[this.cacheId]||(nr.effectiveSpaceRotation[this.cacheId]=new Me),nr.clipOffsetRotation[this.cacheId]=new Me,r&&nr.clipOffsetRotation[this.cacheId].set(r.values[0],r.values[1],r.values[2],r.values[3]).invert(),this.handlePosition(t,n),this.handleRotation(t,r)}set action(i){this._action=i}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(i){if(i.getClip()!==this.clip)return;nr.lastObjRotation[this.cacheId]||(nr.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const e=nr.lastObjRotation[this.cacheId];if(nr.spaceRotation[this.cacheId].copy(e),tx){const t=new Ni().setFromQuaternion(e);console.log("START",this.clip.name,Ze.toDegrees(t.y),this.root.position.z)}}getClipRotationOffset(){return nr.clipOffsetRotation[this.cacheId]}handlePosition(i,e){if(e){const t=this.root;tx&&t.add(new To),nr.lastObjPosition[this.cacheId]||(nr.lastObjPosition[this.cacheId]=this.root.position.clone());const n=new S,r=new S;this.positionWrapper=new p4(e,(s,o)=>{const a=this.action.getEffectiveWeight();return tx&&t.position.length()>8&&t.position.set(0,t.position.y,0),s>this._prevTime&&(n.set(o[0],o[1],o[2]),n.sub(r),n.multiplyScalar(a),n.applyQuaternion(this.getClipRotationOffset()),n.applyQuaternion(t.quaternion),this.positionChange.copy(n)),r.fromArray(o),this._prevTime=s,o[0]=0,o[1]=0,o[2]=0,o})}}handleRotation(i,e){if(e){if(tx){const s=e.values,o=new Ni().setFromQuaternion(new Me(s[0],s[1],s[2],s[3]));console.log(i.name,e.name,"FIRST ROTATION IN TRACK",Ze.toDegrees(o.y));const a=e.values.length-4,l=new Me().set(s[a],s[a+1],s[a+2],s[a+3]),c=new Ni().setFromQuaternion(l);console.log(i.name,e.name,"LAST ROTATION IN TRACK",Ze.toDegrees(c.y))}let t=0;const n=new Me,r=new Me;this.rotationWrapper=new p4(e,(s,o)=>(s>t&&(r.set(o[0],o[1],o[2],o[3]),n.invert(),r.multiply(n),this.rotationChange.copy(r)),n.fromArray(o),t=s,o[0]=0,o[1]=0,o[2]=0,o[3]=1,o))}}onBeforeUpdate(i){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(i){return!this.action||(i*=this.action.getEffectiveWeight(),i<=0)?!1:(this.positionChange.multiplyScalar(i),this.rotationChange.slerp(nr.identityQuaternion,1-i),!0)}};let xh=nr;h(xh,"lastObjPosition",{}),h(xh,"lastObjRotation",{}),h(xh,"firstKeyframeRotation",{}),h(xh,"spaceRotation",{}),h(xh,"effectiveSpaceRotation",{}),h(xh,"clipOffsetRotation",{}),h(xh,"identityQuaternion",new Me);class rne{constructor(e){h(this,"controller"),h(this,"handler",[]),h(this,"root"),h(this,"basePosition",new S),h(this,"baseQuaternion",new Me),h(this,"baseRotation",new Ni),h(this,"summedPosition",new S),h(this,"summedRotation",new Me),this.controller=e}createClip(e,t,n){this.root=t,t&&"name"in t&&t.name;const r=this.findRootTrack(n,".position"),s=this.findRootTrack(n,".quaternion"),o=new xh(this.controller.context,t,n,r,s);this.handler.push(o);const a=e.clipAction(n);return o.action=a,a}onStart(e){for(const t of this.handler)t.onStart(e)}onBeforeUpdate(e){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const t of this.handler)t.onBeforeUpdate(e)}onAfterUpdate(e){if(!(e<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const t of this.handler)t.onAfterUpdate(e)&&(this.summedPosition.add(t.positionChange),this.summedRotation.multiply(t.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(e,t){const n=e.tracks;if(!n)return null;for(const r of n)if(r.name.endsWith(t))return r;return null}}class sne extends Va{onSerialize(e,t){}onDeserialize(e,t){if(t.type===xo&&e?.__type==="AnimatorController")return new xo(e)}}new sne(xo);var one=Object.defineProperty,ane=Object.getOwnPropertyDescriptor,ix=(i,e,t,n)=>{for(var r=n>1?void 0:n?ane(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&one(e,t,r),r};const Vo=ee("debuganimator");class Cr 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(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof xo?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(t=e.model)==null?void 0:t.name),e.model||console.error("AnimatorController has no model"),e=new xo(e.model)),this._animatorController=e,this._animatorController.bind(this)):(Vo&&console.log("Assign animator controller",e,this),this._animatorController=new xo(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){var e;return(e=this.runtimeAnimatorController)==null?void 0:e.getCurrentStateInfo()}get currentAction(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.currentAction)||null}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(e,t=-1,n=Number.NEGATIVE_INFINITY,r=0){this.play(e,t,n,r)}play(e,t=-1,n=Number.NEGATIVE_INFINITY,r=0){var s;(s=this.runtimeAnimatorController)==null||s.play(e,t,n,r),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){var n,r;Vo&&console.log("setBool",e,t),((n=this.runtimeAnimatorController)==null?void 0:n.getBool(e))!==t&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){var t;const n=((t=this.runtimeAnimatorController)==null?void 0:t.getBool(e))??!1;return Vo&&console.log("getBool",e,n),n}toggleBool(e){this.setBool(e,!this.getBool(e))}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){var n,r;((n=this.runtimeAnimatorController)==null?void 0:n.getFloat(e))!==t&&(this._parametersAreDirty=!0),Vo&&console.log("setFloat",e,t),(r=this.runtimeAnimatorController)==null||r.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){var t;const n=((t=this.runtimeAnimatorController)==null?void 0:t.getFloat(e))??-1;return Vo&&console.log("getFloat",e,n),n}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){var n,r;((n=this.runtimeAnimatorController)==null?void 0:n.getInteger(e))!==t&&(this._parametersAreDirty=!0),Vo&&console.log("setInteger",e,t),(r=this.runtimeAnimatorController)==null||r.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){var t;const n=((t=this.runtimeAnimatorController)==null?void 0:t.getInteger(e))??-1;return Vo&&console.log("getInteger",e,n),n}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var t;this._parametersAreDirty=!0,Vo&&console.log("setTrigger",e),(t=this.runtimeAnimatorController)==null||t.setTrigger(e)}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var t;this._parametersAreDirty=!0,Vo&&console.log("resetTrigger",e),(t=this.runtimeAnimatorController)==null||t.resetTrigger(e)}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var t;const n=(t=this.runtimeAnimatorController)==null?void 0:t.getTrigger(e);return Vo&&console.log("getTrigger",e,n),n}IsInTransition(){return this.isInTransition()}isInTransition(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.isInTransition())??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){var t;e!==this._speed&&(Vo&&console.log("setSpeed",e),this._speed=e,((t=this._animatorController)==null?void 0:t.animator)==this&&this._animatorController.setSpeed(e))}set minMaxSpeed(e){var t;this._speed=Ze.lerp(e.x,e.y,Math.random()),((t=this._animatorController)==null?void 0:t.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(e){var t;this._normalizedStartOffset=Ze.lerp(e.x,e.y,Math.random()),((t=this.runtimeAnimatorController)==null?void 0:t.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){Vo&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const n=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=n,n?(console.assert(this.runtimeAnimatorController!==n),this.runtimeAnimatorController=n,console.assert(this.runtimeAnimatorController===n),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 e;this.keepAnimatorControllerStateOnDisable||(e=this._animatorController)==null||e.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!tne(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}ix([x()],Cr.prototype,"applyRootMotion",2),ix([x()],Cr.prototype,"hasRootMotion",2),ix([x()],Cr.prototype,"keepAnimatorControllerStateOnDisable",2),ix([x()],Cr.prototype,"runtimeAnimatorController",1);const el=ee("debugusdzanimation"),cI=ee("debugusdzanimationserialization");class nx{constructor(e,t,n){h(this,"_start"),h(this,"ext"),h(this,"root"),h(this,"clip"),this.ext=e,this.root=t,this.clip=n}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){var e;return((e=this.clip)==null?void 0:e.duration)??rr.restPoseClipDuration}}const f4=class{constructor(i,e,t){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=i,this.target=e,this.clip=t,t?this.duration=t.duration:this.duration=f4.restPoseClipDuration;const n=re.getComponent(i,Cr);n&&(this.useRootMotion=n.applyRootMotion)}get frameRate(){return 60}addTrack(i){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it \u2013 this is likely a bug");return}i.name.endsWith("position")&&(this.pos=i),i.name.endsWith("quaternion")&&(this.rot=i),i.name.endsWith("scale")&&(this.scale=i)}getFrames(){var i,e,t,n,r,s;return this.clip?Math.max(((e=(i=this.pos)==null?void 0:i.times)==null?void 0:e.length)??0,((n=(t=this.rot)==null?void 0:t.times)==null?void 0:n.length)??0,((s=(r=this.scale)==null?void 0:r.times)==null?void 0:s.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(i=!0,e=!0,t=!0){var n,r,s;if(!this.clip)return[0,this.duration];const o=(n=this.pos)==null?void 0:n.times,a=(r=this.rot)==null?void 0:r.times,l=(s=this.scale)==null?void 0:s.times,c=[];if(i&&o)for(const u of o)c.push(u);if(e&&a)for(const u of a)c.push(u);if(t&&l)for(const u of l)c.push(u);return c.includes(0)||c.push(0),c.sort((u,d)=>u-d),[...new Set(c)]}*getValues(i,e=!0,t=!0,n=!0){var r,s,o;const a=new S,l=new Me,c=new S(1,1,1),u=this.target,d=e?(r=this.pos)==null?void 0:r.createInterpolant():void 0,p=t?(s=this.rot)==null?void 0:s.createInterpolant():void 0,f=n?(o=this.scale)==null?void 0:o.createInterpolant():void 0;d||a.set(u.position.x,u.position.y,u.position.z),p||l.set(u.quaternion.x,u.quaternion.y,u.quaternion.z,u.quaternion.w),f||c.set(u.scale.x,u.scale.y,u.scale.z);for(let m=0;m<i.length;m++){const A=i[m];if(d){const v=d.evaluate(A);a.set(v[0],v[1],v[2])}if(p){const v=p.evaluate(A);l.set(v[0],v[1],v[2],v[3])}if(f){const v=f.evaluate(A);c.set(v[0],v[1],v[2])}if(this.useRootMotion&&u===this.root){const v=new Ce;v.compose(a,l,c),v.multiply(u.matrix),v.decompose(a,l,c)}yield{time:A,translation:a,rotation:l,scale:c,index:m}}}};let rr=f4;h(rr,"animationDurationPadding",1/60),h(rr,"restPoseClipDuration",1/60);class Bv{constructor(e){h(this,"dict",new Map),h(this,"rootTargetMap",new Map),h(this,"rootAndClipToRegisteredAnimationMap",new Map),h(this,"rootToRegisteredClip",new Map),h(this,"serializers",[]),h(this,"injectRestPoses",!1),h(this,"injectImplicitBehaviours",!1),this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}getStartTimeCode(){return!this.injectRestPoses||this.rootAndClipToRegisteredAnimationMap.size===0?0:(rr.restPoseClipDuration+rr.animationDurationPadding)*60}getEndTimeCode(){let e=0;for(const[t,n]of this.rootAndClipToRegisteredAnimationMap){const r=n.start+n.duration;r>e&&(e=r)}return e*60}getClipCount(e){var t;let n=((t=this.rootToRegisteredClip.get(e))==null?void 0:t.length)??0;return this.injectRestPoses&&(n=n?n-1:0),n??0}getStartTime01(e,t){if(!t)return 0;const n=this.rootTargetMap.get(e);if(!n)return 0;const r=this.dict.get(n[0]);if(!r)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let s=0;for(let o=0;o<r.length&&r[o].clip!==t;o++)s+=r[o].getDuration()+rr.animationDurationPadding;return s}registerAnimation(e,t){var n;if(!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const r=e.uuid+(t?.uuid??"-rest");if(this.rootAndClipToRegisteredAnimationMap.has(r))return this.rootAndClipToRegisteredAnimationMap.get(r);el&&console.log("registerAnimation",e,t);const s=this.injectRestPoses?1:0,o=(((n=this.rootToRegisteredClip.get(e))==null?void 0:n.length)??0)+s,a=this.rootTargetMap.get(e),l=new Set(a);if(t&&t.tracks)for(const u of t.tracks){const d=Qt.parseTrackName(u.name),p=Qt.findNode(e,d.nodeName);if(!p){console.warn("no object found for track",u.name,"using "+e.name+" instead");continue}this.dict.has(p)||this.dict.set(p,[]);const f=this.dict.get(p);if(!f){console.warn("no transform data found for target ",p,"at slot "+o+", this is likely a bug");continue}l.delete(p),this.injectRestPoses&&!f[0]&&(f[0]=new rr(null,p,null));let m=f[o];m||(m=new rr(e,p,t),f[o]=m),m.addTrack(u),a!=null&&a.includes(p)||a==null||a.push(p)}el&&console.log("Unregistered nodes for this clip",l,"clip",t,"at slot",o,"for root",e,"targets",a);for(const u of l){const d=this.dict.get(u);if(!d)continue;if(this.injectRestPoses&&!d[0]){console.warn("Adding rest pose for ",u,t,"at slot",o,"This is likely a bug, should have been added earlier.");const f=new rr(null,u,null);d[0]=f}let p=d[o];p||(el&&console.log("Adding padding clip for ",u,t,"at slot",o),p=new rr(e,u,t),d[o]=p)}const c=new nx(this,e,t);if(this.rootAndClipToRegisteredAnimationMap.set(r,c),el&&console.log({root:e,clip:t,info:c}),t){const u=this.rootToRegisteredClip.get(e);u?u.push(t):this.rootToRegisteredClip.set(e,[t])}return c}onAfterHierarchy(e){el&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,n;el&&console.log("Animation data",{dict:this.dict,rootTargetMap:this.rootTargetMap,rootToRegisteredClip:this.rootToRegisteredClip});for(const r of this.rootTargetMap.keys()){const s=this.rootTargetMap.get(r);if(!s)continue;let o;const a=[];for(const l of s){const c=this.dict.get(l);if(!c){console.error("No data found for target on USDZ export \u2013 please report a bug!",l);continue}o===void 0&&(o=c?.length),o!==c?.length&&console.error("Different array lengths for targets \u2013 please report a bug!",c);for(let u=0;u<c.length;u++){let d=c[u];if(!d){const p=u-(this.injectRestPoses?1:0);c[u]=new rr(null,l,this.rootToRegisteredClip.get(r)[p]),d=c[u]}if(!a[u])a[u]=d.getDuration();else if(a[u]!==d.getDuration()){console.error("Different durations for targets \u2013 please report a bug!",c);continue}}}}for(const r of this.serializers){const s=(t=r.model)==null?void 0:t.parent,o=s?.isDynamic===!0;cI&&console.log(o,(n=r.model)==null?void 0:n.parent),o&&r.registerCallback(s)}}onExportObject(e,t,n){re.foreachComponent(e,s=>{const o=s;typeof o.createAnimation=="function"&&o.createAnimation(this,t,n)},!1);const r=new lne(e,this.dict);this.serializers.push(r),r.registerCallback(t)}}class lne{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)),cI&&console.log("REPARENT",e),this.model=e,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){var n;const r=this.model,s=this.dict;if(r&&r.skinnedMesh){let o=function(M){const D=[];for(const[C,P]of M){let j=`${C} : [`;const Q=[];for(const O of P)Q.push(`(${$n(O.x)}, ${$n(O.y)}, ${$n(O.z)})`);j=j.concat(Q.join(", ")),j=j.concat("],"),D.push(j)}return D},a=function(M){const D=[];for(const[C,P]of M){let j=`${C} : [`;const Q=[];for(const O of P)Q.push(`(${$n(O.w)}, ${$n(O.x)}, ${$n(O.y)}, ${$n(O.z)})`);j=j.concat(Q.join(", ")),j=j.concat("],"),D.push(j)}return D},l=function(M){let D,C=!0;const P=new Map;for(const[Q,O]of M){D===void 0&&(D=O.length),D!==O.length&&(C=!1);let W=0;for(const L of O)W++,L||(P.has(Q)||P.set(Q,[]),P.get(Q).push(W))}el&&console.log("Bone count: ",M.size,"TransformData entries per bone: ",D,"Undefined bone entries: ",P),console.assert(C,"All bones should have the same number of TransformData entries",M),console.assert(P.size===0,"All TransformData entries should be set",P);const j=[];for(const[Q,O]of M){const W=new Array;let L=0;for(let F=0;F<O.length;F++)W.push(L),L+=O[F].getDuration()+rr.animationDurationPadding;for(let F=0;F<O.length;F++){const z=O[F],Z=W[F];j.length<=F&&j.push({pos:[],rot:[],scale:[],timeOffset:Z});const K=j[F];K.pos.push(...z.getSortedTimesArray(!0,!1,!1)),K.rot.push(...z.getSortedTimesArray(!1,!0,!1)),K.scale.push(...z.getSortedTimesArray(!1,!1,!0))}}for(const Q of j)Q.pos.sort((O,W)=>O-W),Q.rot.sort((O,W)=>O-W),Q.scale.sort((O,W)=>O-W),Q.pos=[...new Set(Q.pos)],Q.rot=[...new Set(Q.rot)],Q.scale=[...new Set(Q.scale)];return j},c=function(M,D,C){const P=new Map,j=new Map,Q=new Map,O=D.length;for(const W of C){const L=M.get(W);let F;L?console.assert(L.length===O,"We should have the same number of TransformData entries for each bone",L,D):F=new rr(null,W,null);for(let z=0;z<O;z++){const Z=L?L[z]:F,K=D[z];for(const{time:se,translation:Ae}of Z.getValues(K.pos,!0,!1,!1)){const Pe=(se+K.timeOffset)*60;P.has(Pe)||P.set(Pe,new Array),P.get(Pe).push(Ae.clone())}for(const{time:se,rotation:Ae}of Z.getValues(K.rot,!1,!0,!1)){const Pe=(se+K.timeOffset)*60;j.has(Pe)||j.set(Pe,new Array),j.get(Pe).push(Ae.clone())}for(const{time:se,scale:Ae}of Z.getValues(K.scale,!1,!1,!0)){const Pe=(se+K.timeOffset)*60;Q.has(Pe)||Q.set(Pe,new Array),Q.get(Pe).push(Ae.clone())}}}return{position:P.size==0?void 0:P,quaternion:j.size==0?void 0:j,scale:Q.size==0?void 0:Q}},u=function(M){const D=[];for(const C of M)D.push(`(${$n(C.x)}, ${$n(C.y)}, ${$n(C.z)})`);return D.join(", ")},d=function(M){const D=[];for(const C of M)D.push(`(${$n(C.w)}, ${$n(C.x)}, ${$n(C.y)}, ${$n(C.z)})`);return D.join(", ")},p=function(M){const D=new Map;if(el){const C=new Array;for(const[P,j]of s)C.push(P.uuid+": "+j.length+" "+j.map(Q=>{var O;return(O=Q.clip)==null?void 0:O.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5507
5507
|
`+C.join(`
|
|
5508
|
-
`))}for(const C of M){const P=s.get(C);P&&D.set(C,P)}return D},f=function(M){const D=p(M),C=l(D);return c(D,C,M)};const m=r.skinnedMesh.skeleton,A=new Array;for(const M in m.bones){const D=m.bones[M],C=m.boneInverses[M];A.push({bone:D,inverse:C})}for(const M of QL(m.bones))A.push({bone:M,inverse:M.matrixWorld.clone().invert()});const v=A[0].bone.parent;v||console.error("No bone parent found for skinned mesh during USDZ export",r.skinnedMesh),A.sort((M,D)=>Hp(M.bone,v)>Hp(D.bone,v)?1:-1);const g=[],y=[],b=[],_=[];for(const{bone:M}of A)g.push(M.matrix.clone()),y.push(M.position),b.push(M.quaternion),_.push(M.scale);const E=A.map(M=>'"'+Hp(M.bone,v)+'"').join(", "),I=A.map(M=>Vp(M.inverse.clone().invert())).join(", ");e.beginBlock('def Skeleton "Rig"'),e.appendLine(`uniform matrix4d[] bindTransforms = [${I}]`),e.appendLine(`uniform token[] joints = [${E}]`),e.appendLine('uniform token purpose = "guide"'),e.appendLine(`uniform matrix4d[] restTransforms = [${g.map(M=>Vp(M)).join(", ")}]`),e.appendLine(`matrix4d xformOp:transform = ${Vp(new Ce)}`),e.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const T=f(A.map(M=>M.bone));if(el){let M=1e7,D=0;for(const C of((n=T.position)==null?void 0:n.keys())??[])M=Math.min(M,C),D=Math.max(D,C);console.log("Time samples",M,D,T)}if(e.beginBlock('def SkelAnimation "_anim"'),e.appendLine(`uniform token[] joints = [${E}]`),e.appendLine(`quatf[] rotations = [${d(b)}]`),T&&T.quaternion){e.beginBlock("quatf[] rotations.timeSamples = {","");const M=a(T.quaternion);for(const D of M)e.appendLine(D);e.closeBlock()}if(e.appendLine(`half3[] scales = [${u(_)}]`),T&&T.scale){e.beginBlock("half3[] scales.timeSamples = {","");const M=o(T.scale);for(const D of M)e.appendLine(D);e.closeBlock()}if(e.appendLine(`float3[] translations = [${u(y)}]`),T&&T.position){e.beginBlock("float3[] translations.timeSamples = {","");const M=o(T.position);for(const D of M)e.appendLine(D);e.closeBlock()}e.closeBlock(),e.closeBlock()}}onSerialize(e,t){var n;if(!this.model)return;const r=this.dict.get(this.object);if(r)for(let d=0;d<r.length;d++)r[d]===void 0&&(r[d]=new rr(null,this.object,null));this.skinnedMeshExport(e,t);const s=this.object,o=this.dict.get(s);if(!o||s.isSkinnedMesh)return;cI&&console.log("SERIALIZE",this.model.name,this.object.type,o);const a=new Ce;e.appendLine("matrix4d xformOp:transform.timeSamples = {"),e.indent++;const l=new Array;let c=0;for(let d=0;d<o.length;d++){if(l.push(c),o[d]===void 0){console.error("Got an undefined transform data, this is likely a bug.",s,o);continue}c+=o[d].getDuration()+rr.animationDurationPadding}const u=Intl.NumberFormat("en",{maximumFractionDigits:2,minimumFractionDigits:0});for(let d=0;d<o.length;d++){const p=o[d];if(!p)continue;const f=l[d];{const m=p.getSortedTimesArray();if(!m||m.length===0){console.error("got an animated object but no time values?",s,p);continue}{const A=((n=p.clip)==null?void 0:n.name)??"rest",v=p.getDuration();el&&console.log("Write .timeSamples:",A,f,v,o),e.appendLine("# "+A+": start="+u.format(f*p.frameRate)+", length="+u.format(v*p.frameRate)+", frames="+p.getFrames())}for(const{time:A,translation:v,rotation:g,scale:y}of p.getValues(m)){a.compose(v,g,y);const b=`${u.format((f+A)*p.frameRate)}: ${Vp(a)},`;e.appendLine(b)}}}e.indent--,e.appendLine("}")}}var cne=Object.defineProperty,hne=Object.getOwnPropertyDescriptor,m4=(i,e,t,n)=>{for(var r=n>1?void 0:n?hne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&cne(e,t,r),r};const g4=ee("debugpost");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 n=this._value;if(g4){let r=!0;if(typeof n=="number"&&typeof e=="number"){const s=n?.toFixed(4),o=e?.toFixed(4);s!=o?r=!0:r=!1}r&&console.log("VolumeParameter: value changed from",n,"to",e)}!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,n,this):g4&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(e){return this._valueRaw!==e}}m4([x()],Rt.prototype,"overrideState",1),m4([x()],Rt.prototype,"value",1);var une=Object.defineProperty,dne=Object.getOwnPropertyDescriptor,pne=(i,e,t,n)=>{for(var r=n>1?void 0:n?dne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&une(e,t,r),r};const fne=ee("debugpost");class Kr extends Ie{constructor(e=void 0){if(super(),h(this,"active",!0),h(this,"_result"),h(this,"_didCreateVolumeParameters",!1),e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const n=e[t],r=this[t];r instanceof Rt&&(r.value=n)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){fne&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const n=this[t];n instanceof Rt&&n.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const n=this.$serializedTypes;if(n){for(const r of Object.keys(n))if(n[r]===Rt){const s=e[r];if(s!==void 0){const o=this[r];o.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Rt){const n=e.value;return this[t].value=n,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Rt&&(this[t]||(this[t]=new Rt))}}pne([x()],Kr.prototype,"active",2);var mne=Object.defineProperty,gne=Object.getOwnPropertyDescriptor,vne=(i,e,t,n)=>{for(var r=n>1?void 0:n?gne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&mne(e,t,r),r};const Ane=ee("debugpost"),hI={};function Wo(i,e){hI[i]=e}function yne(i){return i.__type in hI?hI[i.__type]:(Ane&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),Kr)}class Dv{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}vne([qp([i=>yne(i),Kr])],Dv.prototype,"components",2);var bne=Object.defineProperty,_ne=Object.getOwnPropertyDescriptor,xne=(i,e,t,n)=>{for(var r=n>1?void 0:n?_ne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&bne(e,t,r),r};class kv extends Kr{constructor(){super(...arguments),h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new ZU({preset:Jp.HIGH,edgeDetectionMode:zM.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}xne([x(Rt)],kv.prototype,"preset",2),Wo("Antialiasing",kv);const wne=ee("debugusdz");class Vh{constructor(){h(this,"files",new Array)}static getName(e){var t;const n=e.split(".").pop();let r=(t=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:t.replace(".","_");return r||(r="Audio_"+Math.random().toString(36).substring(2,15)),Aa(r)+"."+n}get extensionName(){return"Audio"}onExportObject(e,t,n){const r=re.getComponents(e,en);if(r.length)for(const s of r){if(!s.clip||typeof s.clip!="string"||!s.playOnAwake)continue;const o=s.clip.split("/").pop()||"Audio",a=Vh.getName(s.clip),l=Aa(a);this.files.some(c=>c.path===s.clip)||this.files.push({path:s.clip,name:a}),n.quickLookCompatible||t.addEventListener("serialize",(c,u)=>{c.appendLine(),c.beginBlock(`def SpatialAudio "${l}"`,"(",!1),c.appendLine(`displayName = "${o}"`),c.closeBlock(")"),c.beginBlock(),c.appendLine(`uniform asset filePath = @audio/${a}@`),c.appendLine(`uniform token auralMode = "${s.spatialBlend>0?"spatial":"nonSpatial"}"`),c.appendLine(`uniform token playbackMode = "${s.loop?"loopFromStage":"onceFromStart"}"`),c.appendLine(`uniform float gain = ${s.volume}`),c.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const n="audio/"+t.name;if(e.files[n]){wne&&console.warn("Audio file with name "+n+" already exists in the context. Skipping.");continue}const r=await(await(await fetch(t.path)).blob()).arrayBuffer(),s=new Uint8Array(r);e.files[n]=s}}}const rd=ee("debugautosync"),uI=Symbol("syncerId");class Sne{constructor(){h(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new Cne(e);return t[uI]=e.guid,this._syncers[t[uI]]=t,t}removeSyncer(e){delete this._syncers[e[uI]]}}const dI=new Sne;class Cne{constructor(e){h(this,"comp"),h(this,"hasChanges",!1),h(this,"changedProperties",{}),h(this,"data",{}),h(this,"_isReceiving",!1),h(this,"_isInit",!1),h(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const t=this.comp.context.connection;if(!t||!t.isConnected||!t.isInRoom){for(const n in this.changedProperties)delete this.changedProperties[n];return}for(const n in this.data)delete this.data[n];this.data.guid=this.comp.guid;for(const n in this.changedProperties){const r=this.changedProperties[n];delete this.changedProperties[n],this.data[n]=r}t.send(this.networkingKey,this.data,Fo.Queued)}),h(this,"onHandleReceiving",t=>{if(rd&&console.log("RECEIVE",this.comp.name,this.comp.guid,t),!this._isInit||!this.comp)return;const n=t.guid;if(!(n&&n!==this.comp.guid)){rd&&console.log("RECEIVED",this.comp.name,this.comp.guid,t);try{this._isReceiving=!0;for(const r in t){if(r==="guid")continue;const s=t[r];this.comp[r]=s,rd&&console.log("SET",r,s)}}catch(r){console.error(r)}finally{this._isReceiving=!1}}}),this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(rd&&console.log("Property changed: "+e,t),this.hasChanges=!0,this.changedProperties[e]=t)}}function Ene(i,e){let t=e!==i;return!t&&i&&e&&(Array.isArray(i)&&Array.isArray(e)||typeof i=="object"&&typeof e=="object")&&(t=!0),t}const Ov=Symbol("AutoSyncHandler");function Mne(i){if(i[Ov])return i[Ov];const e=dI.getOrCreateSyncer(i);return e?.init(i),i[Ov]=e,e}function Tne(i){const e=i[Ov];e&&(dI.removeSyncer(e),e.destroy(),delete i[Ov])}const pI=function(i){return function(e,t){var n;let r="";typeof t=="string"?r=t:r=t.name;let s=null,o;typeof i=="string"?o=e[i]:typeof i=="function"&&(o=i);const a=e,l=a.__internalAwake;if(typeof l!="function"){(rd||ut())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((n=e?.constructor)==null?void 0:n.name)+'" is not supported',e);return}rd&&console.log(r);const c=Symbol(r);a.__internalAwake=function(){if(this[c]!==void 0)return;this[c]=this[r],s=dI.getOrCreateSyncer(this);const d=Object.getOwnPropertyDescriptor(this,r);if(d?.set===void 0){let p=!1;Object.defineProperty(this,r,{set:function(f){var m;const A=this[c];if(this[c]=f,p){ut()&&console.warn("Recursive call detected",r);return}p=!0;try{const v=Ene(f,A);rd&&console.log("SyncField assignment",r,"changed?",v,f),v&&o?.call(this,f,A)!==!1&&((m=Mne(this))==null||m.notifyChanged(r,f))}finally{p=!1}},get:function(){return this[c]},configurable:!0,enumerable:!0})}s?.init(this),l.call(this)};const u=a.__internalDestroy;a.__internalDestroy=function(){Tne(this),u.call(this)}}};var Ine=Object.defineProperty,Rne=Object.getOwnPropertyDescriptor,rx=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ine(e,t,r),r};const so=ee("debugplayersync");class bf extends Ie{constructor(){super(...arguments),h(this,"autoSync",!0),h(this,"asset"),h(this,"onPlayerSpawned"),h(this,"_localInstance"),h(this,"onJoinedRoom",()=>{so&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new Hn)}onEnable(){this.context.connection.beginListen(Kt.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(Kt.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(Kt.JoinedRoom,this.onJoinedRoom)}async getInstance(){var e,t,n,r,s,o;if(this._localInstance)return this._localInstance;if(so&&console.log("PlayerSync.createInstance",(e=this.asset)==null?void 0:e.uri),!((t=this.asset)!=null&&t.asset)&&!((n=this.asset)!=null&&n.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(r=this.asset)==null?void 0:r.instantiateSynced({parent:this.gameObject},!0);const a=await this._localInstance;if(a){const l=re.getComponent(a,qo);l?(l.owner=this.context.connection.connectionId,(s=this.onPlayerSpawned)==null||s.invoke(a)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((o=this.asset)==null?void 0:o.uri)+"</strong>: please make sure the asset has a PlayerState component!"),re.destroySynced(a))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var e;(e=this._localInstance)==null||e.then(t=>(so&&console.log("PlayerSync.destroyInstance",t),re.destroySynced(t))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",e=>{if(document.visibilityState==="visible")for(let t=qo.all.length-1;t>=0;t--){const n=qo.all[t];(!n.owner||!this.context.connection.userIsInRoom(n.owner))&&n.doDestroy()}})}}rx([x()],bf.prototype,"autoSync",2),rx([x(Zt)],bf.prototype,"asset",2),rx([x(Hn)],bf.prototype,"onPlayerSpawned",2);var v4=(i=>(i.OwnerChanged="ownerChanged",i))(v4||{}),Lv;const Er=(Lv=class extends Ie{constructor(){super(...arguments),h(this,"onOwnerChangeEvent",new Hn),h(this,"onFirstOwnerChangeEvent",new Hn),h(this,"hasOwner",!1),h(this,"owner"),h(this,"dontDestroy",!1),h(this,"onUserLeftRoom",i=>{if(i.userId===this.owner){so&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return Er._all}static get local(){return Er._local}static getFor(i){if(i instanceof ge)return re.getComponentInParent(i,Er);if(i instanceof Ie)return re.getComponentInParent(i.gameObject,Er)}static isLocalPlayer(i){const e=Er.getFor(i);return e?.isLocalPlayer??!1}static addEventListener(i,e){return this._callbacks[i]||(this._callbacks[i]=[]),this._callbacks[i].push(e),e}static removeEventListener(i,e){if(!this._callbacks[i])return;const t=this._callbacks[i].indexOf(e);t>=0&&this._callbacks[i].splice(t,1)}static dispatchEvent(i,e){if(this._callbacks[i])for(const t of this._callbacks[i])t(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(i,e){var t,n;so&&console.log("PlayerSync.onOwnerChange",this,"newOwner",i,"oldOwner",e);const r=Er._local.indexOf(this);r>=0&&Er._local.splice(r,1);const s={playerState:this,oldValue:e,newValue:i};if(this.hasOwner||(this.hasOwner=!0,(t=this.onFirstOwnerChangeEvent)==null||t.invoke(s)),(n=this.onOwnerChangeEvent)==null||n.invoke(s),this.owner===this.context.connection.connectionId){Er._local.push(this);const a=new CustomEvent("local-owner-changed",{detail:s});this.dispatchEvent(a)}const o=new CustomEvent("owner-changed",{detail:s});this.dispatchEvent(o),Er.dispatchEvent("ownerChanged",o)}awake(){Er.all.push(this),so&&console.log("Registered new PlayerState",this.guid,Er.all.length-1,Er.all),this.context.connection.beginListen(Kt.UserLeftRoom,this.onUserLeftRoom)}async start(){so&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await ua(300),this.context.connection.userIsInRoom(this.owner)==!1&&(so&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(so&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?so&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(so&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):so&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){so&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),P_(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(Kt.UserLeftRoom,this.onUserLeftRoom),Er.all.splice(Er.all.indexOf(this),1),this.isLocalPlayer){const i=Er._local.indexOf(this);i>=0&&Er._local.splice(i,1)}}},h(Lv,"_all",[]),h(Lv,"_local",[]),h(Lv,"_callbacks",{}),Lv);let qo=Er;rx([pI(qo.prototype.onOwnerChange)],qo.prototype,"owner",2);const Pne=ee("debugavatar"),tl=class extends Ie{constructor(){super(...arguments),h(this,"connectionId"),h(this,"avatar")}static getAvatar(i){return i>=0&&i<tl.instances.length?tl.instances[i]:null}static onAvatarMarkerCreated(i){return tl._onNewAvatarMarkerAdded.push(i),i}static onAvatarMarkerDestroyed(i){return tl._onAvatarMarkerDestroyed.push(i),i}awake(){tl.instances.push(this),Pne&&console.log(this);for(const i of tl._onNewAvatarMarkerAdded)i({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){tl.instances.splice(tl.instances.indexOf(this),1);for(const i of tl._onAvatarMarkerDestroyed)i({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Mr=tl;h(Mr,"instances",[]),h(Mr,"_onNewAvatarMarkerAdded",[]),h(Mr,"_onAvatarMarkerDestroyed",[]);var Bne=Object.defineProperty,Dne=Object.getOwnPropertyDescriptor,kne=(i,e,t,n)=>{for(var r=n>1?void 0:n?Dne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Bne(e,t,r),r};const _f=ee("debugxrflags"),A4=ee("disablexrflags");A4&&console.warn("XRFlags are disabled");var il=(i=>(i[i.Never=0]="Never",i[i.Browser=1]="Browser",i[i.AR=2]="AR",i[i.VR=4]="VR",i[i.FirstPerson=8]="FirstPerson",i[i.ThirdPerson=16]="ThirdPerson",i[i.All=4294967295]="All",i))(il||{});const y4=class{constructor(){h(this,"Mask",17)}Has(i){return(this.Mask&i)!==0}Set(i){_f&&console.warn("Set XR flag state to",i),this.Mask=i,oo.Apply()}Enable(i){this.Mask|=i,oo.Apply()}Disable(i){this.Mask&=~i,oo.Apply()}Toggle(i){this.Mask^=i,oo.Apply()}EnableAll(){this.Mask=-1,oo.Apply()}DisableAll(){this.Mask=0,oo.Apply()}};let ws=y4;h(ws,"Global",new y4);var Uv;const ac=(Uv=class extends Ie{constructor(){super(...arguments),h(this,"visibleIn")}static Apply(){for(const i of this.registry)i.UpdateVisible(ws.Global)}awake(){ac.registry.push(this)}onEnable(){ac.firstApply?this.UpdateVisible(ws.Global):(ac.firstApply=!0,ac.Apply())}onDestroy(){const i=ac.registry.indexOf(this);i>=0&&ac.registry.splice(i,1)}get isOn(){return this.gameObject.visible}UpdateVisible(i=null){if(A4)return;let e;const t=i;if(t&&typeof t=="number"&&(console.assert(typeof t=="number","XRFlag.UpdateVisible: state must be a number",t),_f&&console.log(t),ac.buffer.Mask=t,i=ac.buffer),i instanceof ws?(_f&&console.warn(this.name,"use passed in mask",i.Mask,this.visibleIn),e=i.Has(this.visibleIn)):(_f&&console.log(this.name,"use global mask"),ws.Global.Has(this.visibleIn)),e!==void 0)if(e)_f&&console.log(this.name,"is visible",this.gameObject.uuid),re.setActive(this.gameObject,!0);else{if(_f&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},h(Uv,"registry",[]),h(Uv,"firstApply"),h(Uv,"buffer",new ws),Uv);let oo=ac;kne([x()],oo.prototype,"visibleIn",2);var One=Object.defineProperty,Lne=Object.getOwnPropertyDescriptor,fI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Lne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&One(e,t,r),r};const Fv=ee("debugwebxr"),b4=new Me().setFromAxisAngle(new S(0,1,0),Math.PI);class sd extends Ie{constructor(){super(...arguments),h(this,"head"),h(this,"leftHand"),h(this,"rightHand"),h(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;Fv&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const t=qo.getFor(this);if(t!=null&&t.owner){const n=this.gameObject.addNewComponent(Mr);n.avatar=this.gameObject,n.connectionId=t.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):t&&!this.context.connection.isConnected&&(t.dontDestroy=!0)}onLeaveXR(e){const t=this.gameObject.getComponent(Mr);t&&t.destroy()}onUpdateXR(e){var t,n;if(!this.activeAndEnabled)return;const r=qo.isLocalPlayer(this);if(!r)return;const s=e.xr;if(s.rig&&s.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),s.rig.gameObject.add(this.gameObject)),this._syncTransforms&&r)for(const c of this._syncTransforms)c.fastMode=!0,c.isOwned()||c.requestOwnership();if(this.head&&this.context.mainCamera){const c=this.head.asset;if(c.position.copy(this.context.mainCamera.position),c.quaternion.copy(this.context.mainCamera.quaternion),c.quaternion.x*=-1,this.context.time.frameCount%10===0){const u=re.getComponentsInChildren(this.head.asset,oo);for(const d of u)d.enabled=!1,d.gameObject.visible=!1}}const o=e.xr.leftController,a=(t=this.leftHand)==null?void 0:t.asset;o&&a&&(a.position.copy(o.gripPosition),a.quaternion.copy(o.gripQuaternion),a.quaternion.multiply(b4),a.visible=o.isTracking);const l=e.xr.rightController;if(l&&(n=this.rightHand)!=null&&n.asset){const c=this.rightHand.asset;c.position.copy(l.gripPosition),c.quaternion.copy(l.gripQuaternion),c.quaternion.multiply(b4),c.visible=l.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var e,t,n;if(this.context.connection.isConnected){const r=qo.getFor(this);if(r&&r.isLocalPlayer==!1){const s=_t.getXRSync(this.context);if(s&&s.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const o=(e=this.leftHand)==null?void 0:e.asset;o&&(o.visible=s?.isTracking(r.owner,"left")??!1);const a=(t=this.rightHand)==null?void 0:t.asset;a&&(a.visible=s?.isTracking(r.owner,"right")??!1)}if((n=this.head)!=null&&n.asset){const o=re.getComponentsInChildren(this.head.asset,oo);for(const a of o)a.enabled=!1,a.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};ZF.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof ge&&(this.head=new Zt("",this.sourceId,this.head));else{const e=new ge;e.name="Head";const t=rv.createPrimitive(qu.Cube);e.add(t),this.gameObject.add(e),this.head=new Zt("",this.sourceId,e),Fv&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof ge&&(this.rightHand=new Zt("",this.sourceId,this.rightHand));else{const e=new ge;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new Zt("",this.sourceId,e),Fv&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof ge&&(this.leftHand=new Zt("",this.sourceId,this.leftHand));else{const e=new ge;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new Zt("",this.sourceId,e),Fv&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),qo.isLocalPlayer(this.gameObject)&&(this._syncTransforms=re.getComponentsInChildren(this.gameObject,Ah))}async loadAvatarObjects(e,t,n){const r=e.loadAssetAsync(),s=t.loadAssetAsync(),o=n.loadAssetAsync(),a=new Array;r&&a.push(r),s&&a.push(s),o&&a.push(o);const l=await ag(a);Fv&&console.log("Avatar loaded results:",l)}}fI([x(Zt)],sd.prototype,"head",2),fI([x(Zt)],sd.prototype,"leftHand",2),fI([x(Zt)],sd.prototype,"rightHand",2);class nl{static Add(e,t,n=null){if(t){for(const r of this.Pois)if(r.obj===t)return;this.Pois.push({obj:t,avatar:n}),this.LastChangeTime=e.time.time}}static Remove(e,t){var n;if(t){for(const r of this.Pois)if(r.obj===t){this.Pois.splice(this.Pois.indexOf(r),1),this.LastChangeTime=e?.time.time??((n=Ot.Current)==null?void 0:n.time.time);return}}}}h(nl,"Pois",[]),h(nl,"LastChangeTime",0);class Une{constructor(){h(this,"guid"),h(this,"position",new S)}}class Nv extends Ie{constructor(){super(...arguments),h(this,"target",null),h(this,"avatar",null),h(this,"_model",null),h(this,"_targetModel",new Une),h(this,"_currentTargetObject",null),h(this,"_lastUpdateTime",0),h(this,"_lookDuration",0),h(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const t=q.get("MoveRandom");if(t&&this.target){const n=re.getComponent(this.target,t);n&&n.destroy()}}awake(){if(this.avatar=re.getComponentInParent(this.gameObject,Mr),this.avatar){const e=re.getComponentInParent(this.gameObject,Mr);this._model=new RT(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var t;this.target&&e&&e.guid===((t=this.avatar)==null?void 0:t.guid)&&Wr(this.target,e.position)})}update(){var e;if((!this.context.connection.isConnected||(e=this._model)!=null&&e.hasOwnership)&&(nl.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=nl.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const t=Pt(this._currentTargetObject);Wr(this.target,t),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(t))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const e=nl.Pois;if(e.length>0){const t=e[Math.floor(Math.random()*e.length)];if(t&&t.obj){if(t.avatar&&t.avatar===this.avatar)return;this._currentTargetObject=t.obj}}}}}const xf=ee("debugnetworkingstreams");var rl=(i=>(i.Connected="peer-user-connected",i.StreamReceived="receive-stream",i.StreamEnded="call-ended",i.Disconnected="peer-user-disconnected",i.UserJoined="user-joined",i))(rl||{});class _4{constructor(e,t){h(this,"type","call-ended"),h(this,"userId"),h(this,"direction"),this.userId=e,this.direction=t}}class x4{constructor(e,t){h(this,"type","receive-stream"),h(this,"stream"),h(this,"target"),this.stream=e,this.target=t}}class Fne{constructor(e,t){h(this,"guid"),h(this,"peerId"),h(this,"dontSave",!0),this.guid=e.id,this.peerId=t}}var w4=(i=>(i.Incoming="incoming",i.Outgoing="outgoing",i))(w4||{});class Nne extends Kn{constructor(e,t,n){super(),h(this,"userId"),h(this,"direction"),h(this,"call"),h(this,"_stream",null),h(this,"_isDisposed",!1),this.userId=e,this.call=t,this.direction=n,this._stream=null,t.on("stream",r=>{if(xf&&console.log("Receive video",r.getAudioTracks(),r.getVideoTracks()),this._stream=r,n==="incoming"){const s=new x4(r,this);this.dispatchEvent(s)}}),t.on("close",()=>{this.dispatchEvent(new _4(e,n))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),lc(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const zv=class extends Kn{constructor(i,e){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=i,this.id=e,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(i,e){if(zv.instances.has(e))return zv.instances.get(e);const t=new zv(i,e);return zv.instances.set(e,t),t}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(i){return this.id+"-"+i}getUserIdFromPeerId(i){return i.substring(this.id.length+1)}makeCall(i,e){var t;const n={metadata:{userId:this.context.connection.connectionId}},r=(t=this._peer)==null?void 0:t.call(i,e,n);if(r)return this.registerCall(r,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(Kt.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(Kt.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const i=this.getMyPeerId();i?this._peer=zF(i):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(i){xf&&console.log("Peer connected as",i),this.context.connection.send("peer-user-connected",new Fne(this,i))}onPeerReceivingCall(i){i.answer(),this.registerCall(i,"incoming")}registerCall(i,e){const t=i.metadata;(!t||!t.userId)&&console.error("Missing call metadata",i);const n=t.userId;e==="incoming"&&xf?console.log("Receive call from",i.metadata):xf&&console.log("Make call to",i.metadata);const r=e==="incoming"?this._incomingCalls:this._outgoingCalls,s=new Nne(n,i,e);return r.push(s),i.on("error",o=>{console.error("Call error",o)}),i.on("close",()=>{xf&&console.log("Call ended",i.metadata),i.close();const o=r.indexOf(s);o!==-1&&r.splice(o,1)}),s.addEventListener("call-ended",o=>{this.dispatchEvent(o)}),e==="incoming"&&(s.addEventListener("receive-stream",o=>{this.dispatchEvent(o)}),i.on("stream",()=>{let o=0;const a=setInterval(()=>{const l=o===0;!s.isOpen&&l&&(o+=1,clearInterval(a),s.close())},2e3)})),s}};let sx=zv;h(sx,"instances",new Map);class oA extends Kn{constructor(e,t){super(),h(this,"context"),h(this,"peer"),h(this,"_sendingStreams",new Map),h(this,"debug",!1),h(this,"onJoinedRoom",n=>{this.debug&&console.log(`${n.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()}),h(this,"onReceiveStream",n=>{this.debug&&console.log("RECEIVE STREAM",n),this.dispatchEvent({type:"receive-stream",target:this,stream:n.stream,userId:n.userId})}),h(this,"onCallEnded",n=>{this.dispatchEvent(n)}),h(this,"onUserConnected",n=>{if(this.peer.id===n.guid){this.debug&&console.log("USER CONNECTED",n.guid,n);const r=this._sendingStreams.keys().next().value;this.peer.makeCall(n.peerId,r)}}),h(this,"onUserLeft",n=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()}),this.context=e,this.peer=t,xf&&(this.debug=!0)}static create(e){const t=sx.getOrCreate(e.context,e.context.connection.connectionId);return new oA(e.context,t)}startSendingStream(e){this._sendingStreams.has(e)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(e,[]),this.updateSendingCalls())}stopSendingStream(e){if(e){const t=this._sendingStreams.get(e);if(t){this.debug&&console.log("Closing calls",t);for(const n of t)n.close()}this._sendingStreams.delete(e),t&&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(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Kt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Kt.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(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Kt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Kt.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var e;let t=!1;const n=this.context.connection.connectionId;for(const r of this._sendingStreams.keys()){const s=this._sendingStreams.get(r)||[];for(const o of this.context.connection.usersInRoom()){if(o===n)continue;const a=s.find(l=>l.userId===o);if(!a||((e=a.stream)==null?void 0:e.active)===!1){this.debug&&console.log("Starting call to",o,n);const l=this.peer.makeCall(this.peer.getPeerIdFromUserId(o),r);l&&(t=!0,s.push(l))}}this._sendingStreams.set(r,s)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const e of this._sendingStreams.keys()){const t=this._sendingStreams.get(e);if(t)for(let n=t.length-1;n>=0;n--){const r=t[n];this.context.connection.userIsInRoom(r.userId)||(r.close(),t.splice(n,1))}}}}function lc(i){if(i&&i instanceof MediaStream)for(const e of i.getTracks())e.stop()}var zne=Object.defineProperty,jne=Object.getOwnPropertyDescriptor,S4=(i,e,t,n)=>{for(var r=n>1?void 0:n?jne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&zne(e,t,r),r};const Gne="noVoip",Qne=ee("debugvoip");class od 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 ua(300),this.autoConnect&&!this.isSending&&this.connect()}),h(this,"_incomingStreams",new Map),h(this,"onReceiveStream",e=>{const t=e.target.userId,n=e.stream,r=this._incomingStreams.get(t);if(r)r.srcObject=n,r.setAttribute("autoplay","true");else{const s=new Audio;this._incomingStreams.set(t,s),s.setAttribute("autoplay","true"),s.srcObject=n}}),h(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);lc(t?.srcObject),this._incomingStreams.delete(e.userId)}),h(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}}),h(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const e=document.visibilityState!=="visible";this.setMuted(e);for(const t of this._incomingStreams){const n=t[1];n.muted=e}})}awake(){Qne&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async e=>{e.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=oA.create(this)),this._net.addEventListener(rl.StreamReceived,this.onReceiveStream),this._net.addEventListener(rl.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(Kt.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(rl.StreamReceived,this.onReceiveStream),this._net.removeEventListener(rl.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(Kt.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(e){if(this.context.connection.isConnected){if(!await kC())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),lc(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await kC()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):RE("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),lc(this._outputStream),this._outputStream=null}setMuted(e){var t;const n=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(n)for(const r of n)r.enabled=!e}get isMuted(){var e;if(this._outputStream===null)return!1;const t=(e=this._outputStream)==null?void 0:e.getAudioTracks();if(t){for(const n of t)if(!n.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,ut()&&$i("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(e){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1}).catch(t=>(console.warn("VOIP failed getting audio stream",t),null)):(console.error("No getDisplayMedia support"),null)}}S4([x()],od.prototype,"autoConnect",2),S4([x()],od.prototype,"runInBackground",2);var Hne=Object.defineProperty,Vne=Object.getOwnPropertyDescriptor,C4=(i,e,t,n)=>{for(var r=n>1?void 0:n?Vne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Hne(e,t,r),r};const Wne=ee("debugmouth");class jv 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=re.findObjectOfType(od,this.context),this.marker||(this.marker=re.getComponentInParent(this.gameObject,Mr))},3e3)}update(){var e;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((e=this.marker)==null?void 0:e.connectionId)??null;if(!t){Wne&&(t=null);return}const n=this.voip.getFrequency(t)??0;this.updateLips(n)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(n=>n.visible=!1):this.talking.map(n=>n.visible=!1);for(let n=0;n<e.length;n++){const r=e[n];r&&(r.visible=n===t)}}}}C4([x(ge)],jv.prototype,"idle",2),C4([x(ge)],jv.prototype,"talking",2);class mI extends Ie{constructor(){super(...arguments),h(this,"voip",null),h(this,"marker",null),h(this,"_startPosition",null)}awake(){this.voip=re.findObjectOfType(od,this.context),this.marker=re.getComponentInParent(this.gameObject,Mr)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const n=t/100;this.gameObject.position.y=this._startPosition.y+n*.07}}var qne=Object.defineProperty,Xne=Object.getOwnPropertyDescriptor,ox=(i,e,t,n)=>{for(var r=n>1?void 0:n?Xne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&qne(e,t,r),r};class ad 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=re.getComponentInParent(this.gameObject,oo)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const e of this.eyes)e&&(e.visible=this.eyesOpen)}}}ox([x(ge)],ad.prototype,"eyes",2),ox([x()],ad.prototype,"lastBlinkTime",2),ox([x()],ad.prototype,"blinkLength",2),ox([x()],ad.prototype,"eyesOpen",2);var Yne=Object.defineProperty,Jne=Object.getOwnPropertyDescriptor,gI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Jne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Yne(e,t,r),r},vI;const E4=(vI=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 S),h(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=re.getComponentInParent(this.gameObject,Nv)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=re.addNewComponent(this.gameObject,Nv)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const i=this.target;if(i&&this.head){const e=this.eyes;if(e){const t=Pt(i);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const n=Pt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(n).normalize();if(r.length()<.1)return;const s=E4.forward;if(s.set(0,0,1),s.applyQuaternion(xi(this.head)),s.dot(r)>.45)for(let o=0;o<e.length;o++)e[o].lookAt(this.currentTargetPoint)}}}},h(vI,"forward",new S(0,0,1)),vI);let wf=E4;gI([x(ge)],wf.prototype,"head",2),gI([x(ge)],wf.prototype,"eyes",2),gI([x(ge)],wf.prototype,"target",2);const Gv=ee("debugavatar");class ax{constructor(e,t,n,r){h(this,"root"),h(this,"head"),h(this,"leftHand"),h(this,"rigthHand");var s;this.root=e,this.head=t,this.leftHand=n,this.rigthHand=r,(s=this.root)==null||s.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class AI{constructor(){h(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(e,t){if(!t)return console.error("Can not create avatar: failed to provide id or root object"),null;let n=null;if(typeof t=="string"){if(n=await this.loadAvatar(e,t),!n){const s=new Ra;n=re.instantiate(Ip(t,e.scene),s)}}else n=t;if(!n)return null;const r=this.findAvatar(n);return r.isValid?(Gv&&console.log("[Custom Avatar] valid config",t,Gv?r:""),r):(console.warn("[Custom Avatar] config isn't valid",t,Gv?r:""),null)}async loadAvatar(e,t){if(console.assert(t!=null&&typeof t=="string","Avatar id must not be null"),t.length<=0||!t)return null;if(Gv&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const r=await fetch("./"+t);let s=null;if(r.ok){const a=await r.blob();a&&(s=await a.arrayBuffer())}if(!s&&(s=await iT(t,t,0,"no url here go away",!0),!s))return null;const o=await na().parseSync(e,s,null,0);return o?.scene??null}const n=new Fp;return Cg(n,e),new Promise((r,s)=>{const o=this.avatarRegistryUrl+"/"+t;n.load(o,async a=>{await na().createBuiltinComponents(e,o,a,null,void 0),r(a.scene)},a=>{Gv&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),r(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let n=t;n.children.length==1&&(n=e.children[0]);let r=this.findAvatarPart(n,["head"]);const s=this.findAvatarPart(n,["left","hand"]),o=this.findAvatarPart(n,["right","hand"]);if(!r){r=t;const a=new S;new fi().setFromObject(r).getSize(a);const l=Math.max(a.x,a.y,a.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+l+" meters! Should be < 0.3m"),l>.3&&r.scale.multiplyScalar(1/l*.3)}return new ax(t,r,s,o)}findAvatarPart(e,t){const n=e.name.toLowerCase();let r=!0;for(const s of t){if(!r)break;n.indexOf(s)===-1&&(r=!1)}if(r)return e;if(e.children)for(const s of e.children){const o=this.findAvatarPart(s,t);if(o)return o}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}var Kne=Object.defineProperty,Zne=Object.getOwnPropertyDescriptor,yI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Zne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Kne(e,t,r),r};class Sf 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&&!Vg)return;this._axes||(this._axes=new To(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}yI([x()],Sf.prototype,"length",2),yI([x()],Sf.prototype,"depthTest",2),yI([x()],Sf.prototype,"isGizmo",2);class bI 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 e=Pt(this.to).clone(),t=Pt(this.from).clone(),n=e.distanceTo(t),r=e.clone();r.sub(t);const s=t.clone();s.add(e),s.multiplyScalar(.5);const o=Pt(this.hint).clone();o.sub(s);const a=new S;a.crossVectors(o,r),a.crossVectors(r,a),a.normalize();const l=n*.5,c=Math.max(this.desiredDistance,l),u=Math.sqrt(c*c-l*l),d=a.clone();d.multiplyScalar(u),d.add(s),Wr(this.gameObject,d);const p=s.clone();p.sub(a),this.gameObject.lookAt(p)}}const _I=ee("debugusdzbehaviours");class lx{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(n=>{re.foreachComponent(n,r=>{var s;const o=r;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const a=(s=o.beforeCreateDocument)==null?void 0:s.call(o,this,e);a instanceof Promise&&t.push(a)}},!1)}),_I&&console.log("onBeforeBuildDocument: all components",this.behaviourComponents),Promise.all(t)}onExportObject(e,t,n){var r;for(const s of this.behaviourComponents)_I&&console.log("onExportObject: createBehaviours",s),(r=s.createBehaviours)==null||r.call(s,this,t,n)}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 n;if((n=this.behaviours)!=null&&n.length){t.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){_I&&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 $ne=Object.defineProperty,ere=Object.getOwnPropertyDescriptor,xI=(i,e,t,n)=>{for(var r=n>1?void 0:n?ere(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&$ne(e,t,r),r},wI;const M4=(wI=class extends Kr{constructor(){super(...arguments),h(this,"threshold"),h(this,"intensity"),h(this,"scatter"),h(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=i=>i,this.intensity.valueProcessor=i=>i,this.scatter.valueProcessor=i=>1*Math.PI*(1-i)):(this.threshold.valueProcessor=i=>i,this.intensity.valueProcessor=i=>i,this.scatter.valueProcessor=i=>100*(1-i))}onCreateEffect(){let i;if(this.selectiveBloom==null&&(this.selectiveBloom=M4.useSelectiveBloom),this.selectiveBloom){const e=i=new YU(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});e.inverted=!0}else i=new VM({blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=e=>{i.intensity=e},this.threshold.onValueChanged=e=>{i.luminanceMaterial.threshold=e},this.scatter.onValueChanged=e=>{i.luminancePass.enabled=!0,i.luminanceMaterial.smoothing=e},i}},h(wI,"useSelectiveBloom",!1),wI);let ld=M4;xI([x(Rt)],ld.prototype,"threshold",2),xI([x(Rt)],ld.prototype,"intensity",2),xI([x(Rt)],ld.prototype,"scatter",2),Wo("Bloom",ld);const Cf="NEEDLE_progressive",Zr=ee("debugprogressive"),SI=Symbol("needle-progressive-texture"),Ef=new Map;if(Zr){let i=function(){e+=1,Hi(`Toggle LOD level: ${e}<br/>Registered objects: ${Ef.size}`),console.log("Toggle LOD level",e,Ef);const n=ni.Current;Ef.forEach((r,s)=>{for(const o of r.keys){const a=s[o];if(a instanceof ft){const l=Ii.getMeshLODInformation(a),c=l?Math.min(e,l.lods.length):0;s["DEBUG:LOD"]=c,Ii.assignMeshLOD(n,r.sourceId,s,c),l&&(t=Math.max(t,l.lods.length-1))}else if(s instanceof It){Ii.assignTextureLOD(n,r.sourceId,s,e);break}}}),e>=t&&(e=-1)},e=-1,t=2;window.addEventListener("keyup",n=>{n.key==="p"&&i()}),ni.registerCallback(pn.ContextCreated,n=>{const r=document.createElement("button");r.innerText="Toggle Progressive",r.onclick=i,n.context.menu.appendChild(r)})}function T4(i,e,t){var n;if(!Zr)return;Ef.has(i)||Ef.set(i,{keys:[],sourceId:t});const r=Ef.get(i);((n=r?.keys)==null?void 0:n.includes(e))==!1&&r.keys.push(e)}const ao=class{constructor(i,e,t){h(this,"parser"),h(this,"sourceId"),h(this,"context"),this.parser=i,this.sourceId=e,this.context=t}get name(){return Cf}static getMeshLODInformation(i){const e=this.getAssignedLODInformation(i);return e!=null&&e.key?this.lodInfos.get(e.key):null}static hasLODLevelAvailable(i,e){var t;if(i instanceof It){for(const s of Object.keys(i)){const o=i[s];if(o instanceof gt&&this.hasLODLevelAvailable(o,e))return!0}return!1}else if(i instanceof hs){for(const s of i.children)if(s instanceof ue&&this.hasLODLevelAvailable(s,e))return!0}let n,r;if(i instanceof ue?n=i.geometry:i instanceof gt&&(n=i),n&&(t=n?.userData)!=null&&t.LODS){const s=n.userData.LODS;if(r=this.lodInfos.get(s.key),e===void 0)return r!=null;if(r)return Array.isArray(r.lods)?e<r.lods.length:e===0}return!1}static assignMeshLOD(i,e,t,n){if(!t)return Promise.resolve(null);if(t instanceof ue){const r=t.geometry,s=this.getAssignedLODInformation(r);if(!s)return Promise.resolve(null);av(t)||w_(t,t.geometry);const o=this.onProgressiveLoadStart(i,e,t,null);return t["LOD:requested level"]=n,ao.getOrLoadLOD(i,e,r,n).then(a=>{if(t["LOD:requested level"]===n){if(delete t["LOD:requested level"],Array.isArray(a)){const l=s.index||0;a=a[l]}a&&r!=a&&(Zr=="verbose"&&console.log("Progressive Mesh "+t.name+" loaded",r,"\u2192",a,`
|
|
5508
|
+
`))}for(const C of M){const P=s.get(C);P&&D.set(C,P)}return D},f=function(M){const D=p(M),C=l(D);return c(D,C,M)};const m=r.skinnedMesh.skeleton,A=new Array;for(const M in m.bones){const D=m.bones[M],C=m.boneInverses[M];A.push({bone:D,inverse:C})}for(const M of QL(m.bones))A.push({bone:M,inverse:M.matrixWorld.clone().invert()});const v=A[0].bone.parent;v||console.error("No bone parent found for skinned mesh during USDZ export",r.skinnedMesh),A.sort((M,D)=>Hp(M.bone,v)>Hp(D.bone,v)?1:-1);const g=[],y=[],b=[],_=[];for(const{bone:M}of A)g.push(M.matrix.clone()),y.push(M.position),b.push(M.quaternion),_.push(M.scale);const E=A.map(M=>'"'+Hp(M.bone,v)+'"').join(", "),I=A.map(M=>Vp(M.inverse.clone().invert())).join(", ");e.beginBlock('def Skeleton "Rig"'),e.appendLine(`uniform matrix4d[] bindTransforms = [${I}]`),e.appendLine(`uniform token[] joints = [${E}]`),e.appendLine('uniform token purpose = "guide"'),e.appendLine(`uniform matrix4d[] restTransforms = [${g.map(M=>Vp(M)).join(", ")}]`),e.appendLine(`matrix4d xformOp:transform = ${Vp(new Ce)}`),e.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const T=f(A.map(M=>M.bone));if(el){let M=1e7,D=0;for(const C of((n=T.position)==null?void 0:n.keys())??[])M=Math.min(M,C),D=Math.max(D,C);console.log("Time samples",M,D,T)}if(e.beginBlock('def SkelAnimation "_anim"'),e.appendLine(`uniform token[] joints = [${E}]`),e.appendLine(`quatf[] rotations = [${d(b)}]`),T&&T.quaternion){e.beginBlock("quatf[] rotations.timeSamples = {","");const M=a(T.quaternion);for(const D of M)e.appendLine(D);e.closeBlock()}if(e.appendLine(`half3[] scales = [${u(_)}]`),T&&T.scale){e.beginBlock("half3[] scales.timeSamples = {","");const M=o(T.scale);for(const D of M)e.appendLine(D);e.closeBlock()}if(e.appendLine(`float3[] translations = [${u(y)}]`),T&&T.position){e.beginBlock("float3[] translations.timeSamples = {","");const M=o(T.position);for(const D of M)e.appendLine(D);e.closeBlock()}e.closeBlock(),e.closeBlock()}}onSerialize(e,t){var n;if(!this.model)return;const r=this.dict.get(this.object);if(r)for(let d=0;d<r.length;d++)r[d]===void 0&&(r[d]=new rr(null,this.object,null));this.skinnedMeshExport(e,t);const s=this.object,o=this.dict.get(s);if(!o||s.isSkinnedMesh)return;cI&&console.log("SERIALIZE",this.model.name,this.object.type,o);const a=new Ce;e.appendLine("matrix4d xformOp:transform.timeSamples = {"),e.indent++;const l=new Array;let c=0;for(let d=0;d<o.length;d++){if(l.push(c),o[d]===void 0){console.error("Got an undefined transform data, this is likely a bug.",s,o);continue}c+=o[d].getDuration()+rr.animationDurationPadding}const u=Intl.NumberFormat("en-US",{maximumFractionDigits:3,minimumFractionDigits:0,useGrouping:!1});for(let d=0;d<o.length;d++){const p=o[d];if(!p)continue;const f=l[d];{const m=p.getSortedTimesArray();if(!m||m.length===0){console.error("got an animated object but no time values?",s,p);continue}{const A=((n=p.clip)==null?void 0:n.name)??"rest",v=p.getDuration();el&&console.log("Write .timeSamples:",A,f,v,o),e.appendLine("# "+A+": start="+u.format(f*p.frameRate)+", length="+u.format(v*p.frameRate)+", frames="+p.getFrames())}for(const{time:A,translation:v,rotation:g,scale:y}of p.getValues(m)){a.compose(v,g,y);const b=`${u.format((f+A)*p.frameRate)}: ${Vp(a)},`;e.appendLine(b)}}}e.indent--,e.appendLine("}")}}var cne=Object.defineProperty,hne=Object.getOwnPropertyDescriptor,m4=(i,e,t,n)=>{for(var r=n>1?void 0:n?hne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&cne(e,t,r),r};const g4=ee("debugpost");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 n=this._value;if(g4){let r=!0;if(typeof n=="number"&&typeof e=="number"){const s=n?.toFixed(4),o=e?.toFixed(4);s!=o?r=!0:r=!1}r&&console.log("VolumeParameter: value changed from",n,"to",e)}!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,n,this):g4&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(e){return this._valueRaw!==e}}m4([x()],Rt.prototype,"overrideState",1),m4([x()],Rt.prototype,"value",1);var une=Object.defineProperty,dne=Object.getOwnPropertyDescriptor,pne=(i,e,t,n)=>{for(var r=n>1?void 0:n?dne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&une(e,t,r),r};const fne=ee("debugpost");class Kr extends Ie{constructor(e=void 0){if(super(),h(this,"active",!0),h(this,"_result"),h(this,"_didCreateVolumeParameters",!1),e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const n=e[t],r=this[t];r instanceof Rt&&(r.value=n)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){fne&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const n=this[t];n instanceof Rt&&n.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const n=this.$serializedTypes;if(n){for(const r of Object.keys(n))if(n[r]===Rt){const s=e[r];if(s!==void 0){const o=this[r];o.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Rt){const n=e.value;return this[t].value=n,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Rt&&(this[t]||(this[t]=new Rt))}}pne([x()],Kr.prototype,"active",2);var mne=Object.defineProperty,gne=Object.getOwnPropertyDescriptor,vne=(i,e,t,n)=>{for(var r=n>1?void 0:n?gne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&mne(e,t,r),r};const Ane=ee("debugpost"),hI={};function Wo(i,e){hI[i]=e}function yne(i){return i.__type in hI?hI[i.__type]:(Ane&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),Kr)}class Dv{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}vne([qp([i=>yne(i),Kr])],Dv.prototype,"components",2);var bne=Object.defineProperty,_ne=Object.getOwnPropertyDescriptor,xne=(i,e,t,n)=>{for(var r=n>1?void 0:n?_ne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&bne(e,t,r),r};class kv extends Kr{constructor(){super(...arguments),h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new ZU({preset:Jp.HIGH,edgeDetectionMode:zM.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}xne([x(Rt)],kv.prototype,"preset",2),Wo("Antialiasing",kv);const wne=ee("debugusdz");class Vh{constructor(){h(this,"files",new Array)}static getName(e){var t;const n=e.split(".").pop();let r=(t=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:t.replace(".","_");return r||(r="Audio_"+Math.random().toString(36).substring(2,15)),Aa(r)+"."+n}get extensionName(){return"Audio"}onExportObject(e,t,n){const r=re.getComponents(e,en);if(r.length)for(const s of r){if(!s.clip||typeof s.clip!="string"||!s.playOnAwake)continue;const o=s.clip.split("/").pop()||"Audio",a=Vh.getName(s.clip),l=Aa(a);this.files.some(c=>c.path===s.clip)||this.files.push({path:s.clip,name:a}),n.quickLookCompatible||t.addEventListener("serialize",(c,u)=>{c.appendLine(),c.beginBlock(`def SpatialAudio "${l}"`,"(",!1),c.appendLine(`displayName = "${o}"`),c.closeBlock(")"),c.beginBlock(),c.appendLine(`uniform asset filePath = @audio/${a}@`),c.appendLine(`uniform token auralMode = "${s.spatialBlend>0?"spatial":"nonSpatial"}"`),c.appendLine(`uniform token playbackMode = "${s.loop?"loopFromStage":"onceFromStart"}"`),c.appendLine(`uniform float gain = ${s.volume}`),c.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const n="audio/"+t.name;if(e.files[n]){wne&&console.warn("Audio file with name "+n+" already exists in the context. Skipping.");continue}const r=await(await(await fetch(t.path)).blob()).arrayBuffer(),s=new Uint8Array(r);e.files[n]=s}}}const rd=ee("debugautosync"),uI=Symbol("syncerId");class Sne{constructor(){h(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new Cne(e);return t[uI]=e.guid,this._syncers[t[uI]]=t,t}removeSyncer(e){delete this._syncers[e[uI]]}}const dI=new Sne;class Cne{constructor(e){h(this,"comp"),h(this,"hasChanges",!1),h(this,"changedProperties",{}),h(this,"data",{}),h(this,"_isReceiving",!1),h(this,"_isInit",!1),h(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const t=this.comp.context.connection;if(!t||!t.isConnected||!t.isInRoom){for(const n in this.changedProperties)delete this.changedProperties[n];return}for(const n in this.data)delete this.data[n];this.data.guid=this.comp.guid;for(const n in this.changedProperties){const r=this.changedProperties[n];delete this.changedProperties[n],this.data[n]=r}t.send(this.networkingKey,this.data,Fo.Queued)}),h(this,"onHandleReceiving",t=>{if(rd&&console.log("RECEIVE",this.comp.name,this.comp.guid,t),!this._isInit||!this.comp)return;const n=t.guid;if(!(n&&n!==this.comp.guid)){rd&&console.log("RECEIVED",this.comp.name,this.comp.guid,t);try{this._isReceiving=!0;for(const r in t){if(r==="guid")continue;const s=t[r];this.comp[r]=s,rd&&console.log("SET",r,s)}}catch(r){console.error(r)}finally{this._isReceiving=!1}}}),this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(rd&&console.log("Property changed: "+e,t),this.hasChanges=!0,this.changedProperties[e]=t)}}function Ene(i,e){let t=e!==i;return!t&&i&&e&&(Array.isArray(i)&&Array.isArray(e)||typeof i=="object"&&typeof e=="object")&&(t=!0),t}const Ov=Symbol("AutoSyncHandler");function Mne(i){if(i[Ov])return i[Ov];const e=dI.getOrCreateSyncer(i);return e?.init(i),i[Ov]=e,e}function Tne(i){const e=i[Ov];e&&(dI.removeSyncer(e),e.destroy(),delete i[Ov])}const pI=function(i){return function(e,t){var n;let r="";typeof t=="string"?r=t:r=t.name;let s=null,o;typeof i=="string"?o=e[i]:typeof i=="function"&&(o=i);const a=e,l=a.__internalAwake;if(typeof l!="function"){(rd||ut())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((n=e?.constructor)==null?void 0:n.name)+'" is not supported',e);return}rd&&console.log(r);const c=Symbol(r);a.__internalAwake=function(){if(this[c]!==void 0)return;this[c]=this[r],s=dI.getOrCreateSyncer(this);const d=Object.getOwnPropertyDescriptor(this,r);if(d?.set===void 0){let p=!1;Object.defineProperty(this,r,{set:function(f){var m;const A=this[c];if(this[c]=f,p){ut()&&console.warn("Recursive call detected",r);return}p=!0;try{const v=Ene(f,A);rd&&console.log("SyncField assignment",r,"changed?",v,f),v&&o?.call(this,f,A)!==!1&&((m=Mne(this))==null||m.notifyChanged(r,f))}finally{p=!1}},get:function(){return this[c]},configurable:!0,enumerable:!0})}s?.init(this),l.call(this)};const u=a.__internalDestroy;a.__internalDestroy=function(){Tne(this),u.call(this)}}};var Ine=Object.defineProperty,Rne=Object.getOwnPropertyDescriptor,rx=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ine(e,t,r),r};const so=ee("debugplayersync");class bf extends Ie{constructor(){super(...arguments),h(this,"autoSync",!0),h(this,"asset"),h(this,"onPlayerSpawned"),h(this,"_localInstance"),h(this,"onJoinedRoom",()=>{so&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new Hn)}onEnable(){this.context.connection.beginListen(Kt.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(Kt.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(Kt.JoinedRoom,this.onJoinedRoom)}async getInstance(){var e,t,n,r,s,o;if(this._localInstance)return this._localInstance;if(so&&console.log("PlayerSync.createInstance",(e=this.asset)==null?void 0:e.uri),!((t=this.asset)!=null&&t.asset)&&!((n=this.asset)!=null&&n.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(r=this.asset)==null?void 0:r.instantiateSynced({parent:this.gameObject},!0);const a=await this._localInstance;if(a){const l=re.getComponent(a,qo);l?(l.owner=this.context.connection.connectionId,(s=this.onPlayerSpawned)==null||s.invoke(a)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((o=this.asset)==null?void 0:o.uri)+"</strong>: please make sure the asset has a PlayerState component!"),re.destroySynced(a))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var e;(e=this._localInstance)==null||e.then(t=>(so&&console.log("PlayerSync.destroyInstance",t),re.destroySynced(t))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",e=>{if(document.visibilityState==="visible")for(let t=qo.all.length-1;t>=0;t--){const n=qo.all[t];(!n.owner||!this.context.connection.userIsInRoom(n.owner))&&n.doDestroy()}})}}rx([x()],bf.prototype,"autoSync",2),rx([x(Zt)],bf.prototype,"asset",2),rx([x(Hn)],bf.prototype,"onPlayerSpawned",2);var v4=(i=>(i.OwnerChanged="ownerChanged",i))(v4||{}),Lv;const Er=(Lv=class extends Ie{constructor(){super(...arguments),h(this,"onOwnerChangeEvent",new Hn),h(this,"onFirstOwnerChangeEvent",new Hn),h(this,"hasOwner",!1),h(this,"owner"),h(this,"dontDestroy",!1),h(this,"onUserLeftRoom",i=>{if(i.userId===this.owner){so&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return Er._all}static get local(){return Er._local}static getFor(i){if(i instanceof ge)return re.getComponentInParent(i,Er);if(i instanceof Ie)return re.getComponentInParent(i.gameObject,Er)}static isLocalPlayer(i){const e=Er.getFor(i);return e?.isLocalPlayer??!1}static addEventListener(i,e){return this._callbacks[i]||(this._callbacks[i]=[]),this._callbacks[i].push(e),e}static removeEventListener(i,e){if(!this._callbacks[i])return;const t=this._callbacks[i].indexOf(e);t>=0&&this._callbacks[i].splice(t,1)}static dispatchEvent(i,e){if(this._callbacks[i])for(const t of this._callbacks[i])t(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(i,e){var t,n;so&&console.log("PlayerSync.onOwnerChange",this,"newOwner",i,"oldOwner",e);const r=Er._local.indexOf(this);r>=0&&Er._local.splice(r,1);const s={playerState:this,oldValue:e,newValue:i};if(this.hasOwner||(this.hasOwner=!0,(t=this.onFirstOwnerChangeEvent)==null||t.invoke(s)),(n=this.onOwnerChangeEvent)==null||n.invoke(s),this.owner===this.context.connection.connectionId){Er._local.push(this);const a=new CustomEvent("local-owner-changed",{detail:s});this.dispatchEvent(a)}const o=new CustomEvent("owner-changed",{detail:s});this.dispatchEvent(o),Er.dispatchEvent("ownerChanged",o)}awake(){Er.all.push(this),so&&console.log("Registered new PlayerState",this.guid,Er.all.length-1,Er.all),this.context.connection.beginListen(Kt.UserLeftRoom,this.onUserLeftRoom)}async start(){so&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await ua(300),this.context.connection.userIsInRoom(this.owner)==!1&&(so&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(so&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?so&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(so&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):so&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){so&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),P_(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(Kt.UserLeftRoom,this.onUserLeftRoom),Er.all.splice(Er.all.indexOf(this),1),this.isLocalPlayer){const i=Er._local.indexOf(this);i>=0&&Er._local.splice(i,1)}}},h(Lv,"_all",[]),h(Lv,"_local",[]),h(Lv,"_callbacks",{}),Lv);let qo=Er;rx([pI(qo.prototype.onOwnerChange)],qo.prototype,"owner",2);const Pne=ee("debugavatar"),tl=class extends Ie{constructor(){super(...arguments),h(this,"connectionId"),h(this,"avatar")}static getAvatar(i){return i>=0&&i<tl.instances.length?tl.instances[i]:null}static onAvatarMarkerCreated(i){return tl._onNewAvatarMarkerAdded.push(i),i}static onAvatarMarkerDestroyed(i){return tl._onAvatarMarkerDestroyed.push(i),i}awake(){tl.instances.push(this),Pne&&console.log(this);for(const i of tl._onNewAvatarMarkerAdded)i({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){tl.instances.splice(tl.instances.indexOf(this),1);for(const i of tl._onAvatarMarkerDestroyed)i({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Mr=tl;h(Mr,"instances",[]),h(Mr,"_onNewAvatarMarkerAdded",[]),h(Mr,"_onAvatarMarkerDestroyed",[]);var Bne=Object.defineProperty,Dne=Object.getOwnPropertyDescriptor,kne=(i,e,t,n)=>{for(var r=n>1?void 0:n?Dne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Bne(e,t,r),r};const _f=ee("debugxrflags"),A4=ee("disablexrflags");A4&&console.warn("XRFlags are disabled");var il=(i=>(i[i.Never=0]="Never",i[i.Browser=1]="Browser",i[i.AR=2]="AR",i[i.VR=4]="VR",i[i.FirstPerson=8]="FirstPerson",i[i.ThirdPerson=16]="ThirdPerson",i[i.All=4294967295]="All",i))(il||{});const y4=class{constructor(){h(this,"Mask",17)}Has(i){return(this.Mask&i)!==0}Set(i){_f&&console.warn("Set XR flag state to",i),this.Mask=i,oo.Apply()}Enable(i){this.Mask|=i,oo.Apply()}Disable(i){this.Mask&=~i,oo.Apply()}Toggle(i){this.Mask^=i,oo.Apply()}EnableAll(){this.Mask=-1,oo.Apply()}DisableAll(){this.Mask=0,oo.Apply()}};let ws=y4;h(ws,"Global",new y4);var Uv;const ac=(Uv=class extends Ie{constructor(){super(...arguments),h(this,"visibleIn")}static Apply(){for(const i of this.registry)i.UpdateVisible(ws.Global)}awake(){ac.registry.push(this)}onEnable(){ac.firstApply?this.UpdateVisible(ws.Global):(ac.firstApply=!0,ac.Apply())}onDestroy(){const i=ac.registry.indexOf(this);i>=0&&ac.registry.splice(i,1)}get isOn(){return this.gameObject.visible}UpdateVisible(i=null){if(A4)return;let e;const t=i;if(t&&typeof t=="number"&&(console.assert(typeof t=="number","XRFlag.UpdateVisible: state must be a number",t),_f&&console.log(t),ac.buffer.Mask=t,i=ac.buffer),i instanceof ws?(_f&&console.warn(this.name,"use passed in mask",i.Mask,this.visibleIn),e=i.Has(this.visibleIn)):(_f&&console.log(this.name,"use global mask"),ws.Global.Has(this.visibleIn)),e!==void 0)if(e)_f&&console.log(this.name,"is visible",this.gameObject.uuid),re.setActive(this.gameObject,!0);else{if(_f&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},h(Uv,"registry",[]),h(Uv,"firstApply"),h(Uv,"buffer",new ws),Uv);let oo=ac;kne([x()],oo.prototype,"visibleIn",2);var One=Object.defineProperty,Lne=Object.getOwnPropertyDescriptor,fI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Lne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&One(e,t,r),r};const Fv=ee("debugwebxr"),b4=new Me().setFromAxisAngle(new S(0,1,0),Math.PI);class sd extends Ie{constructor(){super(...arguments),h(this,"head"),h(this,"leftHand"),h(this,"rightHand"),h(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;Fv&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const t=qo.getFor(this);if(t!=null&&t.owner){const n=this.gameObject.addNewComponent(Mr);n.avatar=this.gameObject,n.connectionId=t.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):t&&!this.context.connection.isConnected&&(t.dontDestroy=!0)}onLeaveXR(e){const t=this.gameObject.getComponent(Mr);t&&t.destroy()}onUpdateXR(e){var t,n;if(!this.activeAndEnabled)return;const r=qo.isLocalPlayer(this);if(!r)return;const s=e.xr;if(s.rig&&s.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),s.rig.gameObject.add(this.gameObject)),this._syncTransforms&&r)for(const c of this._syncTransforms)c.fastMode=!0,c.isOwned()||c.requestOwnership();if(this.head&&this.context.mainCamera){const c=this.head.asset;if(c.position.copy(this.context.mainCamera.position),c.quaternion.copy(this.context.mainCamera.quaternion),c.quaternion.x*=-1,this.context.time.frameCount%10===0){const u=re.getComponentsInChildren(this.head.asset,oo);for(const d of u)d.enabled=!1,d.gameObject.visible=!1}}const o=e.xr.leftController,a=(t=this.leftHand)==null?void 0:t.asset;o&&a&&(a.position.copy(o.gripPosition),a.quaternion.copy(o.gripQuaternion),a.quaternion.multiply(b4),a.visible=o.isTracking);const l=e.xr.rightController;if(l&&(n=this.rightHand)!=null&&n.asset){const c=this.rightHand.asset;c.position.copy(l.gripPosition),c.quaternion.copy(l.gripQuaternion),c.quaternion.multiply(b4),c.visible=l.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var e,t,n;if(this.context.connection.isConnected){const r=qo.getFor(this);if(r&&r.isLocalPlayer==!1){const s=_t.getXRSync(this.context);if(s&&s.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const o=(e=this.leftHand)==null?void 0:e.asset;o&&(o.visible=s?.isTracking(r.owner,"left")??!1);const a=(t=this.rightHand)==null?void 0:t.asset;a&&(a.visible=s?.isTracking(r.owner,"right")??!1)}if((n=this.head)!=null&&n.asset){const o=re.getComponentsInChildren(this.head.asset,oo);for(const a of o)a.enabled=!1,a.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};ZF.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof ge&&(this.head=new Zt("",this.sourceId,this.head));else{const e=new ge;e.name="Head";const t=rv.createPrimitive(qu.Cube);e.add(t),this.gameObject.add(e),this.head=new Zt("",this.sourceId,e),Fv&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof ge&&(this.rightHand=new Zt("",this.sourceId,this.rightHand));else{const e=new ge;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new Zt("",this.sourceId,e),Fv&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof ge&&(this.leftHand=new Zt("",this.sourceId,this.leftHand));else{const e=new ge;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new Zt("",this.sourceId,e),Fv&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),qo.isLocalPlayer(this.gameObject)&&(this._syncTransforms=re.getComponentsInChildren(this.gameObject,Ah))}async loadAvatarObjects(e,t,n){const r=e.loadAssetAsync(),s=t.loadAssetAsync(),o=n.loadAssetAsync(),a=new Array;r&&a.push(r),s&&a.push(s),o&&a.push(o);const l=await ag(a);Fv&&console.log("Avatar loaded results:",l)}}fI([x(Zt)],sd.prototype,"head",2),fI([x(Zt)],sd.prototype,"leftHand",2),fI([x(Zt)],sd.prototype,"rightHand",2);class nl{static Add(e,t,n=null){if(t){for(const r of this.Pois)if(r.obj===t)return;this.Pois.push({obj:t,avatar:n}),this.LastChangeTime=e.time.time}}static Remove(e,t){var n;if(t){for(const r of this.Pois)if(r.obj===t){this.Pois.splice(this.Pois.indexOf(r),1),this.LastChangeTime=e?.time.time??((n=Ot.Current)==null?void 0:n.time.time);return}}}}h(nl,"Pois",[]),h(nl,"LastChangeTime",0);class Une{constructor(){h(this,"guid"),h(this,"position",new S)}}class Nv extends Ie{constructor(){super(...arguments),h(this,"target",null),h(this,"avatar",null),h(this,"_model",null),h(this,"_targetModel",new Une),h(this,"_currentTargetObject",null),h(this,"_lastUpdateTime",0),h(this,"_lookDuration",0),h(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const t=q.get("MoveRandom");if(t&&this.target){const n=re.getComponent(this.target,t);n&&n.destroy()}}awake(){if(this.avatar=re.getComponentInParent(this.gameObject,Mr),this.avatar){const e=re.getComponentInParent(this.gameObject,Mr);this._model=new RT(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var t;this.target&&e&&e.guid===((t=this.avatar)==null?void 0:t.guid)&&Wr(this.target,e.position)})}update(){var e;if((!this.context.connection.isConnected||(e=this._model)!=null&&e.hasOwnership)&&(nl.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=nl.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const t=Pt(this._currentTargetObject);Wr(this.target,t),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(t))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const e=nl.Pois;if(e.length>0){const t=e[Math.floor(Math.random()*e.length)];if(t&&t.obj){if(t.avatar&&t.avatar===this.avatar)return;this._currentTargetObject=t.obj}}}}}const xf=ee("debugnetworkingstreams");var rl=(i=>(i.Connected="peer-user-connected",i.StreamReceived="receive-stream",i.StreamEnded="call-ended",i.Disconnected="peer-user-disconnected",i.UserJoined="user-joined",i))(rl||{});class _4{constructor(e,t){h(this,"type","call-ended"),h(this,"userId"),h(this,"direction"),this.userId=e,this.direction=t}}class x4{constructor(e,t){h(this,"type","receive-stream"),h(this,"stream"),h(this,"target"),this.stream=e,this.target=t}}class Fne{constructor(e,t){h(this,"guid"),h(this,"peerId"),h(this,"dontSave",!0),this.guid=e.id,this.peerId=t}}var w4=(i=>(i.Incoming="incoming",i.Outgoing="outgoing",i))(w4||{});class Nne extends Kn{constructor(e,t,n){super(),h(this,"userId"),h(this,"direction"),h(this,"call"),h(this,"_stream",null),h(this,"_isDisposed",!1),this.userId=e,this.call=t,this.direction=n,this._stream=null,t.on("stream",r=>{if(xf&&console.log("Receive video",r.getAudioTracks(),r.getVideoTracks()),this._stream=r,n==="incoming"){const s=new x4(r,this);this.dispatchEvent(s)}}),t.on("close",()=>{this.dispatchEvent(new _4(e,n))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),lc(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const zv=class extends Kn{constructor(i,e){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=i,this.id=e,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(i,e){if(zv.instances.has(e))return zv.instances.get(e);const t=new zv(i,e);return zv.instances.set(e,t),t}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(i){return this.id+"-"+i}getUserIdFromPeerId(i){return i.substring(this.id.length+1)}makeCall(i,e){var t;const n={metadata:{userId:this.context.connection.connectionId}},r=(t=this._peer)==null?void 0:t.call(i,e,n);if(r)return this.registerCall(r,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(Kt.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(Kt.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const i=this.getMyPeerId();i?this._peer=zF(i):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(i){xf&&console.log("Peer connected as",i),this.context.connection.send("peer-user-connected",new Fne(this,i))}onPeerReceivingCall(i){i.answer(),this.registerCall(i,"incoming")}registerCall(i,e){const t=i.metadata;(!t||!t.userId)&&console.error("Missing call metadata",i);const n=t.userId;e==="incoming"&&xf?console.log("Receive call from",i.metadata):xf&&console.log("Make call to",i.metadata);const r=e==="incoming"?this._incomingCalls:this._outgoingCalls,s=new Nne(n,i,e);return r.push(s),i.on("error",o=>{console.error("Call error",o)}),i.on("close",()=>{xf&&console.log("Call ended",i.metadata),i.close();const o=r.indexOf(s);o!==-1&&r.splice(o,1)}),s.addEventListener("call-ended",o=>{this.dispatchEvent(o)}),e==="incoming"&&(s.addEventListener("receive-stream",o=>{this.dispatchEvent(o)}),i.on("stream",()=>{let o=0;const a=setInterval(()=>{const l=o===0;!s.isOpen&&l&&(o+=1,clearInterval(a),s.close())},2e3)})),s}};let sx=zv;h(sx,"instances",new Map);class oA extends Kn{constructor(e,t){super(),h(this,"context"),h(this,"peer"),h(this,"_sendingStreams",new Map),h(this,"debug",!1),h(this,"onJoinedRoom",n=>{this.debug&&console.log(`${n.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()}),h(this,"onReceiveStream",n=>{this.debug&&console.log("RECEIVE STREAM",n),this.dispatchEvent({type:"receive-stream",target:this,stream:n.stream,userId:n.userId})}),h(this,"onCallEnded",n=>{this.dispatchEvent(n)}),h(this,"onUserConnected",n=>{if(this.peer.id===n.guid){this.debug&&console.log("USER CONNECTED",n.guid,n);const r=this._sendingStreams.keys().next().value;this.peer.makeCall(n.peerId,r)}}),h(this,"onUserLeft",n=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()}),this.context=e,this.peer=t,xf&&(this.debug=!0)}static create(e){const t=sx.getOrCreate(e.context,e.context.connection.connectionId);return new oA(e.context,t)}startSendingStream(e){this._sendingStreams.has(e)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(e,[]),this.updateSendingCalls())}stopSendingStream(e){if(e){const t=this._sendingStreams.get(e);if(t){this.debug&&console.log("Closing calls",t);for(const n of t)n.close()}this._sendingStreams.delete(e),t&&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(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Kt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Kt.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(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Kt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Kt.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var e;let t=!1;const n=this.context.connection.connectionId;for(const r of this._sendingStreams.keys()){const s=this._sendingStreams.get(r)||[];for(const o of this.context.connection.usersInRoom()){if(o===n)continue;const a=s.find(l=>l.userId===o);if(!a||((e=a.stream)==null?void 0:e.active)===!1){this.debug&&console.log("Starting call to",o,n);const l=this.peer.makeCall(this.peer.getPeerIdFromUserId(o),r);l&&(t=!0,s.push(l))}}this._sendingStreams.set(r,s)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const e of this._sendingStreams.keys()){const t=this._sendingStreams.get(e);if(t)for(let n=t.length-1;n>=0;n--){const r=t[n];this.context.connection.userIsInRoom(r.userId)||(r.close(),t.splice(n,1))}}}}function lc(i){if(i&&i instanceof MediaStream)for(const e of i.getTracks())e.stop()}var zne=Object.defineProperty,jne=Object.getOwnPropertyDescriptor,S4=(i,e,t,n)=>{for(var r=n>1?void 0:n?jne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&zne(e,t,r),r};const Gne="noVoip",Qne=ee("debugvoip");class od 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 ua(300),this.autoConnect&&!this.isSending&&this.connect()}),h(this,"_incomingStreams",new Map),h(this,"onReceiveStream",e=>{const t=e.target.userId,n=e.stream,r=this._incomingStreams.get(t);if(r)r.srcObject=n,r.setAttribute("autoplay","true");else{const s=new Audio;this._incomingStreams.set(t,s),s.setAttribute("autoplay","true"),s.srcObject=n}}),h(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);lc(t?.srcObject),this._incomingStreams.delete(e.userId)}),h(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}}),h(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const e=document.visibilityState!=="visible";this.setMuted(e);for(const t of this._incomingStreams){const n=t[1];n.muted=e}})}awake(){Qne&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async e=>{e.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=oA.create(this)),this._net.addEventListener(rl.StreamReceived,this.onReceiveStream),this._net.addEventListener(rl.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(Kt.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(rl.StreamReceived,this.onReceiveStream),this._net.removeEventListener(rl.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(Kt.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(e){if(this.context.connection.isConnected){if(!await kC())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),lc(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await kC()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):RE("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),lc(this._outputStream),this._outputStream=null}setMuted(e){var t;const n=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(n)for(const r of n)r.enabled=!e}get isMuted(){var e;if(this._outputStream===null)return!1;const t=(e=this._outputStream)==null?void 0:e.getAudioTracks();if(t){for(const n of t)if(!n.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,ut()&&$i("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(e){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1}).catch(t=>(console.warn("VOIP failed getting audio stream",t),null)):(console.error("No getDisplayMedia support"),null)}}S4([x()],od.prototype,"autoConnect",2),S4([x()],od.prototype,"runInBackground",2);var Hne=Object.defineProperty,Vne=Object.getOwnPropertyDescriptor,C4=(i,e,t,n)=>{for(var r=n>1?void 0:n?Vne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Hne(e,t,r),r};const Wne=ee("debugmouth");class jv 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=re.findObjectOfType(od,this.context),this.marker||(this.marker=re.getComponentInParent(this.gameObject,Mr))},3e3)}update(){var e;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((e=this.marker)==null?void 0:e.connectionId)??null;if(!t){Wne&&(t=null);return}const n=this.voip.getFrequency(t)??0;this.updateLips(n)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(n=>n.visible=!1):this.talking.map(n=>n.visible=!1);for(let n=0;n<e.length;n++){const r=e[n];r&&(r.visible=n===t)}}}}C4([x(ge)],jv.prototype,"idle",2),C4([x(ge)],jv.prototype,"talking",2);class mI extends Ie{constructor(){super(...arguments),h(this,"voip",null),h(this,"marker",null),h(this,"_startPosition",null)}awake(){this.voip=re.findObjectOfType(od,this.context),this.marker=re.getComponentInParent(this.gameObject,Mr)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const n=t/100;this.gameObject.position.y=this._startPosition.y+n*.07}}var qne=Object.defineProperty,Xne=Object.getOwnPropertyDescriptor,ox=(i,e,t,n)=>{for(var r=n>1?void 0:n?Xne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&qne(e,t,r),r};class ad 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=re.getComponentInParent(this.gameObject,oo)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const e of this.eyes)e&&(e.visible=this.eyesOpen)}}}ox([x(ge)],ad.prototype,"eyes",2),ox([x()],ad.prototype,"lastBlinkTime",2),ox([x()],ad.prototype,"blinkLength",2),ox([x()],ad.prototype,"eyesOpen",2);var Yne=Object.defineProperty,Jne=Object.getOwnPropertyDescriptor,gI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Jne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Yne(e,t,r),r},vI;const E4=(vI=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 S),h(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=re.getComponentInParent(this.gameObject,Nv)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=re.addNewComponent(this.gameObject,Nv)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const i=this.target;if(i&&this.head){const e=this.eyes;if(e){const t=Pt(i);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const n=Pt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(n).normalize();if(r.length()<.1)return;const s=E4.forward;if(s.set(0,0,1),s.applyQuaternion(xi(this.head)),s.dot(r)>.45)for(let o=0;o<e.length;o++)e[o].lookAt(this.currentTargetPoint)}}}},h(vI,"forward",new S(0,0,1)),vI);let wf=E4;gI([x(ge)],wf.prototype,"head",2),gI([x(ge)],wf.prototype,"eyes",2),gI([x(ge)],wf.prototype,"target",2);const Gv=ee("debugavatar");class ax{constructor(e,t,n,r){h(this,"root"),h(this,"head"),h(this,"leftHand"),h(this,"rigthHand");var s;this.root=e,this.head=t,this.leftHand=n,this.rigthHand=r,(s=this.root)==null||s.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class AI{constructor(){h(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(e,t){if(!t)return console.error("Can not create avatar: failed to provide id or root object"),null;let n=null;if(typeof t=="string"){if(n=await this.loadAvatar(e,t),!n){const s=new Ra;n=re.instantiate(Ip(t,e.scene),s)}}else n=t;if(!n)return null;const r=this.findAvatar(n);return r.isValid?(Gv&&console.log("[Custom Avatar] valid config",t,Gv?r:""),r):(console.warn("[Custom Avatar] config isn't valid",t,Gv?r:""),null)}async loadAvatar(e,t){if(console.assert(t!=null&&typeof t=="string","Avatar id must not be null"),t.length<=0||!t)return null;if(Gv&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const r=await fetch("./"+t);let s=null;if(r.ok){const a=await r.blob();a&&(s=await a.arrayBuffer())}if(!s&&(s=await iT(t,t,0,"no url here go away",!0),!s))return null;const o=await na().parseSync(e,s,null,0);return o?.scene??null}const n=new Fp;return Cg(n,e),new Promise((r,s)=>{const o=this.avatarRegistryUrl+"/"+t;n.load(o,async a=>{await na().createBuiltinComponents(e,o,a,null,void 0),r(a.scene)},a=>{Gv&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),r(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let n=t;n.children.length==1&&(n=e.children[0]);let r=this.findAvatarPart(n,["head"]);const s=this.findAvatarPart(n,["left","hand"]),o=this.findAvatarPart(n,["right","hand"]);if(!r){r=t;const a=new S;new fi().setFromObject(r).getSize(a);const l=Math.max(a.x,a.y,a.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+l+" meters! Should be < 0.3m"),l>.3&&r.scale.multiplyScalar(1/l*.3)}return new ax(t,r,s,o)}findAvatarPart(e,t){const n=e.name.toLowerCase();let r=!0;for(const s of t){if(!r)break;n.indexOf(s)===-1&&(r=!1)}if(r)return e;if(e.children)for(const s of e.children){const o=this.findAvatarPart(s,t);if(o)return o}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}var Kne=Object.defineProperty,Zne=Object.getOwnPropertyDescriptor,yI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Zne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Kne(e,t,r),r};class Sf 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&&!Vg)return;this._axes||(this._axes=new To(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}yI([x()],Sf.prototype,"length",2),yI([x()],Sf.prototype,"depthTest",2),yI([x()],Sf.prototype,"isGizmo",2);class bI 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 e=Pt(this.to).clone(),t=Pt(this.from).clone(),n=e.distanceTo(t),r=e.clone();r.sub(t);const s=t.clone();s.add(e),s.multiplyScalar(.5);const o=Pt(this.hint).clone();o.sub(s);const a=new S;a.crossVectors(o,r),a.crossVectors(r,a),a.normalize();const l=n*.5,c=Math.max(this.desiredDistance,l),u=Math.sqrt(c*c-l*l),d=a.clone();d.multiplyScalar(u),d.add(s),Wr(this.gameObject,d);const p=s.clone();p.sub(a),this.gameObject.lookAt(p)}}const _I=ee("debugusdzbehaviours");class lx{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(n=>{re.foreachComponent(n,r=>{var s;const o=r;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const a=(s=o.beforeCreateDocument)==null?void 0:s.call(o,this,e);a instanceof Promise&&t.push(a)}},!1)}),_I&&console.log("onBeforeBuildDocument: all components",this.behaviourComponents),Promise.all(t)}onExportObject(e,t,n){var r;for(const s of this.behaviourComponents)_I&&console.log("onExportObject: createBehaviours",s),(r=s.createBehaviours)==null||r.call(s,this,t,n)}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 n;if((n=this.behaviours)!=null&&n.length){t.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){_I&&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 $ne=Object.defineProperty,ere=Object.getOwnPropertyDescriptor,xI=(i,e,t,n)=>{for(var r=n>1?void 0:n?ere(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&$ne(e,t,r),r},wI;const M4=(wI=class extends Kr{constructor(){super(...arguments),h(this,"threshold"),h(this,"intensity"),h(this,"scatter"),h(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=i=>i,this.intensity.valueProcessor=i=>i,this.scatter.valueProcessor=i=>1*Math.PI*(1-i)):(this.threshold.valueProcessor=i=>i,this.intensity.valueProcessor=i=>i,this.scatter.valueProcessor=i=>100*(1-i))}onCreateEffect(){let i;if(this.selectiveBloom==null&&(this.selectiveBloom=M4.useSelectiveBloom),this.selectiveBloom){const e=i=new YU(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});e.inverted=!0}else i=new VM({blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=e=>{i.intensity=e},this.threshold.onValueChanged=e=>{i.luminanceMaterial.threshold=e},this.scatter.onValueChanged=e=>{i.luminancePass.enabled=!0,i.luminanceMaterial.smoothing=e},i}},h(wI,"useSelectiveBloom",!1),wI);let ld=M4;xI([x(Rt)],ld.prototype,"threshold",2),xI([x(Rt)],ld.prototype,"intensity",2),xI([x(Rt)],ld.prototype,"scatter",2),Wo("Bloom",ld);const Cf="NEEDLE_progressive",Zr=ee("debugprogressive"),SI=Symbol("needle-progressive-texture"),Ef=new Map;if(Zr){let i=function(){e+=1,Hi(`Toggle LOD level: ${e}<br/>Registered objects: ${Ef.size}`),console.log("Toggle LOD level",e,Ef);const n=ni.Current;Ef.forEach((r,s)=>{for(const o of r.keys){const a=s[o];if(a instanceof ft){const l=Ii.getMeshLODInformation(a),c=l?Math.min(e,l.lods.length):0;s["DEBUG:LOD"]=c,Ii.assignMeshLOD(n,r.sourceId,s,c),l&&(t=Math.max(t,l.lods.length-1))}else if(s instanceof It){Ii.assignTextureLOD(n,r.sourceId,s,e);break}}}),e>=t&&(e=-1)},e=-1,t=2;window.addEventListener("keyup",n=>{n.key==="p"&&i()}),ni.registerCallback(pn.ContextCreated,n=>{const r=document.createElement("button");r.innerText="Toggle Progressive",r.onclick=i,n.context.menu.appendChild(r)})}function T4(i,e,t){var n;if(!Zr)return;Ef.has(i)||Ef.set(i,{keys:[],sourceId:t});const r=Ef.get(i);((n=r?.keys)==null?void 0:n.includes(e))==!1&&r.keys.push(e)}const ao=class{constructor(i,e,t){h(this,"parser"),h(this,"sourceId"),h(this,"context"),this.parser=i,this.sourceId=e,this.context=t}get name(){return Cf}static getMeshLODInformation(i){const e=this.getAssignedLODInformation(i);return e!=null&&e.key?this.lodInfos.get(e.key):null}static hasLODLevelAvailable(i,e){var t;if(i instanceof It){for(const s of Object.keys(i)){const o=i[s];if(o instanceof gt&&this.hasLODLevelAvailable(o,e))return!0}return!1}else if(i instanceof hs){for(const s of i.children)if(s instanceof ue&&this.hasLODLevelAvailable(s,e))return!0}let n,r;if(i instanceof ue?n=i.geometry:i instanceof gt&&(n=i),n&&(t=n?.userData)!=null&&t.LODS){const s=n.userData.LODS;if(r=this.lodInfos.get(s.key),e===void 0)return r!=null;if(r)return Array.isArray(r.lods)?e<r.lods.length:e===0}return!1}static assignMeshLOD(i,e,t,n){if(!t)return Promise.resolve(null);if(t instanceof ue){const r=t.geometry,s=this.getAssignedLODInformation(r);if(!s)return Promise.resolve(null);av(t)||w_(t,t.geometry);const o=this.onProgressiveLoadStart(i,e,t,null);return t["LOD:requested level"]=n,ao.getOrLoadLOD(i,e,r,n).then(a=>{if(t["LOD:requested level"]===n){if(delete t["LOD:requested level"],Array.isArray(a)){const l=s.index||0;a=a[l]}a&&r!=a&&(Zr=="verbose"&&console.log("Progressive Mesh "+t.name+" loaded",r,"\u2192",a,`
|
|
5509
5509
|
`,t),a instanceof ft&&(t.geometry=a,Zr&&T4(t,"geometry",e)))}return this.onProgressiveLoadEnd(o),a}).catch(a=>(this.onProgressiveLoadEnd(o),console.error("Error loading mesh LOD",t,a),null))}else Zr&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",t);return Promise.resolve(null)}static assignTextureLOD(i,e,t,n=0){if(!t)return Promise.resolve(null);if(t instanceof It){const r=t,s=[],o=new Array;if(r instanceof tg)for(const a of Object.keys(r.uniforms)){const l=r.uniforms[a].value;if(l instanceof gt){const c=this.assignTextureLODForSlot(i,e,l,n,r,a);s.push(c),o.push(a)}}else for(const a of Object.keys(r)){const l=r[a];if(l instanceof gt){const c=this.assignTextureLODForSlot(i,e,l,n,r,a);s.push(c),o.push(a)}}return ag(s).then(a=>{const l=new Array;for(let c=0;c<a.results.length;c++){const u=a.results[c],d=o[c];u instanceof gt?l.push({material:r,slot:d,texture:u,level:n}):l.push({material:r,slot:d,texture:null,level:n})}return l})}if(t instanceof gt){const r=t;return this.assignTextureLODForSlot(i,e,r,n,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(i,e,t,n,r,s){if(t?.isTexture!==!0)return Promise.resolve(null);const o=this.onProgressiveLoadStart(i,e,r,s);return ao.getOrLoadLOD(i,e,t,n).then(a=>Array.isArray(a)?null:a?.isTexture===!0?(a!=t&&(r&&s&&(r[s]=a),Zr&&s&&r&&T4(r,s,e)),this.onProgressiveLoadEnd(o),a):(Zr=="verbose"&&console.warn("No LOD found for",t,n),this.onProgressiveLoadEnd(o),null)).catch(a=>(this.onProgressiveLoadEnd(o),console.error("Error loading LOD",t,a),null))}afterRoot(i){var e,t;Zr&&console.log("AFTER",this.sourceId,i),(e=this.parser.json.textures)==null||e.forEach((r,s)=>{if(r!=null&&r.extensions){const o=r?.extensions[Cf];if(o){for(const a of this.parser.associations.keys())if(a instanceof gt&&this.parser.associations.get(a).textures===s){const l=a;Zr&&console.log("> Progressive: register texture",s,l.name,l.uuid,l,o),l.source&&(l.source[SI]=o);const c=l.uuid;ao.assignLODInformation(l,c,0,0,void 0),ao.lodInfos.set(c,o),ao.lowresCache.set(c,l)}}}});const n=(r,s,o,a,l)=>{const c=s.geometry;c["needle:raycast-mesh"]=!0,c&&!av(s)&&(Zr&&console.log("Set raycast mesh",s.name,s.uuid,c),w_(s,c),zb(c,!0).forEach(u=>{u instanceof ue&&w_(u,c)})),c.userData||(c.userData={}),ao.assignLODInformation(c,r,o,a,l.density),ao.lodInfos.set(r,l)};return(t=this.parser.json.meshes)==null||t.forEach((r,s)=>{if(r!=null&&r.extensions){const o=r?.extensions[Cf];if(o&&o.lods){for(const a of this.parser.associations.keys())if(a instanceof ue){const l=this.parser.associations.get(a);if(l.meshes===s){const c=a;Zr&&console.log("> Progressive: register mesh",s,c.name,o,c.uuid,c);const u=c.uuid,d=o.lods.length;if(c instanceof ue){n(u,c,d,l.primitives,o);let p=ao.lowresCache.get(u);p?p.push(c.geometry):p=[c.geometry],ao.lowresCache.set(u,p)}}}}}}),null}static async getOrLoadLOD(i,e,t,n){var r,s,o;const a=Zr=="verbose",l=t.userData.LODS;if(!l)return null;const c=l?.key;let u;if(t instanceof gt&&t.source&&t.source[SI]&&(u=t.source[SI]),u||(u=ao.lodInfos.get(c)),u){if(n>0){let f=!1;const m=Array.isArray(u.lods);if(m&&n>=u.lods.length?f=!0:m||(f=!0),f)return this.lowresCache.get(c)}const d=Array.isArray(u.lods)?u.lods[n].path:u.lods;if(!d)return Zr&&!u["missing:uri"]&&(u["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+n,u)),null;let p=jl(e,d);if(p.endsWith(".glb")||p.endsWith(".gltf")){if(!u.guid)return console.warn("missing pointer for glb/gltf texture",u),null;const f=p+"_"+u.guid,m=this.previouslyLoaded.get(f);if(m!==void 0){a&&console.log(`LOD ${n} was already loading/loaded: ${f}`);let g=await m.catch(b=>(console.error(`Error loading LOD ${n} from ${p}
|
|
5510
5510
|
`,b),null)),y=!1;if(g==null||(g instanceof gt&&t instanceof gt?(r=g.image)!=null&&r.data||(s=g.source)!=null&&s.data?g=this.copySettings(t,g):(y=!0,this.previouslyLoaded.delete(f)):g instanceof ft&&t instanceof ft&&((o=g.attributes.position)!=null&&o.array||(y=!0,this.previouslyLoaded.delete(f)))),!y)return g}const A=u,v=new Promise(async(g,y)=>{const b=new Fp;if(Cg(b,i),u&&Array.isArray(u.lods)){const T=u.lods[n];T.hash&&(p+="?v="+T.hash)}Zr&&(await ua(Math.random()*1e3),a&&console.warn("Start loading (delayed) "+p,A.guid));const _=await b.loadAsync(p).catch(T=>(console.error(`Error loading LOD ${n} from ${p}
|
|
5511
5511
|
`,T),null));if(!_)return null;const E=_.parser;a&&console.log("Loading finished "+p,A.guid);let I=0;if(_.parser.json.textures){let T=!1;for(const M of _.parser.json.textures){if(M!=null&&M.extensions){const D=M?.extensions[Cf];if(D!=null&&D.guid&&D.guid===A.guid){T=!0;break}}I++}if(T){let M=await E.getDependency("texture",I);return a&&console.log('change "'+t.name+'" \u2192 "'+M.name+'"',p,I,M,f),t instanceof gt&&(M=this.copySettings(t,M)),M&&(M.guid=A.guid),g(M)}}if(I=0,_.parser.json.meshes){let T=!1;for(const M of _.parser.json.meshes){if(M!=null&&M.extensions){const D=M?.extensions[Cf];if(D!=null&&D.guid&&D.guid===A.guid){T=!0;break}}I++}if(T){const M=await E.getDependency("mesh",I),D=A;if(a&&console.log(`Loaded Mesh "${M.name}"`,p,I,M,f),M instanceof ue){const C=M.geometry;return ao.assignLODInformation(C,c,n,void 0,D.density),g(C)}else{const C=new Array;for(let P=0;P<M.children.length;P++){const j=M.children[P];if(j instanceof ue){const Q=j.geometry;ao.assignLODInformation(Q,c,n,P,D.density),C.push(Q)}}return g(C)}}}return g(null)});return this.previouslyLoaded.set(f,v),await v}else if(t instanceof gt){a&&console.log("Load texture from uri: "+p);const f=await new Fa().loadAsync(p);return f?(f.guid=u.guid,f.flipY=!1,f.needsUpdate=!0,f.colorSpace=t.colorSpace,a&&console.log(u,f)):Zr&&console.warn("failed loading",p),f}}else Zr&&console.warn(`Can not load LOD ${n}: no LOD info found for "${c}" ${t.name}`,t.type);return null}static assignLODInformation(i,e,t,n,r){if(!i)return;i.userData||(i.userData={});const s=new tre(e,t,n,r);i.userData.LODS=s,i.userData.LOD=t}static getAssignedLODInformation(i){var e;return((e=i?.userData)==null?void 0:e.LODS)||null}static copySettings(i,e){return this._copiedTextures.get(i)||(e=e.clone(),this._copiedTextures.set(i,e),e.offset=i.offset,e.repeat=i.repeat,e.colorSpace=i.colorSpace,e)}static beginListenStart(i,e){this._progressiveEventListeners.has(i)||this._progressiveEventListeners.set(i,new R4),this._progressiveEventListeners.get(i).start.push(e)}static stopListenStart(i,e){if(!this._progressiveEventListeners.has(i))return;const t=this._progressiveEventListeners.get(i).start,n=t.indexOf(e);n>=0&&t.splice(n,1)}static beginListenEnd(i,e){this._progressiveEventListeners.has(i)||this._progressiveEventListeners.set(i,new R4),this._progressiveEventListeners.get(i).end.push(e)}static stopListenEnd(i,e){if(!this._progressiveEventListeners.has(i))return;const t=this._progressiveEventListeners.get(i).end,n=t.indexOf(e);n>=0&&t.splice(n,1)}static onProgressiveLoadStart(i,e,t,n){this._currentProgressiveLoadingInfo.has(i)||this._currentProgressiveLoadingInfo.set(i,[]);const r=new I4(i,e,t,n),s=this._currentProgressiveLoadingInfo.get(i),o=this._progressiveEventListeners.get(i);return o&&o.onStart(r),s.push(r),r}static onProgressiveLoadEnd(i){if(!i)return;const e=i.context;if(!this._currentProgressiveLoadingInfo.has(e))return;const t=this._currentProgressiveLoadingInfo.get(e),n=t.indexOf(i);if(n<0)return;t.splice(n,1);const r=this._progressiveEventListeners.get(e);r&&r.onEnd(i)}};let Ii=ao;h(Ii,"lodInfos",new Map),h(Ii,"previouslyLoaded",new Map),h(Ii,"lowresCache",new Map),h(Ii,"_copiedTextures",new Map),h(Ii,"_progressiveEventListeners",new Map),h(Ii,"_currentProgressiveLoadingInfo",new Map);class tre{constructor(e,t,n,r){h(this,"key"),h(this,"level"),h(this,"index"),h(this,"density"),this.key=e,this.level=t,n!=null&&(this.index=n),r!=null&&(this.density=r)}}class I4{constructor(e,t,n,r){h(this,"context"),h(this,"source"),h(this,"material"),h(this,"slot"),h(this,"mesh"),this.context=e,this.source=t,n instanceof ue?this.mesh=n:this.material=n,this.slot=r}}class R4{constructor(){h(this,"start",[]),h(this,"end",[])}onStart(e){for(const t of this.start)t(e)}onEnd(e){for(const t of this.end)t(e)}}var ire=Object.defineProperty,nre=Object.getOwnPropertyDescriptor,Ns=(i,e,t,n)=>{for(var r=n>1?void 0:n?nre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&ire(e,t,r),r};class lo extends Ie{constructor(){super(...arguments),h(this,"attachedRigidbody",null),h(this,"isTrigger",!1),h(this,"sharedMaterial"),h(this,"membership",[0]),h(this,"filter"),h(this,"updateProperties",()=>{var e;(e=this.context.physics.engine)==null||e.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Si))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Si))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Si))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}get body(){var e;return(e=this.context.physics.engine)==null?void 0:e.getBody(this)}updatePhysicsMaterial(){var e;(e=this.context.physics.engine)==null||e.updatePhysicsMaterial(this)}}Ns([x(Si)],lo.prototype,"attachedRigidbody",2),Ns([x()],lo.prototype,"isTrigger",2),Ns([x()],lo.prototype,"sharedMaterial",2),Ns([x()],lo.prototype,"membership",2),Ns([x()],lo.prototype,"filter",2);class Mf extends lo{constructor(){super(...arguments),h(this,"radius",.5),h(this,"center",new S(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),tb(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),DC(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Ns([Sr(),x()],Mf.prototype,"radius",2),Ns([x(S)],Mf.prototype,"center",2);class Tf extends lo{constructor(){super(...arguments),h(this,"size",new S(1,1,1)),h(this,"center",new S(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.size),tb(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),DC(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Ns([Sr(),x(S)],Tf.prototype,"size",2),Ns([x(S)],Tf.prototype,"center",2);class cd extends lo{constructor(){super(...arguments),h(this,"sharedMesh"),h(this,"convex",!1)}onEnable(){var e,t,n;if(super.onEnable(),!this.context.physics.engine)return;(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof ue&&(this.sharedMesh=this.gameObject);const r=0;if((t=this.sharedMesh)!=null&&t.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Ui(this.gameObject)),Ii.assignMeshLOD(this.context,this.sourceId,this.sharedMesh,r).then(s=>{s&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=s,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Ui(this.gameObject)))});else{const s=this.sharedMesh;if(s!=null&&s.isGroup){console.warn(`MeshCollider mesh is a group "${((n=this.sharedMesh)==null?void 0:n.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);const o=new Array;for(const a in s.children){const l=s.children[a];l.isMesh&&(this.context.physics.engine.addMeshCollider(this,l,this.convex,Ui(this.gameObject)),o.push(Ii.assignMeshLOD(this.context,this.sourceId,l,r)))}Promise.all(o).then(a=>{var l,c;if(a.some(d=>d)==!1)return;(l=this.context.physics.engine)==null||l.removeBody(this);const u=new ue;for(const d of a)d&&this.activeAndEnabled&&(u.geometry=d,(c=this.context.physics.engine)==null||c.addMeshCollider(this,u,this.convex,Ui(this.gameObject)))})}}}}Ns([x(ue)],cd.prototype,"sharedMesh",2),Ns([x()],cd.prototype,"convex",2);class cc extends lo{constructor(){super(...arguments),h(this,"center",new S(0,0,0)),h(this,"radius",.5),h(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}Ns([x(S)],cc.prototype,"center",2),Ns([x()],cc.prototype,"radius",2),Ns([x()],cc.prototype,"height",2);var rre=Object.defineProperty,sre=Object.getOwnPropertyDescriptor,CI=(i,e,t,n)=>{for(var r=n>1?void 0:n?sre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&rre(e,t,r),r};class hd 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&&!Vg||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new CC(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=sT(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Fi.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var e;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}CI([x()],hd.prototype,"objectBounds",2),CI([x(Se)],hd.prototype,"color",2),CI([x()],hd.prototype,"isGizmo",2);const ore=ee("gizmos"),are=ee("debugboxhelper"),xa=class extends Ie{constructor(){super(...arguments),h(this,"box",null),h(this,"_lastMatrixUpdateFrame",-1),h(this,"_helper",null),h(this,"_color",null)}isInBox(i,e){var t;if(!i)return;if(this.box||(this.box=new fi),i.type==="Mesh")xa.testBox.setFromObject(i);else if(i.type==="Group"){if(xa.testBox.makeEmpty(),i.children.length>0)for(let r=0;r<i.children.length;r++)i.children[r].type==="Mesh"&&xa.testBox.expandByObject(i)}else{const r=Pt(i,xa._position),s=Ui(i,xa._size);e!==void 0&&s.multiplyScalar(e),xa.testBox.setFromCenterAndSize(r,s)}this.updateBox();const n=(t=this.box)==null?void 0:t.intersectsBox(xa.testBox);return n&&are&&yt.DrawWireBox3(xa.testBox,16711680,5),n}intersects(i){return i?this.updateBox(!1).intersectsBox(i):!1}updateBox(i=!1){if(this.box||(this.box=new fi),i||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const e=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const t=e,n=Pt(this.gameObject,xa._position,t),r=Ui(this.gameObject,xa._size);this.box.setFromCenterAndSize(n,r)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(i=null,e=!1){var t;if(!(!ore&&!e)){if(this._helper){i&&((t=this._color)==null||t.set(i)),this.gameObject.add(this._helper);return}this._helper=sT(i),this.gameObject.add(this._helper)}}};let sl=xa;h(sl,"testBox",new fi),h(sl,"_position",new S),h(sl,"_size",new S(.01,.01,.01));class lre extends LO{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const n in t)for(const r in t[n])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(n);for(const n of e._components)e._simpleState__statesProperties[n.id]&&(e._simpleState__normalStyles[n.id]=n.inline?n.inline:n._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 n=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],n.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)n.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const n in e)this._simpleState__statesProperties[n]&&(this._simpleState__normalStyles[n]=e[n]);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 cre=Object.defineProperty,hre=Object.getOwnPropertyDescriptor,P4=(i,e,t,n)=>{for(var r=n>1?void 0:n?hre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&cre(e,t,r),r};class If extends Ie{constructor(){super(...arguments),h(this,"effectColor"),h(this,"effectDistance")}}P4([x(yi)],If.prototype,"effectColor",2),P4([x($)],If.prototype,"effectDistance",2);var ure=Object.defineProperty,dre=Object.getOwnPropertyDescriptor,Qv=(i,e,t,n)=>{for(var r=n>1?void 0:n?dre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&ure(e,t,r),r};const EI=ee("debugui"),MI=ee("debuguilayout");class TI{constructor(){h(this,"width"),h(this,"height")}}class II{constructor(){h(this,"x"),h(this,"y"),h(this,"width"),h(this,"height")}}const wa=new S,Hv=new Ce,cx=new Me,B4=class extends Pa{constructor(){super(...arguments),h(this,"_anchoredPosition"),h(this,"sizeDelta",new $(100,100)),h(this,"pivot",new $(.5,.5)),h(this,"anchorMin",new $(0,0)),h(this,"anchorMax",new $(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 $),this._anchoredPosition}set anchoredPosition(i){this._anchoredPosition=i}get width(){let i=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;i=e*t,i+=this.sizeDelta.x}return this.minWidth!==void 0&&i<this.minWidth?this.minWidth:i}get height(){let i=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;i=e*t,i+=this.sizeDelta.y}return this.minHeight!==void 0&&i<this.minHeight?this.minHeight:i}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new $),this.lastMatrix=new Ce,this.rectBlock=new ge,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,gf(this,"_anchoredPosition",()=>{this.markDirty()}),gf(this,"sizeDelta",()=>{this.markDirty()}),gf(this,"pivot",()=>{this.markDirty()}),gf(this,"anchorMin",()=>{this.markDirty()}),gf(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var i;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(i=this.Canvas)==null||i.registerTransform(this)}onDisable(){var i;super.onDisable(),this.removeShadowComponent(),(i=this.Canvas)==null||i.unregisterTransform(this)}onParentRectTransformChanged(i){this._transformNeedsUpdate||this.onApplyTransform(MI?`${i.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(MI&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(i){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=re.getComponentInParent(this.gameObject.parent,B4):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,MI&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+i),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,wa.set(0,0,0),this.applyPivot(wa),t.matrix.setPosition(wa.x,wa.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(cx.copy(this.gameObject.quaternion),cx.x*=-1,cx.z*=-1,Hv.makeRotationFromQuaternion(cx),t.matrix.premultiply(Hv)),wa.set(0,0,0),this.applyAnchoring(wa),(e=this.Canvas)!=null&&e.screenspace?wa.z+=.1:wa.z+=.01,Hv.identity(),Hv.setPosition(wa.x,wa.y,wa.z),t.matrix.premultiply(Hv),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const n=!0;for(const r of VT(this.gameObject,Pa,n,1)){if(r===this||!r.activeAndEnabled)continue;const s=r;s.onParentRectTransformChanged&&s.onParentRectTransformChanged(this)}}applyAnchoring(i){this._lastAnchoring||(this._lastAnchoring=new $);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),i.x+=this._initialPosition.x-this.gameObject.position.x,i.y+=this._initialPosition.y-this.gameObject.position.y,i.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let n=0;const r=1-this.anchorMax.y-this.anchorMin.y;n-=t.height*.5*r,i.y+=n;let s=0;const o=1-this.anchorMax.x-this.anchorMin.x;s-=t.width*.5*o,i.x+=s}}applyPivot(i){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;i.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;i.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const i={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(i),i}ensureValidSize(i,e=1e-4){return i.width<=0&&(i.width=e),i.height<=0&&(i.height=1e-4),i}createNewBlock(i){i={...this.getBasicOptions(),...i},EI&&console.log(this.name,i);const e=new yE(i);return this._createdBlocks.push(e),e}createNewText(i){EI&&console.log(i),i={...this.getBasicOptions(),...i},EI&&console.log(this.name,i);const e=new _E(i);return this._createdTextBlocks.push(e),e}};let Ss=B4;Qv([x($)],Ss.prototype,"anchoredPosition",1),Qv([x($)],Ss.prototype,"sizeDelta",2),Qv([x($)],Ss.prototype,"pivot",2),Qv([x($)],Ss.prototype,"anchorMin",2),Qv([x($)],Ss.prototype,"anchorMax",2);var pre=Object.defineProperty,fre=Object.getOwnPropertyDescriptor,D4=(i,e,t,n)=>{for(var r=n>1?void 0:n?fre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&pre(e,t,r),r};const hx={backgroundColor:new Se(1,1,1),backgroundOpacity:1,borderColor:new Se(1,1,1),borderOpacity:1};var RI;const ux=(RI=class extends Pa{constructor(){super(...arguments),h(this,"_alphaFactor",1),h(this,"sRGBColor",new Se(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 yi(1,1,1,1)),this._color}set color(i){(!this._color||this._color.r!==i.r||this._color.g!==i.g||this._color.b!==i.b||this._color.alpha!==i.alpha)&&(this._color||(this._color=new yi(1,1,1,1)),this._color.copy(i),this.onColorChanged())}setAlphaFactor(i){this._alphaFactor=i,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),hx.backgroundColor=this.sRGBColor,hx.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(hx,this._alphaFactor),this.uiObject.set(hx),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=re.getComponent(this.gameObject,Ss)),!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 i;(i=this.uiObject)==null||i.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(i){return super.__internalNewInstanceCreated(i),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(i){this.makePanel(),this.uiObject&&(this.uiObject.setState(i),this==null||this.markDirty())}setupState(i){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new lre(this.uiObject)),this.uiObject.setupState(i.state,i.attributes))}setOptions(i){this.makePanel(),this.uiObject&&this.uiObject.set(i)}awake(){super.awake(),this.makePanel(),gf(this,"_color",()=>jie(this,this.onColorChanged))}onEnable(){var i;super.onEnable(),this.uiObject&&((i=this.rectTransform.shadowComponent)==null||i.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const i=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:i};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(i){}onCreate(i){this.uiObject=this.rectTransform.createNewBlock(i),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(i,e=1){var t;const n=(t=this.gameObject)==null?void 0:t.getComponent(If);n&&(n.effectDistance&&(i.borderWidth=Math.max(Math.abs(n.effectDistance.x),Math.abs(n.effectDistance.y))),n.effectColor&&(i.borderColor=n.effectColor,i.borderOpacity=n.effectColor.alpha*e))}async setTexture(i){if(this.setOptions({backgroundOpacity:0}),i){if(ux.textureCache.has(i))i=ux.textureCache.get(i);else if(!i.isRenderTargetTexture){const e=i.clone();e.colorSpace=di,ux.textureCache.set(i,e),i=e}this.setOptions({backgroundImage:i,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),Ii.assignTextureLOD(this.context,this.sourceId,i,0).then(e=>{e instanceof gt&&this.setOptions({backgroundImage:e})})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},h(RI,"textureCache",new Map),RI);let ud=ux;D4([x(yi)],ud.prototype,"color",1),D4([x()],ud.prototype,"raycastTarget",2);class Vv extends ud{constructor(){super(...arguments),h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var mre=Object.defineProperty,gre=Object.getOwnPropertyDescriptor,dx=(i,e,t,n)=>{for(var r=n>1?void 0:n?gre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&mre(e,t,r),r};let PI=class{constructor(){h(this,"texture",null),h(this,"rect")}};dx([x(gt)],PI.prototype,"texture",2);let Rf=class extends Vv{constructor(){super(...arguments),h(this,"_sprite"),h(this,"pixelsPerUnitMultiplier",1)}set image(i){this.sprite||(this.sprite=new PI),this.sprite.texture=i,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(i){this._sprite!==i&&(this._sprite=i,this.onAfterCreated())}isBuiltinSprite(){var i,e,t,n,r,s,o;const a=this.sprite;switch((i=a?.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((t=(e=a?.texture)==null?void 0:e.name)!=null&&t.length)&&((r=(n=a?.texture)==null?void 0:n.image)==null?void 0:r.width)===32&&((o=(s=a?.texture)==null?void 0:s.image)==null?void 0:o.height)===32}onBeforeCreate(i){var e,t;super.onBeforeCreate(i),this.isBuiltinSprite()&&(i.borderRadius=5/this.pixelsPerUnitMultiplier,((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name)==="Knob"&&(i.borderRadius=999))}onAfterCreated(){var i;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((i=this.sprite)==null?void 0:i.texture))}};dx([x(PI)],Rf.prototype,"sprite",1),dx([x()],Rf.prototype,"pixelsPerUnitMultiplier",2);class px extends Vv{constructor(){super(...arguments),h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}dx([x(gt)],px.prototype,"mainTexture",1);var vre=Object.defineProperty,Are=Object.getOwnPropertyDescriptor,co=(i,e,t,n)=>{for(var r=n>1?void 0:n?Are(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&vre(e,t,r),r};const dd=ee("debugbutton");class wh{constructor(){h(this,"colorMultiplier"),h(this,"disabledColor"),h(this,"fadeDuration"),h(this,"highlightedColor"),h(this,"normalColor"),h(this,"pressedColor"),h(this,"selectedColor")}}co([x()],wh.prototype,"colorMultiplier",2),co([x(yi)],wh.prototype,"disabledColor",2),co([x()],wh.prototype,"fadeDuration",2),co([x(yi)],wh.prototype,"highlightedColor",2),co([x(yi)],wh.prototype,"normalColor",2),co([x(yi)],wh.prototype,"pressedColor",2),co([x(yi)],wh.prototype,"selectedColor",2);class yre{constructor(){h(this,"disabledTrigger"),h(this,"highlightedTrigger"),h(this,"normalTrigger"),h(this,"pressedTrigger"),h(this,"selectedTrigger")}}class hc extends Ie{constructor(){super(...arguments),h(this,"onClick"),h(this,"_isHovered",0),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(e){var t,n;const r=e.event.pointerType==="mouse"&&e.button===0;r&&(this._isHovered+=1),dd&&console.warn("Button Enter",r,this._isHovered,(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((n=this._image)==null||n.setState("hovered")),r&&this.context.input.setCursorPointer())}onPointerExit(){var e,t;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),dd&&console.log("Button Exit",this._isHovered,(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(e){var t,n;dd&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((n=this._image)==null||n.setState("pressed")))}onPointerUp(e){var t,n;dd&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((n=this._image)==null||n.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===r_.Mouse)&&(dd&&(console.warn("Button Click",this.onClick),Hi("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),dd))){const t=this.gameObject.worldPosition;t.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),yt.DrawLabel(t,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),dd&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(_v)||this.gameObject.addComponent(V_)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=re.getComponent(this.gameObject,Rf),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var t,n,r,s,o;e.setInteractable(this.interactable);const a=this.getFinalColor(e.color,(t=this.colors)==null?void 0:t.normalColor),l={state:"normal",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};e.setupState(l);const c=this.getFinalColor(e.color,(n=this.colors)==null?void 0:n.highlightedColor),u={state:"hovered",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};e.setupState(u);const d=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),p={state:"pressed",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(p);const f=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.selectedColor),m={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(m);const A=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.disabledColor),v={state:"disabled",attributes:{backgroundColor:A,backgroundOpacity:A.alpha}};e.setupState(v)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}co([x(Hn)],hc.prototype,"onClick",2),co([x(wh)],hc.prototype,"colors",2),co([x()],hc.prototype,"transition",2),co([x(yre)],hc.prototype,"animationTriggers",2),co([x(Cr)],hc.prototype,"animator",2),co([x()],hc.prototype,"interactable",1);var bre=Object.defineProperty,_re=Object.getOwnPropertyDescriptor,Bn=(i,e,t,n)=>{for(var r=n>1?void 0:n?_re(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&bre(e,t,r),r};const k4=ee("debuguilayout");class Sh{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}}Bn([x()],Sh.prototype,"left",2),Bn([x()],Sh.prototype,"right",2),Bn([x()],Sh.prototype,"top",2),Bn([x()],Sh.prototype,"bottom",2);class ho 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(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(k4&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){k4&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Ss);const e=this.gameObject.getComponentInParent(Tr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(Tr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}Bn([x()],ho.prototype,"childAlignment",2),Bn([x()],ho.prototype,"reverseArrangement",2),Bn([x()],ho.prototype,"spacing",2),Bn([x(Sh)],ho.prototype,"padding",2),Bn([x()],ho.prototype,"minWidth",2),Bn([x()],ho.prototype,"minHeight",2),Bn([x()],ho.prototype,"flexibleHeight",2),Bn([x()],ho.prototype,"flexibleWidth",2),Bn([x()],ho.prototype,"preferredHeight",2),Bn([x()],ho.prototype,"preferredWidth",2);class Ch extends ho{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(e){var t;const n=this.primaryAxis,r=e.width;let s=r;const o=e.height;let a=o;s-=this.padding.horizontal,a-=this.padding.vertical,n==="x"?this.padding.horizontal:this.padding.vertical;const l=n==="x",c=l?"y":"x",u=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,p=l?this.childForceExpandWidth:this.childForceExpandHeight,f=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:s,A=l?r:o,v=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let g=0;l?g+=this.padding.left:g+=this.padding.top;let y=0,b=0;for(let M=0;M<this.gameObject.children.length;M++){const D=this.gameObject.children[M],C=re.getComponent(D,Ss);C!=null&&C.activeAndEnabled&&(b+=1,l?y+=C.width:y+=C.height)}let _=0;const E=this.spacing*(b-1);if(p||u){let M=0;l?M=s-=E:M=a-=E,b>0&&(_=M/b)}let I=0;I+=this.padding.left,I-=this.padding.right,v!==0&&(g=A-y,g*=v,g-=E*v,l?(g-=this.padding.right*v,g+=this.padding.left*(1-v),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*v,g+=this.padding.top*(1-v),g<this.padding.top&&(g=this.padding.top)));let T=1;for(let M=0;M<this.gameObject.children.length;M++){const D=this.gameObject.children[M],C=re.getComponent(D,Ss);if(C!=null&&C.activeAndEnabled){(t=C.pivot)==null||t.set(.5,.5),C.anchorMin.set(0,1),C.anchorMax.set(0,1);const P=r*.5+I*.5;C.anchoredPosition.x!==P&&(C.anchoredPosition.x=P);const j=o*-.5;C.anchoredPosition.y!==j&&(C.anchoredPosition.y=j),f&&d&&C.sizeDelta[c]!==m&&(C.sizeDelta[c]=m),p&&u&&C.sizeDelta[n]!==_&&(C.sizeDelta[n]=_);const Q=l?C.width:C.height,O=Q*.5;if(g+=O,p){const L=_*T-_*.5;L>g&&(g=L-_*.5+Q+this.padding.left,g-=O)}let W=g;n==="y"&&(W=-W),C.anchoredPosition[n]!==W&&(C.anchoredPosition[n]=W),g+=O,g+=this.spacing,T+=1}}}}Bn([x()],Ch.prototype,"childControlHeight",2),Bn([x()],Ch.prototype,"childControlWidth",2),Bn([x()],Ch.prototype,"childForceExpandHeight",2),Bn([x()],Ch.prototype,"childForceExpandWidth",2),Bn([x()],Ch.prototype,"childScaleHeight",2),Bn([x()],Ch.prototype,"childScaleWidth",2);class BI extends Ch{get primaryAxis(){return"y"}}class DI extends Ch{get primaryAxis(){return"x"}}class kI extends ho{onCalculateLayout(){}}var xre=Object.defineProperty,wre=Object.getOwnPropertyDescriptor,ol=(i,e,t,n)=>{for(var r=n>1?void 0:n?wre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&xre(e,t,r),r},O4=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(O4||{});const OI=ee("debuguilayout"),L4=class extends bv{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 i,e,t,n;if(this.previousParent=this.gameObject.parent,((i=this.context.xr)!=null&&i.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(n=this.shadowComponent)==null||n.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Ho.ensureUpdateMeshUI(FO,this.context))}),h(this,"onAfterRenderRoutine",()=>{var i,e,t,n,r;if(((i=this.context.xr)!=null&&i.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){(t=this.previousParent)==null||t.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const a=this.context.mainCamera;a?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const s=this.context.renderer.autoClear,o=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(n=this.shadowComponent)==null||n.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),Ho.ensureUpdateMeshUI(FO,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=s,this.context.renderer.autoClearColor=o,this.previousParent.add(this.gameObject)}(r=this._lastMatrixWorld)==null||r.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(i){i!==this._renderOnTop&&(this._renderOnTop=i,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(i){this._depthWrite!==i&&(this._depthWrite=i,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(i){this._doubleSided!==i&&(this._doubleSided=i,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(i){this._castShadows!==i&&(this._castShadows=i,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(i){this._receiveShadows!==i&&(this._receiveShadows=i,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(i){this._renderMode!==i&&(this._renderMode=i,this.onRenderSettingsChanged())}set rootCanvas(i){this._rootCanvas instanceof L4||(this._rootCanvas=i)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(i){this._scaleFactor=i}awake(){var i;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,OI&&console.log("Canvas.Awake()",((i=this.previousParent)==null?void 0:i.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Ce,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const i=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);i!==-1&&this.context.pre_render_callbacks.splice(i,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(i){this._rectTransforms.push(i)}unregisterTransform(i){const e=this._rectTransforms.indexOf(i);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(i){const e=i.gameObject;this._layoutGroups.set(e,i)}unregisterLayoutGroup(i){const e=i.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(i){this._receivers.push(i)}unregisterEventReceiver(i){const e=this._receivers.indexOf(i);e!==-1&&this._receivers.splice(e,1)}async onEnterXR(i){this.screenspace?(i.xr.isVR||i.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await Ck(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(i){this.screenspace&&(i.xr.isVR||i.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var i;for(const e of this._receivers)(i=e.onBeforeCanvasRender)==null||i.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Ce);const i=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);OI&&i&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){i&&t.markDirty();let n=this._layoutGroups.get(t.gameObject);t.isDirty&&!n&&(n=t.gameObject.getComponentInParent(ho)),(t.isDirty||n!=null&&n.isDirty)&&(OI&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),n?.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Fi.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),q_(this.shadowComponent,this);for(const i of re.getComponentsInChildren(this.gameObject,Pa))q_(i.shadowComponent,this)}}onUpdateRenderMode(i=!1){if(!i&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=Ze.lerp(e.nearClipPlane,e.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const n=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-n,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(Ss);let s=!1;r.sizeDelta.x!==this.context.domWidth&&(s=!0),r.sizeDelta.y!==this.context.domHeight&&(s=!0);const o=e.fieldOfView*Math.PI/180,a=2*Math.tan(o/2)*Math.abs(n);this.gameObject.scale.x=a/this.context.domHeight,this.gameObject.scale.y=a/this.context.domHeight,this.gameObject.scale.z=.01,s&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Tr=L4;ol([x()],Tr.prototype,"renderOnTop",1),ol([x()],Tr.prototype,"depthWrite",1),ol([x()],Tr.prototype,"doubleSided",1),ol([x()],Tr.prototype,"castShadows",1),ol([x()],Tr.prototype,"receiveShadows",1),ol([x()],Tr.prototype,"renderMode",1),ol([x(Tr)],Tr.prototype,"rootCanvas",1),ol([x()],Tr.prototype,"scaleFactor",1),ol([x(Bi)],Tr.prototype,"worldCamera",2),ol([x()],Tr.prototype,"planeDistance",2);var Sre=Object.defineProperty,Cre=Object.getOwnPropertyDescriptor,LI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Sre(e,t,r),r};class Eh 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(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Fi.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const e of re.getComponentsInChildren(this.gameObject,Pa,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}LI([x()],Eh.prototype,"alpha",1),LI([x()],Eh.prototype,"interactable",2),LI([x()],Eh.prototype,"blocksRaycasts",2);var Ere=Object.defineProperty,Mre=Object.getOwnPropertyDescriptor,tn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Mre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ere(e,t,r),r};const U4=ee("debugusdzbehaviours");function Wv(i){i&&(i.getComponentInParent(_v)||(ut()&&console.warn("Create Raycaster on "+i.name+" because no raycaster was found in the hierarchy"),i.addNewComponent(no)))}class pd 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 S),h(this,"targetRot",new Me),h(this,"targetScale",new S)}start(){Wv(this.gameObject)}onPointerClick(e){e.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 e=Pt(this.object).clone(),t=Pt(this.target).clone(),n=xi(this.object).clone(),r=xi(this.target).clone(),s=Ui(this.object).clone(),o=Ui(this.target).clone(),a=e.distanceTo(t),l=n.angleTo(r),c=s.distanceTo(o);if(a<.01&&l<.01&&c<.01){Wr(this.object,t),Do(this.object,r),fg(this.object,o),this.coroutine=null;return}let u=0,d=0;for(;u<1;)u+=this.context.time.deltaTime/this.duration,u>1&&(u=1),d=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,this.targetPos.lerpVectors(e,t,d),this.targetRot.slerpQuaternions(n,r,d),this.targetScale.lerpVectors(s,o,d),Wr(this.object,this.targetPos),Do(this.object,this.targetRot),fg(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),n=this.object.scale.clone(),r=this.target.position.clone(),s=this.target.quaternion.clone(),o=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(s),this.targetScale.copy(this.object.scale).multiply(o);let a=0,l=0;for(;a<1;)a+=this.context.time.deltaTime/this.duration,a>1&&(a=1),l=a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,l),this.object.quaternion.slerpQuaternions(t,this.targetRot,l),this.object.scale.lerpVectors(n,this.targetScale,l),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const n=new fr("Move to "+((t=this.target)==null?void 0:t.name),mr.tapTrigger(this.gameObject),ai.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));e.addBehavior(n)}}}tn([x(ge)],pd.prototype,"object",2),tn([x(ge)],pd.prototype,"target",2),tn([x()],pd.prototype,"duration",2),tn([x()],pd.prototype,"relativeMotion",2);var fx;const al=(fx=class extends Ie{constructor(){super(...arguments),h(this,"materialToSwitch"),h(this,"variantMaterial"),h(this,"fadeDuration",0),h(this,"_objectsWithThisMaterial",null),h(this,"selfModel"),h(this,"targetModels")}start(){this._objectsWithThisMaterial=this.objectsWithThisMaterial,Wv(this.gameObject)}onPointerClick(i){if(i.use(),!!this.variantMaterial)for(let e=0;e<this.objectsWithThisMaterial.length;e++){const t=this.objectsWithThisMaterial[e];t.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(i=>{if(i instanceof ue)if(Array.isArray(i.material)){for(const e of i.material)if(e===this.materialToSwitch){this.objectsWithThisMaterial.push(i);break}}else i.material===this.materialToSwitch&&this.objectsWithThisMaterial.push(i)}),this._objectsWithThisMaterial)}async beforeCreateDocument(i,e){this.targetModels=[],al._materialTriggersPerId={},al.variantSwitchIndex=0,this.materialToSwitch&&await Ii.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Ii.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(i,e,t){this.objectsWithThisMaterial.find(n=>n.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(al._materialTriggersPerId[this.materialToSwitch.uuid]||(al._materialTriggersPerId[this.materialToSwitch.uuid]=[]),al._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(i,e){if(!this.materialToSwitch)return;const t=al._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const n={};for(const r of t){const s=r.createVariants();s&&s.length>0&&(n[r.selfModel.uuid]=s)}for(const r of t){const s=[];for(const o in n)o!==r.selfModel.uuid&&s.push(...n[o]);r.createAndAttachBehaviors(i,n[r.selfModel.uuid],s)}}delete al._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(i,e,t){const n=[],r=[],s=Math.max(0,this.fadeDuration);r.push(ai.fadeAction([...this.targetModels,...t],s,!1)),n.push(ai.fadeAction(e,s,!1)),r.push(ai.fadeAction(e,s,!0)),i.addBehavior(new fr("Select_"+this.selfModel.name,mr.tapTrigger(this.selfModel),ai.parallel(...r))),i.addBehavior(new fr("StartHidden_"+this.selfModel.name,mr.sceneStartTrigger(),ai.parallel(...n)))}static getMaterialName(i){return Aa(i.name||"Material")+"_"+i.id}createVariants(){if(!this.variantMaterial)return null;const i=[];for(const e of this.targetModels){const t=e.clone();t.name+="_Variant_"+al.variantSwitchIndex+++"_"+al.getMaterialName(this.variantMaterial),t.displayName=t.displayName+": Variant with material "+this.variantMaterial.name,t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&Zs.createEmptyParent(e),e.parent&&e.parent.add(t),i.push(t)}return i}},h(fx,"_materialTriggersPerId",{}),h(fx,"variantSwitchIndex",0),fx);let Pf=al;tn([x(It)],Pf.prototype,"materialToSwitch",2),tn([x(It)],Pf.prototype,"variantMaterial",2),tn([x()],Pf.prototype,"fadeDuration",2);var Bf;const nn=(Bf=class 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,"selfModelClone"),h(this,"targetModel"),h(this,"toggleModel"),h(this,"stateBeforeCreatingDocument",!1),h(this,"targetStateBeforeCreatingDocument",!1)}start(){Wv(this.gameObject)}onPointerClick(i){i.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[nn.wasVisible]===void 0&&(this.gameObject[nn.wasVisible]=this.gameObject.activeSelf),this.target[nn.wasVisible]===void 0&&(this.target[nn.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[nn.wasVisible],this.targetStateBeforeCreatingDocument=this.target[nn.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(i,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const t=this.selfModel;if(this.selfModel&&this.targetModel){let n=this.selfModel,r=this.targetState;if(this.toggleOnClick)if(r=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&HL.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[nn.toggleClone]){const l=this.selfModelClone.clone();l.matrix.identity(),l.name+="_toggle"+nn.clonedToggleIndex++,t.add(l),this.gameObject[nn.toggleClone]=l,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const a=this.gameObject[nn.toggleClone];if(!this.gameObject[nn.reverseToggleClone]){const l=this.selfModelClone.clone();l.matrix.identity(),l.name+="_toggleReverse"+nn.clonedToggleIndex++,t.add(l),this.gameObject[nn.reverseToggleClone]=l}this.toggleModel=this.gameObject[nn.reverseToggleClone],(!this.toggleModel.geometry||!a.geometry)&&console.error("triggers without childs and without geometry won't work!",this,t.geometry),n=a,t.geometry=null,t.material=null}if(this.toggleModel){if(this.toggleOnClick){const a=[];a.push(ai.fadeAction(n,0,!1)),a.push(ai.fadeAction(this.toggleModel,0,!0)),a.push(ai.fadeAction(this.targetModel,0,r)),i.addBehavior(new fr("Toggle_"+n.name+"_toggleTo"+(r?"On":"Off"),mr.tapTrigger(n),ai.parallel(...a)));const l=[];l.push(ai.fadeAction(this.toggleModel,0,!1)),l.push(ai.fadeAction(n,0,!0)),l.push(ai.fadeAction(this.targetModel,0,!r)),i.addBehavior(new fr("Toggle_"+n.name+"_toggleTo"+(r?"Off":"On"),mr.tapTrigger(this.toggleModel),ai.parallel(...l)))}}else{const a=[];this.hideSelf&&a.push(ai.fadeAction(n,0,!1)),a.push(ai.fadeAction(this.targetModel,0,r)),i.addBehavior(new fr("Toggle_"+n.name+"_toggleTo"+(r?"On":"Off"),mr.tapTrigger(n),ai.parallel(...a)))}const s=a=>{const l=Zs.createEmpty();l.name="InputTarget",l.displayName=void 0,l.type="RealityKitComponent",l.onSerialize=c=>{c.appendLine("bool allowsDirectInput = 1"),c.appendLine("bool allowsIndirectInput = 1"),c.appendLine('uniform token info:id = "RealityKit.InputTarget"')},a.add(l)};s(n),this.toggleModel&&s(this.toggleModel);const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(t),this.toggleModel&&o.push(this.toggleModel),i.addBehavior(new fr("HideOnStart_"+this.gameObject.name,mr.sceneStartTrigger(),ai.fadeAction(o,0,!1)))}}afterSerialize(i,e){this.gameObject[nn.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[nn.wasVisible],delete this.gameObject[nn.wasVisible]),this.target&&this.target[nn.wasVisible]!==void 0&&(this.target.visible=this.target[nn.wasVisible],delete this.target[nn.wasVisible]),delete this.gameObject[nn.toggleClone],delete this.gameObject[nn.reverseToggleClone]}},h(Bf,"clonedToggleIndex",0),h(Bf,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),h(Bf,"toggleClone",Symbol("clone for toggling")),h(Bf,"reverseToggleClone",Symbol("clone for reverse toggling")),Bf);let fd=nn;tn([x(ge)],fd.prototype,"target",2),tn([x()],fd.prototype,"toggleOnClick",2),tn([x()],fd.prototype,"targetState",2),tn([x()],fd.prototype,"hideSelf",2);class UI extends Ie{start(){this.gameObject.visible=!1}createBehaviours(e,t,n){t.uuid===this.gameObject.uuid&&e.addBehavior(new fr("HideOnStart_"+this.gameObject.name,mr.sceneStartTrigger(),ai.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Df extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"duration",.5),h(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(e,t,n){if(this.target&&t.uuid===this.gameObject.uuid){const r=new fr("emphasize "+this.name,mr.tapTrigger(this.gameObject),ai.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,t){}}tn([x()],Df.prototype,"target",2),tn([x()],Df.prototype,"duration",2),tn([x()],Df.prototype,"motionType",2);class Mh extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"clip",""),h(this,"toggleOnClick",!1)}start(){Wv(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addNewComponent(en);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1)}}onPointerClick(e){var t;e.use(),!(!((t=this.target)!=null&&t.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(e,t,n){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const s=this.target?this.target.gameObject:this.gameObject,o=Vh.getName(r),a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let c=!1;if(this.gameObject.traverse(u=>{u instanceof ue&&u.visible&&(c=!0)}),c=!0,c){let u=ai.playAudioAction(s,"audio/"+o,"play",a,l);this.toggleOnClick&&(u.multiplePerformOperation="stop"),this.target&&this.target.loop&&(u=ai.sequence(u).makeLooping());const d=new fr("playAudio "+this.name,mr.tapTrigger(this.gameObject),u);e.addBehavior(d)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let u=ai.playAudioAction(s,"audio/"+o,"play",a,l);this.target.loop&&(u=ai.sequence(u).makeLooping());const d=new fr("playAudioOnStart"+(this.name?"_"+this.name:""),mr.sceneStartTrigger(),u);e.addBehavior(d)}}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const n=this.clip?this.clip:this.target?this.target.clip:void 0;if(!n||typeof n!="string")return;const r="audio/"+Vh.getName(n);if(t.files[r])return;const s=await(await(await fetch(n)).blob()).arrayBuffer(),o=new Uint8Array(s);t.files[r]=o}}tn([x(en)],Mh.prototype,"target",2),tn([x(URL)],Mh.prototype,"clip",2),tn([x()],Mh.prototype,"toggleOnClick",2);var mx;const Th=(mx=class extends Ie{constructor(){super(...arguments),h(this,"animator"),h(this,"stateName"),h(this,"trigger","tap"),h(this,"animation"),h(this,"selfModel"),h(this,"stateAnimationModel"),h(this,"animationSequence",new Array),h(this,"animationLoopAfterSequence",new Array)}get target(){var i,e;return((i=this.animator)==null?void 0:i.gameObject)||((e=this.animation)==null?void 0:e.gameObject)}start(){Wv(this.gameObject)}onPointerClick(i){var e;i.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(Th.rootsWithExclusivePlayback.size>1){const i='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.';ut()&&$i(i),console.warn(i,...Th.rootsWithExclusivePlayback)}Th.animationActions=[],Th.rootsWithExclusivePlayback=new Set}afterCreateDocument(i,e){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const t=e.document,n=e.extensions.find(o=>o instanceof Bv);if(!n)return;const r=n.getClipCount(this.target)>1;r&&(ut()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+n.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Th.rootsWithExclusivePlayback.add(this.target));const s=(o,a)=>{let l=Th.animationActions.find(c=>c.affectedObjects==o&&c.start==a.start&&c.duration==a.duration);return l||(l=ai.startAnimationAction(o,a.start,a.duration),Th.animationActions.push(l)),l};t.traverse(o=>{var a,l;if(o.uuid===((a=this.target)==null?void 0:a.uuid)){const c=ai.sequence();if(this.animationSequence&&this.animationSequence.length>0)for(const d of this.animationSequence)c.addAction(s(o,d));if(this.animationLoopAfterSequence&&this.animationLoopAfterSequence.length>0){const d=c.actions.length==0?c:ai.sequence();for(const p of this.animationLoopAfterSequence)d.addAction(s(o,p));d.makeLooping(),c!==d&&c.addAction(d)}const u=new fr("_tap_"+this.name+"_toPlayClip_"+this.stateName+"_on_"+((l=this.target)==null?void 0:l.name),this.trigger=="tap"?mr.tapTrigger(this.selfModel):mr.sceneStartTrigger(),c);r&&u.makeExclusive(!0),i.addBehavior(u)}})}createAnimation(i,e,t){var n,r,s,o,a,l,c;if(!this.target||!this.animator&&!this.animation)return;if(this.stateAnimationModel=e,this.animation){this.animationSequence=new Array,this.animationLoopAfterSequence=new Array;const A=i.registerAnimation(this.target,this.animation.clip);A&&this.animationLoopAfterSequence.push(A);return}const u=(n=this.animator)==null?void 0:n.runtimeAnimatorController;let d=u?.findState(this.stateName),p=[],f=[];if(u&&d){const A=new Array;A.push(d);let v=!1;for(;A.length<100;){if(!d||d===null||!d.transitions||d.transitions.length===0){(r=d.motion)!=null&&r.isLooping&&(v=!0);break}const g=d.transitions.find(b=>b.conditions.length===0),y=g?u.getState(g.destinationState,0):null;if(y&&A.includes(y)){d=y,v=!0;break}else if(g){if(d=y,!d)break;A.push(d)}else{v=((s=d.motion)==null?void 0:s.isLooping)??!1;break}}if(v&&d){const g=A.indexOf(d);p=A.slice(0,g),f=A.slice(g),U4&&console.log("found loop from "+this.stateName,"states until loop",p,"states looping",f)}else p=A,f=[],U4&&console.log("found no loop from "+this.stateName,"states",p)}if(p.length===1&&(!((o=p[0].motion)!=null&&o.clip)||((l=(a=p[0].motion)==null?void 0:a.clip.tracks)==null?void 0:l.length)===0)){this.animationSequence=new Array;const A=i.registerAnimation(this.target,null);A&&this.animationSequence.push(A);return}if(p=p.filter(A=>{var v,g,y;return((v=A.motion)==null?void 0:v.clip)&&((y=(g=A.motion)==null?void 0:g.clip.tracks)==null?void 0:y.length)>0}),f=f.filter(A=>{var v,g,y;return((v=A.motion)==null?void 0:v.clip)&&((y=(g=A.motion)==null?void 0:g.clip.tracks)==null?void 0:y.length)>0}),p.length===0&&f.length===0){console.warn("No clips found for state "+this.stateName+" on "+((c=this.animator)==null?void 0:c.name)+", can't export animation data");return}const m=(A,v)=>{var g;if(!this.target)return;const y=i.registerAnimation(this.target,A.motion.clip??null);y?v.push(y):console.warn("Couldn't register animation for state "+A.name+" on "+((g=this.animator)==null?void 0:g.name))};if(p.length>0){this.animationSequence=new Array;for(const A of p)m(A,this.animationSequence)}if(f.length>0){this.animationLoopAfterSequence=new Array;for(const A of f)m(A,this.animationLoopAfterSequence)}}},h(mx,"animationActions",[]),h(mx,"rootsWithExclusivePlayback",new Set),mx);let md=Th;tn([x(Cr)],md.prototype,"animator",2),tn([x()],md.prototype,"stateName",2);class kf extends Ie{constructor(){super(...arguments),h(this,"target")}getType(){}getDuration(){}}tn([x(ge)],kf.prototype,"target",2);class qv extends Ie{constructor(){super(...arguments),h(this,"target")}}tn([x(kf)],qv.prototype,"target",2);class Xv extends kf{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}}tn([x()],Xv.prototype,"type",2),tn([x()],Xv.prototype,"duration",2);class FI extends qv{}var Tre=Object.defineProperty,Ire=Object.getOwnPropertyDescriptor,uc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ire(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Tre(e,t,r),r};const F4=ee("debugcharactercontroller");class gd extends Ie{constructor(){super(...arguments),h(this,"center",new S(0,0,0)),h(this,"radius",.5),h(this,"height",2),h(this,"_rigidbody",null),h(this,"_activeGroundCollisions"),h(this,"_contactVelocity",new S)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Si),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Si)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(cc);t||(t=this.gameObject.addNewComponent(cc)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const n=new S(0,0,1),r=new S(1,0,0),s=new S(0,1,0),o=this.gameObject.getWorldDirection(new S);o.y=0;const a=r.dot(o)<0?-1:1,l=n.angleTo(o)*a;this.gameObject.setRotationFromAxisAngle(s,l),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(t=>t.normal.y>.2))&&(this._activeGroundCollisions.add(e),F4&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),F4&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const t of this._activeGroundCollisions){const n=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);n&&(this._contactVelocity.x+=n.x,this._contactVelocity.y+=n.y,this._contactVelocity.z+=n.z)}return this._contactVelocity}}uc([x(S)],gd.prototype,"center",2),uc([x()],gd.prototype,"radius",2),uc([x()],gd.prototype,"height",2);class dc 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 $(0,0)),h(this,"moveInput",new $(0,0)),h(this,"jumpInput",!1),h(this,"_currentSpeed",new S(0,0,0)),h(this,"_currentAngularSpeed",new S(0,0,0)),h(this,"_temp",new S(0,0,0)),h(this,"_jumpCount",0),h(this,"_currentRotation"),h(this,"_raycastOptions",new jo)}awake(){this._currentRotation=new Me}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}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(e,t,n){var r,s,o,a,l,c,u,d,p,f,m;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((s=this.animator)==null||s.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(o=this.animator)==null||o.setBool("running",e.length()>.01),(l=this.animator)==null||l.setBool("jumping",((a=this.controller)==null?void 0:a.isGrounded)===!0&&n),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+=Ze.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const A=this.context.mainCameraComponent.forward;A.y=0,A.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),A),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&&n&&this.jumpForce>0){let A=(c=this.controller)==null?void 0:c.isGrounded;if(this.doubleJumpForce>0&&!((u=this.controller)!=null&&u.isGrounded)&&this._jumpCount===1&&(A=!0,(d=this.animator)==null||d.setBool("doubleJump",!0)),A){this._jumpCount+=1;const v=this.controller.rigidbody,g=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new S(0,1,0).multiplyScalar(g))}}if(this.controller){const A=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(A<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Ds),this._raycastOptions.ray.origin.copy(Pt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const g=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(g.length&&g[0].distance>2||A<-10)&&((f=this.animator)==null||f.setBool("falling",!0))}else(m=this.animator)==null||m.setBool("falling",!1)}}}uc([x(gd)],dc.prototype,"controller",2),uc([x()],dc.prototype,"movementSpeed",2),uc([x()],dc.prototype,"rotationSpeed",2),uc([x()],dc.prototype,"jumpForce",2),uc([x()],dc.prototype,"doubleJumpForce",2),uc([x(Cr)],dc.prototype,"animator",2);var Rre=Object.defineProperty,Pre=Object.getOwnPropertyDescriptor,Bre=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Rre(e,t,r),r};class Yv extends Kr{constructor(){super(...arguments),h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new VU;return e.offset=new $(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}Bre([x(Rt)],Yv.prototype,"intensity",2),Wo("ChromaticAberration",Yv);const Jv=new ft;Jv.setAttribute("position",new $e(new Float32Array([-1,-1,3,-1,-1,3]),2)),Jv.setAttribute("uv",new $e(new Float32Array([0,0,2,0,0,2]),2)),Jv.boundingSphere=new un,Jv.computeBoundingSphere=function(){};const Dre=new Ll;class vd{constructor(e){this._mesh=new ue(Jv,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,Dre)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const kre={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new Ce},viewMat:{value:new Ce},projViewMat:{value:new Ce},projectionMatrixInv:{value:new Ce},viewMatrixInv:{value:new Ce},cameraPos:{value:new S},resolution:{value:new $},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
|